[mutter] cursor-tracker: Add X11 cursor tracker backend
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cursor-tracker: Add X11 cursor tracker backend
- Date: Thu, 6 Aug 2020 16:26:40 +0000 (UTC)
commit 3abbfef66eea26e9ffc0d10589d0eb8733e3ee6b
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Wed Jul 29 11:06:43 2020 +0200
cursor-tracker: Add X11 cursor tracker backend
The intention is to use this to actively track the cursor position given
a fixed interval when needed, e.g. when screen casting.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
src/backends/meta-backend-private.h | 1 +
src/backends/meta-backend.c | 14 +++++++---
src/backends/meta-cursor-tracker-private.h | 5 ++++
src/backends/meta-cursor-tracker.c | 5 ----
src/backends/x11/cm/meta-backend-x11-cm.c | 10 ++++++++
src/backends/x11/meta-cursor-tracker-x11.c | 41 ++++++++++++++++++++++++++++++
src/backends/x11/meta-cursor-tracker-x11.h | 31 ++++++++++++++++++++++
src/meson.build | 2 ++
src/meta/meta-cursor-tracker.h | 9 +++----
9 files changed, 105 insertions(+), 13 deletions(-)
---
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index f93b5760a4..87247fcc9e 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -68,6 +68,7 @@ struct _MetaBackendClass
MetaMonitorManager * (* create_monitor_manager) (MetaBackend *backend,
GError **error);
MetaCursorRenderer * (* create_cursor_renderer) (MetaBackend *backend);
+ MetaCursorTracker * (* create_cursor_tracker) (MetaBackend *backend);
MetaRenderer * (* create_renderer) (MetaBackend *backend,
GError **error);
MetaInputSettings * (* create_input_settings) (MetaBackend *backend);
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 70e9d080fc..8145565dab 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -592,6 +592,14 @@ meta_backend_real_is_lid_closed (MetaBackend *backend)
return priv->lid_is_closed;
}
+static MetaCursorTracker *
+meta_backend_real_create_cursor_tracker (MetaBackend *backend)
+{
+ return g_object_new (META_TYPE_CURSOR_TRACKER,
+ "backend", backend,
+ NULL);
+}
+
gboolean
meta_backend_is_lid_closed (MetaBackend *backend)
{
@@ -745,6 +753,7 @@ meta_backend_class_init (MetaBackendClass *klass)
klass->ungrab_device = meta_backend_real_ungrab_device;
klass->select_stage_events = meta_backend_real_select_stage_events;
klass->is_lid_closed = meta_backend_real_is_lid_closed;
+ klass->create_cursor_tracker = meta_backend_real_create_cursor_tracker;
signals[KEYMAP_CHANGED] =
g_signal_new ("keymap-changed",
@@ -988,9 +997,8 @@ meta_backend_initable_init (GInitable *initable,
if (!priv->renderer)
return FALSE;
- priv->cursor_tracker = g_object_new (META_TYPE_CURSOR_TRACKER,
- "backend", backend,
- NULL);
+ priv->cursor_tracker =
+ META_BACKEND_GET_CLASS (backend)->create_cursor_tracker (backend);
priv->dnd = g_object_new (META_TYPE_DND, NULL);
diff --git a/src/backends/meta-cursor-tracker-private.h b/src/backends/meta-cursor-tracker-private.h
index dfc8f51b75..54cdb588e8 100644
--- a/src/backends/meta-cursor-tracker-private.h
+++ b/src/backends/meta-cursor-tracker-private.h
@@ -27,6 +27,11 @@
#include "backends/x11/cm/meta-cursor-sprite-xfixes.h"
#include "meta/meta-cursor-tracker.h"
+struct _MetaCursorTrackerClass
+{
+ GObjectClass parent_class;
+};
+
gboolean meta_cursor_tracker_handle_xevent (MetaCursorTracker *tracker,
XEvent *xevent);
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
index 3ec546934d..39f6b2b007 100644
--- a/src/backends/meta-cursor-tracker.c
+++ b/src/backends/meta-cursor-tracker.c
@@ -56,11 +56,6 @@ enum
static GParamSpec *obj_props[N_PROPS];
-struct _MetaCursorTracker
-{
- GObject parent;
-};
-
typedef struct _MetaCursorTrackerPrivate
{
MetaBackend *backend;
diff --git a/src/backends/x11/cm/meta-backend-x11-cm.c b/src/backends/x11/cm/meta-backend-x11-cm.c
index 35f1fd4c2f..28726f7d7d 100644
--- a/src/backends/x11/cm/meta-backend-x11-cm.c
+++ b/src/backends/x11/cm/meta-backend-x11-cm.c
@@ -29,6 +29,7 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-dnd-private.h"
#include "backends/x11/meta-cursor-renderer-x11.h"
+#include "backends/x11/meta-cursor-tracker-x11.h"
#include "backends/x11/meta-gpu-xrandr.h"
#include "backends/x11/meta-input-settings-x11.h"
#include "backends/x11/meta-monitor-manager-xrandr.h"
@@ -122,6 +123,14 @@ meta_backend_x11_cm_create_cursor_renderer (MetaBackend *backend)
NULL);
}
+static MetaCursorTracker *
+meta_backend_x11_cm_create_cursor_tracker (MetaBackend *backend)
+{
+ return g_object_new (META_TYPE_CURSOR_TRACKER_X11,
+ "backend", backend,
+ NULL);
+}
+
static MetaInputSettings *
meta_backend_x11_cm_create_input_settings (MetaBackend *backend)
{
@@ -436,6 +445,7 @@ meta_backend_x11_cm_class_init (MetaBackendX11CmClass *klass)
backend_class->create_renderer = meta_backend_x11_cm_create_renderer;
backend_class->create_monitor_manager = meta_backend_x11_cm_create_monitor_manager;
backend_class->create_cursor_renderer = meta_backend_x11_cm_create_cursor_renderer;
+ backend_class->create_cursor_tracker = meta_backend_x11_cm_create_cursor_tracker;
backend_class->create_input_settings = meta_backend_x11_cm_create_input_settings;
backend_class->update_screen_size = meta_backend_x11_cm_update_screen_size;
backend_class->select_stage_events = meta_backend_x11_cm_select_stage_events;
diff --git a/src/backends/x11/meta-cursor-tracker-x11.c b/src/backends/x11/meta-cursor-tracker-x11.c
new file mode 100644
index 0000000000..7072275a68
--- /dev/null
+++ b/src/backends/x11/meta-cursor-tracker-x11.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2020 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "backends/x11/meta-cursor-tracker-x11.h"
+
+struct _MetaCursorTrackerX11
+{
+ MetaCursorTracker parent;
+};
+
+G_DEFINE_TYPE (MetaCursorTrackerX11, meta_cursor_tracker_x11,
+ META_TYPE_CURSOR_TRACKER)
+
+static void
+meta_cursor_tracker_x11_init (MetaCursorTrackerX11 *tracker_x11)
+{
+}
+
+static void
+meta_cursor_tracker_x11_class_init (MetaCursorTrackerX11Class *klass)
+{
+}
diff --git a/src/backends/x11/meta-cursor-tracker-x11.h b/src/backends/x11/meta-cursor-tracker-x11.h
new file mode 100644
index 0000000000..033c43b1a7
--- /dev/null
+++ b/src/backends/x11/meta-cursor-tracker-x11.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2020 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ */
+
+#ifndef META_CURSOR_TRACKER_X11_H
+#define META_CURSOR_TRACKER_X11_H
+
+#include "backends/meta-cursor-tracker-private.h"
+
+#define META_TYPE_CURSOR_TRACKER_X11 (meta_cursor_tracker_x11_get_type ())
+G_DECLARE_FINAL_TYPE (MetaCursorTrackerX11, meta_cursor_tracker_x11,
+ META, CURSOR_TRACKER_X11,
+ MetaCursorTracker)
+
+#endif /* META_CURSOR_TRACKER_X11_H */
diff --git a/src/meson.build b/src/meson.build
index 51a4d46fa6..e260d2588b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -249,6 +249,8 @@ mutter_sources = [
'backends/x11/meta-crtc-xrandr.h',
'backends/x11/meta-cursor-renderer-x11.c',
'backends/x11/meta-cursor-renderer-x11.h',
+ 'backends/x11/meta-cursor-tracker-x11.c',
+ 'backends/x11/meta-cursor-tracker-x11.h',
'backends/x11/meta-event-x11.c',
'backends/x11/meta-event-x11.h',
'backends/x11/meta-gpu-xrandr.c',
diff --git a/src/meta/meta-cursor-tracker.h b/src/meta/meta-cursor-tracker.h
index 2f51115e4b..87e408d940 100644
--- a/src/meta/meta-cursor-tracker.h
+++ b/src/meta/meta-cursor-tracker.h
@@ -32,11 +32,10 @@
#define META_TYPE_CURSOR_TRACKER (meta_cursor_tracker_get_type ())
META_EXPORT
-G_DECLARE_FINAL_TYPE (MetaCursorTracker,
- meta_cursor_tracker,
- META, CURSOR_TRACKER,
- GObject)
-
+G_DECLARE_DERIVABLE_TYPE (MetaCursorTracker,
+ meta_cursor_tracker,
+ META, CURSOR_TRACKER,
+ GObject)
META_EXPORT
MetaCursorTracker *meta_cursor_tracker_get_for_display (MetaDisplay *display);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]