[gtk/wip/chergert/quartz4u] stub out devices
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/quartz4u] stub out devices
- Date: Mon, 27 Apr 2020 21:25:21 +0000 (UTC)
commit cb8f14416827f7d25068fb38c4bd4805637c2ccc
Author: Christian Hergert <chergert redhat com>
Date: Mon Apr 27 14:13:40 2020 -0700
stub out devices
gdk/macos/gdkmacosdevice-private.h | 42 ++++++++++++++++++++++++
gdk/macos/gdkmacosdevice.c | 55 +++++++++++++++++++++++++++++++
gdk/macos/gdkmacosdisplay.c | 14 ++++++++
gdk/macos/gdkmacosmonitor-private.h | 10 ------
gdk/macos/gdkmacosmonitor.c | 10 ++++++
gdk/macos/gdkmacosseat-private.h | 35 ++++++++++++++++++++
gdk/macos/gdkmacosseat.c | 65 +++++++++++++++++++++++++++++++++++++
gdk/macos/meson.build | 2 ++
8 files changed, 223 insertions(+), 10 deletions(-)
---
diff --git a/gdk/macos/gdkmacosdevice-private.h b/gdk/macos/gdkmacosdevice-private.h
new file mode 100644
index 0000000000..4c41219b60
--- /dev/null
+++ b/gdk/macos/gdkmacosdevice-private.h
@@ -0,0 +1,42 @@
+/*
+ * 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_DEVICE_PRIVATE_H__
+#define __GDK_MACOS_DEVICE_PRIVATE_H__
+
+#if !defined (__GDKMACOS_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gdk/macos/gdkmacos.h> can be included directly."
+#endif
+
+#include "gdkdeviceprivate.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GdkMacosDevice GdkMacosDevice;
+typedef struct _GdkMacosDeviceClass GdkMacosDeviceClass;
+
+#define GDK_TYPE_MACOS_DEVICE (gdk_macos_device_get_type())
+#define GDK_MACOS_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MACOS_DEVICE,
GdkMacosDevice))
+#define GDK_IS_MACOS_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MACOS_DEVICE))
+
+GType gdk_macos_device_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GDK_MACOS_DEVICE_PRIVATE_H__ */
diff --git a/gdk/macos/gdkmacosdevice.c b/gdk/macos/gdkmacosdevice.c
new file mode 100644
index 0000000000..3a1d50a1a7
--- /dev/null
+++ b/gdk/macos/gdkmacosdevice.c
@@ -0,0 +1,55 @@
+/*
+ * 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 "gdkmacosdevice-private.h"
+
+struct _GdkMacosDevice
+{
+ GdkDevice parent_instance;
+};
+
+struct _GdkMacosDeviceClass
+{
+ GdkDeviceClass parent_class;
+};
+
+G_DEFINE_TYPE (GdkMacosDevice, gdk_macos_device, GDK_TYPE_DEVICE)
+
+static void
+gdk_macos_device_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gdk_macos_device_parent_class)->finalize (object);
+}
+
+static void
+gdk_macos_device_class_init (GdkMacosDeviceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gdk_macos_device_finalize;
+}
+
+static void
+gdk_macos_device_init (GdkMacosDevice *self)
+{
+}
diff --git a/gdk/macos/gdkmacosdisplay.c b/gdk/macos/gdkmacosdisplay.c
index e0ae8b161f..342e299ba5 100644
--- a/gdk/macos/gdkmacosdisplay.c
+++ b/gdk/macos/gdkmacosdisplay.c
@@ -27,6 +27,7 @@
#include "gdkmacosdisplay-private.h"
#include "gdkmacoskeymap-private.h"
#include "gdkmacosmonitor-private.h"
+#include "gdkmacosseat-private.h"
#include "gdkmacossurface-private.h"
#include "gdkmacosutils-private.h"
@@ -174,6 +175,18 @@ gdk_macos_display_load_monitors (GdkMacosDisplay *self)
GDK_END_MACOS_ALLOC_POOL;
}
+static void
+gdk_macos_display_load_seat (GdkMacosDisplay *self)
+{
+ GdkSeat *seat;
+
+ g_assert (GDK_IS_MACOS_DISPLAY (self));
+
+ seat = _gdk_macos_seat_new (self);
+ gdk_display_add_seat (GDK_DISPLAY (self), seat);
+ g_object_unref (seat);
+}
+
static const gchar *
gdk_macos_display_get_name (GdkDisplay *display)
{
@@ -353,6 +366,7 @@ _gdk_macos_display_open (const gchar *display_name)
self->name = g_strdup (display_name);
self->keymap = _gdk_macos_keymap_new (self);
+ gdk_macos_display_load_seat (self);
gdk_macos_display_load_monitors (self);
if (event_source == NULL)
diff --git a/gdk/macos/gdkmacosmonitor-private.h b/gdk/macos/gdkmacosmonitor-private.h
index ef5721e27d..7eb24819f4 100644
--- a/gdk/macos/gdkmacosmonitor-private.h
+++ b/gdk/macos/gdkmacosmonitor-private.h
@@ -29,16 +29,6 @@
G_BEGIN_DECLS
-struct _GdkMacosMonitor
-{
- GdkMonitor parent_instance;
-};
-
-struct _GdkMacosMonitorClass
-{
- GdkMonitorClass parent_class;
-};
-
GdkMacosMonitor *_gdk_macos_monitor_new (GdkMacosDisplay *display,
CGDirectDisplayID monitor_id);
diff --git a/gdk/macos/gdkmacosmonitor.c b/gdk/macos/gdkmacosmonitor.c
index 37dc40274e..652c400696 100644
--- a/gdk/macos/gdkmacosmonitor.c
+++ b/gdk/macos/gdkmacosmonitor.c
@@ -23,6 +23,16 @@
#include "gdkmacosmonitor-private.h"
+struct _GdkMacosMonitor
+{
+ GdkMonitor parent_instance;
+};
+
+struct _GdkMacosMonitorClass
+{
+ GdkMonitorClass parent_class;
+};
+
G_DEFINE_TYPE (GdkMacosMonitor, gdk_macos_monitor, GDK_TYPE_MONITOR)
static void
diff --git a/gdk/macos/gdkmacosseat-private.h b/gdk/macos/gdkmacosseat-private.h
new file mode 100644
index 0000000000..57e5605018
--- /dev/null
+++ b/gdk/macos/gdkmacosseat-private.h
@@ -0,0 +1,35 @@
+/*
+ * 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_SEAT_PRIVATE_H__
+#define __GDK_MACOS_SEAT_PRIVATE_H__
+
+#include <AppKit/AppKit.h>
+
+#include "gdkmacosdisplay.h"
+
+#include "gdkseatprivate.h"
+
+G_BEGIN_DECLS
+
+GdkSeat *_gdk_macos_seat_new (GdkMacosDisplay *display);
+
+G_END_DECLS
+
+#endif /* __GDK_MACOS_SEAT_PRIVATE_H__ */
diff --git a/gdk/macos/gdkmacosseat.c b/gdk/macos/gdkmacosseat.c
new file mode 100644
index 0000000000..04282a9744
--- /dev/null
+++ b/gdk/macos/gdkmacosseat.c
@@ -0,0 +1,65 @@
+/*
+ * 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 "gdkdeviceprivate.h"
+#include "gdkseatdefaultprivate.h"
+
+#include "gdkmacosdevice-private.h"
+#include "gdkmacosseat-private.h"
+
+GdkSeat *
+_gdk_macos_seat_new (GdkMacosDisplay *display)
+{
+ GdkDevice *core_keyboard;
+ GdkDevice *core_pointer;
+ GdkSeat *seat;
+
+ g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL);
+
+ core_pointer = g_object_new (GDK_TYPE_MACOS_DEVICE,
+ "name", "Core Pointer",
+ "type", GDK_DEVICE_TYPE_MASTER,
+ "source", GDK_SOURCE_MOUSE,
+ "has-cursor", TRUE,
+ "display", display,
+ NULL);
+ core_keyboard = g_object_new (GDK_TYPE_MACOS_DEVICE,
+ "name", "Core Keyboard",
+ "type", GDK_DEVICE_TYPE_MASTER,
+ "source", GDK_SOURCE_KEYBOARD,
+ "has-cursor", FALSE,
+ "display", display,
+ NULL);
+
+ _gdk_device_set_associated_device (GDK_DEVICE (core_pointer),
+ GDK_DEVICE (core_keyboard));
+ _gdk_device_set_associated_device (GDK_DEVICE (core_keyboard),
+ GDK_DEVICE (core_pointer));
+
+ seat = gdk_seat_default_new_for_master_pair (core_pointer, core_keyboard);
+
+ g_object_unref (core_pointer);
+ g_object_unref (core_keyboard);
+
+ return g_steal_pointer (&seat);
+}
diff --git a/gdk/macos/meson.build b/gdk/macos/meson.build
index da4b9911b1..8a43f3375d 100644
--- a/gdk/macos/meson.build
+++ b/gdk/macos/meson.build
@@ -1,8 +1,10 @@
gdk_macos_sources = files([
+ 'gdkmacosdevice.c',
'gdkmacosdisplay.c',
'gdkmacoseventsource.c',
'gdkmacoskeymap.c',
'gdkmacosmonitor.c',
+ 'gdkmacosseat.c',
'gdkmacossurface.c',
# 'GdkMacosView.c',
'GdkMacosWindow.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]