From 60f11e419f708034f88ea53c55835383a2dfacc9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 27 Oct 2022 18:01:02 +0200 Subject: [PATCH] compositor: Pass MetaWindowDrag to edge resistance functions This code will be poked exclusively from the MetaWindowDrag, so change the API to start passing this object around. Part-of: --- src/compositor/edge-resistance.c | 24 +++++++++++++-------- src/compositor/edge-resistance.h | 21 ++++++++++-------- src/compositor/meta-window-drag.c | 36 +++++++++++++++---------------- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/compositor/edge-resistance.c b/src/compositor/edge-resistance.c index 06ed81a5e..1426f1dab 100644 --- a/src/compositor/edge-resistance.c +++ b/src/compositor/edge-resistance.c @@ -1065,13 +1065,16 @@ compute_resistance_and_snapping_edges (MetaDisplay *display) } void -meta_window_edge_resistance_for_move (MetaWindow *window, - int *new_x, - int *new_y, - MetaEdgeResistanceFlags flags) +meta_window_drag_edge_resistance_for_move (MetaWindowDrag *window_drag, + int *new_x, + int *new_y, + MetaEdgeResistanceFlags flags) { MetaRectangle old_outer, proposed_outer, new_outer; gboolean is_resize, is_keyboard_op, snap; + MetaWindow *window; + + window = meta_window_drag_get_window (window_drag); meta_window_get_frame_rect (window, &old_outer); @@ -1141,14 +1144,17 @@ meta_window_edge_resistance_for_move (MetaWindow *window, } void -meta_window_edge_resistance_for_resize (MetaWindow *window, - int *new_width, - int *new_height, - MetaGravity gravity, - MetaEdgeResistanceFlags flags) +meta_window_drag_edge_resistance_for_resize (MetaWindowDrag *window_drag, + int *new_width, + int *new_height, + MetaGravity gravity, + MetaEdgeResistanceFlags flags) { MetaRectangle old_outer, new_outer; int proposed_outer_width, proposed_outer_height; + MetaWindow *window; + + window = meta_window_drag_get_window (window_drag); meta_window_get_frame_rect (window, &old_outer); proposed_outer_width = *new_width; diff --git a/src/compositor/edge-resistance.h b/src/compositor/edge-resistance.h index a1df48029..58b7a5f82 100644 --- a/src/compositor/edge-resistance.h +++ b/src/compositor/edge-resistance.h @@ -24,15 +24,18 @@ #include "core/window-private.h" -void meta_window_edge_resistance_for_move (MetaWindow *window, - int *new_x, - int *new_y, - MetaEdgeResistanceFlags flags); -void meta_window_edge_resistance_for_resize (MetaWindow *window, - int *new_width, - int *new_height, - MetaGravity gravity, - MetaEdgeResistanceFlags flags); +#include "compositor/meta-window-drag.h" + +void meta_window_drag_edge_resistance_for_move (MetaWindowDrag *window_drag, + int *new_x, + int *new_y, + MetaEdgeResistanceFlags flags); + +void meta_window_drag_edge_resistance_for_resize (MetaWindowDrag *window_drag, + int *new_width, + int *new_height, + MetaGravity gravity, + MetaEdgeResistanceFlags flags); #endif /* META_EDGE_RESISTANCE_H */ diff --git a/src/compositor/meta-window-drag.c b/src/compositor/meta-window-drag.c index c272ea50d..ca3156307 100644 --- a/src/compositor/meta-window-drag.c +++ b/src/compositor/meta-window-drag.c @@ -615,10 +615,10 @@ process_keyboard_move_grab (MetaWindowDrag *window_drag, window_drag->last_edge_resistance_flags = flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP; - meta_window_edge_resistance_for_move (window, - &x, - &y, - flags); + meta_window_drag_edge_resistance_for_move (window_drag, + &x, + &y, + flags); meta_window_move_frame (window, TRUE, x, y); update_keyboard_move (window_drag); @@ -970,11 +970,11 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag, flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP; /* Do any edge resistance/snapping */ - meta_window_edge_resistance_for_resize (window, - &width, - &height, - gravity, - flags); + meta_window_drag_edge_resistance_for_resize (window_drag, + &width, + &height, + gravity, + flags); meta_window_resize_frame_with_gravity (window, TRUE, @@ -1271,10 +1271,10 @@ update_move (MetaWindowDrag *window_drag, flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP; /* Do any edge resistance/snapping */ - meta_window_edge_resistance_for_move (window, - &new_x, - &new_y, - flags); + meta_window_drag_edge_resistance_for_move (window_drag, + &new_x, + &new_y, + flags); meta_window_move_frame (window, TRUE, new_x, new_y); } @@ -1427,11 +1427,11 @@ update_resize (MetaWindowDrag *window_drag, flags & ~META_EDGE_RESISTANCE_KEYBOARD_OP; /* Do any edge resistance/snapping */ - meta_window_edge_resistance_for_resize (window, - &new_rect.width, - &new_rect.height, - gravity, - flags); + meta_window_drag_edge_resistance_for_resize (window_drag, + &new_rect.width, + &new_rect.height, + gravity, + flags); meta_window_resize_frame_with_gravity (window, TRUE, new_rect.width, new_rect.height,