[gtk/wip/chergert/quartz4u: 5/7] macos: use GDK_WINDOWING_MACOS instead of GDK_WINDOWING_QUARTZ



commit f35095bc5daa1ff774f688adefc6da437bd16227
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jul 21 18:02:25 2020 -0700

    macos: use GDK_WINDOWING_MACOS instead of GDK_WINDOWING_QUARTZ
    
    Various bits in gtk/ need to be updated to connect to the macOS GDK backend. This
    gets some of that changed over. Additional modules still need updating but require
    more in-depth changes.

 gtk/gtkaccelgroup.c               | 14 +++++++-------
 gtk/gtkapplicationimpl.c          |  8 ++++----
 gtk/gtkfilechoosernative.c        | 12 ++++++------
 gtk/gtkfilechoosernativequartz.c  | 13 +++++++++----
 gtk/gtkfilefilter.c               |  2 +-
 gtk/gtkfilefilterprivate.h        |  4 ++--
 gtk/gtkimmodule.c                 | 12 ++++++------
 gtk/gtkprivate.c                  |  2 +-
 gtk/gtkrange.c                    |  2 +-
 gtk/gtkscrolledwindow.c           |  2 +-
 gtk/gtksearchengine.c             |  4 ++--
 gtk/gtksearchenginequartz.c       |  3 +--
 gtk/gtksettings.c                 | 10 +++++-----
 gtk/inspector/general.c           | 10 +++++-----
 gtk/inspector/visual.c            |  2 +-
 gtk/meson.build                   |  4 ++--
 testsuite/gtk/autotestkeywords.cc |  4 ++--
 17 files changed, 56 insertions(+), 52 deletions(-)
