[gtk: 13/19] Add _gdk_win32_get_cursor_pos utility
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 13/19] Add _gdk_win32_get_cursor_pos utility
- Date: Fri, 20 Aug 2021 11:31:18 +0000 (UTC)
commit 52f7bb6950ee53f5873d765165b7b1f14cac33a6
Author: Luca Bacci <luca bacci982 gmail com>
Date: Mon Aug 16 14:39:25 2021 +0200
Add _gdk_win32_get_cursor_pos utility
gdk/win32/gdkdevice-win32.c | 4 +--
gdk/win32/gdkdevice-winpointer.c | 4 +--
gdk/win32/gdkdevice-wintab.c | 2 +-
gdk/win32/gdkevents-win32.c | 69 ++++++++++++++++++++++++++++++++++++++--
gdk/win32/gdkprivate-win32.h | 2 ++
5 files changed, 74 insertions(+), 7 deletions(-)
---
diff --git a/gdk/win32/gdkdevice-win32.c b/gdk/win32/gdkdevice-win32.c
index 35802b93a2..d153fcfd23 100644
--- a/gdk/win32/gdkdevice-win32.c
+++ b/gdk/win32/gdkdevice-win32.c
@@ -89,7 +89,7 @@ gdk_device_win32_query_state (GdkDevice *device,
hwnd = NULL;
}
- GetCursorPos (&point);
+ _gdk_win32_get_cursor_pos (&point);
if (hwnd)
ScreenToClient (hwnd, &point);
@@ -177,7 +177,7 @@ _gdk_device_win32_surface_at_position (GdkDevice *device,
HWND hwnd;
RECT rect;
- if (!GetCursorPos (&screen_pt))
+ if (!_gdk_win32_get_cursor_pos (&screen_pt))
return NULL;
/* Use WindowFromPoint instead of ChildWindowFromPoint(Ex).
diff --git a/gdk/win32/gdkdevice-winpointer.c b/gdk/win32/gdkdevice-winpointer.c
index a2190ed4d5..774932bc25 100644
--- a/gdk/win32/gdkdevice-winpointer.c
+++ b/gdk/win32/gdkdevice-winpointer.c
@@ -80,7 +80,7 @@ gdk_device_winpointer_query_state (GdkDevice *device,
hwnd = NULL;
}
- GetCursorPos (&point);
+ _gdk_win32_get_cursor_pos (&point);
if (hwnd)
ScreenToClient (hwnd, &point);
@@ -154,7 +154,7 @@ gdk_device_winpointer_surface_at_position (GdkDevice *device,
HWND hwnd;
RECT rect;
- if (!GetCursorPos (&screen_pt))
+ if (!_gdk_win32_get_cursor_pos (&screen_pt))
return NULL;
/* Use WindowFromPoint instead of ChildWindowFromPoint(Ex).
diff --git a/gdk/win32/gdkdevice-wintab.c b/gdk/win32/gdkdevice-wintab.c
index 6e94545767..267e773ee0 100644
--- a/gdk/win32/gdkdevice-wintab.c
+++ b/gdk/win32/gdkdevice-wintab.c
@@ -88,7 +88,7 @@ gdk_device_wintab_query_state (GdkDevice *device,
hwnd = NULL;
}
- GetCursorPos (&point);
+ _gdk_win32_get_cursor_pos (&point);
if (hwnd)
ScreenToClient (hwnd, &point);
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index c49c0ed2fd..08f08b85ae 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -166,6 +166,9 @@ static int both_shift_pressed[2]; /* to store keycodes for shift keys */
static HHOOK keyboard_hook = NULL;
static UINT aerosnap_message;
+static gboolean pen_touch_input;
+static POINT pen_touch_cursor_position;
+
static void
track_mouse_event (DWORD dwFlags,
HWND hwnd)
@@ -200,6 +203,18 @@ _gdk_win32_get_next_tick (gulong suggested_tick)
return cur_tick = suggested_tick;
}
+BOOL
+_gdk_win32_get_cursor_pos (LPPOINT lpPoint)
+{
+ if (pen_touch_input)
+ {
+ *lpPoint = pen_touch_cursor_position;
+ return TRUE;
+ }
+ else
+ return GetCursorPos (lpPoint);
+}
+
static void
generate_focus_event (GdkDeviceManagerWin32 *device_manager,
GdkSurface *window,
@@ -2215,6 +2230,8 @@ gdk_event_translate (MSG *msg,
g_print (" (%d,%d)",
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
+ pen_touch_input = FALSE;
+
g_set_object (&window, find_window_for_mouse_event (window, msg));
/* TODO_CSW?: there used to some synthesize and propagate */
if (GDK_SURFACE_DESTROYED (window))
@@ -2257,6 +2274,8 @@ gdk_event_translate (MSG *msg,
g_print (" (%d,%d)",
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
+ pen_touch_input = FALSE;
+
g_set_object (&window, find_window_for_mouse_event (window, msg));
if (pointer_grab == NULL && implicit_grab_surface != NULL)
@@ -2315,6 +2334,8 @@ gdk_event_translate (MSG *msg,
(gpointer) msg->wParam,
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
+ pen_touch_input = FALSE;
+
new_window = window;
if (pointer_grab != NULL)
@@ -2417,6 +2438,8 @@ gdk_event_translate (MSG *msg,
GDK_NOTE (EVENTS, g_print (" %d (%ld,%ld)",
HIWORD (msg->wParam), msg->pt.x, msg->pt.y));
+ pen_touch_input = FALSE;
+
new_window = NULL;
hwnd = WindowFromPoint (msg->pt);
ignore_leave = FALSE;
@@ -2464,6 +2487,13 @@ gdk_event_translate (MSG *msg,
break;
}
+ if (IS_POINTER_PRIMARY_WPARAM (msg->wParam))
+ {
+ current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
+ current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
+ pen_touch_input = TRUE;
+ }
+
if (pointer_grab != NULL &&
!pointer_grab->implicit &&
!pointer_grab->owner_events)
@@ -2486,6 +2516,13 @@ gdk_event_translate (MSG *msg,
break;
}
+ if (IS_POINTER_PRIMARY_WPARAM (msg->wParam))
+ {
+ current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
+ current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
+ pen_touch_input = TRUE;
+ }
+
if (pointer_grab != NULL &&
!pointer_grab->implicit &&
!pointer_grab->owner_events)
@@ -2511,6 +2548,13 @@ gdk_event_translate (MSG *msg,
break;
}
+ if (IS_POINTER_PRIMARY_WPARAM (msg->wParam))
+ {
+ current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
+ current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
+ pen_touch_input = TRUE;
+ }
+
if (pointer_grab != NULL &&
!pointer_grab->implicit &&
!pointer_grab->owner_events)
@@ -2542,6 +2586,13 @@ gdk_event_translate (MSG *msg,
break;
}
+ if (IS_POINTER_PRIMARY_WPARAM (msg->wParam))
+ {
+ current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
+ current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
+ pen_touch_input = TRUE;
+ }
+
if (IS_POINTER_PRIMARY_WPARAM (msg->wParam) &&
!IS_POINTER_INCONTACT_WPARAM (msg->wParam) &&
mouse_window != NULL)
@@ -2553,7 +2604,7 @@ gdk_event_translate (MSG *msg,
{
make_crossing_event(event_device,
NULL,
- &msg->pt,
+ &pen_touch_cursor_position,
event_time);
}
}
@@ -2569,6 +2620,13 @@ gdk_event_translate (MSG *msg,
break;
}
+ if (IS_POINTER_PRIMARY_WPARAM (msg->wParam))
+ {
+ current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
+ current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
+ pen_touch_input = TRUE;
+ }
+
if (pointer_grab != NULL &&
!pointer_grab->implicit &&
!pointer_grab->owner_events)
@@ -2591,6 +2649,13 @@ gdk_event_translate (MSG *msg,
break;
}
+ if (IS_POINTER_PRIMARY_WPARAM (msg->wParam))
+ {
+ current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
+ current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
+ pen_touch_input = TRUE;
+ }
+
if (!IS_POINTER_INRANGE_WPARAM (msg->wParam))
{
gdk_winpointer_input_events (window, NULL, msg);
@@ -2604,7 +2669,7 @@ gdk_event_translate (MSG *msg,
{
make_crossing_event(event_device,
NULL,
- &msg->pt,
+ &pen_touch_cursor_position,
event_time);
}
}
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index 58714024eb..67d99a4532 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -157,6 +157,8 @@ GType _gdk_gc_win32_get_type (void);
gulong _gdk_win32_get_next_tick (gulong suggested_tick);
+BOOL _gdk_win32_get_cursor_pos (LPPOINT lpPoint);
+
void _gdk_surface_init_position (GdkSurface *window);
void _gdk_surface_move_resize_child (GdkSurface *window,
int x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]