[gtk/wip/otte/win32-cleanup: 9/11] win32: Use the right display in event handling
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/win32-cleanup: 9/11] win32: Use the right display in event handling
- Date: Fri, 23 Jul 2021 03:11:48 +0000 (UTC)
commit 46a60494f856dc5adba06740a7ce5926264336ea
Author: Benjamin Otte <otte redhat com>
Date: Wed Jul 21 05:48:40 2021 +0200
win32: Use the right display in event handling
... instead of just using gdk_display_get_default().
gdk/win32/gdkevents-win32.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 2b8a6876a5..1cbf638795 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -100,7 +100,8 @@
#define SYNAPSIS_ICON_WINDOW_CLASS "SynTrackCursorWindowClass"
-static gboolean gdk_event_translate (MSG *msg,
+static gboolean gdk_event_translate (GdkDisplay *display,
+ MSG *msg,
int *ret_valp);
static gboolean gdk_event_prepare (GSource *source,
int *timeout);
@@ -239,10 +240,12 @@ inner_window_procedure (HWND hwnd,
WPARAM wparam,
LPARAM lparam)
{
+ GdkDisplay *display;
MSG msg;
DWORD pos;
int ret_val = 0;
+ display = gdk_surface_get_display (GDK_SURFACE (GetWindowLongPtr (hwnd, GWLP_USERDATA)));
msg.hwnd = hwnd;
msg.message = message;
msg.wParam = wparam;
@@ -252,7 +255,7 @@ inner_window_procedure (HWND hwnd,
msg.pt.x = GET_X_LPARAM (pos);
msg.pt.y = GET_Y_LPARAM (pos);
- if (gdk_event_translate (&msg, &ret_val))
+ if (gdk_event_translate (display, &msg, &ret_val))
{
/* If gdk_event_translate() returns TRUE, we return ret_val from
* the window procedure.
@@ -571,18 +574,17 @@ event_mask_string (GdkEventMask mask)
#endif
static GdkSurface *
-find_window_for_mouse_event (GdkSurface* reported_window,
- MSG* msg)
+find_window_for_mouse_event (GdkDisplay *display,
+ GdkSurface *reported_window,
+ MSG *msg)
{
POINT pt;
- GdkDisplay *display;
GdkDeviceManagerWin32 *device_manager;
GdkSurface *event_surface;
HWND hwnd;
RECT rect;
GdkDeviceGrabInfo *grab;
- display = gdk_display_get_default ();
device_manager = GDK_WIN32_DISPLAY (display)->device_manager;
grab = _gdk_display_get_last_device_grab (display, device_manager->core_pointer);
@@ -886,8 +888,8 @@ _gdk_win32_append_event (GdkEvent *event)
GdkDisplay *display;
GList *link;
- display = gdk_display_get_default ();
-
+ display = gdk_event_get_display (event);
+
fixup_event (event);
#if 1
link = _gdk_event_queue_append (display, event);
@@ -1471,7 +1473,7 @@ handle_dpi_changed (GdkSurface *window,
MSG *msg)
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
- GdkDisplay *display = gdk_display_get_default ();
+ GdkDisplay *display = gdk_surface_get_display (window);
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
RECT *rect = (RECT *)msg->lParam;
guint old_scale = impl->surface_scale;
@@ -1725,8 +1727,9 @@ _gdk_win32_surface_fill_min_max_info (GdkSurface *window,
GDK_BUTTON5_MASK)
static gboolean
-gdk_event_translate (MSG *msg,
- int *ret_valp)
+gdk_event_translate (GdkDisplay *display,
+ MSG *msg,
+ int *ret_valp)
{
RECT rect;
POINT point;
@@ -1742,7 +1745,6 @@ gdk_event_translate (MSG *msg,
wchar_t wbuf[100];
int ccount;
- GdkDisplay *display;
GdkSurface *window = NULL;
GdkWin32Surface *impl;
GdkWin32Display *win32_display;
@@ -1772,7 +1774,6 @@ gdk_event_translate (MSG *msg,
GdkScrollDirection direction;
GdkTranslatedKey translated;
- display = gdk_display_get_default ();
win32_display = GDK_WIN32_DISPLAY (display);
device_manager_win32 = win32_display->device_manager;
@@ -2035,7 +2036,7 @@ gdk_event_translate (MSG *msg,
fake_release.lParam = both_shift_pressed[0];
both_shift_pressed[0] = both_shift_pressed[1] = 0;
- gdk_event_translate (&fake_release, &tmp_retval);
+ gdk_event_translate (display, &fake_release, &tmp_retval);
}
both_shift_pressed[0] = both_shift_pressed[1] = 0;
}
@@ -2176,7 +2177,7 @@ gdk_event_translate (MSG *msg,
g_print (" (%d,%d)",
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
- g_set_object (&window, find_window_for_mouse_event (window, msg));
+ g_set_object (&window, find_window_for_mouse_event (display, window, msg));
/* TODO_CSW?: there used to some synthesize and propagate */
if (GDK_SURFACE_DESTROYED (window))
break;
@@ -2219,7 +2220,7 @@ gdk_event_translate (MSG *msg,
g_print (" (%d,%d)",
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
- g_set_object (&window, find_window_for_mouse_event (window, msg));
+ g_set_object (&window, find_window_for_mouse_event (display, window, msg));
if (pointer_grab == NULL && implicit_grab_surface != NULL)
{
@@ -2329,7 +2330,7 @@ gdk_event_translate (MSG *msg,
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (new_window));
}
- g_set_object (&window, find_window_for_mouse_event (window, msg));
+ g_set_object (&window, find_window_for_mouse_event (display, window, msg));
impl = GDK_WIN32_SURFACE (window);
/* If we haven't moved, don't create any GDK event. Windows
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]