---
diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c
index 2a861d23d6..99ff8529c6 100644
--- a/gtk/gtkaccelgroup.c
+++ b/gtk/gtkaccelgroup.c
@@ -707,7 +707,7 @@ static gboolean
 append_keyval_symbol (guint    accelerator_key,
                       GString *gstring)
 {
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
   switch (accelerator_key)
   {
   case GDK_KEY_Return:
@@ -778,7 +778,7 @@ append_keyval_symbol (guint    accelerator_key,
   default:
     return FALSE;
   }
-#else /* !GDK_WINDOWING_QUARTZ */
+#else /* !GDK_WINDOWING_MACOS */
   return FALSE;
 #endif
 }
@@ -786,7 +786,7 @@ append_keyval_symbol (guint    accelerator_key,
 static void
 append_separator (GString *string)
 {
-#ifndef GDK_WINDOWING_QUARTZ
+#ifndef GDK_WINDOWING_MACOS
   g_string_append (string, "+");
 #else
   /* no separator on quartz */
@@ -826,7 +826,7 @@ gtk_accelerator_print_label (GString        *gstring,
 
   if (accelerator_mods & GDK_SHIFT_MASK)
     {
-#ifndef GDK_WINDOWING_QUARTZ
+#ifndef GDK_WINDOWING_MACOS
       /* This is the text that should appear next to menu accelerators
        * that use the shift key. If the text on this key isn't typically
        * translated on keyboards used for your language, don't translate
@@ -845,7 +845,7 @@ gtk_accelerator_print_label (GString        *gstring,
       if (seen_mod)
         append_separator (gstring);
 
-#ifndef GDK_WINDOWING_QUARTZ
+#ifndef GDK_WINDOWING_MACOS
       /* This is the text that should appear next to menu accelerators
        * that use the control key. If the text on this key isn't typically
        * translated on keyboards used for your language, don't translate
@@ -864,7 +864,7 @@ gtk_accelerator_print_label (GString        *gstring,
       if (seen_mod)
         append_separator (gstring);
 
-#ifndef GDK_WINDOWING_QUARTZ
+#ifndef GDK_WINDOWING_MACOS
       /* This is the text that should appear next to menu accelerators
        * that use the alt key. If the text on this key isn't typically
        * translated on keyboards used for your language, don't translate
@@ -911,7 +911,7 @@ gtk_accelerator_print_label (GString        *gstring,
       if (seen_mod)
         append_separator (gstring);
 
-#ifndef GDK_WINDOWING_QUARTZ
+#ifndef GDK_WINDOWING_MACOS
       /* This is the text that should appear next to menu accelerators
        * that use the meta key. If the text on this key isn't typically
        * translated on keyboards used for your language, don't translate
diff --git a/gtk/gtkapplicationimpl.c b/gtk/gtkapplicationimpl.c
index c72514d0af..5e66193e66 100644
--- a/gtk/gtkapplicationimpl.c
+++ b/gtk/gtkapplicationimpl.c
@@ -29,8 +29,8 @@
 #include <gdk/wayland/gdkwayland.h>
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
-#include <gdk/quartz/gdkquartz.h>
+#ifdef GDK_WINDOWING_MACOS
+#include <gdk/macos/gdkmacos.h>
 #endif
 
 G_DEFINE_TYPE (GtkApplicationImpl, gtk_application_impl, G_TYPE_OBJECT)
@@ -172,8 +172,8 @@ gtk_application_impl_new (GtkApplication *application,
     impl_type = gtk_application_impl_wayland_get_type ();
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
-  if (GDK_IS_QUARTZ_DISPLAY (display))
+#ifdef GDK_WINDOWING_MACOS
+  if (GDK_IS_MACOS_DISPLAY (display))
     impl_type = gtk_application_impl_quartz_get_type ();
 #endif
 
diff --git a/gtk/gtkfilechoosernative.c b/gtk/gtkfilechoosernative.c
index 6755eb90d7..50e4acd94d 100644
--- a/gtk/gtkfilechoosernative.c
+++ b/gtk/gtkfilechoosernative.c
@@ -189,7 +189,7 @@
 enum {
   MODE_FALLBACK,
   MODE_WIN32,
-  MODE_QUARTZ,
+  MODE_MACOS,
   MODE_PORTAL,
 };
 
@@ -672,7 +672,7 @@ gtk_file_chooser_native_get_files (GtkFileChooser *chooser)
     {
     case MODE_PORTAL:
     case MODE_WIN32:
-    case MODE_QUARTZ:
+    case MODE_MACOS:
       {
         GListStore *store;
         GSList *l;
@@ -709,9 +709,9 @@ gtk_file_chooser_native_show (GtkNativeDialog *native)
     self->mode = MODE_WIN32;
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
   if (gtk_file_chooser_native_quartz_show (self))
-    self->mode = MODE_QUARTZ;
+    self->mode = MODE_MACOS;
 #endif
 
   if (self->mode == MODE_FALLBACK &&
@@ -737,8 +737,8 @@ gtk_file_chooser_native_hide (GtkNativeDialog *native)
       gtk_file_chooser_native_win32_hide (self);
 #endif
       break;
-    case MODE_QUARTZ:
-#ifdef GDK_WINDOWING_QUARTZ
+    case MODE_MACOS:
+#ifdef GDK_WINDOWING_MACOS
       gtk_file_chooser_native_quartz_hide (self);
 #endif
       break;
diff --git a/gtk/gtkfilechoosernativequartz.c b/gtk/gtkfilechoosernativequartz.c
index 847a461536..29d6ebb62d 100644
--- a/gtk/gtkfilechoosernativequartz.c
+++ b/gtk/gtkfilechoosernativequartz.c
@@ -19,6 +19,8 @@
 
 #include "config.h"
 
+#include <Cocoa/Cocoa.h>
+
 #include "gtkfilechoosernativeprivate.h"
 #include "gtknativedialogprivate.h"
 
@@ -28,6 +30,7 @@
 #include "gtkfilechooserwidget.h"
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
+#include "gtknative.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
@@ -38,7 +41,9 @@
 #include "gtklabel.h"
 #include "gtkfilefilterprivate.h"
 
-#include "quartz/gdkquartz.h"
+#include <gdk/macos/gdkmacos.h>
+
+#include "gdk/macos/gdkmacossurface-private.h"
 
 typedef struct {
   GtkFileChooserNative *self;
@@ -346,7 +351,7 @@ filechooser_quartz_launch (FileChooserQuartzData *data)
   
   void (^handler)(NSInteger ret) = ^(NSInteger result) {
 
-    if (result == NSFileHandlingPanelOKButton)
+    if (result == NSModalResponseOK)
       {
         // get selected files and update data->files
         data->response = GTK_RESPONSE_ACCEPT;
@@ -467,7 +472,7 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
       data->filter_names = [NSMutableArray arrayWithCapacity:n_filters];
       [data->filter_names retain];
 
-      for (i = 0; i < n; i++)
+      for (i = 0; i < n_filters; i++)
         {
           GtkFileFilter *filter = g_list_model_get_item (filters, i);
           if (!file_filter_to_quartz (filter, data->filters, data->filter_names))
@@ -516,7 +521,7 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
   if (transient_for)
     {
       gtk_widget_realize (GTK_WIDGET (transient_for));
-      data->parent = gdk_quartz_surface_get_nswindow (gtk_native_get_surface (GTK_NATIVE (transient_for)));
+      data->parent = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (gtk_native_get_surface (GTK_NATIVE 
(transient_for))));
 
       if (gtk_native_dialog_get_modal (GTK_NATIVE_DIALOG (self)))
         data->modal = TRUE;
diff --git a/gtk/gtkfilefilter.c b/gtk/gtkfilefilter.c
index cf6121eaca..b90f812b1e 100644
--- a/gtk/gtkfilefilter.c
+++ b/gtk/gtkfilefilter.c
@@ -625,7 +625,7 @@ gtk_file_filter_get_attributes (GtkFileFilter *filter)
   return (const char **)filter->attributes;
 }
 
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
 
 #import <Foundation/Foundation.h>
 
diff --git a/gtk/gtkfilefilterprivate.h b/gtk/gtkfilefilterprivate.h
index 340caf80e7..29c4859d65 100644
--- a/gtk/gtkfilefilterprivate.h
+++ b/gtk/gtkfilefilterprivate.h
@@ -22,7 +22,7 @@
 #include <gtk/gtkfilefilter.h>
 #include <gdk/gdkconfig.h>
 
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
 #import <Foundation/Foundation.h>
 #endif
 
@@ -30,7 +30,7 @@ G_BEGIN_DECLS
 
 char ** _gtk_file_filter_get_as_patterns (GtkFileFilter      *filter);
 
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
 NSArray * _gtk_file_filter_get_as_pattern_nsstrings (GtkFileFilter *filter);
 #endif
 
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c
index 3181ee26b7..1c9ec68109 100644
--- a/gtk/gtkimmodule.c
+++ b/gtk/gtkimmodule.c
@@ -58,8 +58,8 @@
 #include "gtkimcontextime.h"
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
-#include "quartz/gdkquartz.h"
+#ifdef GDK_WINDOWING_MACOS
+#include "macos/gdkmacos.h"
 #include "gtkimcontextquartz.h"
 #endif
 
@@ -131,9 +131,9 @@ match_backend (GdkDisplay *display,
     return FALSE;
 #endif
 
-  if (g_strcmp0 (context_id, "quartz") == 0)
-#ifdef GDK_WINDOWING_QUARTZ
-    return GDK_IS_QUARTZ_DISPLAY (display);
+  if (g_strcmp0 (context_id, "macos") == 0)
+#ifdef GDK_WINDOWING_MACOS
+    return GDK_IS_MACOS_DISPLAY (display);
 #else
     return FALSE;
 #endif
@@ -270,7 +270,7 @@ gtk_im_modules_init (void)
 #ifdef GDK_WINDOWING_WIN32
   g_type_ensure (gtk_im_context_ime_get_type ());
 #endif
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
   g_type_ensure (gtk_im_context_quartz_get_type ());
 #endif
 
diff --git a/gtk/gtkprivate.c b/gtk/gtkprivate.c
index 105cf4a8ce..45838be9eb 100644
--- a/gtk/gtkprivate.c
+++ b/gtk/gtkprivate.c
@@ -33,7 +33,7 @@
 #include "gtkresources.h"
 
 
-#if !defined G_OS_WIN32 && !(defined GDK_WINDOWING_QUARTZ && defined QUARTZ_RELOCATION)
+#if !defined G_OS_WIN32 && !(defined GDK_WINDOWING_MACOS && defined QUARTZ_RELOCATION)
 
 const gchar *
 _gtk_get_datadir (void)
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index e76ca4e688..2916c917d5 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -2182,7 +2182,7 @@ gtk_range_scroll_controller_scroll (GtkEventControllerScroll *scroll,
   gboolean handled;
   GtkOrientation move_orientation;
 
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
   scroll_unit = 1;
 #else
   scroll_unit = gtk_adjustment_get_page_increment (priv->adjustment);
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index bb74c4f17b..6d0014c24d 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1202,7 +1202,7 @@ get_scroll_unit (GtkScrolledWindow *sw,
 {
   gdouble scroll_unit;
 
-#ifndef GDK_WINDOWING_QUARTZ
+#ifndef GDK_WINDOWING_MACOS
   GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
   GtkScrollbar *scrollbar;
   GtkAdjustment *adj;
diff --git a/gtk/gtksearchengine.c b/gtk/gtksearchengine.c
index d9f39bc1fc..9c2d73f779 100644
--- a/gtk/gtksearchengine.c
+++ b/gtk/gtksearchengine.c
@@ -25,7 +25,7 @@
 #include "gtksearchenginequartz.h"
 #include "gtkintl.h"
 
-#include <gdk/gdk.h> /* for GDK_WINDOWING_QUARTZ */
+#include <gdk/gdk.h> /* for GDK_WINDOWING_MACOS */
 
 #if defined(HAVE_TRACKER3)
 #include "gtksearchenginetracker3.h"
@@ -342,7 +342,7 @@ _gtk_search_engine_new (void)
     }
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
   engine->priv->native = _gtk_search_engine_quartz_new ();
   if (engine->priv->native)
     {
diff --git a/gtk/gtksearchenginequartz.c b/gtk/gtksearchenginequartz.c
index d10cdf5987..35335587f7 100644
--- a/gtk/gtksearchenginequartz.c
+++ b/gtk/gtksearchenginequartz.c
@@ -16,7 +16,6 @@
  */
 
 #include <Cocoa/Cocoa.h>
-#include <quartz/gdkquartz.h>
 
 #include "gtksearchenginequartz.h"
 
@@ -262,7 +261,7 @@ _gtk_search_engine_quartz_init (GtkSearchEngineQuartz *engine)
 GtkSearchEngine *
 _gtk_search_engine_quartz_new (void)
 {
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
   return g_object_new (GTK_TYPE_SEARCH_ENGINE_QUARTZ, NULL);
 #else
   return NULL;
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index fe1af8e9bf..0d4e889e96 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -49,15 +49,15 @@
 #include "broadway/gdkbroadway.h"
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
-#include "quartz/gdkquartz.h"
+#ifdef GDK_WINDOWING_MACOS
+#include "macos/gdkmacos.h"
 #endif
 
 #ifdef GDK_WINDOWING_WIN32
 #include "win32/gdkwin32.h"
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
 #define PRINT_PREVIEW_COMMAND "open -b com.apple.Preview %f"
 #else
 #define PRINT_PREVIEW_COMMAND "evince --unlink-tempfile --preview --print-settings %s %f"
@@ -1095,8 +1095,8 @@ gtk_settings_create_for_display (GdkDisplay *display)
 {
   GtkSettings *settings;
 
-#ifdef GDK_WINDOWING_QUARTZ
-  if (GDK_IS_QUARTZ_DISPLAY (display))
+#ifdef GDK_WINDOWING_MACOS
+  if (GDK_IS_MACOS_DISPLAY (display))
     settings = g_object_new (GTK_TYPE_SETTINGS,
                              "gtk-key-theme-name", "Mac",
                              "gtk-shell-shows-app-menu", TRUE,
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index 2a5b304d09..0ec34f2a43 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -44,8 +44,8 @@
 #include "win32/gdkwin32.h"
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
-#include "quartz/gdkquartz.h"
+#ifdef GDK_WINDOWING_MACOS
+#include "macos/gdkmacos.h"
 #endif
 
 #ifdef GDK_WINDOWING_WAYLAND
@@ -134,9 +134,9 @@ init_version (GtkInspectorGeneral *gen)
     backend = "Windows";
   else
 #endif
-#ifdef GDK_WINDOWING_QUARTZ
-  if (GDK_IS_QUARTZ_DISPLAY (gen->display))
-    backend = "Quartz";
+#ifdef GDK_WINDOWING_MACOS
+  if (GDK_IS_MACOS_DISPLAY (gen->display))
+    backend = "macOS";
   else
 #endif
     backend = "Unknown";
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index 928b644a41..8baca53877 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -486,7 +486,7 @@ static gchar*
 get_data_path (const gchar *subdir)
 {
   gchar *base_datadir, *full_datadir;
-#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
+#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_MACOS)
   base_datadir = g_strdup (_gtk_get_datadir ());
 #else
   base_datadir = g_strdup (GTK_DATADIR);
diff --git a/gtk/meson.build b/gtk/meson.build
index 9a209b468f..5fdc74c205 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -799,7 +799,7 @@ if win32_enabled
   gtk_sources += ['gtkmountoperation-stub.c']
 endif
 
-if quartz_enabled
+if macos_enabled
   gtk_sources += files([
     'gtksearchenginequartz.c',
     'gtkmountoperation-stub.c',
@@ -813,7 +813,7 @@ if quartz_enabled
   gtk_cargs += ['-xobjective-c']  # FIXME? maybe add_languages() instead?
 endif
 
-if not (x11_enabled or win32_enabled or quartz_enabled)
+if not (x11_enabled or win32_enabled or macos_enabled)
   gtk_sources += ['gtkmountoperation-stub.c', ]
 endif
 
diff --git a/testsuite/gtk/autotestkeywords.cc b/testsuite/gtk/autotestkeywords.cc
index 04c637ea1e..971fdc50ac 100644
--- a/testsuite/gtk/autotestkeywords.cc
+++ b/testsuite/gtk/autotestkeywords.cc
@@ -4,9 +4,9 @@
 #include <gdk/broadway/gdkbroadway.h>
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
+#ifdef GDK_WINDOWING_MACOS
 #if HAVE_OBJC
-#include <gdk/quartz/gdkquartz.h>
+#include <gdk/macos/gdkmacos.h>
 #endif
 #endif
 


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