[mutter/wip/carlosg/sync-pointer-in-mutter: 1/3] compositor: Refactor backend-specific code into MetaCompositor vfuncs
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/sync-pointer-in-mutter: 1/3] compositor: Refactor backend-specific code into MetaCompositor vfuncs
- Date: Sat, 13 Feb 2021 12:45:21 +0000 (UTC)
commit 335a1098166c14b88ddc2c29eba0fa98cbf697ca
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Feb 13 12:48:31 2021 +0100
compositor: Refactor backend-specific code into MetaCompositor vfuncs
Do these Wayland operations (that apply on both native and nested backends)
in the MetaCompositorServer subclass. We want to add more backend specific
behavior here in the future.
src/compositor/compositor-private.h | 2 ++
src/compositor/compositor.c | 32 ++++++++++++++------------------
src/compositor/meta-compositor-server.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 18 deletions(-)
---
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index b81e77d4cf..580618e481 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -32,6 +32,8 @@ struct _MetaCompositorClass
MetaWindow *window);
int64_t (* monotonic_to_high_res_xserver_time) (MetaCompositor *compositor,
int64_t time_us);
+ void (* grab_begin) (MetaCompositor *compositor);
+ void (* grab_end) (MetaCompositor *compositor);
};
gboolean meta_compositor_do_manage (MetaCompositor *compositor,
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 613b3f66db..8c72d92b90 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -56,7 +56,6 @@
#include <X11/extensions/Xcomposite.h>
-#include "backends/meta-dnd-private.h"
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-event-x11.h"
#include "backends/x11/meta-stage-x11.h"
@@ -66,7 +65,6 @@
#include "compositor/meta-window-actor-x11.h"
#include "compositor/meta-window-actor-private.h"
#include "compositor/meta-window-group-private.h"
-#include "core/display-private.h"
#include "core/frame.h"
#include "core/util-private.h"
#include "core/window-private.h"
@@ -384,6 +382,18 @@ grab_devices (MetaModalOptions options,
return FALSE;
}
+static void
+meta_compositor_grab_begin (MetaCompositor *compositor)
+{
+ META_COMPOSITOR_GET_CLASS (compositor)->grab_begin (compositor);
+}
+
+static void
+meta_compositor_grab_end (MetaCompositor *compositor)
+{
+ META_COMPOSITOR_GET_CLASS (compositor)->grab_end (compositor);
+}
+
gboolean
meta_begin_modal_for_plugin (MetaCompositor *compositor,
MetaPlugin *plugin,
@@ -431,15 +441,7 @@ meta_begin_modal_for_plugin (MetaCompositor *compositor,
meta_plugin_get_display (plugin),
display->grab_window, display->grab_op);
- if (meta_is_wayland_compositor ())
- {
- meta_display_sync_wayland_input_focus (display);
- meta_display_cancel_touch (display);
-
-#ifdef HAVE_WAYLAND
- meta_dnd_wayland_handle_begin_modal (compositor);
-#endif
- }
+ meta_compositor_grab_begin (compositor);
return TRUE;
}
@@ -467,13 +469,7 @@ meta_end_modal_for_plugin (MetaCompositor *compositor,
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp);
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
-#ifdef HAVE_WAYLAND
- if (meta_is_wayland_compositor ())
- {
- meta_dnd_wayland_handle_end_modal (compositor);
- meta_display_sync_wayland_input_focus (display);
- }
-#endif
+ meta_compositor_grab_end (compositor);
g_signal_emit_by_name (display, "grab-op-end",
meta_plugin_get_display (plugin),
diff --git a/src/compositor/meta-compositor-server.c b/src/compositor/meta-compositor-server.c
index 2dbaf34eb5..179dc83ef4 100644
--- a/src/compositor/meta-compositor-server.c
+++ b/src/compositor/meta-compositor-server.c
@@ -20,7 +20,9 @@
#include "config.h"
+#include "backends/meta-dnd-private.h"
#include "compositor/meta-compositor-server.h"
+#include "core/display-private.h"
G_DEFINE_TYPE (MetaCompositorServer, meta_compositor_server, META_TYPE_COMPOSITOR)
@@ -43,6 +45,32 @@ meta_compositor_server_monotonic_to_high_res_xserver_time (MetaCompositor *compo
return meta_translate_to_high_res_xserver_time (monotonic_time_us);
}
+static void
+meta_compositor_server_grab_begin (MetaCompositor *compositor)
+{
+ MetaDisplay *display;
+
+ display = meta_compositor_get_display (compositor);
+ meta_display_sync_wayland_input_focus (display);
+ meta_display_cancel_touch (display);
+
+#ifdef HAVE_WAYLAND
+ meta_dnd_wayland_handle_begin_modal (compositor);
+#endif
+}
+
+static void
+meta_compositor_server_grab_end (MetaCompositor *compositor)
+{
+ MetaDisplay *display;
+
+ display = meta_compositor_get_display (compositor);
+#ifdef HAVE_WAYLAND
+ meta_dnd_wayland_handle_end_modal (compositor);
+#endif
+ meta_display_sync_wayland_input_focus (display);
+}
+
MetaCompositorServer *
meta_compositor_server_new (MetaDisplay *display,
MetaBackend *backend)
@@ -67,4 +95,6 @@ meta_compositor_server_class_init (MetaCompositorServerClass *klass)
compositor_class->unmanage = meta_compositor_server_unmanage;
compositor_class->monotonic_to_high_res_xserver_time =
meta_compositor_server_monotonic_to_high_res_xserver_time;
+ compositor_class->grab_begin = meta_compositor_server_grab_begin;
+ compositor_class->grab_end = meta_compositor_server_grab_end;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]