mirror of
https://github.com/libretro/RetroArch
synced 2025-03-24 04:44:02 +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
|
#ifdef HAVE_DINPUT
|
||||||
extern bool dinput_handle_message(void *dinput, UINT message,
|
extern bool dinput_handle_message(void *dinput, UINT message,
|
||||||
WPARAM wParam, LPARAM lParam);
|
WPARAM wParam, LPARAM lParam);
|
||||||
#ifdef HAVE_GDI
|
|
||||||
extern void *dinput_gdi;
|
|
||||||
#endif
|
|
||||||
extern void *dinput_wgl;
|
|
||||||
extern void *dinput;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct DISPLAYCONFIG_RATIONAL_CUSTOM {
|
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*);
|
typedef LONG (WINAPI *GETDISPLAYCONFIGBUFFERSIZES)(UINT32, UINT32*, UINT32*);
|
||||||
|
|
||||||
bool g_win32_restore_desktop = false;
|
bool g_win32_restore_desktop = false;
|
||||||
static bool doubleclick_on_titlebar = false;
|
|
||||||
static bool taskbar_is_created = false;
|
static bool taskbar_is_created = false;
|
||||||
bool g_win32_inited = false;
|
bool g_win32_inited = false;
|
||||||
|
|
||||||
@ -307,16 +301,6 @@ bool win32_taskbar_is_created(void)
|
|||||||
return taskbar_is_created;
|
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(
|
static INT_PTR_COMPAT CALLBACK PickCoreProc(
|
||||||
HWND hDlg, UINT message,
|
HWND hDlg, UINT message,
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
@ -848,7 +832,19 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
|
|||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_NCLBUTTONDBLCLK:
|
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;
|
break;
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
/* Prevent screensavers, etc, while running. */
|
/* Prevent screensavers, etc, while running. */
|
||||||
@ -1004,6 +1000,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
|
|||||||
case WM_DEVICECHANGE:
|
case WM_DEVICECHANGE:
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
|
case WM_NCLBUTTONDBLCLK:
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
@ -1016,13 +1013,6 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
|
|||||||
message, wparam, lparam))
|
message, wparam, lparam))
|
||||||
return 0;
|
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
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_DROPFILES:
|
case WM_DROPFILES:
|
||||||
@ -1075,21 +1065,18 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message,
|
|||||||
case WM_DEVICECHANGE:
|
case WM_DEVICECHANGE:
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
|
case WM_NCLBUTTONDBLCLK:
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_DINPUT
|
#ifdef HAVE_DINPUT
|
||||||
if (dinput_wgl && dinput_handle_message(dinput_wgl,
|
{
|
||||||
message, wparam, lparam))
|
void* input_data = input_get_data();
|
||||||
return 0;
|
if (input_data && dinput_handle_message(input_data,
|
||||||
#endif
|
message, wparam, lparam))
|
||||||
break;
|
return 0;
|
||||||
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
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_DROPFILES:
|
case WM_DROPFILES:
|
||||||
@ -1142,21 +1129,18 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
|
|||||||
case WM_DEVICECHANGE:
|
case WM_DEVICECHANGE:
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
|
case WM_NCLBUTTONDBLCLK:
|
||||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||||
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
|
||||||
taskbar_is_created = true;
|
taskbar_is_created = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_DINPUT
|
#ifdef HAVE_DINPUT
|
||||||
if (dinput_gdi && dinput_handle_message(dinput_gdi,
|
{
|
||||||
message, wparam, lparam))
|
void* input_data = input_get_data();
|
||||||
return 0;
|
if (input_data && dinput_handle_message(input_data,
|
||||||
#endif
|
message, wparam, lparam))
|
||||||
break;
|
return 0;
|
||||||
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
|
#endif
|
||||||
break;
|
break;
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
|
@ -54,7 +54,7 @@ typedef struct gfx_ctx_gdi_data
|
|||||||
void *empty;
|
void *empty;
|
||||||
} gfx_ctx_gdi_data_t;
|
} gfx_ctx_gdi_data_t;
|
||||||
|
|
||||||
void *dinput_gdi;
|
static void *dinput_gdi;
|
||||||
|
|
||||||
static void gfx_ctx_gdi_check_window(void *data, bool *quit,
|
static void gfx_ctx_gdi_check_window(void *data, bool *quit,
|
||||||
bool *resize, unsigned *width, unsigned *height)
|
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;
|
static egl_ctx_data_t win32_egl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void *dinput_wgl = NULL;
|
||||||
|
|
||||||
static unsigned win32_major = 0;
|
static unsigned win32_major = 0;
|
||||||
static unsigned win32_minor = 0;
|
static unsigned win32_minor = 0;
|
||||||
static int win32_interval = 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)
|
static void gfx_ctx_wgl_swap_interval(void *data, int interval)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
|
@ -84,6 +84,7 @@ struct dinput_input
|
|||||||
int mouse_rel_y;
|
int mouse_rel_y;
|
||||||
int mouse_x;
|
int mouse_x;
|
||||||
int mouse_y;
|
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;
|
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 */
|
struct pointer_status pointer_head; /* dummy head for easier iteration */
|
||||||
};
|
};
|
||||||
@ -190,9 +191,6 @@ static void *dinput_init(const char *joypad_driver)
|
|||||||
return di;
|
return di;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doubleclick_on_titlebar_pressed(void);
|
|
||||||
void unset_doubleclick_on_titlebar(void);
|
|
||||||
|
|
||||||
static void dinput_poll(void *data)
|
static void dinput_poll(void *data)
|
||||||
{
|
{
|
||||||
struct dinput_input *di = (struct dinput_input*)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;
|
di->mouse_rel_y = mouse_state.lY;
|
||||||
|
|
||||||
if (!mouse_state.rgbButtons[0])
|
if (!mouse_state.rgbButtons[0])
|
||||||
unset_doubleclick_on_titlebar();
|
di->doubleclick_on_titlebar = false;
|
||||||
if (doubleclick_on_titlebar_pressed())
|
if (di->doubleclick_on_titlebar)
|
||||||
di->mouse_l = 0;
|
di->mouse_l = 0;
|
||||||
else
|
else
|
||||||
di->mouse_l = mouse_state.rgbButtons[0];
|
di->mouse_l = mouse_state.rgbButtons[0];
|
||||||
@ -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;
|
struct dinput_input *di = (struct dinput_input *)data;
|
||||||
/* WM_POINTERDOWN : Arrives for each new touch event
|
/* 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)
|
switch (message)
|
||||||
{
|
{
|
||||||
|
case WM_NCLBUTTONDBLCLK:
|
||||||
|
di->doubleclick_on_titlebar = true;
|
||||||
|
break;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
di->window_pos_x = GET_X_LPARAM(lParam);
|
di->window_pos_x = GET_X_LPARAM(lParam);
|
||||||
di->window_pos_y = GET_Y_LPARAM(lParam);
|
di->window_pos_y = GET_Y_LPARAM(lParam);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user