From a9445fb3004ca395e4105d16d52a991cbbea28e8 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 18 Oct 2023 05:22:06 +0200 Subject: [PATCH] add new window message to toggle fullscreen/maximize --- inc/wndproc.h | 5 +++++ src/debug.c | 2 ++ src/wndproc.c | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/inc/wndproc.h b/inc/wndproc.h index 6d2a199..3cb6a97 100644 --- a/inc/wndproc.h +++ b/inc/wndproc.h @@ -7,9 +7,14 @@ #define WM_SIZE_DDRAW WM_APP+114 #define WM_MOVE_DDRAW WM_APP+115 #define WM_DISPLAYCHANGE_DDRAW WM_APP+116 +#define WM_TOGGLE_FULLSCREEN WM_APP+117 +#define WM_TOGGLE_MAXIMIZE WM_APP+118 #define IDT_TIMER_LEAVE_BNET 541287654 +#define CNC_DDRAW_SET_FULLSCREEN 1 +#define CNC_DDRAW_SET_WINDOWED 2 + LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); #endif diff --git a/src/debug.c b/src/debug.c index c38c940..aaa8cb7 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1502,6 +1502,8 @@ char* dbg_mes_to_str(int id) case WM_D3D9DEVICELOST: return "WM_D3D9DEVICELOST"; case WM_WINEFULLSCREEN: return "WM_WINEFULLSCREEN"; case WM_AUTORENDERER: return "WM_AUTORENDERER"; + case WM_TOGGLE_FULLSCREEN: return "WM_TOGGLE_FULLSCREEN"; + case WM_TOGGLE_MAXIMIZE: return "WM_TOGGLE_MAXIMIZE"; } return 0; diff --git a/src/wndproc.c b/src/wndproc.c index 4fccc95..db1c00a 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -652,6 +652,32 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam mouse_lock(); return 0; } + case WM_TOGGLE_FULLSCREEN: + { + if (!g_config.fullscreen || (g_config.windowed && g_config.toggle_borderless)) + { + /* Check if we are fullscreen/borderless already */ + if (wParam == CNC_DDRAW_SET_FULLSCREEN && (!g_config.windowed || g_config.fullscreen)) + return 0; + + /* Check if we are windowed already */ + if (wParam == CNC_DDRAW_SET_WINDOWED && g_config.windowed && !g_config.fullscreen) + return 0; + + util_toggle_fullscreen(); + } + + return 0; + } + case WM_TOGGLE_MAXIMIZE: + { + if (g_config.resizable) + { + util_toggle_maximize(); + } + + return 0; + } case WM_NCLBUTTONDBLCLK: { if (g_config.resizable)