From 58f941346495caa684dc38ba2dc1feffa268b088 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 9 Oct 2020 20:02:18 -0700 Subject: [PATCH] macos: track various changes in GDK --- gdk/macos/GdkMacosWindow.c | 3 ++- gdk/macos/gdkmacosdevice.c | 3 ++- gdk/macos/gdkmacosdisplay-translate.c | 9 --------- gdk/macos/gdkmacosdisplay.c | 5 ++--- gdk/macos/gdkmacosmonitor.h | 11 +++++++---- gdk/macos/gdkmacospopupsurface.c | 3 ++- gdk/macos/gdkmacossurface.c | 3 +-- gdk/macos/gdkmacostoplevelsurface.c | 5 ++++- gdk/macos/meson.build | 1 + 9 files changed, 21 insertions(+), 22 deletions(-) diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c index 030ac0fb51..3c4671aa46 100644 --- a/gdk/macos/GdkMacosWindow.c +++ b/gdk/macos/GdkMacosWindow.c @@ -28,6 +28,7 @@ #import "GdkMacosWindow.h" #include "gdkmacosdisplay-private.h" +#include "gdkmacosmonitor-private.h" #include "gdkmacossurface-private.h" #include "gdkmacospopupsurface-private.h" #include "gdkmacostoplevelsurface-private.h" @@ -352,7 +353,7 @@ monitor = _gdk_macos_display_get_monitor_at_display_coords ([self gdkDisplay], currentLocation.x, currentLocation.y); - gdk_macos_monitor_get_geometry (monitor, &geometry); + gdk_monitor_get_geometry (monitor, &geometry); gdk_macos_monitor_get_workarea (monitor, &workarea); _edge_snapping_set_monitor (&self->snapping, &geometry, &workarea); diff --git a/gdk/macos/gdkmacosdevice.c b/gdk/macos/gdkmacosdevice.c index b4c71c2e51..5c97d24799 100644 --- a/gdk/macos/gdkmacosdevice.c +++ b/gdk/macos/gdkmacosdevice.c @@ -28,8 +28,9 @@ #include "gdkmacoscursor-private.h" #include "gdkmacosdevice.h" -#include "gdkmacosdisplay-private.h" #include "gdkmacosdevice-private.h" +#include "gdkmacosdisplay-private.h" +#include "gdkmacossurface-private.h" struct _GdkMacosDevice { diff --git a/gdk/macos/gdkmacosdisplay-translate.c b/gdk/macos/gdkmacosdisplay-translate.c index 799031e3ef..8a47cfc4a0 100644 --- a/gdk/macos/gdkmacosdisplay-translate.c +++ b/gdk/macos/gdkmacosdisplay-translate.c @@ -242,7 +242,6 @@ fill_button_event (GdkMacosDisplay *display, GDK_SURFACE (surface), gdk_seat_get_pointer (seat), NULL, - NULL, get_time_from_ns_event (nsevent), state, get_mouse_button_from_ns_event (nsevent), @@ -283,7 +282,6 @@ synthesize_crossing_event (GdkMacosDisplay *display, return gdk_crossing_event_new (event_type, GDK_SURFACE (surface), gdk_seat_get_pointer (seat), - NULL, get_time_from_ns_event (nsevent), state, x, @@ -410,7 +408,6 @@ fill_key_event (GdkMacosDisplay *display, return gdk_key_event_new (type, GDK_SURFACE (surface), gdk_seat_get_keyboard (seat), - NULL, get_time_from_ns_event (nsevent), [nsevent keyCode], state, @@ -526,7 +523,6 @@ fill_pinch_event (GdkMacosDisplay *display, return gdk_touchpad_event_new_pinch (GDK_SURFACE (surface), gdk_seat_get_pointer (seat), - NULL, get_time_from_ns_event (nsevent), get_keyboard_modifiers_from_ns_event (nsevent), phase, @@ -570,7 +566,6 @@ fill_motion_event (GdkMacosDisplay *display, return gdk_motion_event_new (GDK_SURFACE (surface), gdk_seat_get_pointer (seat), NULL, - NULL, get_time_from_ns_event (nsevent), state, x, @@ -623,7 +618,6 @@ fill_scroll_event (GdkMacosDisplay *self, ret = gdk_scroll_event_new (GDK_SURFACE (surface), pointer, NULL, - NULL, get_time_from_ns_event (nsevent), state, -sx, @@ -661,7 +655,6 @@ fill_scroll_event (GdkMacosDisplay *self, emulated = gdk_scroll_event_new_discrete (GDK_SURFACE (surface), pointer, NULL, - NULL, get_time_from_ns_event (nsevent), state, direction, @@ -675,7 +668,6 @@ fill_scroll_event (GdkMacosDisplay *self, ret = gdk_scroll_event_new (GDK_SURFACE (surface), pointer, NULL, - NULL, get_time_from_ns_event (nsevent), state, dx, @@ -1188,7 +1180,6 @@ _gdk_macos_display_synthesize_motion (GdkMacosDisplay *self, event = gdk_motion_event_new (GDK_SURFACE (surface), gdk_seat_get_pointer (seat), NULL, - NULL, get_time_from_ns_event ([NSApp currentEvent]), state, x, diff --git a/gdk/macos/gdkmacosdisplay.c b/gdk/macos/gdkmacosdisplay.c index 8f6a9eb558..78af1cefce 100644 --- a/gdk/macos/gdkmacosdisplay.c +++ b/gdk/macos/gdkmacosdisplay.c @@ -503,7 +503,7 @@ _gdk_macos_display_surface_became_key (GdkMacosDisplay *self, seat = gdk_display_get_default_seat (GDK_DISPLAY (self)); keyboard = gdk_seat_get_keyboard (seat); - event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, NULL, TRUE); + event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, TRUE); _gdk_event_queue_append (GDK_DISPLAY (self), event); /* We just became the active window. Unlike X11, Mac OS X does @@ -529,7 +529,7 @@ _gdk_macos_display_surface_resigned_key (GdkMacosDisplay *self, seat = gdk_display_get_default_seat (GDK_DISPLAY (self)); keyboard = gdk_seat_get_keyboard (seat); - event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, NULL, FALSE); + event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, FALSE); _gdk_event_queue_append (GDK_DISPLAY (self), event); } @@ -897,7 +897,6 @@ _gdk_macos_display_break_all_grabs (GdkMacosDisplay *self, event = gdk_grab_broken_event_new (grab->surface, device, - NULL, grab->surface, TRUE); node = _gdk_event_queue_append (GDK_DISPLAY (self), event); diff --git a/gdk/macos/gdkmacosmonitor.h b/gdk/macos/gdkmacosmonitor.h index 7be6e5ea28..b25ed9ae8b 100644 --- a/gdk/macos/gdkmacosmonitor.h +++ b/gdk/macos/gdkmacosmonitor.h @@ -36,10 +36,13 @@ typedef struct _GdkMacosMonitorClass GdkMacosMonitorClass; #define GDK_IS_MACOS_MONITOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MACOS_MONITOR)) GDK_AVAILABLE_IN_ALL -GType gdk_macos_monitor_get_type (void); - -void gdk_macos_monitor_get_workarea (GdkMonitor *monitor, - GdkRectangle *geometry); +GType gdk_macos_monitor_get_type (void); +GDK_AVAILABLE_IN_ALL +void gdk_macos_monitor_get_geometry (GdkMonitor *self, + GdkRectangle *geometry); +GDK_AVAILABLE_IN_ALL +void gdk_macos_monitor_get_workarea (GdkMonitor *self, + GdkRectangle *geometry); G_END_DECLS diff --git a/gdk/macos/gdkmacospopupsurface.c b/gdk/macos/gdkmacospopupsurface.c index 37bee532ca..a3ae3f4fda 100644 --- a/gdk/macos/gdkmacospopupsurface.c +++ b/gdk/macos/gdkmacospopupsurface.c @@ -25,6 +25,7 @@ #include "gdkpopupprivate.h" #include "gdkmacosdisplay-private.h" +#include "gdkmacosmonitor.h" #include "gdkmacospopupsurface-private.h" #include "gdkmacosutils-private.h" @@ -60,7 +61,7 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self, self->layout = gdk_popup_layout_ref (layout); } - monitor = gdk_surface_get_layout_monitor (surface, layout, + monitor = gdk_surface_get_layout_monitor (GDK_SURFACE (self), layout, gdk_macos_monitor_get_workarea); gdk_macos_monitor_get_workarea (monitor, &bounds); diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c index 14408dd62a..8139d2c84d 100644 --- a/gdk/macos/gdkmacossurface.c +++ b/gdk/macos/gdkmacossurface.c @@ -84,7 +84,7 @@ _gdk_macos_surface_reposition_children (GdkMacosSurface *self) _gdk_macos_popup_surface_reposition (GDK_MACOS_POPUP_SURFACE (child)); } - if (GDK_IS_POPUP (self) || self->did_initial_present) + if (GDK_IS_POPUP (self)) g_signal_emit_by_name (self, "popup-layout-changed"); } @@ -820,7 +820,6 @@ _gdk_macos_surface_synthesize_null_key (GdkMacosSurface *self) event = gdk_key_event_new (GDK_KEY_PRESS, GDK_SURFACE (self), gdk_seat_get_keyboard (seat), - NULL, GDK_CURRENT_TIME, 0, 0, diff --git a/gdk/macos/gdkmacostoplevelsurface.c b/gdk/macos/gdkmacostoplevelsurface.c index 0e5a2a0ae7..2615957b2c 100644 --- a/gdk/macos/gdkmacostoplevelsurface.c +++ b/gdk/macos/gdkmacostoplevelsurface.c @@ -25,6 +25,7 @@ #include "gdktoplevelprivate.h" #include "gdkmacosdisplay-private.h" +#include "gdkmacosmonitor-private.h" #include "gdkmacostoplevelsurface-private.h" #include "gdkmacosutils-private.h" @@ -95,6 +96,7 @@ static gboolean _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel, GdkToplevelLayout *layout) { + GdkSurface *surface = GDK_SURFACE (toplevel); GdkMacosToplevelSurface *self = (GdkMacosToplevelSurface *)toplevel; NSWindow *nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self)); GdkDisplay *display = gdk_surface_get_display (surface); @@ -190,10 +192,11 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel, (GDK_MACOS_SURFACE (self)->shadow_left || GDK_MACOS_SURFACE (self)->shadow_top)) { - GdkMonitor *monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self)); int x = GDK_SURFACE (self)->x; int y = GDK_SURFACE (self)->y; + monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self)); + if (monitor != NULL) { GdkRectangle visible; diff --git a/gdk/macos/meson.build b/gdk/macos/meson.build index ef9f21ea85..0c0fbff9c2 100644 --- a/gdk/macos/meson.build +++ b/gdk/macos/meson.build @@ -43,6 +43,7 @@ gdk_macos_frameworks = [ 'Carbon', 'CoreVideo', 'CoreServices', + 'Foundation', 'OpenGL', 'QuartzCore', ]