Revert "(Win32) Move global state to struct"
This reverts commit dfa1288988
.
This commit is contained in:
parent
26bb0105c0
commit
b4da4940eb
|
@ -111,10 +111,6 @@
|
||||||
#define WM_POINTERUP 0x0247
|
#define WM_POINTERUP 0x0247
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAX_MONITORS
|
|
||||||
#define MAX_MONITORS 9
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const GUID GUID_DEVINTERFACE_HID = { 0x4d1e55b2, 0xf16f, 0x11Cf, { 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } };
|
const GUID GUID_DEVINTERFACE_HID = { 0x4d1e55b2, 0xf16f, 0x11Cf, { 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } };
|
||||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x501
|
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x501
|
||||||
static HDEVNOTIFY notification_handler;
|
static HDEVNOTIFY notification_handler;
|
||||||
|
@ -140,17 +136,14 @@ typedef struct DISPLAYCONFIG_2DREGION_CUSTOM {
|
||||||
UINT32 cy;
|
UINT32 cy;
|
||||||
} DISPLAYCONFIG_2DREGION_CUSTOM;
|
} DISPLAYCONFIG_2DREGION_CUSTOM;
|
||||||
|
|
||||||
typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM
|
typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM {
|
||||||
{
|
|
||||||
UINT64 pixelRate;
|
UINT64 pixelRate;
|
||||||
DISPLAYCONFIG_RATIONAL_CUSTOM hSyncFreq;
|
DISPLAYCONFIG_RATIONAL_CUSTOM hSyncFreq;
|
||||||
DISPLAYCONFIG_RATIONAL_CUSTOM vSyncFreq;
|
DISPLAYCONFIG_RATIONAL_CUSTOM vSyncFreq;
|
||||||
DISPLAYCONFIG_2DREGION_CUSTOM activeSize;
|
DISPLAYCONFIG_2DREGION_CUSTOM activeSize;
|
||||||
DISPLAYCONFIG_2DREGION_CUSTOM totalSize;
|
DISPLAYCONFIG_2DREGION_CUSTOM totalSize;
|
||||||
union
|
union {
|
||||||
{
|
struct {
|
||||||
struct
|
|
||||||
{
|
|
||||||
UINT32 videoStandard :16;
|
UINT32 videoStandard :16;
|
||||||
UINT32 vSyncFreqDivider :6;
|
UINT32 vSyncFreqDivider :6;
|
||||||
UINT32 reserved :10;
|
UINT32 reserved :10;
|
||||||
|
@ -160,20 +153,16 @@ typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM
|
||||||
UINT32 scanLineOrdering;
|
UINT32 scanLineOrdering;
|
||||||
} DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM;
|
} DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM;
|
||||||
|
|
||||||
typedef struct DISPLAYCONFIG_TARGET_MODE_CUSTOM
|
typedef struct DISPLAYCONFIG_TARGET_MODE_CUSTOM {
|
||||||
{
|
|
||||||
DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM targetVideoSignalInfo;
|
DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM targetVideoSignalInfo;
|
||||||
} DISPLAYCONFIG_TARGET_MODE_CUSTOM;
|
} DISPLAYCONFIG_TARGET_MODE_CUSTOM;
|
||||||
|
|
||||||
typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM
|
typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM {
|
||||||
{
|
|
||||||
LUID adapterId;
|
LUID adapterId;
|
||||||
UINT32 id;
|
UINT32 id;
|
||||||
union
|
union {
|
||||||
{
|
|
||||||
UINT32 modeInfoIdx;
|
UINT32 modeInfoIdx;
|
||||||
struct
|
struct {
|
||||||
{
|
|
||||||
UINT32 cloneGroupId :16;
|
UINT32 cloneGroupId :16;
|
||||||
UINT32 sourceModeInfoIdx :16;
|
UINT32 sourceModeInfoIdx :16;
|
||||||
} dummystructname;
|
} dummystructname;
|
||||||
|
@ -181,43 +170,36 @@ typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM
|
||||||
UINT32 statusFlags;
|
UINT32 statusFlags;
|
||||||
} DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM;
|
} DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM;
|
||||||
|
|
||||||
typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM
|
typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM {
|
||||||
{
|
|
||||||
POINTL PathSourceSize;
|
POINTL PathSourceSize;
|
||||||
RECTL DesktopImageRegion;
|
RECTL DesktopImageRegion;
|
||||||
RECTL DesktopImageClip;
|
RECTL DesktopImageClip;
|
||||||
} DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM;
|
} DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM;
|
||||||
|
|
||||||
typedef struct DISPLAYCONFIG_SOURCE_MODE_CUSTOM
|
typedef struct DISPLAYCONFIG_SOURCE_MODE_CUSTOM {
|
||||||
{
|
|
||||||
UINT32 width;
|
UINT32 width;
|
||||||
UINT32 height;
|
UINT32 height;
|
||||||
UINT32 pixelFormat;
|
UINT32 pixelFormat;
|
||||||
POINTL position;
|
POINTL position;
|
||||||
} DISPLAYCONFIG_SOURCE_MODE_CUSTOM;
|
} DISPLAYCONFIG_SOURCE_MODE_CUSTOM;
|
||||||
|
|
||||||
typedef struct DISPLAYCONFIG_MODE_INFO_CUSTOM
|
typedef struct DISPLAYCONFIG_MODE_INFO_CUSTOM {
|
||||||
{
|
|
||||||
UINT32 infoType;
|
UINT32 infoType;
|
||||||
UINT32 id;
|
UINT32 id;
|
||||||
LUID adapterId;
|
LUID adapterId;
|
||||||
union
|
union {
|
||||||
{
|
|
||||||
DISPLAYCONFIG_TARGET_MODE_CUSTOM targetMode;
|
DISPLAYCONFIG_TARGET_MODE_CUSTOM targetMode;
|
||||||
DISPLAYCONFIG_SOURCE_MODE_CUSTOM sourceMode;
|
DISPLAYCONFIG_SOURCE_MODE_CUSTOM sourceMode;
|
||||||
DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM desktopImageInfo;
|
DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM desktopImageInfo;
|
||||||
} dummyunionname;
|
} dummyunionname;
|
||||||
} DISPLAYCONFIG_MODE_INFO_CUSTOM;
|
} DISPLAYCONFIG_MODE_INFO_CUSTOM;
|
||||||
|
|
||||||
typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM
|
typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM {
|
||||||
{
|
|
||||||
LUID adapterId;
|
LUID adapterId;
|
||||||
UINT32 id;
|
UINT32 id;
|
||||||
union
|
union {
|
||||||
{
|
|
||||||
UINT32 modeInfoIdx;
|
UINT32 modeInfoIdx;
|
||||||
struct
|
struct {
|
||||||
{
|
|
||||||
UINT32 desktopModeInfoIdx :16;
|
UINT32 desktopModeInfoIdx :16;
|
||||||
UINT32 targetModeInfoIdx :16;
|
UINT32 targetModeInfoIdx :16;
|
||||||
} dummystructname;
|
} dummystructname;
|
||||||
|
@ -231,8 +213,7 @@ typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM
|
||||||
UINT32 statusFlags;
|
UINT32 statusFlags;
|
||||||
} DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM;
|
} DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM;
|
||||||
|
|
||||||
typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM
|
typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM {
|
||||||
{
|
|
||||||
DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM sourceInfo;
|
DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM sourceInfo;
|
||||||
DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM targetInfo;
|
DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM targetInfo;
|
||||||
UINT32 flags;
|
UINT32 flags;
|
||||||
|
@ -241,45 +222,22 @@ typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM
|
||||||
typedef LONG (WINAPI *QUERYDISPLAYCONFIG)(UINT32, UINT32*, DISPLAYCONFIG_PATH_INFO_CUSTOM*, UINT32*, DISPLAYCONFIG_MODE_INFO_CUSTOM*, UINT32*);
|
typedef LONG (WINAPI *QUERYDISPLAYCONFIG)(UINT32, UINT32*, DISPLAYCONFIG_PATH_INFO_CUSTOM*, UINT32*, DISPLAYCONFIG_MODE_INFO_CUSTOM*, UINT32*);
|
||||||
typedef LONG (WINAPI *GETDISPLAYCONFIGBUFFERSIZES)(UINT32, UINT32*, UINT32*);
|
typedef LONG (WINAPI *GETDISPLAYCONFIGBUFFERSIZES)(UINT32, UINT32*, UINT32*);
|
||||||
|
|
||||||
typedef struct win32_common_state
|
static bool g_win32_resized = false;
|
||||||
{
|
|
||||||
bool resized;
|
|
||||||
bool doubleclick_on_titlebar;
|
|
||||||
bool taskbar_is_created;
|
|
||||||
bool quit;
|
|
||||||
|
|
||||||
int pos_x;
|
|
||||||
int pos_y;
|
|
||||||
unsigned pos_width;
|
|
||||||
unsigned pos_height;
|
|
||||||
unsigned taskbar_message;
|
|
||||||
unsigned monitor_count;
|
|
||||||
|
|
||||||
HMONITOR monitor_last;
|
|
||||||
HMONITOR monitor_all[MAX_MONITORS];
|
|
||||||
} win32_common_state_t;
|
|
||||||
|
|
||||||
static win32_common_state_t win32_common_st =
|
|
||||||
{
|
|
||||||
false, /* resized */
|
|
||||||
false, /* doubleclick_on_titlebar */
|
|
||||||
false, /* taskbar_is_created */
|
|
||||||
false, /* quit */
|
|
||||||
CW_USEDEFAULT, /* pos_x */
|
|
||||||
CW_USEDEFAULT, /* pos_y */
|
|
||||||
0, /* pos_width */
|
|
||||||
0, /* pos_height */
|
|
||||||
0, /* taskbar_message */
|
|
||||||
0, /* monitor_count */
|
|
||||||
|
|
||||||
NULL, /* monitor_last */
|
|
||||||
};
|
|
||||||
|
|
||||||
bool g_win32_restore_desktop = false;
|
bool g_win32_restore_desktop = false;
|
||||||
|
static bool doubleclick_on_titlebar = false;
|
||||||
|
static bool taskbar_is_created = false;
|
||||||
bool g_win32_inited = false;
|
bool g_win32_inited = false;
|
||||||
|
static bool g_win32_quit = false;
|
||||||
|
|
||||||
|
static int g_win32_pos_x = CW_USEDEFAULT;
|
||||||
|
static int g_win32_pos_y = CW_USEDEFAULT;
|
||||||
|
static unsigned g_win32_pos_width = 0;
|
||||||
|
static unsigned g_win32_pos_height = 0;
|
||||||
|
|
||||||
unsigned g_win32_resize_width = 0;
|
unsigned g_win32_resize_width = 0;
|
||||||
unsigned g_win32_resize_height = 0;
|
unsigned g_win32_resize_height = 0;
|
||||||
|
static unsigned g_taskbar_message = 0;
|
||||||
|
static unsigned win32_monitor_count = 0;
|
||||||
|
|
||||||
static void *curD3D = NULL;
|
static void *curD3D = NULL;
|
||||||
|
|
||||||
|
@ -322,29 +280,32 @@ typedef enum _POWER_REQUEST_TYPE
|
||||||
typedef REASON_CONTEXT POWER_REQUEST_CONTEXT, *PPOWER_REQUEST_CONTEXT, *LPPOWER_REQUEST_CONTEXT;
|
typedef REASON_CONTEXT POWER_REQUEST_CONTEXT, *PPOWER_REQUEST_CONTEXT, *LPPOWER_REQUEST_CONTEXT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX_MONITORS
|
||||||
|
#define MAX_MONITORS 9
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1200
|
#if defined(_MSC_VER) && _MSC_VER <= 1200
|
||||||
#define INT_PTR_COMPAT int
|
#define INT_PTR_COMPAT int
|
||||||
#else
|
#else
|
||||||
#define INT_PTR_COMPAT INT_PTR
|
#define INT_PTR_COMPAT INT_PTR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static HMONITOR win32_monitor_last;
|
||||||
|
static HMONITOR win32_monitor_all[MAX_MONITORS];
|
||||||
|
|
||||||
bool win32_taskbar_is_created(void)
|
bool win32_taskbar_is_created(void)
|
||||||
{
|
{
|
||||||
win32_common_state_t *g_win32 = &win32_common_st;
|
return taskbar_is_created;
|
||||||
return g_win32->taskbar_is_created;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doubleclick_on_titlebar_pressed(void)
|
bool doubleclick_on_titlebar_pressed(void)
|
||||||
{
|
{
|
||||||
win32_common_state_t *g_win32 = &win32_common_st;
|
return doubleclick_on_titlebar;
|
||||||
return g_win32->doubleclick_on_titlebar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unset_doubleclick_on_titlebar(void)
|
void unset_doubleclick_on_titlebar(void)
|
||||||
{
|
{
|
||||||
win32_common_state_t *g_win32 = &win32_common_st;
|
doubleclick_on_titlebar = false;
|
||||||
|
|
||||||
g_win32->doubleclick_on_titlebar = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR_COMPAT CALLBACK PickCoreProc(
|
static INT_PTR_COMPAT CALLBACK PickCoreProc(
|
||||||
|
@ -414,23 +375,20 @@ static INT_PTR_COMPAT CALLBACK PickCoreProc(
|
||||||
static BOOL CALLBACK win32_monitor_enum_proc(HMONITOR hMonitor,
|
static BOOL CALLBACK win32_monitor_enum_proc(HMONITOR hMonitor,
|
||||||
HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
||||||
{
|
{
|
||||||
win32_common_state_t *g_win32 = &win32_common_st;
|
win32_monitor_all[win32_monitor_count++] = hMonitor;
|
||||||
|
|
||||||
g_win32->monitor_all[g_win32->monitor_count++] = hMonitor;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void win32_monitor_from_window(void)
|
void win32_monitor_from_window(void)
|
||||||
{
|
{
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
win32_common_state_t
|
ui_window_t *window = NULL;
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
ui_window_t *window = (ui_window_t*)
|
|
||||||
ui_companion_driver_get_window_ptr();
|
|
||||||
|
|
||||||
g_win32->monitor_last =
|
win32_monitor_last =
|
||||||
MonitorFromWindow(main_window.hwnd, MONITOR_DEFAULTTONEAREST);
|
MonitorFromWindow(main_window.hwnd, MONITOR_DEFAULTTONEAREST);
|
||||||
|
|
||||||
|
window = (ui_window_t*)ui_companion_driver_get_window_ptr();
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
window->destroy(&main_window);
|
window->destroy(&main_window);
|
||||||
#endif
|
#endif
|
||||||
|
@ -452,14 +410,11 @@ int win32_change_display_settings(const char *str, void *devmode_data,
|
||||||
void win32_monitor_get_info(void)
|
void win32_monitor_get_info(void)
|
||||||
{
|
{
|
||||||
MONITORINFOEX current_mon;
|
MONITORINFOEX current_mon;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
|
|
||||||
memset(¤t_mon, 0, sizeof(current_mon));
|
memset(¤t_mon, 0, sizeof(current_mon));
|
||||||
current_mon.cbSize = sizeof(MONITORINFOEX);
|
current_mon.cbSize = sizeof(MONITORINFOEX);
|
||||||
|
|
||||||
GetMonitorInfo(g_win32->monitor_last,
|
GetMonitorInfo(win32_monitor_last, (LPMONITORINFO)¤t_mon);
|
||||||
(LPMONITORINFO)¤t_mon);
|
|
||||||
|
|
||||||
win32_change_display_settings(current_mon.szDevice, NULL, 0);
|
win32_change_display_settings(current_mon.szDevice, NULL, 0);
|
||||||
}
|
}
|
||||||
|
@ -470,27 +425,25 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
MONITORINFOEX *mon = (MONITORINFOEX*)data;
|
MONITORINFOEX *mon = (MONITORINFOEX*)data;
|
||||||
HMONITOR *hm_to_use = (HMONITOR*)hm_data;
|
HMONITOR *hm_to_use = (HMONITOR*)hm_data;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
unsigned fs_monitor = settings->uints.video_monitor_index;
|
unsigned fs_monitor = settings->uints.video_monitor_index;
|
||||||
|
|
||||||
if (!g_win32->monitor_last)
|
if (!win32_monitor_last)
|
||||||
g_win32->monitor_last = MonitorFromWindow(GetDesktopWindow(),
|
win32_monitor_last = MonitorFromWindow(GetDesktopWindow(),
|
||||||
MONITOR_DEFAULTTONEAREST);
|
MONITOR_DEFAULTTONEAREST);
|
||||||
|
|
||||||
*hm_to_use = g_win32->monitor_last;
|
*hm_to_use = win32_monitor_last;
|
||||||
|
|
||||||
if (fs_monitor && fs_monitor <= g_win32->monitor_count
|
if (fs_monitor && fs_monitor <= win32_monitor_count
|
||||||
&& g_win32->monitor_all[fs_monitor - 1])
|
&& win32_monitor_all[fs_monitor - 1])
|
||||||
{
|
{
|
||||||
*hm_to_use = g_win32->monitor_all[fs_monitor - 1];
|
*hm_to_use = win32_monitor_all[fs_monitor - 1];
|
||||||
*mon_id = fs_monitor - 1;
|
*mon_id = fs_monitor - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < g_win32->monitor_count; i++)
|
for (i = 0; i < win32_monitor_count; i++)
|
||||||
{
|
{
|
||||||
if (g_win32->monitor_all[i] != *hm_to_use)
|
if (win32_monitor_all[i] != *hm_to_use)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
*mon_id = i;
|
*mon_id = i;
|
||||||
|
@ -626,8 +579,6 @@ static void win32_save_position(void)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
WINDOWPLACEMENT placement;
|
WINDOWPLACEMENT placement;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
|
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
|
||||||
int title_bar_height = GetSystemMetrics(SM_CYCAPTION);
|
int title_bar_height = GetSystemMetrics(SM_CYCAPTION);
|
||||||
int menu_bar_height = GetSystemMetrics(SM_CYMENU);
|
int menu_bar_height = GetSystemMetrics(SM_CYMENU);
|
||||||
|
@ -638,17 +589,17 @@ static void win32_save_position(void)
|
||||||
|
|
||||||
memset(&placement, 0, sizeof(placement));
|
memset(&placement, 0, sizeof(placement));
|
||||||
|
|
||||||
placement.length = sizeof(placement);
|
placement.length = sizeof(placement);
|
||||||
|
|
||||||
GetWindowPlacement(main_window.hwnd, &placement);
|
GetWindowPlacement(main_window.hwnd, &placement);
|
||||||
|
|
||||||
g_win32->pos_x = placement.rcNormalPosition.left;
|
g_win32_pos_x = placement.rcNormalPosition.left;
|
||||||
g_win32->pos_y = placement.rcNormalPosition.top;
|
g_win32_pos_y = placement.rcNormalPosition.top;
|
||||||
|
|
||||||
if (GetWindowRect(main_window.hwnd, &rect))
|
if (GetWindowRect(main_window.hwnd, &rect))
|
||||||
{
|
{
|
||||||
g_win32->pos_width = rect.right - rect.left;
|
g_win32_pos_width = rect.right - rect.left;
|
||||||
g_win32->pos_height = rect.bottom - rect.top;
|
g_win32_pos_height = rect.bottom - rect.top;
|
||||||
}
|
}
|
||||||
if (window_save_positions)
|
if (window_save_positions)
|
||||||
{
|
{
|
||||||
|
@ -656,14 +607,10 @@ static void win32_save_position(void)
|
||||||
!retroarch_is_forced_fullscreen() &&
|
!retroarch_is_forced_fullscreen() &&
|
||||||
!retroarch_is_switching_display_mode())
|
!retroarch_is_switching_display_mode())
|
||||||
{
|
{
|
||||||
settings->uints.window_position_x = g_win32->pos_x;
|
settings->uints.window_position_x = g_win32_pos_x;
|
||||||
settings->uints.window_position_y = g_win32->pos_y;
|
settings->uints.window_position_y = g_win32_pos_y;
|
||||||
settings->uints.window_position_width = g_win32->pos_width -
|
settings->uints.window_position_width = g_win32_pos_width - border_thickness * 2;
|
||||||
border_thickness * 2;
|
settings->uints.window_position_height = g_win32_pos_height - border_thickness * 2 - title_bar_height - (ui_menubar_enable ? menu_bar_height : 0);
|
||||||
settings->uints.window_position_height = g_win32->pos_height -
|
|
||||||
border_thickness * 2 -
|
|
||||||
title_bar_height -
|
|
||||||
(ui_menubar_enable ? menu_bar_height : 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -877,13 +824,11 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
|
||||||
WPARAM wparam, LPARAM lparam)
|
WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
bool keydown = true;
|
bool keydown = true;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_NCLBUTTONDBLCLK:
|
case WM_NCLBUTTONDBLCLK:
|
||||||
g_win32->doubleclick_on_titlebar = true;
|
doubleclick_on_titlebar = true;
|
||||||
break;
|
break;
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
/* Prevent screensavers, etc, while running. */
|
/* Prevent screensavers, etc, while running. */
|
||||||
|
@ -989,7 +934,7 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
case WM_QUIT:
|
case WM_QUIT:
|
||||||
g_win32->quit = true;
|
g_win32_quit = true;
|
||||||
*quit = true;
|
*quit = true;
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
case WM_MOVE:
|
case WM_MOVE:
|
||||||
|
@ -1005,7 +950,7 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
|
||||||
{
|
{
|
||||||
g_win32_resize_width = LOWORD(lparam);
|
g_win32_resize_width = LOWORD(lparam);
|
||||||
g_win32_resize_height = HIWORD(lparam);
|
g_win32_resize_height = HIWORD(lparam);
|
||||||
g_win32->resized = true;
|
g_win32_resized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*quit = true;
|
*quit = true;
|
||||||
|
@ -1027,9 +972,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
|
||||||
WPARAM wparam, LPARAM lparam)
|
WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
LRESULT ret;
|
LRESULT ret;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
|
@ -1041,8 +984,8 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_DINPUT
|
#ifdef HAVE_DINPUT
|
||||||
if (input_get_ptr() == &input_dinput)
|
if (input_get_ptr() == &input_dinput)
|
||||||
|
@ -1055,10 +998,10 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_NCLBUTTONDBLCLK:
|
case WM_NCLBUTTONDBLCLK:
|
||||||
g_win32->doubleclick_on_titlebar = true;
|
doubleclick_on_titlebar = true;
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_DROPFILES:
|
case WM_DROPFILES:
|
||||||
|
@ -1078,8 +1021,8 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
|
||||||
if (quit)
|
if (quit)
|
||||||
return ret;
|
return ret;
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
|
@ -1104,8 +1047,6 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message,
|
||||||
{
|
{
|
||||||
LRESULT ret;
|
LRESULT ret;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
|
@ -1117,8 +1058,8 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message,
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_DINPUT
|
#ifdef HAVE_DINPUT
|
||||||
if (dinput_wgl && dinput_handle_message(dinput_wgl,
|
if (dinput_wgl && dinput_handle_message(dinput_wgl,
|
||||||
|
@ -1127,10 +1068,10 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message,
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_NCLBUTTONDBLCLK:
|
case WM_NCLBUTTONDBLCLK:
|
||||||
g_win32->doubleclick_on_titlebar = true;
|
doubleclick_on_titlebar = true;
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_DROPFILES:
|
case WM_DROPFILES:
|
||||||
|
@ -1151,12 +1092,12 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message,
|
||||||
if (quit)
|
if (quit)
|
||||||
return ret;
|
return ret;
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
create_graphics_context(hwnd, &g_win32->quit);
|
create_graphics_context(hwnd, &g_win32_quit);
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1172,8 +1113,6 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
|
||||||
{
|
{
|
||||||
LRESULT ret;
|
LRESULT ret;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
|
@ -1185,8 +1124,8 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_DINPUT
|
#ifdef HAVE_DINPUT
|
||||||
if (dinput_gdi && dinput_handle_message(dinput_gdi,
|
if (dinput_gdi && dinput_handle_message(dinput_gdi,
|
||||||
|
@ -1195,10 +1134,10 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_NCLBUTTONDBLCLK:
|
case WM_NCLBUTTONDBLCLK:
|
||||||
g_win32->doubleclick_on_titlebar = true;
|
doubleclick_on_titlebar = true;
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
|
@ -1235,8 +1174,8 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1257,12 +1196,12 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
|
||||||
if (quit)
|
if (quit)
|
||||||
return ret;
|
return ret;
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_taskbar_message && message == g_taskbar_message)
|
||||||
g_win32->taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
create_gdi_context(hwnd, &g_win32->quit);
|
create_gdi_context(hwnd, &g_win32_quit);
|
||||||
if (DragAcceptFiles_func)
|
if (DragAcceptFiles_func)
|
||||||
DragAcceptFiles_func(hwnd, true);
|
DragAcceptFiles_func(hwnd, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1286,19 +1225,17 @@ bool win32_window_create(void *data, unsigned style,
|
||||||
bool window_save_positions = settings->bools.video_window_save_positions;
|
bool window_save_positions = settings->bools.video_window_save_positions;
|
||||||
unsigned user_width = width;
|
unsigned user_width = width;
|
||||||
unsigned user_height = height;
|
unsigned user_height = height;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
|
|
||||||
if (window_save_positions && !fullscreen)
|
if (window_save_positions && !fullscreen)
|
||||||
{
|
{
|
||||||
user_width = g_win32->pos_width;
|
user_width = g_win32_pos_width;
|
||||||
user_height= g_win32->pos_height;
|
user_height= g_win32_pos_height;
|
||||||
}
|
}
|
||||||
main_window.hwnd = CreateWindowEx(0,
|
main_window.hwnd = CreateWindowEx(0,
|
||||||
msg_hash_to_str(MSG_PROGRAM), msg_hash_to_str(MSG_PROGRAM),
|
msg_hash_to_str(MSG_PROGRAM), msg_hash_to_str(MSG_PROGRAM),
|
||||||
style,
|
style,
|
||||||
fullscreen ? mon_rect->left : g_win32->pos_x,
|
fullscreen ? mon_rect->left : g_win32_pos_x,
|
||||||
fullscreen ? mon_rect->top : g_win32->pos_y,
|
fullscreen ? mon_rect->top : g_win32_pos_y,
|
||||||
user_width,
|
user_width,
|
||||||
user_height,
|
user_height,
|
||||||
NULL, NULL, NULL, data);
|
NULL, NULL, NULL, data);
|
||||||
|
@ -1306,7 +1243,7 @@ bool win32_window_create(void *data, unsigned style,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 /* 2K */
|
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
g_win32->taskbar_message = RegisterWindowMessage("TaskbarButtonCreated");
|
g_taskbar_message = RegisterWindowMessage("TaskbarButtonCreated");
|
||||||
|
|
||||||
memset(¬ification_filter, 0, sizeof(notification_filter));
|
memset(¬ification_filter, 0, sizeof(notification_filter));
|
||||||
notification_filter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
|
notification_filter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
|
||||||
|
@ -1386,14 +1323,11 @@ bool win32_get_metrics(void *data,
|
||||||
void win32_monitor_init(void)
|
void win32_monitor_init(void)
|
||||||
{
|
{
|
||||||
#if !defined(_XBOX)
|
#if !defined(_XBOX)
|
||||||
win32_common_state_t
|
win32_monitor_count = 0;
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
|
|
||||||
g_win32->monitor_count = 0;
|
|
||||||
EnumDisplayMonitors(NULL, NULL,
|
EnumDisplayMonitors(NULL, NULL,
|
||||||
win32_monitor_enum_proc, 0);
|
win32_monitor_enum_proc, 0);
|
||||||
#endif
|
#endif
|
||||||
g_win32->quit = false;
|
g_win32_quit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool win32_monitor_set_fullscreen(
|
static bool win32_monitor_set_fullscreen(
|
||||||
|
@ -1433,19 +1367,17 @@ void win32_check_window(bool *quit, bool *resize,
|
||||||
unsigned *width, unsigned *height)
|
unsigned *width, unsigned *height)
|
||||||
{
|
{
|
||||||
#if !defined(_XBOX)
|
#if !defined(_XBOX)
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
bool video_is_threaded = video_driver_is_threaded();
|
bool video_is_threaded = video_driver_is_threaded();
|
||||||
if (video_is_threaded)
|
if (video_is_threaded)
|
||||||
ui_companion_win32.application->process_events();
|
ui_companion_win32.application->process_events();
|
||||||
*quit = g_win32->quit;
|
*quit = g_win32_quit;
|
||||||
|
|
||||||
if (g_win32->resized)
|
if (g_win32_resized)
|
||||||
{
|
{
|
||||||
*resize = true;
|
*resize = true;
|
||||||
*width = g_win32_resize_width;
|
*width = g_win32_resize_width;
|
||||||
*height = g_win32_resize_width;
|
*height = g_win32_resize_height;
|
||||||
g_win32->resized = false;
|
g_win32_resized = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1542,7 +1474,6 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
|
||||||
unsigned window_position_y = settings->uints.window_position_y;
|
unsigned window_position_y = settings->uints.window_position_y;
|
||||||
unsigned window_position_width = settings->uints.window_position_width;
|
unsigned window_position_width = settings->uints.window_position_width;
|
||||||
unsigned window_position_height = settings->uints.window_position_height;
|
unsigned window_position_height = settings->uints.window_position_height;
|
||||||
win32_common_state_t *g_win32 = &win32_common_st;
|
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
|
@ -1583,27 +1514,24 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
|
||||||
if (video_window_save_positions)
|
if (video_window_save_positions)
|
||||||
{
|
{
|
||||||
/* Set position from config */
|
/* Set position from config */
|
||||||
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
|
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
|
||||||
int title_bar_height = GetSystemMetrics(SM_CYCAPTION);
|
int title_bar_height = GetSystemMetrics(SM_CYCAPTION);
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
|
|
||||||
g_win32->pos_x = window_position_x;
|
g_win32_pos_x = window_position_x;
|
||||||
g_win32->pos_y = window_position_y;
|
g_win32_pos_y = window_position_y;
|
||||||
g_win32->pos_width = window_position_width
|
g_win32_pos_width = window_position_width
|
||||||
+ border_thickness * 2;
|
+ border_thickness * 2;
|
||||||
g_win32->pos_height = window_position_height
|
g_win32_pos_height = window_position_height
|
||||||
+ border_thickness * 2 + title_bar_height;
|
+ border_thickness * 2 + title_bar_height;
|
||||||
|
|
||||||
if ( (g_win32->pos_width != 0) &&
|
if (g_win32_pos_width != 0 && g_win32_pos_height != 0)
|
||||||
(g_win32->pos_height != 0))
|
|
||||||
position_set_from_config = true;
|
position_set_from_config = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position_set_from_config)
|
if (position_set_from_config)
|
||||||
{
|
{
|
||||||
g_win32_resize_width = *width = g_win32->pos_width;
|
g_win32_resize_width = *width = g_win32_pos_width;
|
||||||
g_win32_resize_height = *height = g_win32->pos_height;
|
g_win32_resize_height = *height = g_win32_pos_height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1666,8 +1594,6 @@ bool win32_set_video_mode(void *data,
|
||||||
int res = 0;
|
int res = 0;
|
||||||
unsigned mon_id = 0;
|
unsigned mon_id = 0;
|
||||||
HMONITOR hm_to_use = NULL;
|
HMONITOR hm_to_use = NULL;
|
||||||
win32_common_state_t
|
|
||||||
*g_win32 = &win32_common_st;
|
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
bool windowed_full = settings->bools.video_windowed_fullscreen;
|
bool windowed_full = settings->bools.video_windowed_fullscreen;
|
||||||
|
|
||||||
|
@ -1694,7 +1620,7 @@ bool win32_set_video_mode(void *data,
|
||||||
|
|
||||||
/* Wait until context is created (or failed to do so ...).
|
/* Wait until context is created (or failed to do so ...).
|
||||||
* Please don't remove the (res = ) as GetMessage can return -1. */
|
* Please don't remove the (res = ) as GetMessage can return -1. */
|
||||||
while (!g_win32_inited && !g_win32->quit
|
while (!g_win32_inited && !g_win32_quit
|
||||||
&& (res = GetMessage(&msg, main_window.hwnd, 0, 0)) != 0)
|
&& (res = GetMessage(&msg, main_window.hwnd, 0, 0)) != 0)
|
||||||
{
|
{
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
|
@ -1707,7 +1633,7 @@ bool win32_set_video_mode(void *data,
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_win32->quit)
|
if (g_win32_quit)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1751,10 +1677,8 @@ HWND win32_get_window(void)
|
||||||
|
|
||||||
void win32_window_reset(void)
|
void win32_window_reset(void)
|
||||||
{
|
{
|
||||||
win32_common_state_t *g_win32 = &win32_common_st;
|
g_win32_quit = false;
|
||||||
|
g_win32_restore_desktop = false;
|
||||||
g_win32->quit = false;
|
|
||||||
g_win32_restore_desktop = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void win32_destroy_window(void)
|
void win32_destroy_window(void)
|
||||||
|
|
Loading…
Reference in New Issue