|
@@ -873,6 +873,10 @@ SOKOL_API_DECL float sapp_dpi_scale(void);
|
|
|
SOKOL_API_DECL void sapp_show_keyboard(bool visible);
|
|
|
/* return true if the mobile device onscreen keyboard is currently shown */
|
|
|
SOKOL_API_DECL bool sapp_keyboard_shown(void);
|
|
|
+/* query fullscreen mode */
|
|
|
+SOKOL_API_DECL bool sapp_is_fullscreen(void);
|
|
|
+/* toggle fullscreen mode */
|
|
|
+SOKOL_API_DECL void sapp_toggle_fullscreen(void);
|
|
|
/* show or hide the mouse cursor */
|
|
|
SOKOL_API_DECL void sapp_show_mouse(bool visible);
|
|
|
/* show or hide the mouse cursor */
|
|
@@ -1080,6 +1084,7 @@ typedef struct {
|
|
|
int sample_count;
|
|
|
int swap_interval;
|
|
|
float dpi_scale;
|
|
|
+ bool fullscreen;
|
|
|
bool gles2_fallback;
|
|
|
bool first_frame;
|
|
|
bool init_called;
|
|
@@ -1210,6 +1215,7 @@ _SOKOL_PRIVATE void _sapp_init_state(const sapp_desc* desc) {
|
|
|
_sapp_strcpy("sokol_app", _sapp.window_title, sizeof(_sapp.window_title));
|
|
|
}
|
|
|
_sapp.dpi_scale = 1.0f;
|
|
|
+ _sapp.fullscreen = _sapp.desc.fullscreen;
|
|
|
}
|
|
|
|
|
|
_SOKOL_PRIVATE void _sapp_discard_state(void) {
|
|
@@ -1473,7 +1479,7 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
|
|
|
@implementation _sapp_macos_app_delegate
|
|
|
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
|
|
|
_SOKOL_UNUSED(aNotification);
|
|
|
- if (_sapp.desc.fullscreen) {
|
|
|
+ if (_sapp.fullscreen) {
|
|
|
NSRect screen_rect = NSScreen.mainScreen.frame;
|
|
|
_sapp.window_width = screen_rect.size.width;
|
|
|
_sapp.window_height = screen_rect.size.height;
|
|
@@ -1566,7 +1572,7 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
|
|
|
[[NSRunLoop currentRunLoop] addTimer:_sapp_macos_timer_obj forMode:NSDefaultRunLoopMode];
|
|
|
#endif
|
|
|
_sapp.valid = true;
|
|
|
- if (_sapp.desc.fullscreen) {
|
|
|
+ if (_sapp.fullscreen) {
|
|
|
/* on GL, this already toggles a rendered frame, so set the valid flag before */
|
|
|
[_sapp_macos_window_obj toggleFullScreen:self];
|
|
|
}
|
|
@@ -4433,6 +4439,41 @@ _SOKOL_PRIVATE bool _sapp_win32_wide_to_utf8(const wchar_t* src, char* dst, int
|
|
|
return 0 != WideCharToMultiByte(CP_UTF8, 0, src, -1, dst, dst_num_bytes, NULL, NULL);
|
|
|
}
|
|
|
|
|
|
+_SOKOL_PRIVATE void _sapp_win32_toggle_fullscreen() {
|
|
|
+ HMONITOR monitor = MonitorFromWindow(_sapp_win32_hwnd, MONITOR_DEFAULTTONEAREST);
|
|
|
+ MONITORINFO minfo = { .cbSize = sizeof(MONITORINFO) };
|
|
|
+ GetMonitorInfo(monitor, &minfo);
|
|
|
+ const RECT mr = minfo.rcMonitor;
|
|
|
+ const int monitor_w = mr.right - mr.left;
|
|
|
+ const int monitor_h = mr.bottom - mr.top;
|
|
|
+
|
|
|
+ const DWORD win_ex_style = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
|
|
|
+ DWORD win_style;
|
|
|
+ RECT rect = { 0, 0, 0, 0 };
|
|
|
+
|
|
|
+ _sapp.fullscreen = !_sapp.fullscreen;
|
|
|
+ if (!_sapp.fullscreen) {
|
|
|
+ win_style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SIZEBOX;
|
|
|
+ rect.right = (int) ((float)_sapp_def(_sapp.desc.width, 640) * _sapp_win32_window_scale);
|
|
|
+ rect.bottom = (int) ((float)_sapp_def(_sapp.desc.height, 480) * _sapp_win32_window_scale);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ win_style = WS_POPUP | WS_SYSMENU | WS_VISIBLE;
|
|
|
+ rect.right = monitor_w;
|
|
|
+ rect.bottom = monitor_h;
|
|
|
+ }
|
|
|
+ AdjustWindowRectEx(&rect, win_style, FALSE, win_ex_style);
|
|
|
+ int win_width = rect.right - rect.left;
|
|
|
+ int win_height = rect.bottom - rect.top;
|
|
|
+ if (!_sapp.fullscreen) {
|
|
|
+ rect.left = (monitor_w - win_width) / 2;
|
|
|
+ rect.top = (monitor_h - win_height) / 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ SetWindowLongPtr(_sapp_win32_hwnd, GWL_STYLE, win_style);
|
|
|
+ SetWindowPos(_sapp_win32_hwnd, HWND_TOP, mr.left + rect.left, mr.top + rect.top, win_width, win_height, SWP_SHOWWINDOW | SWP_FRAMECHANGED);
|
|
|
+}
|
|
|
+
|
|
|
_SOKOL_PRIVATE void _sapp_win32_show_mouse(bool shown) {
|
|
|
ShowCursor((BOOL)shown);
|
|
|
}
|
|
@@ -4576,8 +4617,8 @@ _SOKOL_PRIVATE bool _sapp_win32_update_dimensions(void) {
|
|
|
const int fb_width = (int)((float)_sapp.window_width * _sapp_win32_content_scale);
|
|
|
const int fb_height = (int)((float)_sapp.window_height * _sapp_win32_content_scale);
|
|
|
if ((fb_width != _sapp.framebuffer_width) || (fb_height != _sapp.framebuffer_height)) {
|
|
|
- _sapp.framebuffer_width = (int)((float)_sapp.window_width * _sapp_win32_content_scale);
|
|
|
- _sapp.framebuffer_height = (int)((float)_sapp.window_height * _sapp_win32_content_scale);
|
|
|
+ _sapp.framebuffer_width = fb_width;
|
|
|
+ _sapp.framebuffer_height = fb_height;
|
|
|
/* prevent a framebuffer size of 0 when window is minimized */
|
|
|
if (_sapp.framebuffer_width == 0) {
|
|
|
_sapp.framebuffer_width = 1;
|
|
@@ -4694,7 +4735,7 @@ _SOKOL_PRIVATE LRESULT CALLBACK _sapp_win32_wndproc(HWND hWnd, UINT uMsg, WPARAM
|
|
|
switch (wParam & 0xFFF0) {
|
|
|
case SC_SCREENSAVE:
|
|
|
case SC_MONITORPOWER:
|
|
|
- if (_sapp.desc.fullscreen) {
|
|
|
+ if (_sapp.fullscreen) {
|
|
|
/* disable screen saver and blanking in fullscreen mode */
|
|
|
return 0;
|
|
|
}
|
|
@@ -4803,7 +4844,7 @@ _SOKOL_PRIVATE void _sapp_win32_create_window(void) {
|
|
|
DWORD win_style;
|
|
|
const DWORD win_ex_style = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
|
|
|
RECT rect = { 0, 0, 0, 0 };
|
|
|
- if (_sapp.desc.fullscreen) {
|
|
|
+ if (_sapp.fullscreen) {
|
|
|
win_style = WS_POPUP | WS_SYSMENU | WS_VISIBLE;
|
|
|
rect.right = GetSystemMetrics(SM_CXSCREEN);
|
|
|
rect.bottom = GetSystemMetrics(SM_CYSCREEN);
|
|
@@ -7757,6 +7798,18 @@ SOKOL_API_IMPL bool sapp_keyboard_shown(void) {
|
|
|
return _sapp.onscreen_keyboard_shown;
|
|
|
}
|
|
|
|
|
|
+SOKOL_API_DECL bool sapp_is_fullscreen(void) {
|
|
|
+ return _sapp.fullscreen;
|
|
|
+}
|
|
|
+
|
|
|
+SOKOL_API_DECL void sapp_toggle_fullscreen(void) {
|
|
|
+ #if defined(_WIN32)
|
|
|
+ _sapp_win32_toggle_fullscreen();
|
|
|
+ #else
|
|
|
+ _SOKOL_UNUSED(shown);
|
|
|
+ #endif
|
|
|
+}
|
|
|
+
|
|
|
SOKOL_API_IMPL void sapp_show_mouse(bool shown) {
|
|
|
#if defined(__APPLE__) && !TARGET_OS_IPHONE
|
|
|
_sapp_macos_show_mouse(shown);
|