diff --git a/doc/code-overview.txt b/doc/code-overview.txt index 450f7a828..8e9dfcc85 100644 --- a/doc/code-overview.txt +++ b/doc/code-overview.txt @@ -132,6 +132,7 @@ Getting started -- where to look constraints.c update_move update_resize + meta-window-drag.c meta_window_handle_mouse_grab_op_event _NET_MOVERESIZE_WINDOW _NET_WM_STRUT diff --git a/src/compositor/meta-window-actor-x11.c b/src/compositor/meta-window-actor-x11.c index 8f538f3df..919984054 100644 --- a/src/compositor/meta-window-actor-x11.c +++ b/src/compositor/meta-window-actor-x11.c @@ -1242,6 +1242,7 @@ meta_window_actor_x11_after_paint (MetaWindowActor *actor, { MetaWindowActorX11 *actor_x11 = META_WINDOW_ACTOR_X11 (actor); MetaSyncCounter *sync_counter; + MetaWindowDrag *window_drag; MetaWindow *window; 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); } - if (window == window->display->grab_window && - meta_grab_op_is_resizing (window->display->grab_op)) + window_drag = 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))) { /* This means we are ready for another configure; * no pointer round trip here, to keep in sync */ diff --git a/src/compositor/meta-window-drag.c b/src/compositor/meta-window-drag.c index 1e2894a75..64a2cc279 100644 --- a/src/compositor/meta-window-drag.c +++ b/src/compositor/meta-window-drag.c @@ -608,6 +608,9 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag, "Computed new window location %d,%d due to keypress", x, y); + window_drag->last_edge_resistance_flags = + flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP; + meta_window_edge_resistance_for_move (window, &x, &y, @@ -959,6 +962,9 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag, "%dx%d, gravity %s", width, height, meta_gravity_to_string (gravity)); + window_drag->last_edge_resistance_flags = + flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP; + /* Do any edge resistance/snapping */ meta_window_edge_resistance_for_resize (window, &width, @@ -1257,6 +1263,9 @@ update_move (MetaWindowDrag *window_drag, if (window->maximized_vertically) new_y = old.y; + window_drag->last_edge_resistance_flags = + flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP; + /* Do any edge resistance/snapping */ meta_window_edge_resistance_for_move (window, &new_x, @@ -1410,6 +1419,9 @@ update_resize (MetaWindowDrag *window_drag, gravity = meta_resize_gravity_from_grab_op (window_drag->grab_op); g_assert (gravity >= 0); + window_drag->last_edge_resistance_flags = + flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP; + /* Do any edge resistance/snapping */ meta_window_edge_resistance_for_resize (window, &new_rect.width, diff --git a/src/core/constraints.c b/src/core/constraints.c index e1d1303ed..d9e4c75b5 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -31,6 +31,7 @@ #include "backends/meta-backend-private.h" #include "backends/meta-logical-monitor.h" #include "backends/meta-monitor-manager-private.h" +#include "compositor/compositor-private.h" #include "core/boxes-private.h" #include "core/meta-workspace-manager-private.h" #include "core/place.h" @@ -1761,16 +1762,21 @@ constrain_titlebar_visible (MetaWindow *window, int bottom_amount; int horiz_amount_offscreen, vert_amount_offscreen; int horiz_amount_onscreen, vert_amount_onscreen; + MetaWindowDrag *window_drag; if (priority > PRIORITY_TITLEBAR_VISIBLE) 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 * clicking on the frame to start the move. */ unconstrained_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 * is only meant for normal windows (e.g. we don't want docks to be shoved diff --git a/src/core/delete.c b/src/core/delete.c index 1e0de455d..48cecdaca 100644 --- a/src/core/delete.c +++ b/src/core/delete.c @@ -69,7 +69,7 @@ meta_window_show_close_dialog (MetaWindow *window) meta_close_dialog_show (window->close_dialog); 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) meta_close_dialog_focus (window->close_dialog); } diff --git a/src/core/display.c b/src/core/display.c index 512d6863b..d8d131926 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1259,10 +1259,7 @@ meta_display_windows_are_interactable (MetaDisplay *display) if (clutter_stage_get_grab_actor (CLUTTER_STAGE (stage))) return FALSE; - if (display->grab_op == META_GRAB_OP_NONE) - return TRUE; - - return FALSE; + return TRUE; } /** @@ -1998,7 +1995,7 @@ meta_display_end_grab_op (MetaDisplay *display, gboolean 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 @@ -3151,11 +3148,16 @@ static gboolean meta_display_update_tile_preview_timeout (gpointer data) { MetaDisplay *display = data; - MetaWindow *window = display->grab_window; + MetaWindowDrag *window_drag; + MetaWindow *window = NULL; gboolean needs_preview = FALSE; 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) { switch (display->preview_tile_mode) diff --git a/src/core/edge-resistance.c b/src/core/edge-resistance.c index eeaf055ca..164e85213 100644 --- a/src/core/edge-resistance.c +++ b/src/core/edge-resistance.c @@ -23,6 +23,7 @@ #include "core/edge-resistance.h" +#include "compositor/compositor-private.h" #include "core/boxes-private.h" #include "core/display-private.h" #include "core/meta-workspace-manager-private.h" @@ -33,7 +34,8 @@ */ #define WINDOW_EDGES_RELEVANT(window, display) \ 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_MENU && \ window->type != META_WINDOW_SPLASHSCREEN @@ -887,11 +889,14 @@ compute_resistance_and_snapping_edges (MetaDisplay *display) */ GSList *rem_windows, *rem_win_stacking; 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, "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 diff --git a/src/core/events.c b/src/core/events.c index e2f79635b..edf010337 100644 --- a/src/core/events.c +++ b/src/core/events.c @@ -43,8 +43,6 @@ #include "wayland/meta-wayland-private.h" #endif -#define META_GRAB_OP_GET_BASE_TYPE(op) (op & 0x00FF) - #define IS_GESTURE_EVENT(e) ((e)->type == CLUTTER_TOUCHPAD_SWIPE || \ (e)->type == CLUTTER_TOUCHPAD_PINCH || \ (e)->type == CLUTTER_TOUCHPAD_HOLD || \ @@ -87,34 +85,23 @@ get_window_for_event (MetaDisplay *display, const ClutterEvent *event, 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: - { - 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; + 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; } static void @@ -224,6 +211,7 @@ meta_display_handle_event (MetaDisplay *display, { MetaContext *context = meta_display_get_context (display); MetaBackend *backend = meta_context_get_backend (context); + MetaCompositor *compositor = meta_display_get_compositor (display); ClutterInputDevice *device; MetaWindow *window = NULL; gboolean bypass_clutter = FALSE; @@ -243,8 +231,6 @@ meta_display_handle_event (MetaDisplay *display, if (display->grabbed_in_clutter != has_grab) { - MetaCompositor *compositor = meta_display_get_compositor (display); - #ifdef HAVE_WAYLAND if (wayland_compositor) meta_display_sync_wayland_input_focus (display); @@ -389,23 +375,14 @@ meta_display_handle_event (MetaDisplay *display, 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 * 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 * 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. */ - 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_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 * 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)) { @@ -484,7 +461,7 @@ meta_display_handle_event (MetaDisplay *display, * event, and if it doesn't, replay the event to release our * own sync grab. */ - if (display->grab_op != META_GRAB_OP_NONE) + if (meta_compositor_get_current_window_drag (compositor)) { bypass_clutter = TRUE; bypass_wayland = TRUE; diff --git a/src/core/window.c b/src/core/window.c index 2ed9ab10a..beb921480 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -1531,11 +1531,6 @@ meta_window_unmanage (MetaWindow *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) unmaximize_window_before_freeing (window); @@ -2832,6 +2827,7 @@ meta_window_update_tile_fraction (MetaWindow *window, { MetaWindow *tile_match = window->tile_match; MetaRectangle work_area; + MetaWindowDrag *window_drag; if (!META_WINDOW_TILED_SIDE_BY_SIDE (window)) return; @@ -2841,7 +2837,12 @@ meta_window_update_tile_fraction (MetaWindow *window, &work_area); 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); } @@ -2925,6 +2926,7 @@ meta_window_tile (MetaWindow *window, MetaTileMode tile_mode) { MetaMaximizeFlags directions; + MetaWindowDrag *window_drag; 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_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; @@ -4175,10 +4182,16 @@ meta_window_resize_frame_with_gravity (MetaWindow *window, 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 * 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); meta_window_update_tile_fraction (window, w, h); } @@ -4557,6 +4570,8 @@ meta_window_focus (MetaWindow *window, MetaWindow *modal_transient; MetaBackend *backend; ClutterStage *stage; + MetaWindowDrag *window_drag; + MetaWindow *grab_window = NULL; g_return_if_fail (!window->override_redirect); @@ -4575,14 +4590,18 @@ meta_window_focus (MetaWindow *window, return; } - if (window->display->grab_window && - window->display->grab_window != window && - window->display->grab_window->all_keys_grabbed && - !window->display->grab_window->unmanaging) + window_drag = + meta_compositor_get_current_window_drag (window->display->compositor); + if (window_drag) + grab_window = meta_window_drag_get_window (window_drag); + + if (grab_window && + grab_window != window && + !grab_window->unmanaging) { meta_topic (META_DEBUG_FOCUS, "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; } @@ -6735,31 +6754,9 @@ meta_window_begin_grab_op (MetaWindow *window, MetaGrabOp op, guint32 timestamp) { - int x, y; - - if ((op & META_GRAB_OP_KEYBOARD_MOVING) == META_GRAB_OP_KEYBOARD_MOVING) - { - 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); + return meta_compositor_drag_window (window->display->compositor, + window, op, + timestamp); } void @@ -7823,6 +7820,7 @@ meta_window_find_tile_match (MetaWindow *window, { MetaWindow *above, *bottommost, *topmost; MetaRectangle above_rect, bottommost_rect, topmost_rect; + MetaWindowDrag *window_drag; 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 (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, * rather than a match for a potential tile mode, then discard * windows with too much gap or overlap */ if (window->tile_mode == current_mode && - !(meta_grab_op_is_resizing (window->display->grab_op) && - window->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 && window->tile_match != NULL)) { int threshold = meta_prefs_get_drag_threshold (); diff --git a/src/core/workspace.c b/src/core/workspace.c index b638177a8..9718f31e1 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -576,6 +576,7 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace, MetaWorkspaceLayout layout1, layout2; gint num_workspaces, current_space, new_space; MetaMotionDirection direction; + MetaWindowDrag *window_drag; g_return_if_fail (META_IS_WORKSPACE (workspace)); 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"); move_window = NULL; - if (meta_grab_op_is_moving (workspace->display->grab_op)) - move_window = workspace->display->grab_window; + window_drag = + 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) { diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index 6709d9b5a..d324d167e 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -108,17 +108,6 @@ backend_from_pointer (MetaWaylandPointer *pointer) 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 * meta_wayland_pointer_client_new (void) { @@ -312,7 +301,6 @@ surface_get_effective_window (MetaWaylandSurface *surface) static void sync_focus_surface (MetaWaylandPointer *pointer) { - MetaDisplay *display = display_from_pointer (pointer); MetaBackend *backend = backend_from_pointer (pointer); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); ClutterBackend *clutter_backend = clutter_get_default_backend (); @@ -327,16 +315,8 @@ sync_focus_surface (MetaWaylandPointer *pointer) return; } - if (display->grab_op == META_GRAB_OP_NONE) - { - 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); - } + const MetaWaylandPointerGrabInterface *interface = pointer->grab->interface; + interface->focus (pointer->grab, pointer->current); } static void @@ -476,7 +456,6 @@ default_grab_focus (MetaWaylandPointerGrab *grab, { MetaWaylandPointer *pointer = grab->pointer; MetaWaylandSeat *seat = meta_wayland_pointer_get_seat (pointer); - MetaDisplay *display = display_from_pointer (pointer); MetaBackend *backend = backend_from_pointer (pointer); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); ClutterBackend *clutter_backend = clutter_get_default_backend (); @@ -496,9 +475,6 @@ default_grab_focus (MetaWaylandPointerGrab *grab, if (pointer->button_count > 0) return; - if (display->grab_op != META_GRAB_OP_NONE) - return; - if (surface) { MetaWindow *window = NULL; diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c index 2982dce65..8c7e45953 100644 --- a/src/wayland/meta-wayland-tablet-tool.c +++ b/src/wayland/meta-wayland-tablet-tool.c @@ -50,16 +50,6 @@ backend_from_tool (MetaWaylandTabletTool *tool) 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 unbind_resource (struct wl_resource *resource) { @@ -575,7 +565,6 @@ static void sync_focus_surface (MetaWaylandTabletTool *tool, const ClutterEvent *event) { - MetaDisplay *display = display_from_tool (tool); MetaBackend *backend = backend_from_tool (tool); ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); @@ -585,15 +574,7 @@ sync_focus_surface (MetaWaylandTabletTool *tool, return; } - if (display->grab_op == META_GRAB_OP_NONE) - { - 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); - } + meta_wayland_tablet_tool_set_focus (tool, tool->current, event); } static void diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c index 0984dc0d3..907d5139a 100644 --- a/src/wayland/meta-wayland-xdg-shell.c +++ b/src/wayland/meta-wayland-xdg-shell.c @@ -26,6 +26,7 @@ #include "wayland/meta-wayland-xdg-shell.h" #include "backends/meta-logical-monitor.h" +#include "compositor/compositor-private.h" #include "core/boxes-private.h" #include "core/window-private.h" #include "wayland/meta-wayland-outputs.h" @@ -685,12 +686,17 @@ fill_states (MetaWaylandXdgToplevel *xdg_toplevel, MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (surface_role); 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)) add_state_value (states, XDG_TOPLEVEL_STATE_MAXIMIZED); if (meta_window_is_fullscreen (window)) 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); if (meta_window_appears_focused (window)) add_state_value (states, XDG_TOPLEVEL_STATE_ACTIVATED); diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index d4ef5f86c..fb907b2f9 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -1125,6 +1125,7 @@ meta_window_wayland_finish_move_resize (MetaWindow *window, MetaWaylandWindowConfiguration *acked_configuration; gboolean is_window_being_resized; gboolean is_client_resize; + MetaWindowDrag *window_drag; /* 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 @@ -1168,9 +1169,13 @@ meta_window_wayland_finish_move_resize (MetaWindow *window, 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 */ - is_window_being_resized = (meta_grab_op_is_resizing (display->grab_op) && - display->grab_window == window); + is_window_being_resized = + (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) { .x = window->rect.x, @@ -1229,8 +1234,9 @@ meta_window_wayland_finish_move_resize (MetaWindow *window, meta_wayland_window_configuration_free); wl_window->last_acked_configuration = g_steal_pointer (&acked_configuration); - if (window->display->grab_window == window) - gravity = meta_resize_gravity_from_grab_op (window->display->grab_op); + if (window_drag && + meta_window_drag_get_window (window_drag) == window) + gravity = meta_resize_gravity_from_grab_op (meta_window_drag_get_grab_op (window_drag)); else gravity = META_GRAVITY_STATIC; meta_window_move_resize_internal (window, flags, gravity, rect); diff --git a/src/x11/events.c b/src/x11/events.c index 7e6c15cd8..92f12e041 100644 --- a/src/x11/events.c +++ b/src/x11/events.c @@ -970,9 +970,6 @@ handle_input_xevent (MetaX11Display *x11_display, switch (input_event->evtype) { case XI_Enter: - if (display->grab_op != META_GRAB_OP_NONE) - break; - if (clutter_stage_get_grab_actor (stage) != NULL) break; @@ -992,9 +989,6 @@ handle_input_xevent (MetaX11Display *x11_display, } break; case XI_Leave: - if (display->grab_op != META_GRAB_OP_NONE) - break; - if (clutter_stage_get_grab_actor (stage) != NULL) break; @@ -1412,10 +1406,6 @@ handle_other_xevent (MetaX11Display *x11_display, guint32 timestamp; 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) { meta_x11_error_trap_push (x11_display); @@ -1440,11 +1430,6 @@ handle_other_xevent (MetaX11Display *x11_display, guint32 timestamp; 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 (window->unmaps_pending == 0) diff --git a/src/x11/meta-sync-counter.c b/src/x11/meta-sync-counter.c index 39aca58a1..2ac665856 100644 --- a/src/x11/meta-sync-counter.c +++ b/src/x11/meta-sync-counter.c @@ -191,6 +191,7 @@ sync_request_timeout (gpointer data) { MetaSyncCounter *sync_counter = data; MetaWindow *window = sync_counter->window; + MetaWindowDrag *window_drag; sync_counter->sync_request_timeout_id = 0; @@ -205,8 +206,12 @@ sync_request_timeout (gpointer data) sync_counter->sync_request_wait_serial = 0; meta_compositor_sync_updates_frozen (window->display->compositor, window); - if (window == window->display->grab_window && - meta_grab_op_is_resizing (window->display->grab_op)) + window_drag = + 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); return G_SOURCE_REMOVE; diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 6e9a48cb4..63e1aaf9d 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -1310,8 +1310,8 @@ meta_window_x11_move_resize_internal (MetaWindow *window, gboolean need_resize_frame = FALSE; gboolean frame_shape_changed = FALSE; gboolean configure_frame_first; - gboolean is_configure_request; + MetaWindowDrag *window_drag; 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); + window_drag = + meta_compositor_get_current_window_drag (window->display->compositor); + if (mask != 0 && - window == window->display->grab_window && - meta_grab_op_is_resizing (window->display->grab_op)) + window_drag && + 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); if (window->frame) @@ -2642,6 +2646,7 @@ meta_window_move_resize_request (MetaWindow *window, gboolean in_grab_op; MetaMoveResizeFlags flags; MetaRectangle buffer_rect; + MetaWindowDrag *window_drag; /* We ignore configure requests while the user is moving/resizing * 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 * app asked for the current size/position instead of the new one. */ - in_grab_op = (window->display->grab_window == window && - meta_grab_op_is_mouse (window->display->grab_op)); + window_drag = + 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, * 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); width = buffer_rect.width; 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) width = new_width; @@ -3271,6 +3280,7 @@ meta_window_x11_client_message (MetaWindow *window, MetaGrabOp op; int button; guint32 timestamp; + MetaWindowDrag *window_drag; x_root = event->xclient.data.l[0]; y_root = event->xclient.data.l[1]; @@ -3327,9 +3337,13 @@ meta_window_x11_client_message (MetaWindow *window, break; } + window_drag = + meta_compositor_get_current_window_drag (window->display->compositor); + 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 && ((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) button = 3; - if (button == 0) - meta_display_end_grab_op (window->display, timestamp); + if (button == 0 && window_drag) + meta_window_drag_end (window_drag); } else { @@ -3383,8 +3397,8 @@ meta_window_x11_client_message (MetaWindow *window, * drag immediately. */ - if ((button_mask & (1 << button)) == 0) - meta_display_end_grab_op (window->display, timestamp); + if (window_drag && (button_mask & (1 << button)) == 0) + 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); MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11); + MetaWindowDrag *window_drag; if (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)) return; - meta_window_update_resize (window, - window->display->grab_last_edge_resistance_flags, - window->display->grab_latest_motion_x, - window->display->grab_latest_motion_y); + window_drag = + meta_compositor_get_current_window_drag (window->display->compositor); + meta_window_drag_update_resize (window_drag); } gboolean