[gtk+/gtk-2-24] quartz: Separate out screen_point conversion in function
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] quartz: Separate out screen_point conversion in function
- Date: Sun, 6 Nov 2011 08:38:36 +0000 (UTC)
commit cca1621e7117333ff6306b05e6508baab42e6210
Author: Kristian Rietveld <kris lanedo com>
Date: Sat Nov 5 22:43:17 2011 +0100
quartz: Separate out screen_point conversion in function
Reduces code duplication and confusion.
gdk/quartz/gdkevents-quartz.c | 69 ++++++++++++++--------------------------
1 files changed, 24 insertions(+), 45 deletions(-)
---
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index b1f5ddf..1d58d0e 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -354,6 +354,25 @@ get_event_mask_from_ns_event (NSEvent *nsevent)
return 0;
}
+static void
+get_window_point_from_screen_point (GdkWindow *window,
+ NSPoint screen_point,
+ gint *x,
+ gint *y)
+{
+ NSPoint point;
+ NSWindow *nswindow;
+ GdkWindowObject *private;
+
+ private = (GdkWindowObject *)window;
+ nswindow = ((GdkWindowImplQuartz *)private->impl)->toplevel;
+
+ point = [nswindow convertScreenToBase:screen_point];
+
+ *x = point.x;
+ *y = private->height - point.y;
+}
+
static GdkEvent *
create_focus_event (GdkWindow *window,
gboolean in)
@@ -371,10 +390,7 @@ create_focus_event (GdkWindow *window,
static void
generate_motion_event (GdkWindow *window)
{
- NSPoint point;
NSPoint screen_point;
- NSWindow *nswindow;
- GdkWindowObject *private;
GdkEvent *event;
gint x, y, x_root, y_root;
@@ -382,17 +398,10 @@ generate_motion_event (GdkWindow *window)
event->any.window = NULL;
event->any.send_event = TRUE;
- private = (GdkWindowObject *)window;
- nswindow = ((GdkWindowImplQuartz *)private->impl)->toplevel;
-
screen_point = [NSEvent mouseLocation];
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &x_root, &y_root);
-
- point = [nswindow convertScreenToBase:screen_point];
-
- x = point.x;
- y = private->height - point.y;
+ get_window_point_from_screen_point (window, screen_point, &x, &y);
event->any.type = GDK_MOTION_NOTIFY;
event->motion.window = window;
@@ -457,10 +466,7 @@ _gdk_quartz_events_update_focus_window (GdkWindow *window,
void
_gdk_quartz_events_send_enter_notify_event (GdkWindow *window)
{
- NSPoint point;
NSPoint screen_point;
- NSWindow *nswindow;
- GdkWindowObject *private;
GdkEvent *event;
gint x, y, x_root, y_root;
@@ -468,17 +474,10 @@ _gdk_quartz_events_send_enter_notify_event (GdkWindow *window)
event->any.window = NULL;
event->any.send_event = FALSE;
- private = (GdkWindowObject *)window;
- nswindow = ((GdkWindowImplQuartz *)private->impl)->toplevel;
-
screen_point = [NSEvent mouseLocation];
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &x_root, &y_root);
-
- point = [nswindow convertScreenToBase:screen_point];
-
- x = point.x;
- y = private->height - point.y;
+ get_window_point_from_screen_point (window, screen_point, &x, &y);
event->crossing.window = window;
event->crossing.subwindow = NULL;
@@ -524,19 +523,7 @@ find_toplevel_under_pointer (GdkDisplay *display,
toplevel = display->pointer_info.toplevel_under_pointer;
if (toplevel && WINDOW_IS_TOPLEVEL (toplevel))
- {
- GdkWindowObject *private;
- NSWindow *nswindow;
- NSPoint point;
-
- private = (GdkWindowObject *)toplevel;
- nswindow = ((GdkWindowImplQuartz *)private->impl)->toplevel;
-
- point = [nswindow convertScreenToBase:screen_point];
-
- *x = point.x;
- *y = private->height - point.y;
- }
+ get_window_point_from_screen_point (toplevel, screen_point, x, y);
return toplevel;
}
@@ -637,18 +624,10 @@ find_window_for_ns_event (NSEvent *nsevent,
{
/* Finally check the grab window. */
GdkWindow *grab_toplevel;
- GdkWindowObject *grab_private;
- NSWindow *grab_nswindow;
grab_toplevel = gdk_window_get_effective_toplevel (grab->window);
- grab_private = (GdkWindowObject *)grab_toplevel;
-
- grab_nswindow = ((GdkWindowImplQuartz *)grab_private->impl)->toplevel;
- point = [grab_nswindow convertScreenToBase:screen_point];
-
- /* Note: x_root and y_root are already right. */
- *x = point.x;
- *y = grab_private->height - point.y;
+ get_window_point_from_screen_point (grab_toplevel,
+ screen_point, x, y);
return grab_toplevel;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]