[gtk/wip/chergert/quartz4u] macos: fix some deprecation warnings



commit f275f3a50e1d43e91dd752fd425dae81b404f163
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 4 20:30:16 2020 -0700

    macos: fix some deprecation warnings

 gdk/macos/gdkmacosdisplay-translate.c | 46 +++++++++++++++++------------------
 gdk/macos/gdkmacoskeymap.c            | 32 +++++++++---------------
 2 files changed, 35 insertions(+), 43 deletions(-)
---
diff --git a/gdk/macos/gdkmacosdisplay-translate.c b/gdk/macos/gdkmacosdisplay-translate.c
index 9ec3b78e0e..cf2991fcc3 100644
--- a/gdk/macos/gdkmacosdisplay-translate.c
+++ b/gdk/macos/gdkmacosdisplay-translate.c
@@ -47,7 +47,7 @@ test_resize (NSEvent         *event,
   /* Resizing from the resize indicator only begins if an NSLeftMouseButton
    * event is received in the resizing area.
    */
-  if ([event type] == NSLeftMouseDown &&
+  if ([event type] == NSEventTypeLeftMouseDown &&
       [window showsResizeIndicator])
     {
       NSRect frame;
@@ -81,9 +81,9 @@ test_resize (NSEvent         *event,
    * window finding code, because there are no GdkSurfaces present in
    * the range [-3, 0].
    */
-  if (([event type] == NSLeftMouseDown ||
-       [event type] == NSRightMouseDown ||
-       [event type] == NSOtherMouseDown))
+  if (([event type] == NSEventTypeLeftMouseDown ||
+       [event type] == NSEventTypeRightMouseDown ||
+       [event type] == NSEventTypeOtherMouseDown))
     {
       if (x < GDK_LION_RESIZE ||
           x > GDK_SURFACE (surface)->width - GDK_LION_RESIZE ||
@@ -160,15 +160,15 @@ get_keyboard_modifiers_from_ns_flags (NSUInteger nsflags)
 {
   GdkModifierType modifiers = 0;
 
-  if (nsflags & NSAlphaShiftKeyMask)
+  if (nsflags & NSEventModifierFlagCapsLock)
     modifiers |= GDK_LOCK_MASK;
-  if (nsflags & NSShiftKeyMask)
+  if (nsflags & NSEventModifierFlagShift)
     modifiers |= GDK_SHIFT_MASK;
-  if (nsflags & NSControlKeyMask)
+  if (nsflags & NSEventModifierFlagControl)
     modifiers |= GDK_CONTROL_MASK;
-  if (nsflags & NSAlternateKeyMask)
+  if (nsflags & NSEventModifierFlagOption)
     modifiers |= GDK_ALT_MASK;
-  if (nsflags & NSCommandKeyMask)
+  if (nsflags & NSEventModifierFlagCommand)
     modifiers |= GDK_SUPER_MASK;
 
   return modifiers;
@@ -212,16 +212,16 @@ fill_button_event (GdkMacosDisplay *display,
 
   switch ([nsevent type])
     {
-    case NSLeftMouseDown:
-    case NSRightMouseDown:
-    case NSOtherMouseDown:
+    case NSEventTypeLeftMouseDown:
+    case NSEventTypeRightMouseDown:
+    case NSEventTypeOtherMouseDown:
       type = GDK_BUTTON_PRESS;
       state &= ~get_mouse_button_modifiers_from_ns_event (nsevent);
       break;
 
-    case NSLeftMouseUp:
-    case NSRightMouseUp:
-    case NSOtherMouseUp:
+    case NSEventTypeLeftMouseUp:
+    case NSEventTypeRightMouseUp:
+    case NSEventTypeOtherMouseUp:
       type = GDK_BUTTON_RELEASE;
       state |= get_mouse_button_modifiers_from_ns_event (nsevent);
       break;
@@ -256,11 +256,11 @@ synthesize_crossing_event (GdkMacosDisplay *display,
 
   switch ([nsevent type])
     {
-    case NSMouseEntered:
+    case NSEventTypeMouseEntered:
       event_type = GDK_ENTER_NOTIFY;
       break;
 
-    case NSMouseExited:
+    case NSEventTypeMouseExited:
       event_type = GDK_LEAVE_NOTIFY;
       break;
 
@@ -273,7 +273,7 @@ synthesize_crossing_event (GdkMacosDisplay *display,
   seat = gdk_display_get_default_seat (GDK_DISPLAY (display));
 
   return gdk_crossing_event_new (event_type,
-                                 surface,
+                                 GDK_SURFACE (surface),
                                  gdk_seat_get_pointer (seat),
                                  NULL,
                                  get_time_from_ns_event (nsevent),
@@ -488,9 +488,9 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
    * grabs when the application loses focus (gets deactivated).
    */
   event_type = [nsevent type];
-  if (event_type == NSAppKitDefined)
+  if (event_type == NSEventTypeAppKitDefined)
     {
-      if ([nsevent subtype] == NSApplicationDeactivatedEventType)
+      if ([nsevent subtype] == NSEventSubtypeApplicationDeactivated)
         _gdk_macos_display_break_all_grabs (self, get_time_from_ns_event (nsevent));
 
       /* This could potentially be used to break grabs when clicking
@@ -545,9 +545,9 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
    * native apps). If the app is active, we focus the window and then handle
    * the event, also to match native apps.
    */
-  if ((event_type == NSRightMouseDown ||
-       event_type == NSOtherMouseDown ||
-       event_type == NSLeftMouseDown))
+  if ((event_type == NSEventTypeRightMouseDown ||
+       event_type == NSEventTypeOtherMouseDown ||
+       event_type == NSEventTypeLeftMouseDown))
     {
       if (![NSApp isActive])
         {
diff --git a/gdk/macos/gdkmacoskeymap.c b/gdk/macos/gdkmacoskeymap.c
index 0c2cd1d5bd..641612b968 100644
--- a/gdk/macos/gdkmacoskeymap.c
+++ b/gdk/macos/gdkmacoskeymap.c
@@ -570,40 +570,32 @@ translate_keysym (guint            hardware_keycode,
 }
 
 static gboolean
-gdk_macos_keymap_get_entries_for_keyval (GdkKeymap     *keymap,
-                                         guint          keyval,
-                                         GdkKeymapKey **keys,
-                                         gint          *n_keys)
+gdk_macos_keymap_get_entries_for_keyval (GdkKeymap *keymap,
+                                         guint      keyval,
+                                         GArray    *keys)
 {
-  GArray *keys_array;
-  guint i;
+  gboolean ret = FALSE;
 
   g_assert (GDK_IS_MACOS_KEYMAP (keymap));
   g_assert (keys != NULL);
-  g_assert (n_keys != NULL);
-
-  *n_keys = 0;
-  keys_array = g_array_new (FALSE, FALSE, sizeof (GdkKeymapKey));
 
-  for (i = 0; i < NUM_KEYCODES * KEYVALS_PER_KEYCODE; i++)
+  for (guint i = 0; i < NUM_KEYCODES * KEYVALS_PER_KEYCODE; i++)
     {
       GdkKeymapKey key;
 
       if (keyval_array[i] != keyval)
         continue;
 
-      (*n_keys)++;
-
       key.keycode = i / KEYVALS_PER_KEYCODE;
       key.group = (i % KEYVALS_PER_KEYCODE) >= 2;
       key.level = i % 2;
 
-      g_array_append_val (keys_array, key);
-    }
+      g_array_append_val (keys, key);
 
-  *keys = (GdkKeymapKey *)(gpointer)g_array_free (keys_array, FALSE);
+      ret = TRUE;
+    }
 
-  return *n_keys > 0;
+  return ret;
 }
 
 static gboolean
@@ -801,11 +793,11 @@ _gdk_macos_keymap_get_event_type (NSEvent *event)
 
   switch ([event type])
     {
-    case NSKeyDown:
+    case NSEventTypeKeyDown:
       return GDK_KEY_PRESS;
-    case NSKeyUp:
+    case NSEventTypeKeyUp:
       return GDK_KEY_RELEASE;
-    case NSFlagsChanged:
+    case NSEventTypeFlagsChanged:
       break;
     default:
       g_assert_not_reached ();


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