quartz: Factor out toplevel from NSEvent code into function

This commit is contained in:
Kristian Rietveld 2011-11-05 22:53:22 +01:00
parent cca1621e71
commit d0e5025694

View File

@ -373,6 +373,31 @@ get_window_point_from_screen_point (GdkWindow *window,
*y = private->height - point.y;
}
static GdkWindow *
get_toplevel_from_ns_event (NSEvent *nsevent,
NSPoint *screen_point,
gint *x,
gint *y)
{
GdkQuartzView *view;
GdkWindow *toplevel;
GdkWindowObject *private;
NSPoint point;
view = (GdkQuartzView *)[[nsevent window] contentView];
toplevel = [view gdkWindow];
private = GDK_WINDOW_OBJECT (toplevel);
point = [nsevent locationInWindow];
*screen_point = [[nsevent window] convertBaseToScreen:point];
*x = point.x;
*y = private->height - point.y;
return toplevel;
}
static GdkEvent *
create_focus_event (GdkWindow *window,
gboolean in)
@ -540,22 +565,12 @@ find_window_for_ns_event (NSEvent *nsevent,
{
GdkQuartzView *view;
GdkWindow *toplevel;
GdkWindowObject *private;
NSPoint point;
NSPoint screen_point;
NSEventType event_type;
view = (GdkQuartzView *)[[nsevent window] contentView];
toplevel = [view gdkWindow];
private = GDK_WINDOW_OBJECT (toplevel);
point = [nsevent locationInWindow];
screen_point = [[nsevent window] convertBaseToScreen:point];
*x = point.x;
*y = private->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];