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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
This commit is contained in:
Carlos Garnacho 2022-10-27 18:11:21 +02:00 committed by Marge Bot
parent 60f11e419f
commit 675d0df09b
7 changed files with 26 additions and 12 deletions

View File

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

View File

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

View File

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

View File

@ -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 */

View File

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

View File

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

View File

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