1
0
Fork 0

window: Add a meta_window_get_titlebar_rect

This commit is contained in:
Jasper St. Pierre 2014-05-22 16:48:58 -04:00
parent 0890eaa3fe
commit 3a0af0faae
4 changed files with 35 additions and 26 deletions

View file

@ -637,13 +637,10 @@ update_onscreen_requirements (MetaWindow *window,
*/
if (window->frame && window->decorated)
{
MetaFrameBorders borders;
MetaRectangle titlebar_rect;
meta_frame_calc_borders (window->frame, &borders);
meta_window_get_titlebar_rect (window, &titlebar_rect);
titlebar_rect = info->current;
titlebar_rect.height = borders.visible.top;
old = window->require_titlebar_visible;
window->require_titlebar_visible =
meta_rectangle_overlaps_with_region (info->usable_screen_region,

View file

@ -82,6 +82,7 @@ find_next_cascade (MetaWindow *window,
GList *tmp;
GList *sorted;
int cascade_x, cascade_y;
MetaRectangle titlebar_rect;
int x_threshold, y_threshold;
MetaRectangle frame_rect;
int window_width, window_height;
@ -102,19 +103,9 @@ find_next_cascade (MetaWindow *window,
* manually cascade.
*/
#define CASCADE_FUZZ 15
if (window->frame)
{
MetaFrameBorders borders;
meta_frame_calc_borders (window->frame, &borders);
x_threshold = MAX (borders.visible.left, CASCADE_FUZZ);
y_threshold = MAX (borders.visible.top, CASCADE_FUZZ);
}
else
{
x_threshold = CASCADE_FUZZ;
y_threshold = CASCADE_FUZZ;
}
meta_window_get_titlebar_rect (window, &titlebar_rect);
x_threshold = MAX (titlebar_rect.x, CASCADE_FUZZ);
y_threshold = MAX (titlebar_rect.y, CASCADE_FUZZ);
/* Find furthest-SE origin of all workspaces.
* cascade_x, cascade_y are the target position
@ -151,13 +142,11 @@ find_next_cascade (MetaWindow *window,
if (ABS (wx - cascade_x) < x_threshold &&
ABS (wy - cascade_y) < y_threshold)
{
/* This window is "in the way", move to next cascade
* point. The new window frame should go at the origin
* of the client window we're stacking above.
*/
meta_window_get_position (w, &wx, &wy);
cascade_x = wx;
cascade_y = wy;
meta_window_get_titlebar_rect (w, &titlebar_rect);
/* Cascade the window evenly by the titlebar height; this isn't a typo. */
cascade_x = wx + titlebar_rect.height;
cascade_y = wy + titlebar_rect.height;
/* If we go off the screen, start over with a new cascade */
if (((cascade_x + window_width) >

View file

@ -703,6 +703,8 @@ Window meta_window_get_toplevel_xwindow (MetaWindow *window);
void meta_window_get_client_area_rect (const MetaWindow *window,
cairo_rectangle_int_t *rect);
void meta_window_get_titlebar_rect (MetaWindow *window,
MetaRectangle *titlebar_rect);
void meta_window_activate_full (MetaWindow *window,
guint32 timestamp,

View file

@ -4310,6 +4310,28 @@ meta_window_get_client_area_rect (const MetaWindow *window,
rect->height = window->rect.height;
}
void
meta_window_get_titlebar_rect (MetaWindow *window,
MetaRectangle *rect)
{
meta_window_get_frame_rect (window, rect);
/* The returned rectangle is relative to the frame rect. */
rect->x = 0;
rect->y = 0;
if (window->frame)
{
rect->height = window->frame->child_y;
}
else
{
/* Pick an arbitrary height for a titlebar. We might want to
* eventually have CSD windows expose their borders to us. */
rect->height = 15;
}
}
const char*
meta_window_get_startup_id (MetaWindow *window)
{
@ -5381,8 +5403,7 @@ meta_window_titlebar_is_onscreen (MetaWindow *window)
return TRUE;
/* Get the rectangle corresponding to the titlebar */
meta_window_get_frame_rect (window, &titlebar_rect);
titlebar_rect.height = window->frame->child_y;
meta_window_get_titlebar_rect (window, &titlebar_rect);
/* Run through the spanning rectangles for the screen and see if one of
* them overlaps with the titlebar sufficiently to consider it onscreen.