1
0
Fork 0

core,wayland,compositor,x11: Migrate to MetaWindowDrag

Flip the switch in using MetaWindowDrag, leaving display grab
ops and a bunch other code unused. Some places checked the grab op
and/or window in complex ways, others just checked for grab existence
and should now look for clutter ones, and others already were already
doing this in addition.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
This commit is contained in:
Carlos Garnacho 2022-10-21 12:56:24 +02:00 committed by Marge Bot
parent db1c64fe06
commit bec8a5860a
17 changed files with 167 additions and 181 deletions

View file

@ -132,6 +132,7 @@ Getting started -- where to look
constraints.c constraints.c
update_move update_move
update_resize update_resize
meta-window-drag.c
meta_window_handle_mouse_grab_op_event meta_window_handle_mouse_grab_op_event
_NET_MOVERESIZE_WINDOW _NET_MOVERESIZE_WINDOW
_NET_WM_STRUT _NET_WM_STRUT

View file

@ -1242,6 +1242,7 @@ meta_window_actor_x11_after_paint (MetaWindowActor *actor,
{ {
MetaWindowActorX11 *actor_x11 = META_WINDOW_ACTOR_X11 (actor); MetaWindowActorX11 *actor_x11 = META_WINDOW_ACTOR_X11 (actor);
MetaSyncCounter *sync_counter; MetaSyncCounter *sync_counter;
MetaWindowDrag *window_drag;
MetaWindow *window; MetaWindow *window;
actor_x11->repaint_scheduled = FALSE; actor_x11->repaint_scheduled = FALSE;
@ -1274,8 +1275,11 @@ meta_window_actor_x11_after_paint (MetaWindowActor *actor,
meta_window_x11_set_thaw_after_paint (window, FALSE); meta_window_x11_set_thaw_after_paint (window, FALSE);
} }
if (window == window->display->grab_window && window_drag = meta_compositor_get_current_window_drag (window->display->compositor);
meta_grab_op_is_resizing (window->display->grab_op))
if (window_drag &&
window == meta_window_drag_get_window (window_drag) &&
meta_grab_op_is_resizing (meta_window_drag_get_grab_op (window_drag)))
{ {
/* This means we are ready for another configure; /* This means we are ready for another configure;
* no pointer round trip here, to keep in sync */ * no pointer round trip here, to keep in sync */

View file

@ -608,6 +608,9 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag,
"Computed new window location %d,%d due to keypress", "Computed new window location %d,%d due to keypress",
x, y); x, y);
window_drag->last_edge_resistance_flags =
flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP;
meta_window_edge_resistance_for_move (window, meta_window_edge_resistance_for_move (window,
&x, &x,
&y, &y,
@ -959,6 +962,9 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag,
"%dx%d, gravity %s", "%dx%d, gravity %s",
width, height, meta_gravity_to_string (gravity)); width, height, meta_gravity_to_string (gravity));
window_drag->last_edge_resistance_flags =
flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP;
/* Do any edge resistance/snapping */ /* Do any edge resistance/snapping */
meta_window_edge_resistance_for_resize (window, meta_window_edge_resistance_for_resize (window,
&width, &width,
@ -1257,6 +1263,9 @@ update_move (MetaWindowDrag *window_drag,
if (window->maximized_vertically) if (window->maximized_vertically)
new_y = old.y; new_y = old.y;
window_drag->last_edge_resistance_flags =
flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP;
/* Do any edge resistance/snapping */ /* Do any edge resistance/snapping */
meta_window_edge_resistance_for_move (window, meta_window_edge_resistance_for_move (window,
&new_x, &new_x,
@ -1410,6 +1419,9 @@ update_resize (MetaWindowDrag *window_drag,
gravity = meta_resize_gravity_from_grab_op (window_drag->grab_op); gravity = meta_resize_gravity_from_grab_op (window_drag->grab_op);
g_assert (gravity >= 0); g_assert (gravity >= 0);
window_drag->last_edge_resistance_flags =
flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP;
/* Do any edge resistance/snapping */ /* Do any edge resistance/snapping */
meta_window_edge_resistance_for_resize (window, meta_window_edge_resistance_for_resize (window,
&new_rect.width, &new_rect.width,

View file

@ -31,6 +31,7 @@
#include "backends/meta-backend-private.h" #include "backends/meta-backend-private.h"
#include "backends/meta-logical-monitor.h" #include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor-manager-private.h" #include "backends/meta-monitor-manager-private.h"
#include "compositor/compositor-private.h"
#include "core/boxes-private.h" #include "core/boxes-private.h"
#include "core/meta-workspace-manager-private.h" #include "core/meta-workspace-manager-private.h"
#include "core/place.h" #include "core/place.h"
@ -1761,16 +1762,21 @@ constrain_titlebar_visible (MetaWindow *window,
int bottom_amount; int bottom_amount;
int horiz_amount_offscreen, vert_amount_offscreen; int horiz_amount_offscreen, vert_amount_offscreen;
int horiz_amount_onscreen, vert_amount_onscreen; int horiz_amount_onscreen, vert_amount_onscreen;
MetaWindowDrag *window_drag;
if (priority > PRIORITY_TITLEBAR_VISIBLE) if (priority > PRIORITY_TITLEBAR_VISIBLE)
return TRUE; return TRUE;
window_drag = meta_compositor_get_current_window_drag (window->display->compositor);
/* Allow the titlebar beyond the top of the screen only if the user wasn't /* Allow the titlebar beyond the top of the screen only if the user wasn't
* clicking on the frame to start the move. * clicking on the frame to start the move.
*/ */
unconstrained_user_action = unconstrained_user_action =
info->is_user_action && info->is_user_action &&
(window->display->grab_op & META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED) != 0; window_drag &&
(meta_window_drag_get_grab_op (window_drag) &
META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED) != 0;
/* Exit early if we know the constraint won't apply--note that this constraint /* Exit early if we know the constraint won't apply--note that this constraint
* is only meant for normal windows (e.g. we don't want docks to be shoved * is only meant for normal windows (e.g. we don't want docks to be shoved

View file

@ -69,7 +69,7 @@ meta_window_show_close_dialog (MetaWindow *window)
meta_close_dialog_show (window->close_dialog); meta_close_dialog_show (window->close_dialog);
if (window->display && if (window->display &&
window->display->grab_op == META_GRAB_OP_NONE && !meta_compositor_get_current_window_drag (window->display->compositor) &&
window == window->display->focus_window) window == window->display->focus_window)
meta_close_dialog_focus (window->close_dialog); meta_close_dialog_focus (window->close_dialog);
} }

View file

@ -1259,10 +1259,7 @@ meta_display_windows_are_interactable (MetaDisplay *display)
if (clutter_stage_get_grab_actor (CLUTTER_STAGE (stage))) if (clutter_stage_get_grab_actor (CLUTTER_STAGE (stage)))
return FALSE; return FALSE;
if (display->grab_op == META_GRAB_OP_NONE) return TRUE;
return TRUE;
return FALSE;
} }
/** /**
@ -1998,7 +1995,7 @@ meta_display_end_grab_op (MetaDisplay *display,
gboolean gboolean
meta_display_is_grabbed (MetaDisplay *display) meta_display_is_grabbed (MetaDisplay *display)
{ {
return display->grab_op != META_GRAB_OP_NONE; return meta_compositor_get_current_window_drag (display->compositor) != NULL;
} }
void void
@ -3151,11 +3148,16 @@ static gboolean
meta_display_update_tile_preview_timeout (gpointer data) meta_display_update_tile_preview_timeout (gpointer data)
{ {
MetaDisplay *display = data; MetaDisplay *display = data;
MetaWindow *window = display->grab_window; MetaWindowDrag *window_drag;
MetaWindow *window = NULL;
gboolean needs_preview = FALSE; gboolean needs_preview = FALSE;
display->tile_preview_timeout_id = 0; display->tile_preview_timeout_id = 0;
window_drag = meta_compositor_get_current_window_drag (display->compositor);
if (window_drag)
window = meta_window_drag_get_window (window_drag);
if (window) if (window)
{ {
switch (display->preview_tile_mode) switch (display->preview_tile_mode)

View file

@ -23,6 +23,7 @@
#include "core/edge-resistance.h" #include "core/edge-resistance.h"
#include "compositor/compositor-private.h"
#include "core/boxes-private.h" #include "core/boxes-private.h"
#include "core/display-private.h" #include "core/display-private.h"
#include "core/meta-workspace-manager-private.h" #include "core/meta-workspace-manager-private.h"
@ -33,7 +34,8 @@
*/ */
#define WINDOW_EDGES_RELEVANT(window, display) \ #define WINDOW_EDGES_RELEVANT(window, display) \
meta_window_should_be_showing (window) && \ meta_window_should_be_showing (window) && \
window != display->grab_window && \ (!meta_compositor_get_current_window_drag (display->compositor) || \
window != meta_window_drag_get_window (meta_compositor_get_current_window_drag (display->compositor))) && \
window->type != META_WINDOW_DESKTOP && \ window->type != META_WINDOW_DESKTOP && \
window->type != META_WINDOW_MENU && \ window->type != META_WINDOW_MENU && \
window->type != META_WINDOW_SPLASHSCREEN window->type != META_WINDOW_SPLASHSCREEN
@ -887,11 +889,14 @@ compute_resistance_and_snapping_edges (MetaDisplay *display)
*/ */
GSList *rem_windows, *rem_win_stacking; GSList *rem_windows, *rem_win_stacking;
MetaWorkspaceManager *workspace_manager = display->workspace_manager; MetaWorkspaceManager *workspace_manager = display->workspace_manager;
MetaWindowDrag *window_drag;
g_assert (display->grab_window != NULL); window_drag = meta_compositor_get_current_window_drag (display->compositor);
g_assert (window_drag != NULL);
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"Computing edges to resist-movement or snap-to for %s.", "Computing edges to resist-movement or snap-to for %s.",
display->grab_window->desc); meta_window_drag_get_window (window_drag)->desc);
/* /*
* 1st: Get the list of relevant windows, from bottom to top * 1st: Get the list of relevant windows, from bottom to top

View file

@ -43,8 +43,6 @@
#include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-private.h"
#endif #endif
#define META_GRAB_OP_GET_BASE_TYPE(op) (op & 0x00FF)
#define IS_GESTURE_EVENT(e) ((e)->type == CLUTTER_TOUCHPAD_SWIPE || \ #define IS_GESTURE_EVENT(e) ((e)->type == CLUTTER_TOUCHPAD_SWIPE || \
(e)->type == CLUTTER_TOUCHPAD_PINCH || \ (e)->type == CLUTTER_TOUCHPAD_PINCH || \
(e)->type == CLUTTER_TOUCHPAD_HOLD || \ (e)->type == CLUTTER_TOUCHPAD_HOLD || \
@ -87,34 +85,23 @@ get_window_for_event (MetaDisplay *display,
const ClutterEvent *event, const ClutterEvent *event,
ClutterActor *event_actor) ClutterActor *event_actor)
{ {
switch (META_GRAB_OP_GET_BASE_TYPE (display->grab_op)) MetaWindowActor *window_actor;
if (stage_has_grab (display))
return NULL;
/* Always use the key focused window for key events. */
if (IS_KEY_EVENT (event))
{ {
case META_GRAB_OP_NONE: return stage_has_key_focus (display) ? display->focus_window
{ : NULL;
MetaWindowActor *window_actor;
if (stage_has_grab (display))
return NULL;
/* Always use the key focused window for key events. */
if (IS_KEY_EVENT (event))
{
return stage_has_key_focus (display) ? display->focus_window
: NULL;
}
window_actor = meta_window_actor_from_actor (event_actor);
if (window_actor)
return meta_window_actor_get_meta_window (window_actor);
else
return NULL;
}
case META_GRAB_OP_WINDOW_BASE:
return display->grab_window;
default:
g_assert_not_reached ();
return NULL;
} }
window_actor = meta_window_actor_from_actor (event_actor);
if (window_actor)
return meta_window_actor_get_meta_window (window_actor);
else
return NULL;
} }
static void static void
@ -224,6 +211,7 @@ meta_display_handle_event (MetaDisplay *display,
{ {
MetaContext *context = meta_display_get_context (display); MetaContext *context = meta_display_get_context (display);
MetaBackend *backend = meta_context_get_backend (context); MetaBackend *backend = meta_context_get_backend (context);
MetaCompositor *compositor = meta_display_get_compositor (display);
ClutterInputDevice *device; ClutterInputDevice *device;
MetaWindow *window = NULL; MetaWindow *window = NULL;
gboolean bypass_clutter = FALSE; gboolean bypass_clutter = FALSE;
@ -243,8 +231,6 @@ meta_display_handle_event (MetaDisplay *display,
if (display->grabbed_in_clutter != has_grab) if (display->grabbed_in_clutter != has_grab)
{ {
MetaCompositor *compositor = meta_display_get_compositor (display);
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
if (wayland_compositor) if (wayland_compositor)
meta_display_sync_wayland_input_focus (display); meta_display_sync_wayland_input_focus (display);
@ -389,23 +375,14 @@ meta_display_handle_event (MetaDisplay *display,
goto out; goto out;
} }
if (display->grab_op != META_GRAB_OP_NONE)
{
if (meta_window_handle_mouse_grab_op_event (window, event))
{
bypass_clutter = TRUE;
bypass_wayland = TRUE;
goto out;
}
}
/* For key events, it's important to enforce single-handling, or /* For key events, it's important to enforce single-handling, or
* we can get into a confused state. So if a keybinding is * we can get into a confused state. So if a keybinding is
* handled (because it's one of our hot-keys, or because we are * handled (because it's one of our hot-keys, or because we are
* in a keyboard-grabbed mode like moving a window, we don't * in a keyboard-grabbed mode like moving a window, we don't
* want to pass the key event to the compositor or Wayland at all. * want to pass the key event to the compositor or Wayland at all.
*/ */
if (meta_keybindings_process_event (display, window, event)) if (!meta_compositor_get_current_window_drag (compositor) &&
meta_keybindings_process_event (display, window, event))
{ {
bypass_clutter = TRUE; bypass_clutter = TRUE;
bypass_wayland = TRUE; bypass_wayland = TRUE;
@ -415,7 +392,7 @@ meta_display_handle_event (MetaDisplay *display,
/* Do not pass keyboard events to Wayland if key focus is not on the /* Do not pass keyboard events to Wayland if key focus is not on the
* stage in normal mode (e.g. during keynav in the panel) * stage in normal mode (e.g. during keynav in the panel)
*/ */
if (display->grab_op == META_GRAB_OP_NONE) if (!has_grab)
{ {
if (IS_KEY_EVENT (event) && !stage_has_key_focus (display)) if (IS_KEY_EVENT (event) && !stage_has_key_focus (display))
{ {
@ -484,7 +461,7 @@ meta_display_handle_event (MetaDisplay *display,
* event, and if it doesn't, replay the event to release our * event, and if it doesn't, replay the event to release our
* own sync grab. */ * own sync grab. */
if (display->grab_op != META_GRAB_OP_NONE) if (meta_compositor_get_current_window_drag (compositor))
{ {
bypass_clutter = TRUE; bypass_clutter = TRUE;
bypass_wayland = TRUE; bypass_wayland = TRUE;

View file

@ -1531,11 +1531,6 @@ meta_window_unmanage (MetaWindow *window,
invalidate_work_areas (window); invalidate_work_areas (window);
} }
if (window->display->grab_window == window)
meta_display_end_grab_op (window->display, timestamp);
g_assert (window->display->grab_window != window);
if (window->maximized_horizontally || window->maximized_vertically) if (window->maximized_horizontally || window->maximized_vertically)
unmaximize_window_before_freeing (window); unmaximize_window_before_freeing (window);
@ -2832,6 +2827,7 @@ meta_window_update_tile_fraction (MetaWindow *window,
{ {
MetaWindow *tile_match = window->tile_match; MetaWindow *tile_match = window->tile_match;
MetaRectangle work_area; MetaRectangle work_area;
MetaWindowDrag *window_drag;
if (!META_WINDOW_TILED_SIDE_BY_SIDE (window)) if (!META_WINDOW_TILED_SIDE_BY_SIDE (window))
return; return;
@ -2841,7 +2837,12 @@ meta_window_update_tile_fraction (MetaWindow *window,
&work_area); &work_area);
window->tile_hfraction = (double)new_w / work_area.width; window->tile_hfraction = (double)new_w / work_area.width;
if (tile_match && window->display->grab_window == window) window_drag =
meta_compositor_get_current_window_drag (window->display->compositor);
if (tile_match &&
window_drag &&
meta_window_drag_get_window (window_drag) == window)
meta_window_tile (tile_match, tile_match->tile_mode); meta_window_tile (tile_match, tile_match->tile_mode);
} }
@ -2925,6 +2926,7 @@ meta_window_tile (MetaWindow *window,
MetaTileMode tile_mode) MetaTileMode tile_mode)
{ {
MetaMaximizeFlags directions; MetaMaximizeFlags directions;
MetaWindowDrag *window_drag;
g_return_if_fail (META_IS_WINDOW (window)); g_return_if_fail (META_IS_WINDOW (window));
@ -2950,7 +2952,12 @@ meta_window_tile (MetaWindow *window,
meta_window_maximize_internal (window, directions, NULL); meta_window_maximize_internal (window, directions, NULL);
meta_display_update_tile_preview (window->display, FALSE); meta_display_update_tile_preview (window->display, FALSE);
if (!window->tile_match || window->tile_match != window->display->grab_window) window_drag =
meta_compositor_get_current_window_drag (window->display->compositor);
if (!window->tile_match ||
!window_drag ||
window->tile_match != meta_window_drag_get_window (window_drag))
{ {
MetaRectangle old_frame_rect, old_buffer_rect; MetaRectangle old_frame_rect, old_buffer_rect;
@ -4175,10 +4182,16 @@ meta_window_resize_frame_with_gravity (MetaWindow *window,
if (user_op) if (user_op)
{ {
MetaWindowDrag *window_drag;
window_drag =
meta_compositor_get_current_window_drag (window->display->compositor);
/* When resizing in-tandem with a tile match, we need to respect /* When resizing in-tandem with a tile match, we need to respect
* its minimum width * its minimum width
*/ */
if (window->display->grab_window == window) if (window_drag &&
meta_window_drag_get_window (window_drag) == window)
adjust_size_for_tile_match (window, &w, &h); adjust_size_for_tile_match (window, &w, &h);
meta_window_update_tile_fraction (window, w, h); meta_window_update_tile_fraction (window, w, h);
} }
@ -4557,6 +4570,8 @@ meta_window_focus (MetaWindow *window,
MetaWindow *modal_transient; MetaWindow *modal_transient;
MetaBackend *backend; MetaBackend *backend;
ClutterStage *stage; ClutterStage *stage;
MetaWindowDrag *window_drag;
MetaWindow *grab_window = NULL;
g_return_if_fail (!window->override_redirect); g_return_if_fail (!window->override_redirect);
@ -4575,14 +4590,18 @@ meta_window_focus (MetaWindow *window,
return; return;
} }
if (window->display->grab_window && window_drag =
window->display->grab_window != window && meta_compositor_get_current_window_drag (window->display->compositor);
window->display->grab_window->all_keys_grabbed && if (window_drag)
!window->display->grab_window->unmanaging) grab_window = meta_window_drag_get_window (window_drag);
if (grab_window &&
grab_window != window &&
!grab_window->unmanaging)
{ {
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Current focus window %s has global keygrab, not focusing window %s after all", "Current focus window %s has global keygrab, not focusing window %s after all",
window->display->grab_window->desc, window->desc); grab_window->desc, window->desc);
return; return;
} }
@ -6735,31 +6754,9 @@ meta_window_begin_grab_op (MetaWindow *window,
MetaGrabOp op, MetaGrabOp op,
guint32 timestamp) guint32 timestamp)
{ {
int x, y; return meta_compositor_drag_window (window->display->compositor,
window, op,
if ((op & META_GRAB_OP_KEYBOARD_MOVING) == META_GRAB_OP_KEYBOARD_MOVING) timestamp);
{
warp_grab_pointer (window, op, &x, &y);
}
else
{
MetaBackend *backend = backend_from_window (window);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
ClutterInputDevice *device;
graphene_point_t pos;
device = clutter_seat_get_pointer (seat);
clutter_seat_query_state (seat, device, NULL, &pos, NULL);
x = pos.x;
y = pos.y;
}
return meta_display_begin_grab_op (window->display,
window,
op,
timestamp,
x, y);
} }
void void
@ -7823,6 +7820,7 @@ meta_window_find_tile_match (MetaWindow *window,
{ {
MetaWindow *above, *bottommost, *topmost; MetaWindow *above, *bottommost, *topmost;
MetaRectangle above_rect, bottommost_rect, topmost_rect; MetaRectangle above_rect, bottommost_rect, topmost_rect;
MetaWindowDrag *window_drag;
if (meta_stack_windows_cmp (window->display->stack, match, window) > 0) if (meta_stack_windows_cmp (window->display->stack, match, window) > 0)
{ {
@ -7838,14 +7836,18 @@ meta_window_find_tile_match (MetaWindow *window,
meta_window_get_frame_rect (bottommost, &bottommost_rect); meta_window_get_frame_rect (bottommost, &bottommost_rect);
meta_window_get_frame_rect (topmost, &topmost_rect); meta_window_get_frame_rect (topmost, &topmost_rect);
window_drag =
meta_compositor_get_current_window_drag (window->display->compositor);
/* /*
* If we are looking for a tile match while actually being tiled, * If we are looking for a tile match while actually being tiled,
* rather than a match for a potential tile mode, then discard * rather than a match for a potential tile mode, then discard
* windows with too much gap or overlap * windows with too much gap or overlap
*/ */
if (window->tile_mode == current_mode && if (window->tile_mode == current_mode &&
!(meta_grab_op_is_resizing (window->display->grab_op) && !(window_drag &&
window->display->grab_window == window && meta_grab_op_is_resizing (meta_window_drag_get_grab_op (window_drag)) &&
meta_window_drag_get_window (window_drag) == window &&
window->tile_match != NULL)) window->tile_match != NULL))
{ {
int threshold = meta_prefs_get_drag_threshold (); int threshold = meta_prefs_get_drag_threshold ();

View file

@ -576,6 +576,7 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
MetaWorkspaceLayout layout1, layout2; MetaWorkspaceLayout layout1, layout2;
gint num_workspaces, current_space, new_space; gint num_workspaces, current_space, new_space;
MetaMotionDirection direction; MetaMotionDirection direction;
MetaWindowDrag *window_drag;
g_return_if_fail (META_IS_WORKSPACE (workspace)); g_return_if_fail (META_IS_WORKSPACE (workspace));
g_return_if_fail (meta_workspace_index (workspace) != -1); g_return_if_fail (meta_workspace_index (workspace) != -1);
@ -619,8 +620,11 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
g_signal_emit_by_name (workspace->manager, "showing-desktop-changed"); g_signal_emit_by_name (workspace->manager, "showing-desktop-changed");
move_window = NULL; move_window = NULL;
if (meta_grab_op_is_moving (workspace->display->grab_op)) window_drag =
move_window = workspace->display->grab_window; meta_compositor_get_current_window_drag (workspace->display->compositor);
if (window_drag &&
meta_grab_op_is_moving (meta_window_drag_get_grab_op (window_drag)))
move_window = meta_window_drag_get_window (window_drag);
if (move_window != NULL) if (move_window != NULL)
{ {

View file

@ -108,17 +108,6 @@ backend_from_pointer (MetaWaylandPointer *pointer)
return meta_context_get_backend (context); return meta_context_get_backend (context);
} }
static MetaDisplay *
display_from_pointer (MetaWaylandPointer *pointer)
{
MetaWaylandInputDevice *input_device = META_WAYLAND_INPUT_DEVICE (pointer);
MetaWaylandSeat *seat = meta_wayland_input_device_get_seat (input_device);
MetaWaylandCompositor *compositor = meta_wayland_seat_get_compositor (seat);
MetaContext *context = meta_wayland_compositor_get_context (compositor);
return meta_context_get_display (context);
}
static MetaWaylandPointerClient * static MetaWaylandPointerClient *
meta_wayland_pointer_client_new (void) meta_wayland_pointer_client_new (void)
{ {
@ -312,7 +301,6 @@ surface_get_effective_window (MetaWaylandSurface *surface)
static void static void
sync_focus_surface (MetaWaylandPointer *pointer) sync_focus_surface (MetaWaylandPointer *pointer)
{ {
MetaDisplay *display = display_from_pointer (pointer);
MetaBackend *backend = backend_from_pointer (pointer); MetaBackend *backend = backend_from_pointer (pointer);
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
ClutterBackend *clutter_backend = clutter_get_default_backend (); ClutterBackend *clutter_backend = clutter_get_default_backend ();
@ -327,16 +315,8 @@ sync_focus_surface (MetaWaylandPointer *pointer)
return; return;
} }
if (display->grab_op == META_GRAB_OP_NONE) const MetaWaylandPointerGrabInterface *interface = pointer->grab->interface;
{ interface->focus (pointer->grab, pointer->current);
const MetaWaylandPointerGrabInterface *interface = pointer->grab->interface;
interface->focus (pointer->grab, pointer->current);
}
else
{
/* The compositor has a grab, so remove our focus... */
meta_wayland_pointer_set_focus (pointer, NULL);
}
} }
static void static void
@ -476,7 +456,6 @@ default_grab_focus (MetaWaylandPointerGrab *grab,
{ {
MetaWaylandPointer *pointer = grab->pointer; MetaWaylandPointer *pointer = grab->pointer;
MetaWaylandSeat *seat = meta_wayland_pointer_get_seat (pointer); MetaWaylandSeat *seat = meta_wayland_pointer_get_seat (pointer);
MetaDisplay *display = display_from_pointer (pointer);
MetaBackend *backend = backend_from_pointer (pointer); MetaBackend *backend = backend_from_pointer (pointer);
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
ClutterBackend *clutter_backend = clutter_get_default_backend (); ClutterBackend *clutter_backend = clutter_get_default_backend ();
@ -496,9 +475,6 @@ default_grab_focus (MetaWaylandPointerGrab *grab,
if (pointer->button_count > 0) if (pointer->button_count > 0)
return; return;
if (display->grab_op != META_GRAB_OP_NONE)
return;
if (surface) if (surface)
{ {
MetaWindow *window = NULL; MetaWindow *window = NULL;

View file

@ -50,16 +50,6 @@ backend_from_tool (MetaWaylandTabletTool *tool)
return meta_context_get_backend (context); return meta_context_get_backend (context);
} }
static MetaDisplay *
display_from_tool (MetaWaylandTabletTool *tool)
{
MetaWaylandCompositor *compositor =
meta_wayland_seat_get_compositor (tool->seat->seat);
MetaContext *context = meta_wayland_compositor_get_context (compositor);
return meta_context_get_display (context);
}
static void static void
unbind_resource (struct wl_resource *resource) unbind_resource (struct wl_resource *resource)
{ {
@ -575,7 +565,6 @@ static void
sync_focus_surface (MetaWaylandTabletTool *tool, sync_focus_surface (MetaWaylandTabletTool *tool,
const ClutterEvent *event) const ClutterEvent *event)
{ {
MetaDisplay *display = display_from_tool (tool);
MetaBackend *backend = backend_from_tool (tool); MetaBackend *backend = backend_from_tool (tool);
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
@ -585,15 +574,7 @@ sync_focus_surface (MetaWaylandTabletTool *tool,
return; return;
} }
if (display->grab_op == META_GRAB_OP_NONE) meta_wayland_tablet_tool_set_focus (tool, tool->current, event);
{
meta_wayland_tablet_tool_set_focus (tool, tool->current, event);
}
else
{
/* The compositor has a grab, so remove our focus */
meta_wayland_tablet_tool_set_focus (tool, NULL, event);
}
} }
static void static void

View file

@ -26,6 +26,7 @@
#include "wayland/meta-wayland-xdg-shell.h" #include "wayland/meta-wayland-xdg-shell.h"
#include "backends/meta-logical-monitor.h" #include "backends/meta-logical-monitor.h"
#include "compositor/compositor-private.h"
#include "core/boxes-private.h" #include "core/boxes-private.h"
#include "core/window-private.h" #include "core/window-private.h"
#include "wayland/meta-wayland-outputs.h" #include "wayland/meta-wayland-outputs.h"
@ -685,12 +686,17 @@ fill_states (MetaWaylandXdgToplevel *xdg_toplevel,
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaWindow *window = meta_wayland_surface_get_window (surface); MetaWindow *window = meta_wayland_surface_get_window (surface);
MetaWindowDrag *window_drag;
window_drag =
meta_compositor_get_current_window_drag (window->display->compositor);
if (META_WINDOW_MAXIMIZED (window)) if (META_WINDOW_MAXIMIZED (window))
add_state_value (states, XDG_TOPLEVEL_STATE_MAXIMIZED); add_state_value (states, XDG_TOPLEVEL_STATE_MAXIMIZED);
if (meta_window_is_fullscreen (window)) if (meta_window_is_fullscreen (window))
add_state_value (states, XDG_TOPLEVEL_STATE_FULLSCREEN); add_state_value (states, XDG_TOPLEVEL_STATE_FULLSCREEN);
if (meta_grab_op_is_resizing (window->display->grab_op)) if (window_drag &&
meta_grab_op_is_resizing (meta_window_drag_get_grab_op (window_drag)))
add_state_value (states, XDG_TOPLEVEL_STATE_RESIZING); add_state_value (states, XDG_TOPLEVEL_STATE_RESIZING);
if (meta_window_appears_focused (window)) if (meta_window_appears_focused (window))
add_state_value (states, XDG_TOPLEVEL_STATE_ACTIVATED); add_state_value (states, XDG_TOPLEVEL_STATE_ACTIVATED);

View file

@ -1125,6 +1125,7 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
MetaWaylandWindowConfiguration *acked_configuration; MetaWaylandWindowConfiguration *acked_configuration;
gboolean is_window_being_resized; gboolean is_window_being_resized;
gboolean is_client_resize; gboolean is_client_resize;
MetaWindowDrag *window_drag;
/* new_geom is in the logical pixel coordinate space, but MetaWindow wants its /* new_geom is in the logical pixel coordinate space, but MetaWindow wants its
* rects to represent what in turn will end up on the stage, i.e. we need to * rects to represent what in turn will end up on the stage, i.e. we need to
@ -1168,9 +1169,13 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
flags = META_MOVE_RESIZE_WAYLAND_FINISH_MOVE_RESIZE; flags = META_MOVE_RESIZE_WAYLAND_FINISH_MOVE_RESIZE;
window_drag = meta_compositor_get_current_window_drag (display->compositor);
/* x/y are ignored when we're doing interactive resizing */ /* x/y are ignored when we're doing interactive resizing */
is_window_being_resized = (meta_grab_op_is_resizing (display->grab_op) && is_window_being_resized =
display->grab_window == window); (window_drag &&
meta_grab_op_is_resizing (meta_window_drag_get_grab_op (window_drag)) &&
meta_window_drag_get_window (window_drag) == window);
rect = (MetaRectangle) { rect = (MetaRectangle) {
.x = window->rect.x, .x = window->rect.x,
@ -1229,8 +1234,9 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
meta_wayland_window_configuration_free); meta_wayland_window_configuration_free);
wl_window->last_acked_configuration = g_steal_pointer (&acked_configuration); wl_window->last_acked_configuration = g_steal_pointer (&acked_configuration);
if (window->display->grab_window == window) if (window_drag &&
gravity = meta_resize_gravity_from_grab_op (window->display->grab_op); meta_window_drag_get_window (window_drag) == window)
gravity = meta_resize_gravity_from_grab_op (meta_window_drag_get_grab_op (window_drag));
else else
gravity = META_GRAVITY_STATIC; gravity = META_GRAVITY_STATIC;
meta_window_move_resize_internal (window, flags, gravity, rect); meta_window_move_resize_internal (window, flags, gravity, rect);

View file

@ -970,9 +970,6 @@ handle_input_xevent (MetaX11Display *x11_display,
switch (input_event->evtype) switch (input_event->evtype)
{ {
case XI_Enter: case XI_Enter:
if (display->grab_op != META_GRAB_OP_NONE)
break;
if (clutter_stage_get_grab_actor (stage) != NULL) if (clutter_stage_get_grab_actor (stage) != NULL)
break; break;
@ -992,9 +989,6 @@ handle_input_xevent (MetaX11Display *x11_display,
} }
break; break;
case XI_Leave: case XI_Leave:
if (display->grab_op != META_GRAB_OP_NONE)
break;
if (clutter_stage_get_grab_actor (stage) != NULL) if (clutter_stage_get_grab_actor (stage) != NULL)
break; break;
@ -1412,10 +1406,6 @@ handle_other_xevent (MetaX11Display *x11_display,
guint32 timestamp; guint32 timestamp;
timestamp = meta_display_get_current_time_roundtrip (display); timestamp = meta_display_get_current_time_roundtrip (display);
if (display->grab_op != META_GRAB_OP_NONE &&
display->grab_window == window)
meta_display_end_grab_op (display, timestamp);
if (frame_was_receiver) if (frame_was_receiver)
{ {
meta_x11_error_trap_push (x11_display); meta_x11_error_trap_push (x11_display);
@ -1440,11 +1430,6 @@ handle_other_xevent (MetaX11Display *x11_display,
guint32 timestamp; guint32 timestamp;
timestamp = meta_display_get_current_time_roundtrip (display); timestamp = meta_display_get_current_time_roundtrip (display);
if (display->grab_op != META_GRAB_OP_NONE &&
display->grab_window == window &&
window->frame == NULL)
meta_display_end_grab_op (display, timestamp);
if (!frame_was_receiver) if (!frame_was_receiver)
{ {
if (window->unmaps_pending == 0) if (window->unmaps_pending == 0)

View file

@ -191,6 +191,7 @@ sync_request_timeout (gpointer data)
{ {
MetaSyncCounter *sync_counter = data; MetaSyncCounter *sync_counter = data;
MetaWindow *window = sync_counter->window; MetaWindow *window = sync_counter->window;
MetaWindowDrag *window_drag;
sync_counter->sync_request_timeout_id = 0; sync_counter->sync_request_timeout_id = 0;
@ -205,8 +206,12 @@ sync_request_timeout (gpointer data)
sync_counter->sync_request_wait_serial = 0; sync_counter->sync_request_wait_serial = 0;
meta_compositor_sync_updates_frozen (window->display->compositor, window); meta_compositor_sync_updates_frozen (window->display->compositor, window);
if (window == window->display->grab_window && window_drag =
meta_grab_op_is_resizing (window->display->grab_op)) meta_compositor_get_current_window_drag (window->display->compositor);
if (window_drag &&
window == meta_window_drag_get_window (window_drag) &&
meta_grab_op_is_resizing (meta_window_drag_get_grab_op (window_drag)))
meta_window_x11_check_update_resize (window); meta_window_x11_check_update_resize (window);
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;

View file

@ -1310,8 +1310,8 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
gboolean need_resize_frame = FALSE; gboolean need_resize_frame = FALSE;
gboolean frame_shape_changed = FALSE; gboolean frame_shape_changed = FALSE;
gboolean configure_frame_first; gboolean configure_frame_first;
gboolean is_configure_request; gboolean is_configure_request;
MetaWindowDrag *window_drag;
is_configure_request = (flags & META_MOVE_RESIZE_CONFIGURE_REQUEST) != 0; is_configure_request = (flags & META_MOVE_RESIZE_CONFIGURE_REQUEST) != 0;
@ -1495,9 +1495,13 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
meta_x11_error_trap_push (window->display->x11_display); meta_x11_error_trap_push (window->display->x11_display);
window_drag =
meta_compositor_get_current_window_drag (window->display->compositor);
if (mask != 0 && if (mask != 0 &&
window == window->display->grab_window && window_drag &&
meta_grab_op_is_resizing (window->display->grab_op)) window == meta_window_drag_get_window (window_drag) &&
meta_grab_op_is_resizing (meta_window_drag_get_grab_op (window_drag)))
{ {
meta_sync_counter_send_request (&priv->sync_counter); meta_sync_counter_send_request (&priv->sync_counter);
if (window->frame) if (window->frame)
@ -2642,6 +2646,7 @@ meta_window_move_resize_request (MetaWindow *window,
gboolean in_grab_op; gboolean in_grab_op;
MetaMoveResizeFlags flags; MetaMoveResizeFlags flags;
MetaRectangle buffer_rect; MetaRectangle buffer_rect;
MetaWindowDrag *window_drag;
/* We ignore configure requests while the user is moving/resizing /* We ignore configure requests while the user is moving/resizing
* the window, since these represent the app sucking and fighting * the window, since these represent the app sucking and fighting
@ -2651,8 +2656,11 @@ meta_window_move_resize_request (MetaWindow *window,
* Still have to do the ConfigureNotify and all, but pretend the * Still have to do the ConfigureNotify and all, but pretend the
* app asked for the current size/position instead of the new one. * app asked for the current size/position instead of the new one.
*/ */
in_grab_op = (window->display->grab_window == window && window_drag =
meta_grab_op_is_mouse (window->display->grab_op)); meta_compositor_get_current_window_drag (window->display->compositor);
in_grab_op = (window_drag &&
meta_window_drag_get_window (window_drag) == window &&
meta_grab_op_is_mouse (meta_window_drag_get_grab_op (window_drag)));
/* it's essential to use only the explicitly-set fields, /* it's essential to use only the explicitly-set fields,
* and otherwise use our current up-to-date position. * and otherwise use our current up-to-date position.
@ -2716,7 +2724,8 @@ meta_window_move_resize_request (MetaWindow *window,
meta_window_get_buffer_rect (window, &buffer_rect); meta_window_get_buffer_rect (window, &buffer_rect);
width = buffer_rect.width; width = buffer_rect.width;
height = buffer_rect.height; height = buffer_rect.height;
if (!in_grab_op || !meta_grab_op_is_resizing (window->display->grab_op)) if (!in_grab_op || !window_drag ||
!meta_grab_op_is_resizing (meta_window_drag_get_grab_op (window_drag)))
{ {
if (value_mask & CWWidth) if (value_mask & CWWidth)
width = new_width; width = new_width;
@ -3271,6 +3280,7 @@ meta_window_x11_client_message (MetaWindow *window,
MetaGrabOp op; MetaGrabOp op;
int button; int button;
guint32 timestamp; guint32 timestamp;
MetaWindowDrag *window_drag;
x_root = event->xclient.data.l[0]; x_root = event->xclient.data.l[0];
y_root = event->xclient.data.l[1]; y_root = event->xclient.data.l[1];
@ -3327,9 +3337,13 @@ meta_window_x11_client_message (MetaWindow *window,
break; break;
} }
window_drag =
meta_compositor_get_current_window_drag (window->display->compositor);
if (action == _NET_WM_MOVERESIZE_CANCEL) if (action == _NET_WM_MOVERESIZE_CANCEL)
{ {
meta_display_end_grab_op (window->display, timestamp); if (window_drag)
meta_window_drag_end (window_drag);
} }
else if (op != META_GRAB_OP_NONE && else if (op != META_GRAB_OP_NONE &&
((window->has_move_func && op == META_GRAB_OP_KEYBOARD_MOVING) || ((window->has_move_func && op == META_GRAB_OP_KEYBOARD_MOVING) ||
@ -3365,8 +3379,8 @@ meta_window_x11_client_message (MetaWindow *window,
else if ((button_mask & (1 << 3)) != 0) else if ((button_mask & (1 << 3)) != 0)
button = 3; button = 3;
if (button == 0) if (button == 0 && window_drag)
meta_display_end_grab_op (window->display, timestamp); meta_window_drag_end (window_drag);
} }
else else
{ {
@ -3383,8 +3397,8 @@ meta_window_x11_client_message (MetaWindow *window,
* drag immediately. * drag immediately.
*/ */
if ((button_mask & (1 << button)) == 0) if (window_drag && (button_mask & (1 << button)) == 0)
meta_display_end_grab_op (window->display, timestamp); meta_window_drag_end (window_drag);
} }
} }
@ -4302,6 +4316,7 @@ meta_window_x11_check_update_resize (MetaWindow *window)
{ {
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window); MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11); MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
MetaWindowDrag *window_drag;
if (window->frame && if (window->frame &&
meta_sync_counter_is_waiting (meta_frame_get_sync_counter (window->frame))) meta_sync_counter_is_waiting (meta_frame_get_sync_counter (window->frame)))
@ -4310,10 +4325,9 @@ meta_window_x11_check_update_resize (MetaWindow *window)
if (meta_sync_counter_is_waiting (&priv->sync_counter)) if (meta_sync_counter_is_waiting (&priv->sync_counter))
return; return;
meta_window_update_resize (window, window_drag =
window->display->grab_last_edge_resistance_flags, meta_compositor_get_current_window_drag (window->display->compositor);
window->display->grab_latest_motion_x, meta_window_drag_update_resize (window_drag);
window->display->grab_latest_motion_y);
} }
gboolean gboolean