From 675d0df09b1119a6bb5562252ec8ce630b1009e2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 27 Oct 2022 18:11:21 +0200 Subject: [PATCH] compositor: Make cleaning cached edges go through MetaWindowDrag Even though the data is still stored in the display, add a "high level" meta_window_drag_update_edges() call, so that the cached edges may be updated while a window drag operation is ongoing. Part-of: --- src/compositor/edge-resistance.c | 4 +++- src/compositor/edge-resistance.h | 2 ++ src/compositor/meta-window-drag.c | 8 +++++++- src/compositor/meta-window-drag.h | 2 ++ src/core/display-private.h | 3 --- src/core/display.c | 2 -- src/core/workspace.c | 17 ++++++++++++----- 7 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/compositor/edge-resistance.c b/src/compositor/edge-resistance.c index 1426f1dab..deccd6802 100644 --- a/src/compositor/edge-resistance.c +++ b/src/compositor/edge-resistance.c @@ -631,8 +631,10 @@ apply_edge_resistance_to_each_side (MetaDisplay *display, } void -meta_display_cleanup_edges (MetaDisplay *display) +meta_window_drag_edge_resistance_cleanup (MetaWindowDrag *window_drag) { + MetaWindow *window = meta_window_drag_get_window (window_drag); + MetaDisplay *display = window->display; guint i,j; MetaEdgeResistanceData *edge_data = display->grab_edge_resistance_data; GHashTable *edges_to_be_freed; diff --git a/src/compositor/edge-resistance.h b/src/compositor/edge-resistance.h index 58b7a5f82..20ce62562 100644 --- a/src/compositor/edge-resistance.h +++ b/src/compositor/edge-resistance.h @@ -26,6 +26,8 @@ #include "compositor/meta-window-drag.h" +void meta_window_drag_edge_resistance_cleanup (MetaWindowDrag *window_drag); + void meta_window_drag_edge_resistance_for_move (MetaWindowDrag *window_drag, int *new_x, int *new_y, diff --git a/src/compositor/meta-window-drag.c b/src/compositor/meta-window-drag.c index ca3156307..33ef0dda0 100644 --- a/src/compositor/meta-window-drag.c +++ b/src/compositor/meta-window-drag.c @@ -277,7 +277,7 @@ meta_window_drag_end (MetaWindowDrag *window_drag) g_assert (grab_window != NULL); /* Clear out the edge cache */ - meta_display_cleanup_edges (display); + meta_window_drag_update_edges (window_drag); /* Only raise the window in orthogonal raise * ('do-not-raise-on-click') mode if the user didn't try to move @@ -1815,3 +1815,9 @@ meta_window_drag_get_grab_op (MetaWindowDrag *window_drag) { return window_drag->grab_op; } + +void +meta_window_drag_update_edges (MetaWindowDrag *window_drag) +{ + meta_window_drag_edge_resistance_cleanup (window_drag); +} diff --git a/src/compositor/meta-window-drag.h b/src/compositor/meta-window-drag.h index 65fbe6ab6..7fe501dd4 100644 --- a/src/compositor/meta-window-drag.h +++ b/src/compositor/meta-window-drag.h @@ -45,4 +45,6 @@ MetaWindow * meta_window_drag_get_window (MetaWindowDrag *window_drag); MetaGrabOp meta_window_drag_get_grab_op (MetaWindowDrag *window_drag); +void meta_window_drag_update_edges (MetaWindowDrag *window_drag); + #endif /* META_WINDOW_DRAG_H */ diff --git a/src/core/display-private.h b/src/core/display-private.h index e4f28d725..b60f5039b 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -268,9 +268,6 @@ void meta_display_grab_focus_window_button (MetaDisplay *display, void meta_display_ungrab_focus_window_button (MetaDisplay *display, MetaWindow *window); -/* Next function is defined in edge-resistance.c */ -void meta_display_cleanup_edges (MetaDisplay *display); - /* utility goo */ const char* meta_event_mode_to_string (int m); const char* meta_event_detail_to_string (int d); diff --git a/src/core/display.c b/src/core/display.c index 1f82b155a..019dbc85d 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -898,8 +898,6 @@ meta_display_new (MetaContext *context, display->current_time = META_CURRENT_TIME; - meta_display_cleanup_edges (display); - meta_display_init_keys (display); meta_prefs_add_listener (prefs_changed_callback, display); diff --git a/src/core/workspace.c b/src/core/workspace.c index 87f4fccec..dfdb6e1fb 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -590,9 +590,13 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace, return; } + window_drag = + meta_compositor_get_current_window_drag (workspace->display->compositor); + /* Free any cached pointers to the workspaces's edges from * a current resize or move operation */ - meta_display_cleanup_edges (workspace->display); + if (window_drag) + meta_window_drag_update_edges (window_drag); if (workspace->manager->active_workspace) workspace_switch_sound (workspace->manager->active_workspace, workspace); @@ -619,8 +623,6 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace, g_signal_emit_by_name (workspace->manager, "showing-desktop-changed"); move_window = NULL; - 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); @@ -787,6 +789,7 @@ meta_workspace_list_windows (MetaWorkspace *workspace) void meta_workspace_invalidate_work_area (MetaWorkspace *workspace) { + MetaWindowDrag *window_drag; GList *windows, *l; if (workspace->work_areas_invalid) @@ -801,10 +804,14 @@ meta_workspace_invalidate_work_area (MetaWorkspace *workspace) "Invalidating work area for workspace %d", meta_workspace_index (workspace)); + window_drag = + meta_compositor_get_current_window_drag (workspace->display->compositor); + /* If we are in the middle of a resize or move operation, we * might have cached pointers to the workspace's edges */ - if (workspace == workspace->manager->active_workspace) - meta_display_cleanup_edges (workspace->display); + if (window_drag && + workspace == workspace->manager->active_workspace) + meta_window_drag_update_edges (window_drag); meta_workspace_clear_logical_monitor_data (workspace);