window: Replace meta_window_resize_with_gravity with a frame-rect variant

More low-hanging fruit for our window geometry cleanups...
This commit is contained in:
Jasper St. Pierre 2014-05-20 18:28:56 -04:00
parent 43762da9d3
commit 1c94df2553
5 changed files with 32 additions and 48 deletions

View File

@ -1218,13 +1218,8 @@ meta_window_edge_resistance_for_move (MetaWindow *window,
}
}
/* Note that old_(width|height) and new_(width|height) are with respect to
* sizes of the inner window.
*/
void
meta_window_edge_resistance_for_resize (MetaWindow *window,
int old_width,
int old_height,
int *new_width,
int *new_height,
int gravity,
@ -1237,8 +1232,8 @@ meta_window_edge_resistance_for_resize (MetaWindow *window,
gboolean is_resize;
meta_window_get_frame_rect (window, &old_outer);
proposed_outer_width = old_outer.width + (*new_width - old_width);
proposed_outer_height = old_outer.height + (*new_height - old_height);
proposed_outer_width = *new_width;
proposed_outer_height = *new_height;
meta_rectangle_resize_with_gravity (&old_outer,
&new_outer,
gravity,
@ -1256,8 +1251,8 @@ meta_window_edge_resistance_for_resize (MetaWindow *window,
is_keyboard_op,
is_resize))
{
*new_width = old_width + (new_outer.width - old_outer.width);
*new_height = old_height + (new_outer.height - old_outer.height);
*new_width = new_outer.width;
*new_height = new_outer.height;
meta_topic (META_DEBUG_EDGE_RESISTANCE,
"outer width & height got changed from %d,%d to %d,%d\n",

View File

@ -33,8 +33,6 @@ void meta_window_edge_resistance_for_move (MetaWindow *window,
gboolean snap,
gboolean is_keyboard_op);
void meta_window_edge_resistance_for_resize (MetaWindow *window,
int old_width,
int old_height,
int *new_width,
int *new_height,
int gravity,

View File

@ -2166,6 +2166,7 @@ process_keyboard_resize_grab (MetaDisplay *display,
MetaWindow *window,
ClutterKeyEvent *event)
{
MetaRectangle frame_rect;
gboolean handled;
int height_inc;
int width_inc;
@ -2202,6 +2203,10 @@ process_keyboard_resize_grab (MetaDisplay *display,
width = window->rect.width;
height = window->rect.height;
meta_window_get_frame_rect (window, &frame_rect);
width = frame_rect.width;
height = frame_rect.height;
gravity = meta_resize_gravity_from_grab_op (display->grab_op);
smart_snap = (event->modifier_state & CLUTTER_SHIFT_MASK) != 0;
@ -2359,18 +2364,13 @@ process_keyboard_resize_grab (MetaDisplay *display,
if (handled)
{
MetaRectangle old_rect;
meta_topic (META_DEBUG_KEYBINDINGS,
"Computed new window size due to keypress: "
"%dx%d, gravity %s\n",
width, height, meta_gravity_to_string (gravity));
old_rect = window->rect; /* Don't actually care about x,y */
/* Do any edge resistance/snapping */
meta_window_edge_resistance_for_resize (window,
old_rect.width,
old_rect.height,
&width,
&height,
gravity,
@ -2378,15 +2378,11 @@ process_keyboard_resize_grab (MetaDisplay *display,
smart_snap,
TRUE);
/* We don't need to update unless the specified width and height
* are actually different from what we had before.
*/
if (window->rect.width != width || window->rect.height != height)
meta_window_resize_with_gravity (window,
TRUE,
width,
height,
gravity);
meta_window_resize_frame_with_gravity (window,
TRUE,
width,
height,
gravity);
meta_window_update_keyboard_resize (window, FALSE);
}

View File

@ -539,8 +539,6 @@ void meta_window_update_fullscreen_monitors (MetaWindow *window,
unsigned long left,
unsigned long right);
/* args to move are window pos, not frame pos */
void meta_window_move (MetaWindow *window,
gboolean user_op,
int root_x_nw,
@ -551,11 +549,12 @@ void meta_window_move_resize (MetaWindow *window,
int root_y_nw,
int w,
int h);
void meta_window_resize_with_gravity (MetaWindow *window,
gboolean user_op,
int w,
int h,
int gravity);
void meta_window_resize_frame_with_gravity (MetaWindow *window,
gboolean user_op,
int w,
int h,
int gravity);
void meta_window_change_workspace (MetaWindow *window,
MetaWorkspace *workspace);

View File

@ -3176,10 +3176,12 @@ meta_window_unmaximize_with_gravity (MetaWindow *window,
{
MetaRectangle desired_rect;
meta_window_get_position (window, &desired_rect.x, &desired_rect.y);
desired_rect.width = new_width;
desired_rect.height = new_height;
meta_window_frame_rect_to_client_rect (window, &desired_rect, &desired_rect);
meta_window_get_position (window, &desired_rect.x, &desired_rect.y);
meta_window_unmaximize_internal (window, directions, &desired_rect, gravity);
}
@ -3910,11 +3912,11 @@ meta_window_move_resize (MetaWindow *window,
}
void
meta_window_resize_with_gravity (MetaWindow *window,
gboolean user_op,
int w,
int h,
int gravity)
meta_window_resize_frame_with_gravity (MetaWindow *window,
gboolean user_op,
int w,
int h,
int gravity)
{
MetaMoveResizeFlags flags;
MetaRectangle rect;
@ -3922,6 +3924,8 @@ meta_window_resize_with_gravity (MetaWindow *window,
rect.width = w;
rect.height = h;
meta_window_frame_rect_to_client_rect (window, &rect, &rect);
flags = (user_op ? META_IS_USER_ACTION : 0) | META_IS_RESIZE_ACTION;
meta_window_move_resize_internal (window, flags, gravity, rect);
}
@ -5998,7 +6002,7 @@ update_resize (MetaWindow *window,
window->display->grab_resize_timeout_id = 0;
}
old = window->rect; /* Don't actually care about x,y */
meta_window_get_frame_rect (window, &old);
/* One sided resizing ought to actually be one-sided, despite the fact that
* aspect ratio windows don't interact nicely with the above stuff. So,
@ -6026,8 +6030,6 @@ update_resize (MetaWindow *window,
/* Do any edge resistance/snapping */
meta_window_edge_resistance_for_resize (window,
old.width,
old.height,
&new_w,
&new_h,
gravity,
@ -6037,13 +6039,7 @@ update_resize (MetaWindow *window,
if (new_unmaximize == window->display->grab_resize_unmaximize)
{
/* We don't need to update unless the specified width and height
* are actually different from what we had before.
*/
if (old.width != new_w || old.height != new_h)
{
meta_window_resize_with_gravity (window, TRUE, new_w, new_h, gravity);
}
meta_window_resize_frame_with_gravity (window, TRUE, new_w, new_h, gravity);
}
else
{