[gtk+] quartz: Factor out toplevel from NSEvent code into function



commit 7269cdf315ffb72918e364aa2dd9f8fc06cd0ca8
Author: Kristian Rietveld <kris lanedo com>
Date:   Sat Nov 5 22:53:22 2011 +0100

    quartz: Factor out toplevel from NSEvent code into function

 gdk/quartz/gdkevents-quartz.c |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index cba9e4a..22a8f28 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -323,6 +323,29 @@ get_window_point_from_screen_point (GdkWindow *window,
   *y = window->height - point.y;
 }
 
+static GdkWindow *
+get_toplevel_from_ns_event (NSEvent *nsevent,
+                            NSPoint *screen_point,
+                            gint    *x,
+                            gint    *y)
+{
+  GdkQuartzView *view;
+  GdkWindow *toplevel;
+  NSPoint point;
+
+  view = (GdkQuartzView *)[[nsevent window] contentView];
+
+  toplevel = [view gdkWindow];
+
+  point = [nsevent locationInWindow];
+  *screen_point = [[nsevent window] convertBaseToScreen:point];
+
+  *x = point.x;
+  *y = toplevel->height - point.y;
+
+  return toplevel;
+}
+
 static GdkEvent *
 create_focus_event (GdkWindow *window,
 		    gboolean   in)
@@ -652,20 +675,13 @@ find_window_for_ns_event (NSEvent *nsevent,
                           gint    *y_root)
 {
   GdkQuartzView *view;
-  NSPoint point;
+  GdkWindow *toplevel;
   NSPoint screen_point;
   NSEventType event_type;
-  GdkWindow *toplevel;
 
   view = (GdkQuartzView *)[[nsevent window] contentView];
-  toplevel = [view gdkWindow];
-
-  point = [nsevent locationInWindow];
-  screen_point = [[nsevent window] convertBaseToScreen:point];
-
-  *x = point.x;
-  *y = toplevel->height - point.y;
 
+  toplevel = get_toplevel_from_ns_event (nsevent, &screen_point, x, y);
   _gdk_quartz_window_nspoint_to_gdk_xy (screen_point, x_root, y_root);
 
   event_type = [nsevent type];



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]