[gtk/wip/chergert/quartz4u] build: stub out macOS backend
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/quartz4u] build: stub out macOS backend
- Date: Fri, 24 Apr 2020 02:23:16 +0000 (UTC)
commit 8c8adf3ae3fe6da7614b8eb214e2ab775661740a
Author: Christian Hergert <chergert redhat com>
Date: Thu Apr 23 16:36:46 2020 -0700
build: stub out macOS backend
gdk/gdkconfig.h.meson | 1 +
gdk/gdkdisplaymanager.c | 7 +++
gdk/macos/gdkmacos-private.h | 31 +++++++++++++
gdk/macos/gdkmacos.h | 27 +++++++++++
gdk/macos/gdkmacosdisplay.c | 106 +++++++++++++++++++++++++++++++++++++++++++
gdk/macos/gdkmacosdisplay.h | 50 ++++++++++++++++++++
gdk/macos/meson.build | 41 +++++++++++++++++
gdk/meson.build | 3 +-
meson.build | 8 +++-
meson_options.txt | 2 +
10 files changed, 273 insertions(+), 3 deletions(-)
---
diff --git a/gdk/gdkconfig.h.meson b/gdk/gdkconfig.h.meson
index 80666b25f0..867b430e43 100644
--- a/gdk/gdkconfig.h.meson
+++ b/gdk/gdkconfig.h.meson
@@ -12,6 +12,7 @@ G_BEGIN_DECLS
#mesondefine GDK_WINDOWING_X11
#mesondefine GDK_WINDOWING_BROADWAY
+#mesondefine GDK_WINDOWING_MACOS
#mesondefine GDK_WINDOWING_WAYLAND
#mesondefine GDK_WINDOWING_WIN32
diff --git a/gdk/gdkdisplaymanager.c b/gdk/gdkdisplaymanager.c
index 8a359b77c6..cd6fb6fe71 100644
--- a/gdk/gdkdisplaymanager.c
+++ b/gdk/gdkdisplaymanager.c
@@ -50,6 +50,10 @@
#include "broadway/gdkprivate-broadway.h"
#endif
+#ifdef GDK_WINDOWING_MACOS
+#include "macos/gdkmacos-private.h"
+#endif
+
#ifdef GDK_WINDOWING_WIN32
#include "win32/gdkwin32.h"
#include "win32/gdkprivate-win32.h"
@@ -262,6 +266,9 @@ static GdkBackend gdk_backends[] = {
#ifdef GDK_WINDOWING_QUARTZ
{ "quartz", _gdk_quartz_display_open },
#endif
+#ifdef GDK_WINDOWING_MACOS
+ { "macos", _gdk_macos_display_open },
+#endif
#ifdef GDK_WINDOWING_WIN32
{ "win32", _gdk_win32_display_open },
#endif
diff --git a/gdk/macos/gdkmacos-private.h b/gdk/macos/gdkmacos-private.h
new file mode 100644
index 0000000000..8423d1256d
--- /dev/null
+++ b/gdk/macos/gdkmacos-private.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * 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.1 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/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GDK_MACOS_PRIVATE_H__
+#define __GDK_MACOS_PRIVATE_H__
+
+#include "gdkmacos.h"
+
+G_BEGIN_DECLS
+
+GdkDisplay *_gdk_macos_display_open (const gchar *name);
+
+G_END_DECLS
+
+#endif /* __GDK_MACOS_PRIVATE_H__ */
diff --git a/gdk/macos/gdkmacos.h b/gdk/macos/gdkmacos.h
new file mode 100644
index 0000000000..f7eea95502
--- /dev/null
+++ b/gdk/macos/gdkmacos.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * 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.1 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/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GDK_MACOS_H__
+#define __GDK_MACOS_H__
+
+#include <gdk/gdk.h>
+
+#include "gdkmacosdisplay.h"
+
+#endif /* __GDK_MACOS_H__ */
diff --git a/gdk/macos/gdkmacosdisplay.c b/gdk/macos/gdkmacosdisplay.c
new file mode 100644
index 0000000000..5e478e3a2b
--- /dev/null
+++ b/gdk/macos/gdkmacosdisplay.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * 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.1 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/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "config.h"
+
+#include <gdk/gdk.h>
+#include <gdk/gdkdisplayprivate.h>
+
+#include "gdkmacos-private.h"
+#include "gdkmacosdisplay.h"
+
+/**
+ * SECTION:macos_interaction
+ * @Short_description: macOS backend-specific functions
+ * @Title: macOS Interaction
+ * @Include: gdk/macos/gdkmacos.h
+ *
+ * The functions in this section are specific to the GDK macOS backend.
+ * To use them, you need to include the `<gdk/macos/gdkmacos.h>` header and
+ * use the macOS-specific pkg-config `gtk4-macos` file to build your
+ * application.
+ *
+ * To make your code compile with other GDK backends, guard backend-specific
+ * calls by an ifdef as follows. Since GDK may be built with multiple
+ * backends, you should also check for the backend that is in use (e.g. by
+ * using the GDK_IS_MACOS_DISPLAY() macro).
+ * |[<!-- language="C" -->
+ * #ifdef GDK_WINDOWING_MACOS
+ * if (GDK_IS_MACOS_DISPLAY (display))
+ * {
+ * // make macOS-specific calls here
+ * }
+ * else
+ * #endif
+ * #ifdef GDK_WINDOWING_X11
+ * if (GDK_IS_X11_DISPLAY (display))
+ * {
+ * // make X11-specific calls here
+ * }
+ * else
+ * #endif
+ * g_error ("Unsupported GDK backend");
+ * ]|
+ */
+
+struct _GdkMacosDisplay
+{
+ GdkDisplay parent_instance;
+};
+
+struct _GdkMacosDisplayClass
+{
+ GdkDisplayClass parent_class;
+};
+
+G_DEFINE_TYPE (GdkMacosDisplay, gdk_macos_display, GDK_TYPE_DISPLAY)
+
+static void
+gdk_macos_display_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gdk_macos_display_parent_class)->finalize (object);
+}
+
+static void
+gdk_macos_display_class_init (GdkMacosDisplayClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gdk_macos_display_finalize;
+}
+
+static void
+gdk_macos_display_init (GdkMacosDisplay *self)
+{
+}
+
+GdkDisplay *
+_gdk_macos_display_open (const gchar *name)
+{
+ GdkDisplay *ret;
+
+ /* Make the current process a foreground application, i.e. an app
+ * with a user interface, in case we're not running from a .app bundle
+ */
+ //TransformProcessType (&psn, kProcessTransformToForegroundApplication);
+
+ ret = g_object_new (GDK_TYPE_MACOS_DISPLAY, NULL);
+
+ return g_steal_pointer (&ret);
+}
diff --git a/gdk/macos/gdkmacosdisplay.h b/gdk/macos/gdkmacosdisplay.h
new file mode 100644
index 0000000000..02bdeb4b91
--- /dev/null
+++ b/gdk/macos/gdkmacosdisplay.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * 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.1 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/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GDK_MACOS_DISPLAY_H__
+#define __GDK_MACOS_DISPLAY_H__
+
+#if !defined (__GDKMACOS_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gdk/macos/gdkmacos.h> can be included directly."
+#endif
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+#ifdef GTK_COMPILATION
+typedef struct _GdkMacosDisplay GdkMacosDisplay;
+#else
+typedef GdkDisplay GdkMacosDisplay;
+#endif
+typedef struct _GdkMacosDisplayClass GdkMacosDisplayClass;
+
+#define GDK_TYPE_MACOS_DISPLAY (gdk_macos_display_get_type())
+#define GDK_MACOS_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MACOS_DISPLAY,
GdkMacosDisplay))
+#define GDK_MACOS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MACOS_DISPLAY,
GdkMacosDisplayClass))
+#define GDK_IS_MACOS_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MACOS_DISPLAY))
+#define GDK_IS_MACOS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MACOS_DISPLAY))
+#define GDK_MACOS_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MACOS_DISPLAY,
GdkMacosDisplayClass))
+
+GDK_AVAILABLE_IN_ALL
+GType gdk_macos_display_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GDK_MACOS_DISPLAY_H__ */
diff --git a/gdk/macos/meson.build b/gdk/macos/meson.build
new file mode 100644
index 0000000000..1a41d726f9
--- /dev/null
+++ b/gdk/macos/meson.build
@@ -0,0 +1,41 @@
+gdk_macos_sources = files([
+ # 'gdkapplaunchcontext-macos.c',
+ # 'gdkcairocontext-macos.c',
+ # 'gdkclipboard-macos.c',
+ # 'gdkcursor-macos.c',
+ # 'gdkdevice-macos.c',
+ 'gdkmacosdisplay.c',
+ # 'gdkdrag-macos.c',
+ # 'gdkdrop-macos.c',
+ # 'gdkeventsource.c',
+ # 'gdkglcontext-macos.c',
+ # 'gdkkeys-macos.c',
+ # 'gdkmonitor-macos.c',
+ # 'gdkprimary-macos.c',
+ # 'gdksurface-macos.c',
+])
+
+gdk_macos_public_headers = files([
+ # 'gdkmacosdevice.h',
+ 'gdkmacosdisplay.h',
+ # 'gdkmacosglcontext.h',
+ # 'gdkmacosmonitor.h',
+ # 'gdkmacossurface.h'
+])
+
+install_headers(gdk_macos_public_headers, 'gdkmacos.h', subdir: 'gtk-4.0/gdk/macos/')
+
+gdk_macos_deps = [
+]
+
+libgdk_macos = static_library('gdk-macos',
+ gdk_macos_sources, gdkconfig, gdkenum_h,
+ include_directories: [ confinc, gdkinc, ],
+ c_args: [
+ '-DGTK_COMPILATION',
+ '-DG_LOG_DOMAIN="Gdk"',
+ '-xobjective-c',
+ ] + common_cflags,
+ link_args: common_ldflags,
+ link_with: [],
+ dependencies: [ gdk_deps, gdk_macos_deps])
diff --git a/gdk/meson.build b/gdk/meson.build
index ac14c3b6fe..5835c0fbbf 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -143,6 +143,7 @@ gdkconfig_cdata.set('GDK_WINDOWING_X11', x11_enabled)
gdkconfig_cdata.set('GDK_WINDOWING_WAYLAND', wayland_enabled)
gdkconfig_cdata.set('GDK_WINDOWING_WIN32', win32_enabled)
gdkconfig_cdata.set('GDK_WINDOWING_BROADWAY', broadway_enabled)
+gdkconfig_cdata.set('GDK_WINDOWING_MACOS', macos_enabled)
gdkconfig_cdata.set('GDK_RENDERING_VULKAN', have_vulkan)
gdkconfig = configure_file(
@@ -218,7 +219,7 @@ endif
gdk_backends = []
gdk_backends_gen_headers = [] # non-public generated headers
-foreach backend : ['broadway', 'quartz', 'wayland', 'win32', 'x11']
+foreach backend : ['broadway', 'quartz', 'wayland', 'win32', 'x11', 'macos']
if get_variable('@0@_enabled'.format(backend))
subdir(backend)
gdk_deps += get_variable('gdk_@0@_deps'.format(backend))
diff --git a/meson.build b/meson.build
index 12388f743a..c5c431a17a 100644
--- a/meson.build
+++ b/meson.build
@@ -93,6 +93,7 @@ gtk_api_version = '4.0'
x11_enabled = get_option('x11-backend')
wayland_enabled = get_option('wayland-backend')
broadway_enabled = get_option('broadway-backend')
+macos_enabled = get_option('macos-backend')
quartz_enabled = get_option('quartz-backend')
win32_enabled = get_option('win32-backend')
@@ -242,6 +243,8 @@ if cc.get_id() == 'msvc'
elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
test_cflags = [
'-fno-strict-aliasing',
+ '-Wno-c++11-extensions',
+ '-Wno-missing-include-dirs',
'-Wno-typedef-redefinition',
'-Wcast-align',
'-Wduplicated-branches',
@@ -368,7 +371,8 @@ pangocairo_dep = dependency('pangocairo', version: cairo_req,
pixbuf_dep = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req,
fallback : ['gdk-pixbuf', 'gdkpixbuf_dep'])
epoxy_dep = dependency('epoxy', version: epoxy_req,
- fallback: ['libepoxy', 'libepoxy_dep'])
+ fallback: ['libepoxy', 'libepoxy_dep'],
+ static: false)
atk_dep = dependency('atk', version: atk_req)
harfbuzz_dep = dependency('harfbuzz', version: '>= 0.9', required: false)
xkbdep = dependency('xkbcommon', version: xkbcommon_req, required: wayland_enabled)
@@ -775,7 +779,7 @@ pkg_install_dir = join_paths(get_option('libdir'), 'pkgconfig')
pkgs = [ 'gtk4.pc' ]
pkg_targets = ''
-foreach backend: [ 'broadway', 'quartz', 'wayland', 'win32', 'x11', ]
+foreach backend: [ 'broadway', 'quartz', 'macos', 'wayland', 'win32', 'x11', ]
if get_variable('@0@_enabled'.format(backend))
pkgs += ['gtk4-@0@.pc'.format(backend)]
pkg_targets += ' ' + backend
diff --git a/meson_options.txt b/meson_options.txt
index 73f26da7da..61c8930ab3 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -9,6 +9,8 @@ option('win32-backend', type: 'boolean', value: true,
description : 'Enable the Windows gdk backend (only when building on Windows)')
option('quartz-backend', type: 'boolean', value: true,
description : 'Enable the macOS gdk backend (only when building on macOS)')
+option('macos-backend', type: 'boolean', value: true,
+ description : 'Enable the macOS gdk backend (only when building on macOS)')
# Media backends
option('media', type: 'string', value: 'gstreamer',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]