[gtk/gtk-3-24: 1/2] Add a public header for Cocoa access functions.
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24: 1/2] Add a public header for Cocoa access functions.
- Date: Sat, 17 Apr 2021 00:28:16 +0000 (UTC)
commit 242b76a7711ab6326a220f9e65e6fc282dc2f8b1
Author: John Ralls <jralls ceridwen us>
Date: Fri Apr 16 16:56:55 2021 -0700
Add a public header for Cocoa access functions.
Some applications need to access gdk_quartz_window_get_nsview,
gdk_quartz_window_get_nswindow, and gdk_quartz_event_get_nsevent
so move these from the private gdkquartz-gtk-only.h to a new
header gdkquartz-cocoa-access.h. Don't include this header in
gdkquartz.h so that user code that doesn't need to access these
functins isn't required to compile with Objective C/C++.
Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/1737
gdk/quartz/Makefile.am | 1 +
gdk/quartz/gdkglcontext-quartz.c | 2 +-
gdk/quartz/gdkinternal-quartz.h | 6 +++++-
gdk/quartz/gdkquartz-cocoa-access.h | 37 +++++++++++++++++++++++++++++++++++++
gdk/quartz/gdkquartz-gtk-only.h | 8 --------
gdk/quartz/gdkutils-quartz.c | 1 +
gdk/quartz/gdkwindow-quartz.c | 2 +-
gdk/quartz/meson.build | 1 +
gtk/gtkdnd-quartz.c | 1 +
gtk/gtkfilechoosernativequartz.c | 2 +-
modules/input/imquartz.c | 2 +-
11 files changed, 50 insertions(+), 13 deletions(-)
---
diff --git a/gdk/quartz/Makefile.am b/gdk/quartz/Makefile.am
index 141d931c64..4782c5aab6 100644
--- a/gdk/quartz/Makefile.am
+++ b/gdk/quartz/Makefile.am
@@ -60,6 +60,7 @@ libgdkinclude_HEADERS = \
gdkquartz.h
libgdkquartzinclude_HEADERS = \
+ gdkquartz-cocoa-access.h \
gdkquartz-gtk-only.h \
gdkquartzcursor.h \
gdkquartzdevice-core.h \
diff --git a/gdk/quartz/gdkglcontext-quartz.c b/gdk/quartz/gdkglcontext-quartz.c
index 5c4b8e7ac9..a244d66e43 100644
--- a/gdk/quartz/gdkglcontext-quartz.c
+++ b/gdk/quartz/gdkglcontext-quartz.c
@@ -28,7 +28,7 @@
#include "gdkquartzglcontext.h"
#include "gdkquartzwindow.h"
#include "gdkprivate-quartz.h"
-#include "gdkquartz-gtk-only.h"
+#include "gdkquartz-cocoa-access.h"
#include "gdkinternals.h"
diff --git a/gdk/quartz/gdkinternal-quartz.h b/gdk/quartz/gdkinternal-quartz.h
index ec4a2c1c3b..271137171b 100644
--- a/gdk/quartz/gdkinternal-quartz.h
+++ b/gdk/quartz/gdkinternal-quartz.h
@@ -79,10 +79,14 @@ typedef enum {
#define GDK_QUARTZ_EVENT_TABLET_PROXIMITY NSEventTypeTabletProximity
#define GDK_QUARTZ_EVENT_SUBTYPE_TABLET_PROXIMITY NSEventSubtypeTabletProximity
#define GDK_QUARTZ_EVENT_SUBTYPE_TABLET_POINT NSEventSubtypeTabletPoint
-#else
+#elif MAC_OS_X_VERSION_MIN_REQUIRED >= 10120
#define GDK_QUARTZ_EVENT_TABLET_PROXIMITY NSTabletProximity
#define GDK_QUARTZ_EVENT_SUBTYPE_TABLET_PROXIMITY NSTabletProximityEventSubtype
#define GDK_QUARTZ_EVENT_SUBTYPE_TABLET_POINT NSTabletPointEventSubtype
+#else
+#define GDK_QUARTZ_EVENT_TABLET_PROXIMITY kEventTabletProximity
+#define GDK_QUARTZ_EVENT_SUBTYPE_TABLET_PROXIMITY NSTabletProximityEventSubtype
+#define GDK_QUARTZ_EVENT_SUBTYPE_TABLET_POINT kCGEventMouseSubtypeTabletPoint
#endif
void _gdk_quartz_events_update_focus_window (GdkWindow *new_window,
diff --git a/gdk/quartz/gdkquartz-cocoa-access.h b/gdk/quartz/gdkquartz-cocoa-access.h
new file mode 100644
index 0000000000..8c18dc1818
--- /dev/null
+++ b/gdk/quartz/gdkquartz-cocoa-access.h
@@ -0,0 +1,37 @@
+/* gdkquartz-gtk-only.h
+ *
+ * Copyright (C) 2005-2007 Imendio AB
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_QUARTZ_COCOA_ACCESS_H__
+#define __GDK_QUARTZ_COCOA_ACCESS_H__
+
+#ifndef __OBJC__
+#error "This header declares Cocoa types and can be included only from source files compiled with
Objective-C."
+#endif
+
+#include <AppKit/AppKit.h>
+#include <gdk/gdk.h>
+#include <gdk/quartz/gdkquartz.h>
+
+GDK_AVAILABLE_IN_ALL
+NSEvent *gdk_quartz_event_get_nsevent (GdkEvent *event);
+GDK_AVAILABLE_IN_ALL
+NSWindow *gdk_quartz_window_get_nswindow (GdkWindow *window);
+GDK_AVAILABLE_IN_ALL
+NSView *gdk_quartz_window_get_nsview (GdkWindow *window);
+
+#endif
diff --git a/gdk/quartz/gdkquartz-gtk-only.h b/gdk/quartz/gdkquartz-gtk-only.h
index 7f9857c829..d44fbda230 100644
--- a/gdk/quartz/gdkquartz-gtk-only.h
+++ b/gdk/quartz/gdkquartz-gtk-only.h
@@ -38,13 +38,5 @@ NSString *gdk_quartz_atom_to_pasteboard_type_libgtk_only (GdkAtom
/* Utilities */
GDK_AVAILABLE_IN_ALL
NSImage *gdk_quartz_pixbuf_to_ns_image_libgtk_only (GdkPixbuf *pixbuf);
-GDK_AVAILABLE_IN_ALL
-NSEvent *gdk_quartz_event_get_nsevent (GdkEvent *event);
-
-/* Window */
-GDK_AVAILABLE_IN_ALL
-NSWindow *gdk_quartz_window_get_nswindow (GdkWindow *window);
-GDK_AVAILABLE_IN_ALL
-NSView *gdk_quartz_window_get_nsview (GdkWindow *window);
#endif
diff --git a/gdk/quartz/gdkutils-quartz.c b/gdk/quartz/gdkutils-quartz.c
index 1edb94ad14..4f1b9c98d4 100644
--- a/gdk/quartz/gdkutils-quartz.c
+++ b/gdk/quartz/gdkutils-quartz.c
@@ -23,6 +23,7 @@
#include <gdkinternals.h>
#include "gdkquartz-gtk-only.h"
+#include "gdkquartz-cocoa-access.h"
#include <gdkquartzutils.h>
NSImage *
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 62558d1527..5b454341df 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -30,7 +30,7 @@
#include "gdkquartzglcontext.h"
#include "gdkquartzscreen.h"
#include "gdkquartzcursor.h"
-#include "gdkquartz-gtk-only.h"
+#include "gdkquartz-cocoa-access.h"
#include <Carbon/Carbon.h>
#include <AvailabilityMacros.h>
diff --git a/gdk/quartz/meson.build b/gdk/quartz/meson.build
index 1f137d18f8..70d688e1a7 100644
--- a/gdk/quartz/meson.build
+++ b/gdk/quartz/meson.build
@@ -26,6 +26,7 @@ gdk_quartz_sources = files(
)
gdk_quartz_public_headers = files(
+ 'gdkquartz-cocoa-access.h',
'gdkquartzcursor.h',
'gdkquartzdevice-core.h',
'gdkquartzdevicemanager-core.h',
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index 9356a69b8a..959e90d930 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -42,6 +42,7 @@
#include "gtkintl.h"
#include "gtkquartz.h"
#include "gdk/quartz/gdkquartz.h"
+#include "gdk/quartz/gdkquartz-cocoa-access.h"
#include "gdk/quartz/gdkquartz-gtk-only.h"
#include "gdk/quartz/gdkquartzdnd.h"
#include "gtkselectionprivate.h"
diff --git a/gtk/gtkfilechoosernativequartz.c b/gtk/gtkfilechoosernativequartz.c
index 680c7f1381..fb5abd5390 100644
--- a/gtk/gtkfilechoosernativequartz.c
+++ b/gtk/gtkfilechoosernativequartz.c
@@ -40,7 +40,7 @@
#include "gtklabel.h"
#include "gtkfilechooserentry.h"
#include "gtkfilefilterprivate.h"
-#include <quartz/gdkquartz-gtk-only.h>
+#include <quartz/gdkquartz-cocoa-access.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
typedef struct {
diff --git a/modules/input/imquartz.c b/modules/input/imquartz.c
index 9b9b733841..bdee6da2f4 100644
--- a/modules/input/imquartz.c
+++ b/modules/input/imquartz.c
@@ -30,7 +30,7 @@
#define GTK_COMPILATION 1 // For gdkquartz-gtk-only.h
#include "gdk/quartz/gdkinternal-quartz.h"
-#include "gdk/quartz/gdkquartz-gtk-only.h"
+#include "gdk/quartz/gdkquartz-cocoa-access.h"
#include "gdk/quartz/GdkQuartzView.h"
#define GTK_IM_CONTEXT_TYPE_QUARTZ (type_quartz)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]