mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 19:40:43 -05:00
compositor: Refactor MetaDnD wayland event handling
Hook MetaDnD event delivery in the case of Wayland DnD ops directly in the Wayland code, instead of indirectly in core/ code. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
This commit is contained in:
parent
d48129f5ee
commit
e7f436bc39
@ -39,8 +39,9 @@ void meta_dnd_init_xdnd (MetaX11Display *x11_display);
|
|||||||
|
|
||||||
#ifdef HAVE_WAYLAND
|
#ifdef HAVE_WAYLAND
|
||||||
void meta_dnd_wayland_handle_begin_modal (MetaCompositor *compositor);
|
void meta_dnd_wayland_handle_begin_modal (MetaCompositor *compositor);
|
||||||
|
|
||||||
void meta_dnd_wayland_handle_end_modal (MetaCompositor *compositor);
|
void meta_dnd_wayland_handle_end_modal (MetaCompositor *compositor);
|
||||||
|
|
||||||
void meta_dnd_wayland_maybe_handle_event (MetaDnd *dnd,
|
void meta_dnd_wayland_on_motion_event (MetaDnd *dnd,
|
||||||
const ClutterEvent *event);
|
const ClutterEvent *event);
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,17 +44,11 @@ meta_compositor_server_monotonic_to_high_res_xserver_time (MetaCompositor *compo
|
|||||||
static void
|
static void
|
||||||
meta_compositor_server_grab_begin (MetaCompositor *compositor)
|
meta_compositor_server_grab_begin (MetaCompositor *compositor)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_WAYLAND
|
|
||||||
meta_dnd_wayland_handle_begin_modal (compositor);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_compositor_server_grab_end (MetaCompositor *compositor)
|
meta_compositor_server_grab_end (MetaCompositor *compositor)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_WAYLAND
|
|
||||||
meta_dnd_wayland_handle_end_modal (compositor);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MetaCompositorView *
|
static MetaCompositorView *
|
||||||
|
@ -241,18 +241,7 @@ meta_dnd_handle_xdnd_event (MetaBackend *backend,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_WAYLAND
|
#ifdef HAVE_WAYLAND
|
||||||
static MetaWaylandDataDevice *
|
void
|
||||||
data_device_from_dnd (MetaDnd *dnd)
|
|
||||||
{
|
|
||||||
MetaDndPrivate *priv = meta_dnd_get_instance_private (dnd);
|
|
||||||
MetaContext *context = meta_backend_get_context (priv->backend);
|
|
||||||
MetaWaylandCompositor *compositor =
|
|
||||||
meta_context_get_wayland_compositor (context);
|
|
||||||
|
|
||||||
return &compositor->seat->data_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
meta_dnd_wayland_on_motion_event (MetaDnd *dnd,
|
meta_dnd_wayland_on_motion_event (MetaDnd *dnd,
|
||||||
const ClutterEvent *event)
|
const ClutterEvent *event)
|
||||||
{
|
{
|
||||||
@ -264,22 +253,6 @@ meta_dnd_wayland_on_motion_event (MetaDnd *dnd,
|
|||||||
meta_dnd_notify_dnd_position_change (dnd, (int)event_x, (int)event_y);
|
meta_dnd_notify_dnd_position_change (dnd, (int)event_x, (int)event_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
meta_dnd_wayland_maybe_handle_event (MetaDnd *dnd,
|
|
||||||
const ClutterEvent *event)
|
|
||||||
{
|
|
||||||
MetaWaylandDataDevice *data_device = data_device_from_dnd (dnd);
|
|
||||||
ClutterEventType event_type;
|
|
||||||
|
|
||||||
if (!meta_wayland_data_device_get_current_grab (data_device))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event_type = clutter_event_type (event);
|
|
||||||
|
|
||||||
if (event_type == CLUTTER_MOTION)
|
|
||||||
meta_dnd_wayland_on_motion_event (dnd, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_dnd_wayland_handle_begin_modal (MetaCompositor *compositor)
|
meta_dnd_wayland_handle_begin_modal (MetaCompositor *compositor)
|
||||||
{
|
{
|
||||||
|
@ -456,11 +456,6 @@ meta_display_handle_event (MetaDisplay *display,
|
|||||||
|
|
||||||
if (stage_has_grab (display))
|
if (stage_has_grab (display))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_WAYLAND
|
|
||||||
if (wayland_compositor)
|
|
||||||
meta_dnd_wayland_maybe_handle_event (meta_backend_get_dnd (backend), event);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bypass_wayland = TRUE;
|
bypass_wayland = TRUE;
|
||||||
bypass_clutter = FALSE;
|
bypass_clutter = FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "backends/meta-dnd-private.h"
|
||||||
#include "compositor/meta-dnd-actor-private.h"
|
#include "compositor/meta-dnd-actor-private.h"
|
||||||
#include "core/meta-selection-private.h"
|
#include "core/meta-selection-private.h"
|
||||||
#include "meta/meta-selection-source-memory.h"
|
#include "meta/meta-selection-source-memory.h"
|
||||||
@ -364,6 +365,8 @@ static void
|
|||||||
data_device_end_drag_grab (MetaWaylandDragGrab *drag_grab)
|
data_device_end_drag_grab (MetaWaylandDragGrab *drag_grab)
|
||||||
{
|
{
|
||||||
MetaWaylandDataDevice *data_device = &drag_grab->seat->data_device;
|
MetaWaylandDataDevice *data_device = &drag_grab->seat->data_device;
|
||||||
|
MetaDisplay *display = display_from_data_device (data_device);
|
||||||
|
MetaCompositor *compositor = meta_display_get_compositor (display);
|
||||||
|
|
||||||
meta_wayland_drag_grab_set_source (drag_grab, NULL);
|
meta_wayland_drag_grab_set_source (drag_grab, NULL);
|
||||||
meta_wayland_drag_grab_set_focus (drag_grab, NULL);
|
meta_wayland_drag_grab_set_focus (drag_grab, NULL);
|
||||||
@ -397,6 +400,8 @@ data_device_end_drag_grab (MetaWaylandDragGrab *drag_grab)
|
|||||||
drag_grab->handler = NULL;
|
drag_grab->handler = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meta_dnd_wayland_handle_end_modal (compositor);
|
||||||
|
|
||||||
g_free (drag_grab);
|
g_free (drag_grab);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,6 +487,10 @@ drag_grab_motion (MetaWaylandEventHandler *handler,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MetaWaylandDragGrab *drag_grab = user_data;
|
MetaWaylandDragGrab *drag_grab = user_data;
|
||||||
|
MetaWaylandCompositor *compositor =
|
||||||
|
meta_wayland_seat_get_compositor (drag_grab->seat);
|
||||||
|
MetaContext *context = meta_wayland_compositor_get_context (compositor);
|
||||||
|
MetaBackend *backend = meta_context_get_backend (context);
|
||||||
graphene_point_t point;
|
graphene_point_t point;
|
||||||
uint32_t time_ms;
|
uint32_t time_ms;
|
||||||
|
|
||||||
@ -503,6 +512,8 @@ drag_grab_motion (MetaWaylandEventHandler *handler,
|
|||||||
event);
|
event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meta_dnd_wayland_on_motion_event (meta_backend_get_dnd (backend), event);
|
||||||
|
|
||||||
return CLUTTER_EVENT_STOP;
|
return CLUTTER_EVENT_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,6 +683,8 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data_devic
|
|||||||
graphene_point_t drag_start)
|
graphene_point_t drag_start)
|
||||||
{
|
{
|
||||||
MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device);
|
MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device);
|
||||||
|
MetaDisplay *display = display_from_data_device (data_device);
|
||||||
|
MetaCompositor *compositor = meta_display_get_compositor (display);
|
||||||
MetaWaylandDragGrab *drag_grab;
|
MetaWaylandDragGrab *drag_grab;
|
||||||
graphene_point_t pos, surface_pos;
|
graphene_point_t pos, surface_pos;
|
||||||
ClutterModifierType modifiers;
|
ClutterModifierType modifiers;
|
||||||
@ -715,8 +728,6 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data_devic
|
|||||||
|
|
||||||
if (icon_surface)
|
if (icon_surface)
|
||||||
{
|
{
|
||||||
MetaDisplay *display = display_from_data_device (data_device);
|
|
||||||
MetaCompositor *compositor = meta_display_get_compositor (display);
|
|
||||||
ClutterActor *drag_surface_actor;
|
ClutterActor *drag_surface_actor;
|
||||||
|
|
||||||
drag_grab->drag_surface = icon_surface;
|
drag_grab->drag_surface = icon_surface;
|
||||||
@ -748,6 +759,8 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data_devic
|
|||||||
TRUE,
|
TRUE,
|
||||||
drag_grab);
|
drag_grab);
|
||||||
meta_wayland_data_source_set_seat (source, seat);
|
meta_wayland_data_source_set_seat (source, seat);
|
||||||
|
|
||||||
|
meta_dnd_wayland_handle_begin_modal (compositor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user