[metacity/argb-frame: 4/7] compositor: add MetaCompositorExternal
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity/argb-frame: 4/7] compositor: add MetaCompositorExternal
- Date: Fri, 28 Feb 2020 18:12:09 +0000 (UTC)
commit f8bdb8494e5f7fe3ecb78664bfc06c62cc87437d
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Feb 27 16:09:17 2020 +0200
compositor: add MetaCompositorExternal
src/Makefile.am | 2 +
src/compositor/meta-compositor-external.c | 138 ++++++++++++++++++++++++++++++
src/compositor/meta-compositor-external.h | 34 ++++++++
src/core/display.c | 7 ++
src/include/meta-compositor.h | 1 +
5 files changed, 182 insertions(+)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 07966e27..373c653c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,6 +27,8 @@ metacity_CFLAGS = \
metacity_SOURCES = \
compositor/meta-compositor.c \
+ compositor/meta-compositor-external.c \
+ compositor/meta-compositor-external.h \
compositor/meta-compositor-none.c \
compositor/meta-compositor-none.h \
compositor/meta-compositor-private.h \
diff --git a/src/compositor/meta-compositor-external.c b/src/compositor/meta-compositor-external.c
new file mode 100644
index 00000000..4e144df7
--- /dev/null
+++ b/src/compositor/meta-compositor-external.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2020 Alberts Muktupāvels
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "meta-compositor-external.h"
+
+#include <X11/extensions/Xfixes.h>
+
+#include "display-private.h"
+
+struct _MetaCompositorExternal
+{
+ MetaCompositor parent;
+
+ Atom cm_atom;
+};
+
+G_DEFINE_TYPE (MetaCompositorExternal, meta_compositor_external, META_TYPE_COMPOSITOR)
+
+static gboolean
+meta_compositor_external_manage (MetaCompositor *compositor,
+ GError **error)
+{
+ MetaCompositorExternal *self;
+ MetaDisplay *display;
+ Display *xdisplay;
+ gchar *atom_name;
+ gboolean composited;
+
+ self = META_COMPOSITOR_EXTERNAL (compositor);
+
+ display = meta_compositor_get_display (compositor);
+ xdisplay = meta_display_get_xdisplay (display);
+
+ if (!display->have_xfixes)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Missing xfixes extension");
+
+ return FALSE;
+ }
+
+ atom_name = g_strdup_printf ("_NET_WM_CM_S%d", DefaultScreen (xdisplay));
+ self->cm_atom = XInternAtom (xdisplay, atom_name, FALSE);
+ g_free (atom_name);
+
+ XFixesSelectSelectionInput (xdisplay,
+ DefaultRootWindow (xdisplay),
+ self->cm_atom,
+ XFixesSetSelectionOwnerNotifyMask);
+
+ composited = XGetSelectionOwner (xdisplay, self->cm_atom) != None;
+ meta_compositor_set_composited (compositor, composited);
+
+ return TRUE;
+}
+
+static MetaSurface *
+meta_compositor_external_add_window (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+ return NULL;
+}
+
+static void
+meta_compositor_external_process_event (MetaCompositor *compositor,
+ XEvent *event,
+ MetaWindow *window)
+{
+ MetaCompositorExternal *self;
+ MetaDisplay *display;
+ XFixesSelectionNotifyEvent *xfixes_event;
+
+ self = META_COMPOSITOR_EXTERNAL (compositor);
+ display = meta_compositor_get_display (compositor);
+
+ if (event->type != display->xfixes_event_base + XFixesSelectionNotify)
+ return;
+
+ xfixes_event = (XFixesSelectionNotifyEvent *) event;
+ if (xfixes_event->selection != self->cm_atom)
+ return;
+
+ meta_compositor_set_composited (compositor, xfixes_event->owner != None);
+}
+
+static void
+meta_compositor_external_sync_screen_size (MetaCompositor *compositor)
+{
+}
+
+static void
+meta_compositor_external_redraw (MetaCompositor *compositor,
+ XserverRegion all_damage)
+{
+}
+
+static void
+meta_compositor_external_class_init (MetaCompositorExternalClass *self_class)
+{
+ MetaCompositorClass *compositor_class;
+
+ compositor_class = META_COMPOSITOR_CLASS (self_class);
+
+ compositor_class->manage = meta_compositor_external_manage;
+ compositor_class->add_window = meta_compositor_external_add_window;
+ compositor_class->process_event = meta_compositor_external_process_event;
+ compositor_class->sync_screen_size = meta_compositor_external_sync_screen_size;
+ compositor_class->redraw = meta_compositor_external_redraw;
+}
+
+static void
+meta_compositor_external_init (MetaCompositorExternal *self)
+{
+}
+
+MetaCompositor *
+meta_compositor_external_new (MetaDisplay *display,
+ GError **error)
+{
+ return g_initable_new (META_TYPE_COMPOSITOR_EXTERNAL, NULL, error,
+ "display", display,
+ NULL);
+}
diff --git a/src/compositor/meta-compositor-external.h b/src/compositor/meta-compositor-external.h
new file mode 100644
index 00000000..438566f8
--- /dev/null
+++ b/src/compositor/meta-compositor-external.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2020 Alberts Muktupāvels
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef META_COMPOSITOR_EXTERNAL_H
+#define META_COMPOSITOR_EXTERNAL_H
+
+#include "meta-compositor-private.h"
+
+G_BEGIN_DECLS
+
+#define META_TYPE_COMPOSITOR_EXTERNAL (meta_compositor_external_get_type ())
+G_DECLARE_FINAL_TYPE (MetaCompositorExternal, meta_compositor_external,
+ META, COMPOSITOR_EXTERNAL, MetaCompositor)
+
+MetaCompositor *meta_compositor_external_new (MetaDisplay *display,
+ GError **error);
+
+G_END_DECLS
+
+#endif
diff --git a/src/core/display.c b/src/core/display.c
index 679b1a89..06d8b580 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -68,6 +68,7 @@
#include "compositor/meta-compositor-none.h"
#include "compositor/meta-compositor-xrender.h"
+#include "compositor/meta-compositor-external.h"
#ifdef HAVE_VULKAN
#include "compositor/meta-compositor-vulkan.h"
@@ -277,6 +278,8 @@ get_compositor_type (MetaDisplay *display)
type = META_COMPOSITOR_TYPE_VULKAN;
else if (g_strcmp0 (compositor, "xrender") == 0)
type = META_COMPOSITOR_TYPE_XRENDER;
+ else if (g_strcmp0 (compositor, "external") == 0)
+ type = META_COMPOSITOR_TYPE_EXTERNAL;
else
type = META_COMPOSITOR_TYPE_NONE;
}
@@ -310,6 +313,10 @@ create_compositor (MetaDisplay *display,
compositor = meta_compositor_xrender_new (display, error);
break;
+ case META_COMPOSITOR_TYPE_EXTERNAL:
+ compositor = meta_compositor_external_new (display, error);
+ break;
+
case META_COMPOSITOR_TYPE_VULKAN:
#ifdef HAVE_VULKAN
compositor = meta_compositor_vulkan_new (display, error);
diff --git a/src/include/meta-compositor.h b/src/include/meta-compositor.h
index 25d09079..0aaa5d27 100644
--- a/src/include/meta-compositor.h
+++ b/src/include/meta-compositor.h
@@ -35,6 +35,7 @@ typedef enum
{
META_COMPOSITOR_TYPE_NONE,
META_COMPOSITOR_TYPE_XRENDER,
+ META_COMPOSITOR_TYPE_EXTERNAL,
META_COMPOSITOR_TYPE_VULKAN
} MetaCompositorType;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]