mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-03-04 09:27:15 +00:00
(GDI/Win32) Refactor code - handle doubleclick press on title bar
inside DInput driver
This commit is contained in:
parent
925ec7bc82
commit
7f8c13ae09
@ -115,11 +115,6 @@ static HDEVNOTIFY notification_handler;
|
||||
#ifdef HAVE_DINPUT
|
||||
extern bool dinput_handle_message(void *dinput, UINT message,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
#ifdef HAVE_GDI
|
||||
extern void *dinput_gdi;
|
||||
#endif
|
||||
extern void *dinput_wgl;
|
||||
extern void *dinput;
|
||||
#endif
|
||||
|
||||
typedef struct DISPLAYCONFIG_RATIONAL_CUSTOM {
|
||||
@ -219,7 +214,6 @@ typedef LONG (WINAPI *QUERYDISPLAYCONFIG)(UINT32, UINT32*, DISPLAYCONFIG_PATH_IN
|
||||
typedef LONG (WINAPI *GETDISPLAYCONFIGBUFFERSIZES)(UINT32, UINT32*, UINT32*);
|
||||
|
||||
bool g_win32_restore_desktop = false;
|
||||
static bool doubleclick_on_titlebar = false;
|
||||
static bool taskbar_is_created = false;
|
||||
bool g_win32_inited = false;
|
||||
|
||||
@ -307,16 +301,6 @@ bool win32_taskbar_is_created(void)
|
||||
return taskbar_is_created;
|
||||
}
|
||||
|
||||
bool doubleclick_on_titlebar_pressed(void)
|
||||
{
|
||||
return doubleclick_on_titlebar;
|
||||
}
|
||||
|
||||
void unset_doubleclick_on_titlebar(void)
|
||||
{
|
||||
doubleclick_on_titlebar = false;
|
||||
}
|
||||
|
||||
static INT_PTR_COMPAT CALLBACK PickCoreProc(
|
||||
HWND hDlg, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
@ -848,7 +832,19 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
|
||||
switch (message)
|
||||
{
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
doubleclick_on_titlebar = true;
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||
taskbar_is_created = true;
|
||||
#endif
|
||||
#ifdef HAVE_DINPUT
|
||||
if (input_get_ptr() == &input_dinput)
|
||||
{
|
||||
void* input_data = input_get_data();
|
||||
if (input_data && dinput_handle_message(input_data,
|
||||
message, wparam, lparam))
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case WM_SYSCOMMAND:
|
||||
/* Prevent screensavers, etc, while running. */
|
||||
@ -1004,6 +1000,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
|
||||
case WM_DEVICECHANGE:
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MOUSEHWHEEL:
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||
taskbar_is_created = true;
|
||||
@ -1016,13 +1013,6 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
|
||||
message, wparam, lparam))
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
doubleclick_on_titlebar = true;
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||
taskbar_is_created = true;
|
||||
#endif
|
||||
break;
|
||||
case WM_DROPFILES:
|
||||
@ -1075,21 +1065,18 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message,
|
||||
case WM_DEVICECHANGE:
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MOUSEHWHEEL:
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||
taskbar_is_created = true;
|
||||
#endif
|
||||
#ifdef HAVE_DINPUT
|
||||
if (dinput_wgl && dinput_handle_message(dinput_wgl,
|
||||
message, wparam, lparam))
|
||||
return 0;
|
||||
#endif
|
||||
break;
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
doubleclick_on_titlebar = true;
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||
taskbar_is_created = true;
|
||||
{
|
||||
void* input_data = input_get_data();
|
||||
if (input_data && dinput_handle_message(input_data,
|
||||
message, wparam, lparam))
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case WM_DROPFILES:
|
||||
@ -1142,21 +1129,18 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
|
||||
case WM_DEVICECHANGE:
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MOUSEHWHEEL:
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||
taskbar_is_created = true;
|
||||
#endif
|
||||
#ifdef HAVE_DINPUT
|
||||
if (dinput_gdi && dinput_handle_message(dinput_gdi,
|
||||
message, wparam, lparam))
|
||||
return 0;
|
||||
#endif
|
||||
break;
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
doubleclick_on_titlebar = true;
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||
taskbar_is_created = true;
|
||||
{
|
||||
void* input_data = input_get_data();
|
||||
if (input_data && dinput_handle_message(input_data,
|
||||
message, wparam, lparam))
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case WM_PAINT:
|
||||
|
@ -54,7 +54,7 @@ typedef struct gfx_ctx_gdi_data
|
||||
void *empty;
|
||||
} gfx_ctx_gdi_data_t;
|
||||
|
||||
void *dinput_gdi;
|
||||
static void *dinput_gdi;
|
||||
|
||||
static void gfx_ctx_gdi_check_window(void *data, bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height)
|
||||
|
@ -114,6 +114,8 @@ static gfx_ctx_vulkan_data_t win32_vk;
|
||||
static egl_ctx_data_t win32_egl;
|
||||
#endif
|
||||
|
||||
static void *dinput_wgl = NULL;
|
||||
|
||||
static unsigned win32_major = 0;
|
||||
static unsigned win32_minor = 0;
|
||||
static int win32_interval = 0;
|
||||
@ -466,8 +468,6 @@ void create_graphics_context(HWND hwnd, bool *quit)
|
||||
}
|
||||
}
|
||||
|
||||
void *dinput_wgl;
|
||||
|
||||
static void gfx_ctx_wgl_swap_interval(void *data, int interval)
|
||||
{
|
||||
(void)data;
|
||||
|
@ -84,6 +84,7 @@ struct dinput_input
|
||||
int mouse_rel_y;
|
||||
int mouse_x;
|
||||
int mouse_y;
|
||||
bool doubleclick_on_titlebar;
|
||||
bool mouse_l, mouse_r, mouse_m, mouse_b4, mouse_b5, mouse_wu, mouse_wd, mouse_hwu, mouse_hwd;
|
||||
struct pointer_status pointer_head; /* dummy head for easier iteration */
|
||||
};
|
||||
@ -190,9 +191,6 @@ static void *dinput_init(const char *joypad_driver)
|
||||
return di;
|
||||
}
|
||||
|
||||
bool doubleclick_on_titlebar_pressed(void);
|
||||
void unset_doubleclick_on_titlebar(void);
|
||||
|
||||
static void dinput_poll(void *data)
|
||||
{
|
||||
struct dinput_input *di = (struct dinput_input*)data;
|
||||
@ -236,8 +234,8 @@ static void dinput_poll(void *data)
|
||||
di->mouse_rel_y = mouse_state.lY;
|
||||
|
||||
if (!mouse_state.rgbButtons[0])
|
||||
unset_doubleclick_on_titlebar();
|
||||
if (doubleclick_on_titlebar_pressed())
|
||||
di->doubleclick_on_titlebar = false;
|
||||
if (di->doubleclick_on_titlebar)
|
||||
di->mouse_l = 0;
|
||||
else
|
||||
di->mouse_l = mouse_state.rgbButtons[0];
|
||||
@ -581,7 +579,7 @@ static int16_t dinput_input_state(void *data,
|
||||
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
|
||||
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
|
||||
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
|
||||
@ -623,7 +621,7 @@ static int16_t dinput_input_state(void *data,
|
||||
}
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
|
||||
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
|
||||
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
|
||||
@ -735,7 +733,7 @@ static int16_t dinput_input_state(void *data,
|
||||
}
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
/* Auto-binds are per joypad, not per user. */
|
||||
const uint64_t joykey = (binds[port][new_id].joykey != NO_BTN)
|
||||
? binds[port][new_id].joykey : joypad_info->auto_binds[new_id].joykey;
|
||||
const uint32_t joyaxis = (binds[port][new_id].joyaxis != AXIS_NONE)
|
||||
@ -852,7 +850,8 @@ static void dinput_clear_pointers(struct dinput_input *di)
|
||||
}
|
||||
}
|
||||
|
||||
bool dinput_handle_message(void *data, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
bool dinput_handle_message(void *data,
|
||||
UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
struct dinput_input *di = (struct dinput_input *)data;
|
||||
/* WM_POINTERDOWN : Arrives for each new touch event
|
||||
@ -865,6 +864,9 @@ bool dinput_handle_message(void *data, UINT message, WPARAM wParam, LPARAM lPara
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
di->doubleclick_on_titlebar = true;
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
di->window_pos_x = GET_X_LPARAM(lParam);
|
||||
di->window_pos_y = GET_Y_LPARAM(lParam);
|
||||
|
Loading…
x
Reference in New Issue
Block a user