summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2015-07-17 10:40:51 +0800
committerJonas Ådahl <jadahl@gmail.com>2015-09-13 21:26:22 +0800
commit8900bd2f5c757e3c6e3dd8693bde803ceb9205a6 (patch)
tree73574fd7cad70319f42cf10bfe4870323f0e5ec4 /src
parent83c17134f1a13f8073816773a357cbc67588bc16 (diff)
downloadmutter-8900bd2f5c757e3c6e3dd8693bde803ceb9205a6.tar.gz
backends/x11: Draw our own cursor sprite when running nested
Use a specialized cursor renderer when running as a nested Wayand compositor. This new renderer sets an empty X11 cursor and draws the cursor as part of the stage using the generic cursor renderer drawing path. https://bugzilla.gnome.org/show_bug.cgi?id=744932
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/backends/x11/meta-backend-x11.c16
-rw-r--r--src/backends/x11/nested/meta-cursor-renderer-x11-nested.c88
-rw-r--r--src/backends/x11/nested/meta-cursor-renderer-x11-nested.h38
4 files changed, 143 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d7122dc9e..3e48bd038 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -96,6 +96,8 @@ libmutter_la_SOURCES = \
backends/x11/meta-barrier-x11.h \
backends/x11/meta-cursor-renderer-x11.c \
backends/x11/meta-cursor-renderer-x11.h \
+ backends/x11/nested/meta-cursor-renderer-x11-nested.c \
+ backends/x11/nested/meta-cursor-renderer-x11-nested.h \
backends/x11/meta-idle-monitor-xsync.c \
backends/x11/meta-idle-monitor-xsync.h \
backends/x11/meta-input-settings-x11.c \
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index e7b491745..e86589ca7 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -40,6 +40,7 @@
#include "meta-idle-monitor-xsync.h"
#include "meta-monitor-manager-xrandr.h"
#include "backends/meta-monitor-manager-dummy.h"
+#include "backends/x11/nested/meta-cursor-renderer-x11-nested.h"
#include "meta-cursor-renderer-x11.h"
#ifdef HAVE_WAYLAND
#include "wayland/meta-wayland.h"
@@ -521,7 +522,20 @@ meta_backend_x11_create_monitor_manager (MetaBackend *backend)
static MetaCursorRenderer *
meta_backend_x11_create_cursor_renderer (MetaBackend *backend)
{
- return g_object_new (META_TYPE_CURSOR_RENDERER_X11, NULL);
+ MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
+ MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
+
+ switch (priv->mode)
+ {
+ case META_BACKEND_X11_MODE_COMPOSITOR:
+ return g_object_new (META_TYPE_CURSOR_RENDERER_X11, NULL);
+ break;
+ case META_BACKEND_X11_MODE_NESTED:
+ return g_object_new (META_TYPE_CURSOR_RENDERER_X11_NESTED, NULL);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
}
static gboolean
diff --git a/src/backends/x11/nested/meta-cursor-renderer-x11-nested.c b/src/backends/x11/nested/meta-cursor-renderer-x11-nested.c
new file mode 100644
index 000000000..15ce57b1d
--- /dev/null
+++ b/src/backends/x11/nested/meta-cursor-renderer-x11-nested.c
@@ -0,0 +1,88 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2015 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.
+ *
+ * Written by:
+ * Jonas Ådahl <jadahl@gmail.com>
+ */
+
+#include "config.h"
+
+#include "backends/x11/nested/meta-cursor-renderer-x11-nested.h"
+
+#include "backends/x11/meta-backend-x11.h"
+
+struct _MetaCursorRendererX11Nested
+{
+ MetaCursorRenderer parent;
+};
+
+GType meta_cursor_renderer_x11_nested_get_type (void) G_GNUC_CONST;
+
+G_DEFINE_TYPE (MetaCursorRendererX11Nested, meta_cursor_renderer_x11_nested,
+ META_TYPE_CURSOR_RENDERER);
+
+static gboolean
+meta_cursor_renderer_x11_nested_update_cursor (MetaCursorRenderer *renderer)
+{
+ return FALSE;
+}
+
+static Cursor
+create_empty_cursor (Display *xdisplay)
+{
+ XcursorImage *image;
+ XcursorPixel *pixels;
+ Cursor xcursor;
+
+ image = XcursorImageCreate (1, 1);
+ if (image == NULL)
+ return None;
+
+ image->xhot = 0;
+ image->yhot = 0;
+
+ pixels = image->pixels;
+ pixels[0] = 0;
+
+ xcursor = XcursorImageLoadCursor (xdisplay, image);
+ XcursorImageDestroy (image);
+
+ return xcursor;
+}
+
+static void
+meta_cursor_renderer_x11_nested_init (MetaCursorRendererX11Nested *x11_nested)
+{
+ MetaBackendX11 *backend = META_BACKEND_X11 (meta_get_backend ());
+ Window xwindow = meta_backend_x11_get_xwindow (backend);
+ Display *xdisplay = meta_backend_x11_get_xdisplay (backend);
+
+ Cursor empty_xcursor = create_empty_cursor (xdisplay);
+ XDefineCursor (xdisplay, xwindow, empty_xcursor);
+ XFreeCursor (xdisplay, empty_xcursor);
+}
+
+static void
+meta_cursor_renderer_x11_nested_class_init (MetaCursorRendererX11NestedClass *klass)
+{
+ MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_CLASS (klass);
+
+ renderer_class->update_cursor = meta_cursor_renderer_x11_nested_update_cursor;
+}
diff --git a/src/backends/x11/nested/meta-cursor-renderer-x11-nested.h b/src/backends/x11/nested/meta-cursor-renderer-x11-nested.h
new file mode 100644
index 000000000..32f816629
--- /dev/null
+++ b/src/backends/x11/nested/meta-cursor-renderer-x11-nested.h
@@ -0,0 +1,38 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2015 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.
+ *
+ * Written by:
+ * Jonas Ådahl <jadahl@gmail.com>
+ */
+
+#ifndef META_CURSOR_RENDERER_X11_NESTED_NESTED_H
+#define META_CURSOR_RENDERER_X11_NESTED_NESTED_H
+
+#include <glib-object.h>
+
+#include "backends/meta-cursor-renderer.h"
+
+#define META_TYPE_CURSOR_RENDERER_X11_NESTED (meta_cursor_renderer_x11_nested_get_type ())
+G_DECLARE_FINAL_TYPE (MetaCursorRendererX11Nested,
+ meta_cursor_renderer_x11_nested,
+ META, CURSOR_RENDERER_X11_NESTED,
+ MetaCursorRenderer);
+
+#endif /* META_CURSOR_RENDERER_X11_NESTED_NESTED_H */