1
0
Fork 0

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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1659>
This commit is contained in:
Carlos Garnacho 2021-02-13 12:48:31 +01:00 committed by Marge Bot
parent 5a1e942f3b
commit 00c7f45a0f
4 changed files with 58 additions and 18 deletions

View file

@ -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,

View file

@ -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),

View file

@ -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;
}

View file

@ -439,6 +439,16 @@ meta_compositor_x11_monotonic_to_high_res_xserver_time (MetaCompositor *composit
return monotonic_time_us + compositor_x11->xserver_time_offset_us;
}
static void
meta_compositor_x11_grab_begin (MetaCompositor *compositor)
{
}
static void
meta_compositor_x11_grab_end (MetaCompositor *compositor)
{
}
Window
meta_compositor_x11_get_output_xwindow (MetaCompositorX11 *compositor_x11)
{
@ -508,4 +518,6 @@ meta_compositor_x11_class_init (MetaCompositorX11Class *klass)
compositor_class->remove_window = meta_compositor_x11_remove_window;
compositor_class->monotonic_to_high_res_xserver_time =
meta_compositor_x11_monotonic_to_high_res_xserver_time;
compositor_class->grab_begin = meta_compositor_x11_grab_begin;
compositor_class->grab_end = meta_compositor_x11_grab_end;
}