window.c: add meta_window_move_resize_frame

meta_window_move_resize_frame operates much like
meta_window_move_resize, but ensures the window
and its frame (if present) will fit within the
specified dimensions.

https://bugzilla.gnome.org/show_bug.cgi?id=651899
This commit is contained in:
Tim Cuthbertson 2011-06-05 11:02:44 +10:00 committed by Jasper St. Pierre
parent 3beb33bb44
commit 4fb2fab7f7
2 changed files with 36 additions and 0 deletions

View File

@ -4996,6 +4996,41 @@ meta_window_move_between_rects (MetaWindow *window,
window->user_rect.height);
}
/**
* meta_window_move_resize_frame:
* @window: a #MetaWindow
* @user_op: bool to indicate whether or not this is a user operation
* @root_x_nw: new x
* @root_y_nw: new y
* @w: desired width
* @h: desired height
*
* Resizes the window so that its outer bounds (including frame)
* fit within the given rect
*/
void
meta_window_move_resize_frame (MetaWindow *window,
gboolean user_op,
int root_x_nw,
int root_y_nw,
int w,
int h)
{
if (window->frame)
{
MetaFrameBorders borders;
meta_frame_calc_borders (window->frame, &borders);
/* offset by the distance between the origin of the window
* and the origin of the enclosing window decorations ( + border)
*/
root_x_nw += borders.visible.left;
root_y_nw += borders.visible.top;
w -= borders.visible.left + borders.visible.right;
h -= borders.visible.top + borders.visible.bottom;
}
meta_window_move_resize (window, user_op, root_x_nw, root_y_nw, w, h);
}
/**
* meta_window_move_to_monitor:
* @window: a #MetaWindow

View File

@ -97,6 +97,7 @@ gboolean meta_window_showing_on_its_workspace (MetaWindow *window);
void meta_window_move(MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw);
void meta_window_move_frame(MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw);
void meta_window_move_resize_frame (MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw, int w, int h);
void meta_window_move_to_monitor (MetaWindow *window, int monitor);
void meta_window_resize(MetaWindow *window, gboolean user_op, int w, int h);