forked from AuroraMiddleware/gtk
quartz: Separate out screen_point conversion in function
Reduces code duplication and confusion.
This commit is contained in:
parent
4d9d8ba96d
commit
6a7280ce1a
@ -306,6 +306,23 @@ 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;
|
||||
|
||||
nswindow = ((GdkWindowImplQuartz *)window->impl)->toplevel;
|
||||
|
||||
point = [nswindow convertScreenToBase:screen_point];
|
||||
|
||||
*x = point.x;
|
||||
*y = window->height - point.y;
|
||||
}
|
||||
|
||||
static GdkEvent *
|
||||
create_focus_event (GdkWindow *window,
|
||||
gboolean in)
|
||||
@ -327,9 +344,7 @@ create_focus_event (GdkWindow *window,
|
||||
static void
|
||||
generate_motion_event (GdkWindow *window)
|
||||
{
|
||||
NSPoint point;
|
||||
NSPoint screen_point;
|
||||
NSWindow *nswindow;
|
||||
GdkEvent *event;
|
||||
gint x, y, x_root, y_root;
|
||||
|
||||
@ -337,16 +352,10 @@ generate_motion_event (GdkWindow *window)
|
||||
event->any.window = NULL;
|
||||
event->any.send_event = TRUE;
|
||||
|
||||
nswindow = ((GdkWindowImplQuartz *)window->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 = window->height - point.y;
|
||||
get_window_point_from_screen_point (window, screen_point, &x, &y);
|
||||
|
||||
event->any.type = GDK_MOTION_NOTIFY;
|
||||
event->motion.window = window;
|
||||
@ -411,9 +420,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;
|
||||
GdkEvent *event;
|
||||
gint x, y, x_root, y_root;
|
||||
|
||||
@ -421,16 +428,10 @@ _gdk_quartz_events_send_enter_notify_event (GdkWindow *window)
|
||||
event->any.window = NULL;
|
||||
event->any.send_event = FALSE;
|
||||
|
||||
nswindow = ((GdkWindowImplQuartz *)window->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 = window->height - point.y;
|
||||
get_window_point_from_screen_point (window, screen_point, &x, &y);
|
||||
|
||||
event->crossing.window = window;
|
||||
event->crossing.subwindow = NULL;
|
||||
@ -479,17 +480,7 @@ find_toplevel_under_pointer (GdkDisplay *display,
|
||||
info = _gdk_display_get_pointer_info (display, display->core_pointer);
|
||||
toplevel = info->toplevel_under_pointer;
|
||||
if (toplevel && WINDOW_IS_TOPLEVEL (toplevel))
|
||||
{
|
||||
NSWindow *nswindow;
|
||||
NSPoint point;
|
||||
|
||||
nswindow = ((GdkWindowImplQuartz *)toplevel->impl)->toplevel;
|
||||
|
||||
point = [nswindow convertScreenToBase:screen_point];
|
||||
|
||||
*x = point.x;
|
||||
*y = toplevel->height - point.y;
|
||||
}
|
||||
get_window_point_from_screen_point (toplevel, screen_point, x, y);
|
||||
|
||||
return toplevel;
|
||||
}
|
||||
@ -600,16 +591,10 @@ find_toplevel_for_mouse_event (NSEvent *nsevent,
|
||||
{
|
||||
/* Finally check the grab window. */
|
||||
GdkWindow *grab_toplevel;
|
||||
NSWindow *grab_nswindow;
|
||||
|
||||
grab_toplevel = gdk_window_get_effective_toplevel (grab->window);
|
||||
|
||||
grab_nswindow = ((GdkWindowImplQuartz *)grab_toplevel->impl)->toplevel;
|
||||
point = [grab_nswindow convertScreenToBase:screen_point];
|
||||
|
||||
/* Note: x_root and y_root are already right. */
|
||||
*x = point.x;
|
||||
*y = grab_toplevel->height - point.y;
|
||||
get_window_point_from_screen_point (grab_toplevel, screen_point,
|
||||
x, y);
|
||||
|
||||
return grab_toplevel;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user