Replace public MetaFrameGeometry with MetaFrameBorders

There were actually *two* MetaFrameGeometry structs: one in theme-private.h,
one in frame.h. The latter public struct was populated by a mix of (void*)
casting and int pointers, usually pulling directly from the data in the private
struct.

Remove the public struct, replace it with MetaFrameBorders and scrap all
the pointer hacks to populate it, instead relying on both structs being used
in common code.

This commit should be relatively straightforward, and it should not do any
tricky logic at all, just a sophisticated find and replace.

https://bugzilla.gnome.org/show_bug.cgi?id=644930
This commit is contained in:
Jasper St. Pierre 2011-07-12 00:37:41 -04:00
parent 7e0a56fb80
commit e0fb83c691
18 changed files with 244 additions and 301 deletions

View File

@ -118,7 +118,7 @@ typedef struct
{
MetaRectangle orig;
MetaRectangle current;
MetaFrameGeometry *fgeom;
MetaFrameBorders *borders;
ActionType action_type;
gboolean is_user_action;
@ -194,7 +194,7 @@ static gboolean constrain_partially_onscreen (MetaWindow *window,
static void setup_constraint_info (ConstraintInfo *info,
MetaWindow *window,
MetaFrameGeometry *orig_fgeom,
MetaFrameBorders *orig_borders,
MetaMoveResizeFlags flags,
int resize_gravity,
const MetaRectangle *orig,
@ -204,11 +204,11 @@ static void place_window_if_needed (MetaWindow *window,
static void update_onscreen_requirements (MetaWindow *window,
ConstraintInfo *info);
static void extend_by_frame (MetaRectangle *rect,
const MetaFrameGeometry *fgeom);
const MetaFrameBorders *borders);
static void unextend_by_frame (MetaRectangle *rect,
const MetaFrameGeometry *fgeom);
const MetaFrameBorders *borders);
static inline void get_size_limits (const MetaWindow *window,
const MetaFrameGeometry *fgeom,
const MetaFrameBorders *borders,
gboolean include_frame,
MetaRectangle *min_size,
MetaRectangle *max_size);
@ -279,7 +279,7 @@ do_all_constraints (MetaWindow *window,
void
meta_window_constrain (MetaWindow *window,
MetaFrameGeometry *orig_fgeom,
MetaFrameBorders *orig_borders,
MetaMoveResizeFlags flags,
int resize_gravity,
const MetaRectangle *orig,
@ -302,7 +302,7 @@ meta_window_constrain (MetaWindow *window,
setup_constraint_info (&info,
window,
orig_fgeom,
orig_borders,
flags,
resize_gravity,
orig,
@ -337,14 +337,14 @@ meta_window_constrain (MetaWindow *window,
* not gobject-style--gobject would be more pain than it's worth) or
* smart pointers would be so much nicer here. *shrug*
*/
if (!orig_fgeom)
g_free (info.fgeom);
if (!orig_borders)
g_free (info.borders);
}
static void
setup_constraint_info (ConstraintInfo *info,
MetaWindow *window,
MetaFrameGeometry *orig_fgeom,
MetaFrameBorders *orig_borders,
MetaMoveResizeFlags flags,
int resize_gravity,
const MetaRectangle *orig,
@ -357,10 +357,10 @@ setup_constraint_info (ConstraintInfo *info,
info->current = *new;
/* Create a fake frame geometry if none really exists */
if (orig_fgeom && !window->fullscreen)
info->fgeom = orig_fgeom;
if (orig_borders && !window->fullscreen)
info->borders = orig_borders;
else
info->fgeom = g_new0 (MetaFrameGeometry, 1);
info->borders = g_new0 (MetaFrameBorders, 1);
if (flags & META_IS_MOVE_ACTION && flags & META_IS_RESIZE_ACTION)
info->action_type = ACTION_MOVE_AND_RESIZE;
@ -461,7 +461,6 @@ setup_constraint_info (ConstraintInfo *info,
"Setting up constraint info:\n"
" orig: %d,%d +%d,%d\n"
" new : %d,%d +%d,%d\n"
" fgeom: %d,%d,%d,%d\n"
" action_type : %s\n"
" is_user_action : %s\n"
" resize_gravity : %s\n"
@ -471,8 +470,6 @@ setup_constraint_info (ConstraintInfo *info,
info->orig.x, info->orig.y, info->orig.width, info->orig.height,
info->current.x, info->current.y,
info->current.width, info->current.height,
info->fgeom->left_width, info->fgeom->right_width,
info->fgeom->top_height, info->fgeom->bottom_height,
(info->action_type == ACTION_MOVE) ? "Move" :
(info->action_type == ACTION_RESIZE) ? "Resize" :
(info->action_type == ACTION_MOVE_AND_RESIZE) ? "Move&Resize" :
@ -513,7 +510,7 @@ place_window_if_needed(MetaWindow *window,
MetaWorkspace *cur_workspace;
const MetaMonitorInfo *monitor_info;
meta_window_place (window, info->fgeom, info->orig.x, info->orig.y,
meta_window_place (window, info->borders, info->orig.x, info->orig.y,
&placed_rect.x, &placed_rect.y);
did_placement = TRUE;
@ -573,7 +570,7 @@ place_window_if_needed(MetaWindow *window,
/* maximization may have changed frame geometry */
if (window->frame && !window->fullscreen)
meta_frame_calc_geometry (window->frame, info->fgeom);
meta_frame_calc_borders (window->frame, info->borders);
if (window->fullscreen_after_placement)
{
@ -634,7 +631,7 @@ update_onscreen_requirements (MetaWindow *window,
/* The require onscreen/on-single-monitor and titlebar_visible
* stuff is relative to the outer window, not the inner
*/
extend_by_frame (&info->current, info->fgeom);
extend_by_frame (&info->current, info->borders);
/* Update whether we want future constraint runs to require the
* window to be on fully onscreen.
@ -670,7 +667,7 @@ update_onscreen_requirements (MetaWindow *window,
MetaRectangle titlebar_rect;
titlebar_rect = info->current;
titlebar_rect.height = info->fgeom->top_height;
titlebar_rect.height = info->borders->visible.top;
old = window->require_titlebar_visible;
window->require_titlebar_visible =
meta_rectangle_overlaps_with_region (info->usable_screen_region,
@ -683,32 +680,32 @@ update_onscreen_requirements (MetaWindow *window,
}
/* Don't forget to restore the position of the window */
unextend_by_frame (&info->current, info->fgeom);
unextend_by_frame (&info->current, info->borders);
}
static void
extend_by_frame (MetaRectangle *rect,
const MetaFrameGeometry *fgeom)
const MetaFrameBorders *borders)
{
rect->x -= fgeom->left_width;
rect->y -= fgeom->top_height;
rect->width += fgeom->left_width + fgeom->right_width;
rect->height += fgeom->top_height + fgeom->bottom_height;
rect->x -= borders->visible.left;
rect->y -= borders->visible.top;
rect->width += borders->visible.left + borders->visible.right;
rect->height += borders->visible.top + borders->visible.bottom;
}
static void
unextend_by_frame (MetaRectangle *rect,
const MetaFrameGeometry *fgeom)
const MetaFrameBorders *borders)
{
rect->x += fgeom->left_width;
rect->y += fgeom->top_height;
rect->width -= fgeom->left_width + fgeom->right_width;
rect->height -= fgeom->top_height + fgeom->bottom_height;
rect->x += borders->visible.left;
rect->y += borders->visible.top;
rect->width -= borders->visible.left + borders->visible.right;
rect->height -= borders->visible.top + borders->visible.bottom;
}
static inline void
get_size_limits (const MetaWindow *window,
const MetaFrameGeometry *fgeom,
const MetaFrameBorders *borders,
gboolean include_frame,
MetaRectangle *min_size,
MetaRectangle *max_size)
@ -723,8 +720,8 @@ get_size_limits (const MetaWindow *window,
if (include_frame)
{
int fw = fgeom->left_width + fgeom->right_width;
int fh = fgeom->top_height + fgeom->bottom_height;
int fw = borders->visible.left + borders->visible.right;
int fh = borders->visible.top + borders->visible.bottom;
min_size->width += fw;
min_size->height += fh;
@ -761,18 +758,18 @@ constrain_modal_dialog (MetaWindow *window,
y = 0;
if (parent->frame)
{
MetaFrameGeometry fgeom;
MetaFrameBorders borders;
x += parent->frame->rect.x;
y += parent->frame->rect.y;
meta_frame_calc_geometry (parent->frame, &fgeom);
y += fgeom.top_height;
meta_frame_calc_borders (parent->frame, &borders);
y += borders.visible.top;
y += info->fgeom->top_height;
y += info->borders->visible.top;
}
else
y = parent->rect.y + info->fgeom->top_height;
y = parent->rect.y + info->borders->visible.top;
constraint_already_satisfied = (x == info->current.x) && (y == info->current.y);
@ -831,19 +828,19 @@ constrain_maximization (MetaWindow *window,
active_workspace_struts = window->screen->active_workspace->all_struts;
target_size = info->current;
extend_by_frame (&target_size, info->fgeom);
extend_by_frame (&target_size, info->borders);
meta_rectangle_expand_to_avoiding_struts (&target_size,
&info->entire_monitor,
direction,
active_workspace_struts);
}
/* Now make target_size = maximized size of client window */
unextend_by_frame (&target_size, info->fgeom);
unextend_by_frame (&target_size, info->borders);
/* Check min size constraints; max size constraints are ignored for maximized
* windows, as per bug 327543.
*/
get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size);
get_size_limits (window, info->borders, FALSE, &min_size, &max_size);
hminbad = target_size.width < min_size.width && window->maximized_horizontally;
vminbad = target_size.height < min_size.height && window->maximized_vertically;
if (hminbad || vminbad)
@ -897,12 +894,12 @@ constrain_tiling (MetaWindow *window,
* use an external function for the actual calculation
*/
meta_window_get_current_tile_area (window, &target_size);
unextend_by_frame (&target_size, info->fgeom);
unextend_by_frame (&target_size, info->borders);
/* Check min size constraints; max size constraints are ignored as for
* maximized windows.
*/
get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size);
get_size_limits (window, info->borders, FALSE, &min_size, &max_size);
hminbad = target_size.width < min_size.width;
vminbad = target_size.height < min_size.height;
if (hminbad || vminbad)
@ -945,7 +942,7 @@ constrain_fullscreen (MetaWindow *window,
monitor = info->entire_monitor;
get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size);
get_size_limits (window, info->borders, FALSE, &min_size, &max_size);
too_big = !meta_rectangle_could_fit_rect (&monitor, &min_size);
too_small = !meta_rectangle_could_fit_rect (&max_size, &monitor);
if (too_big || too_small)
@ -1054,7 +1051,7 @@ constrain_size_limits (MetaWindow *window,
return TRUE;
/* Determine whether constraint is already satisfied; exit if it is */
get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size);
get_size_limits (window, info->borders, FALSE, &min_size, &max_size);
/* We ignore max-size limits for maximized windows; see #327543 */
if (window->maximized_horizontally)
max_size.width = MAX (max_size.width, info->current.width);
@ -1246,8 +1243,8 @@ do_screen_and_monitor_relative_constraints (
/* Determine whether constraint applies; exit if it doesn't */
how_far_it_can_be_smushed = info->current;
get_size_limits (window, info->fgeom, TRUE, &min_size, &max_size);
extend_by_frame (&info->current, info->fgeom);
get_size_limits (window, info->borders, TRUE, &min_size, &max_size);
extend_by_frame (&info->current, info->borders);
if (info->action_type != ACTION_MOVE)
{
@ -1267,7 +1264,7 @@ do_screen_and_monitor_relative_constraints (
&info->current);
if (exit_early || constraint_satisfied || check_only)
{
unextend_by_frame (&info->current, info->fgeom);
unextend_by_frame (&info->current, info->borders);
return constraint_satisfied;
}
@ -1291,7 +1288,7 @@ do_screen_and_monitor_relative_constraints (
info->fixed_directions,
&info->current);
unextend_by_frame (&info->current, info->fgeom);
unextend_by_frame (&info->current, info->borders);
return TRUE;
}
@ -1404,8 +1401,8 @@ constrain_titlebar_visible (MetaWindow *window,
*/
if (window->frame)
{
bottom_amount = info->current.height + info->fgeom->bottom_height;
vert_amount_onscreen = info->fgeom->top_height;
bottom_amount = info->current.height + info->borders->visible.bottom;
vert_amount_onscreen = info->borders->visible.top;
}
else
bottom_amount = vert_amount_offscreen;
@ -1479,8 +1476,8 @@ constrain_partially_onscreen (MetaWindow *window,
*/
if (window->frame)
{
bottom_amount = info->current.height + info->fgeom->bottom_height;
vert_amount_onscreen = info->fgeom->top_height;
bottom_amount = info->current.height + info->borders->visible.bottom;
vert_amount_onscreen = info->borders->visible.top;
}
else
bottom_amount = vert_amount_offscreen;

View File

@ -39,7 +39,7 @@ typedef enum
} MetaMoveResizeFlags;
void meta_window_constrain (MetaWindow *window,
MetaFrameGeometry *orig_fgeom,
MetaFrameBorders *orig_borders,
MetaMoveResizeFlags flags,
int resize_gravity,
const MetaRectangle *orig,

View File

@ -4311,11 +4311,7 @@ process_request_frame_extents (MetaDisplay *display,
&hints);
if ((hints_set && hints->decorations) || !hints_set)
{
int top = 0;
int bottom = 0;
int left = 0;
int right = 0;
MetaFrameBorders borders;
MetaScreen *screen;
screen = meta_display_screen_for_xwindow (display,
@ -4333,15 +4329,11 @@ process_request_frame_extents (MetaDisplay *display,
meta_ui_theme_get_frame_borders (screen->ui,
META_FRAME_TYPE_NORMAL,
0,
&top,
&bottom,
&left,
&right);
data[0] = left;
data[1] = right;
data[2] = top;
data[3] = bottom;
&borders);
data[0] = borders.visible.left;
data[1] = borders.visible.right;
data[2] = borders.visible.top;
data[3] = borders.visible.bottom;
}
meta_topic (META_DEBUG_GEOMETRY,

View File

@ -302,22 +302,12 @@ meta_frame_get_flags (MetaFrame *frame)
}
void
meta_frame_calc_geometry (MetaFrame *frame,
MetaFrameGeometry *geomp)
meta_frame_calc_borders (MetaFrame *frame,
MetaFrameBorders *borders)
{
MetaFrameGeometry geom;
MetaWindow *window;
window = frame->window;
meta_ui_get_frame_geometry (window->screen->ui,
frame->xwindow,
&geom.top_height,
&geom.bottom_height,
&geom.left_width,
&geom.right_width);
*geomp = geom;
meta_ui_get_frame_borders (frame->window->screen->ui,
frame->xwindow,
borders);
}
gboolean

View File

@ -26,17 +26,6 @@
#include "window-private.h"
typedef struct _MetaFrameGeometry MetaFrameGeometry;
struct _MetaFrameGeometry
{
/* border sizes (space between frame and child) */
int left_width;
int right_width;
int top_height;
int bottom_height;
};
struct _MetaFrame
{
/* window we frame */
@ -71,8 +60,9 @@ MetaFrameFlags meta_frame_get_flags (MetaFrame *frame);
Window meta_frame_get_xwindow (MetaFrame *frame);
/* These should ONLY be called from meta_window_move_resize_internal */
void meta_frame_calc_geometry (MetaFrame *frame,
MetaFrameGeometry *geomp);
void meta_frame_calc_borders (MetaFrame *frame,
MetaFrameBorders *borders);
gboolean meta_frame_sync_to_window (MetaFrame *frame,
int gravity,
gboolean need_move,

View File

@ -90,7 +90,7 @@ northwestcmp (gconstpointer a, gconstpointer b)
static void
find_next_cascade (MetaWindow *window,
MetaFrameGeometry *fgeom,
MetaFrameBorders *borders,
/* visible windows on relevant workspaces */
GList *windows,
int x,
@ -120,10 +120,10 @@ find_next_cascade (MetaWindow *window,
* manually cascade.
*/
#define CASCADE_FUZZ 15
if (fgeom)
if (borders)
{
x_threshold = MAX (fgeom->left_width, CASCADE_FUZZ);
y_threshold = MAX (fgeom->top_height, CASCADE_FUZZ);
x_threshold = MAX (borders->visible.left, CASCADE_FUZZ);
y_threshold = MAX (borders->visible.top, CASCADE_FUZZ);
}
else
{
@ -224,21 +224,21 @@ find_next_cascade (MetaWindow *window,
g_list_free (sorted);
/* Convert coords to position of window, not position of frame. */
if (fgeom == NULL)
if (borders == NULL)
{
*new_x = cascade_x;
*new_y = cascade_y;
}
else
{
*new_x = cascade_x + fgeom->left_width;
*new_y = cascade_y + fgeom->top_height;
*new_x = cascade_x + borders->visible.left;
*new_y = cascade_y + borders->visible.top;
}
}
static void
find_most_freespace (MetaWindow *window,
MetaFrameGeometry *fgeom,
MetaFrameBorders *borders,
/* visible windows on relevant workspaces */
MetaWindow *focus_window,
int x,
@ -255,8 +255,8 @@ find_most_freespace (MetaWindow *window,
MetaRectangle avoid;
MetaRectangle outer;
frame_size_left = fgeom ? fgeom->left_width : 0;
frame_size_top = fgeom ? fgeom->top_height : 0;
frame_size_left = borders ? borders->visible.left : 0;
frame_size_top = borders ? borders->visible.top : 0;
meta_window_get_work_area_current_monitor (focus_window, &work_area);
meta_window_get_outer_rect (focus_window, &avoid);
@ -336,7 +336,7 @@ find_most_freespace (MetaWindow *window,
static void
avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
MetaFrameGeometry *fgeom,
MetaFrameBorders *borders,
int *x,
int *y)
{
@ -366,7 +366,7 @@ avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
&focus_window->rect,
&overlap))
{
find_most_freespace (window, fgeom, focus_window, *x, *y, x, y);
find_most_freespace (window, borders, focus_window, *x, *y, x, y);
meta_topic (META_DEBUG_PLACEMENT,
"Dialog window %s was denied focus but may be modal "
"to the focus window; had to move it to avoid the "
@ -506,7 +506,7 @@ center_tile_rect_in_area (MetaRectangle *rect,
*/
static gboolean
find_first_fit (MetaWindow *window,
MetaFrameGeometry *fgeom,
MetaFrameBorders *borders,
/* visible windows on relevant workspaces */
GList *windows,
int monitor,
@ -544,10 +544,10 @@ find_first_fit (MetaWindow *window,
rect.width = window->rect.width;
rect.height = window->rect.height;
if (fgeom)
if (borders)
{
rect.width += fgeom->left_width + fgeom->right_width;
rect.height += fgeom->top_height + fgeom->bottom_height;
rect.width += borders->visible.left + borders->visible.right;
rect.height += borders->visible.top + borders->visible.bottom;
}
#ifdef WITH_VERBOSE_MODE
@ -570,10 +570,10 @@ find_first_fit (MetaWindow *window,
{
*new_x = rect.x;
*new_y = rect.y;
if (fgeom)
if (borders)
{
*new_x += fgeom->left_width;
*new_y += fgeom->top_height;
*new_x += borders->visible.left;
*new_y += borders->visible.top;
}
retval = TRUE;
@ -598,10 +598,10 @@ find_first_fit (MetaWindow *window,
{
*new_x = rect.x;
*new_y = rect.y;
if (fgeom)
if (borders)
{
*new_x += fgeom->left_width;
*new_y += fgeom->top_height;
*new_x += borders->visible.left;
*new_y += borders->visible.top;
}
retval = TRUE;
@ -629,10 +629,10 @@ find_first_fit (MetaWindow *window,
{
*new_x = rect.x;
*new_y = rect.y;
if (fgeom)
if (borders)
{
*new_x += fgeom->left_width;
*new_y += fgeom->top_height;
*new_x += borders->visible.left;
*new_y += borders->visible.top;
}
retval = TRUE;
@ -652,7 +652,7 @@ find_first_fit (MetaWindow *window,
void
meta_window_place (MetaWindow *window,
MetaFrameGeometry *fgeom,
MetaFrameBorders *borders,
int x,
int y,
int *new_x,
@ -662,7 +662,7 @@ meta_window_place (MetaWindow *window,
const MetaMonitorInfo *xi;
/* frame member variables should NEVER be used in here, only
* MetaFrameGeometry. But remember fgeom == NULL
* MetaFrameBorders. But remember borders == NULL
* for undecorated windows. Also, this function should
* NEVER have side effects other than computing the
* placement coordinates.
@ -756,7 +756,7 @@ meta_window_place (MetaWindow *window,
{
meta_topic (META_DEBUG_PLACEMENT,
"Not placing window with PPosition or USPosition set\n");
avoid_being_obscured_as_second_modal_dialog (window, fgeom, &x, &y);
avoid_being_obscured_as_second_modal_dialog (window, borders, &x, &y);
goto done_no_constraints;
}
}
@ -791,13 +791,13 @@ meta_window_place (MetaWindow *window,
y += (parent->rect.height - window->rect.height)/3;
/* put top of child's frame, not top of child's client */
if (fgeom)
y += fgeom->top_height;
if (borders)
y += borders->visible.top;
meta_topic (META_DEBUG_PLACEMENT, "Centered window %s over transient parent\n",
window->desc);
avoid_being_obscured_as_second_modal_dialog (window, fgeom, &x, &y);
avoid_being_obscured_as_second_modal_dialog (window, borders, &x, &y);
goto done;
}
@ -866,7 +866,7 @@ meta_window_place (MetaWindow *window,
x = xi->rect.x;
y = xi->rect.y;
if (find_first_fit (window, fgeom, windows,
if (find_first_fit (window, borders, windows,
xi->number,
x, y, &x, &y))
goto done_check_denied_focus;
@ -900,7 +900,7 @@ meta_window_place (MetaWindow *window,
* fully overlapping window (e.g. starting multiple terminals)
* */
if (x == xi->rect.x && y == xi->rect.y)
find_next_cascade (window, fgeom, windows, x, y, &x, &y);
find_next_cascade (window, borders, windows, x, y, &x, &y);
done_check_denied_focus:
/* If the window is being denied focus and isn't a transient of the
@ -934,7 +934,7 @@ meta_window_place (MetaWindow *window,
x = xi->rect.x;
y = xi->rect.y;
found_fit = find_first_fit (window, fgeom, focus_window_list,
found_fit = find_first_fit (window, borders, focus_window_list,
xi->number,
x, y, &x, &y);
g_list_free (focus_window_list);
@ -944,7 +944,7 @@ meta_window_place (MetaWindow *window,
* as possible.
*/
if (!found_fit)
find_most_freespace (window, fgeom, focus_window, x, y, &x, &y);
find_most_freespace (window, borders, focus_window, x, y, &x, &y);
}
done:

View File

@ -28,7 +28,7 @@
#include "frame.h"
void meta_window_place (MetaWindow *window,
MetaFrameGeometry *fgeom,
MetaFrameBorders *borders,
int x,
int y,
int *new_x,

View File

@ -3530,12 +3530,12 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
if (window->frame)
{
MetaFrameGeometry fgeom;
MetaFrameBorders borders;
meta_frame_calc_geometry (window->frame, &fgeom);
meta_frame_calc_borders (window->frame, &borders);
tile_area.width -= (fgeom.left_width + fgeom.right_width);
tile_area.height -= (fgeom.top_height + fgeom.bottom_height);
tile_area.width -= (borders.visible.left + borders.visible.right);
tile_area.height -= (borders.visible.top + borders.visible.bottom);
}
return tile_area.width >= window->size_hints.min_width &&
@ -4068,7 +4068,7 @@ meta_window_activate_with_workspace (MetaWindow *window,
*/
static void
adjust_for_gravity (MetaWindow *window,
MetaFrameGeometry *fgeom,
MetaFrameBorders *borders,
gboolean coords_assume_border,
int gravity,
MetaRectangle *rect)
@ -4083,12 +4083,12 @@ adjust_for_gravity (MetaWindow *window,
else
bw = 0;
if (fgeom)
if (borders)
{
child_x = fgeom->left_width;
child_y = fgeom->top_height;
frame_width = child_x + rect->width + fgeom->right_width;
frame_height = child_y + rect->height + fgeom->bottom_height;
child_x = borders->visible.left;
child_y = borders->visible.top;
frame_width = child_x + rect->width + borders->visible.right;
frame_height = child_y + rect->height + borders->visible.bottom;
}
else
{
@ -4344,7 +4344,7 @@ meta_window_move_resize_internal (MetaWindow *window,
XWindowChanges values;
unsigned int mask;
gboolean need_configure_notify;
MetaFrameGeometry fgeom;
MetaFrameBorders borders;
gboolean need_move_client = FALSE;
gboolean need_move_frame = FALSE;
gboolean need_resize_client = FALSE;
@ -4389,8 +4389,8 @@ meta_window_move_resize_internal (MetaWindow *window,
old_rect.x, old_rect.y, old_rect.width, old_rect.height);
if (window->frame)
meta_frame_calc_geometry (window->frame,
&fgeom);
meta_frame_calc_borders (window->frame,
&borders);
new_rect.x = root_x_nw;
new_rect.y = root_y_nw;
@ -4417,7 +4417,7 @@ meta_window_move_resize_internal (MetaWindow *window,
else if (is_configure_request || do_gravity_adjust)
{
adjust_for_gravity (window,
window->frame ? &fgeom : NULL,
window->frame ? &borders : NULL,
/* configure request coords assume
* the border width existed
*/
@ -4432,7 +4432,7 @@ meta_window_move_resize_internal (MetaWindow *window,
}
meta_window_constrain (window,
window->frame ? &fgeom : NULL,
window->frame ? &borders : NULL,
flags,
gravity,
&old_rect,
@ -4454,12 +4454,12 @@ meta_window_move_resize_internal (MetaWindow *window,
{
int new_w, new_h;
new_w = window->rect.width + fgeom.left_width + fgeom.right_width;
new_w = window->rect.width + borders.visible.left + borders.visible.right;
if (window->shaded)
new_h = fgeom.top_height;
new_h = borders.visible.top;
else
new_h = window->rect.height + fgeom.top_height + fgeom.bottom_height;
new_h = window->rect.height + borders.visible.top + borders.visible.bottom;
frame_size_dx = new_w - window->frame->rect.width;
frame_size_dy = new_h - window->frame->rect.height;
@ -4501,8 +4501,8 @@ meta_window_move_resize_internal (MetaWindow *window,
int frame_pos_dx, frame_pos_dy;
/* Compute new frame coords */
new_x = root_x_nw - fgeom.left_width;
new_y = root_y_nw - fgeom.top_height;
new_x = root_x_nw - borders.visible.left;
new_y = root_y_nw - borders.visible.top;
frame_pos_dx = new_x - window->frame->rect.x;
frame_pos_dy = new_y - window->frame->rect.y;
@ -4525,8 +4525,8 @@ meta_window_move_resize_internal (MetaWindow *window,
* remember they are the server coords
*/
new_x = fgeom.left_width;
new_y = fgeom.top_height;
new_x = borders.visible.left;
new_y = borders.visible.top;
if (need_resize_frame && need_move_frame &&
static_gravity_works (window->display))
@ -4597,15 +4597,15 @@ meta_window_move_resize_internal (MetaWindow *window,
/* If frame extents have changed, fill in other frame fields and
change frame's extents property. */
if (window->frame &&
(window->frame->child_x != fgeom.left_width ||
window->frame->child_y != fgeom.top_height ||
window->frame->right_width != fgeom.right_width ||
window->frame->bottom_height != fgeom.bottom_height))
(window->frame->child_x != borders.visible.left ||
window->frame->child_y != borders.visible.top ||
window->frame->right_width != borders.visible.right ||
window->frame->bottom_height != borders.visible.bottom))
{
window->frame->child_x = fgeom.left_width;
window->frame->child_y = fgeom.top_height;
window->frame->right_width = fgeom.right_width;
window->frame->bottom_height = fgeom.bottom_height;
window->frame->child_x = borders.visible.left;
window->frame->child_y = borders.visible.top;
window->frame->right_width = borders.visible.right;
window->frame->bottom_height = borders.visible.bottom;
update_net_frame_extents (window);
}

View File

@ -25,9 +25,10 @@
#ifndef META_COMMON_H
#define META_COMMON_H
/* Don't include GTK or core headers here */
/* Don't include core headers here */
#include <X11/Xlib.h>
#include <glib.h>
#include <gtk/gtk.h>
typedef struct _MetaResizePopup MetaResizePopup;
@ -302,6 +303,14 @@ struct _MetaButtonLayout
gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
};
typedef struct _MetaFrameBorders MetaFrameBorders;
struct _MetaFrameBorders
{
/* The frame border is made up of two pieces - an inner visible portion
* and an outer portion that is invisible but responds to events.
*/
GtkBorder visible;
};
/* should investigate changing these to whatever most apps use */
#define META_ICON_WIDTH 32
#define META_ICON_HEIGHT 32

View File

@ -52,11 +52,7 @@ struct _MetaPreview
PangoLayout *layout;
int text_height;
int left_width;
int right_width;
int top_height;
int bottom_height;
MetaFrameBorders borders;
MetaButtonLayout button_layout;
};

View File

@ -790,10 +790,9 @@ meta_frames_lookup_window (MetaFrames *frames,
}
void
meta_frames_get_geometry (MetaFrames *frames,
Window xwindow,
int *top_height, int *bottom_height,
int *left_width, int *right_width)
meta_frames_get_borders (MetaFrames *frames,
Window xwindow,
MetaFrameBorders *borders)
{
MetaFrameFlags flags;
MetaUIFrame *frame;
@ -822,8 +821,7 @@ meta_frames_get_geometry (MetaFrames *frames,
type,
frame->text_height,
flags,
top_height, bottom_height,
left_width, right_width);
borders);
}
void
@ -2051,6 +2049,7 @@ populate_cache (MetaFrames *frames,
MetaUIFrame *frame)
{
int top, bottom, left, right;
MetaFrameBorders borders;
int width, height;
int frame_width, frame_height, screen_width, screen_height;
CachedPixels *pixels;
@ -2081,7 +2080,12 @@ populate_cache (MetaFrames *frames,
frame_type,
frame->text_height,
frame_flags,
&top, &bottom, &left, &right);
&borders);
top = borders.visible.top;
left = borders.visible.left;
right = borders.visible.right;
bottom = borders.visible.bottom;
pixels = get_cache (frames, frame);
@ -2168,6 +2172,7 @@ subtract_client_area (cairo_region_t *region,
cairo_rectangle_int_t area;
MetaFrameFlags flags;
MetaFrameType type;
MetaFrameBorders borders;
cairo_region_t *tmp_region;
Display *display;
@ -2180,8 +2185,11 @@ subtract_client_area (cairo_region_t *region,
META_CORE_GET_CLIENT_HEIGHT, &area.height,
META_CORE_GET_END);
meta_theme_get_frame_borders (meta_theme_get_current (),
type, frame->text_height, flags,
&area.y, NULL, &area.x, NULL);
type, frame->text_height, flags,
&borders);
area.x = borders.visible.left;
area.y = borders.visible.top;
tmp_region = cairo_region_create_rectangle (&area);
cairo_region_subtract (region, tmp_region);

View File

@ -133,10 +133,9 @@ void meta_frames_update_frame_style (MetaFrames *frames,
void meta_frames_repaint_frame (MetaFrames *frames,
Window xwindow);
void meta_frames_get_geometry (MetaFrames *frames,
Window xwindow,
int *top_height, int *bottom_height,
int *left_width, int *right_width);
void meta_frames_get_borders (MetaFrames *frames,
Window xwindow,
MetaFrameBorders *borders);
void meta_frames_reset_bg (MetaFrames *frames,
Window xwindow);

View File

@ -94,10 +94,10 @@ meta_preview_init (MetaPreview *preview)
META_FRAME_ALLOWS_SHADE |
META_FRAME_ALLOWS_MOVE;
preview->left_width = -1;
preview->right_width = -1;
preview->top_height = -1;
preview->bottom_height = -1;
preview->borders.visible.left = -1;
preview->borders.visible.right = -1;
preview->borders.visible.top = -1;
preview->borders.visible.bottom = -1;
}
GtkWidget*
@ -168,7 +168,7 @@ ensure_info (MetaPreview *preview)
pango_font_description_free (font_desc);
}
if (preview->top_height < 0)
if (preview->borders.visible.top < 0)
{
if (preview->theme)
{
@ -176,17 +176,14 @@ ensure_info (MetaPreview *preview)
preview->type,
preview->text_height,
preview->flags,
&preview->top_height,
&preview->bottom_height,
&preview->left_width,
&preview->right_width);
&preview->borders);
}
else
{
preview->top_height = 0;
preview->bottom_height = 0;
preview->left_width = 0;
preview->right_width = 0;
preview->borders.visible.top = 0;
preview->borders.visible.bottom = 0;
preview->borders.visible.left = 0;
preview->borders.visible.right = 0;
}
}
}
@ -215,8 +212,8 @@ meta_preview_draw (GtkWidget *widget,
ensure_info (preview);
cairo_save (cr);
client_width = allocation.width - preview->left_width - preview->right_width;
client_height = allocation.height - preview->top_height - preview->bottom_height;
client_width = allocation.width - preview->borders.visible.left - preview->borders.visible.right;
client_height = allocation.height - preview->borders.visible.top - preview->borders.visible.bottom;
if (client_width < 0)
client_width = 1;
@ -258,7 +255,7 @@ meta_preview_get_preferred_width (GtkWidget *widget,
ensure_info (preview);
*minimum = *natural = preview->left_width + preview->right_width;
*minimum = *natural = preview->borders.visible.left + preview->borders.visible.right;
child = gtk_bin_get_child (GTK_BIN (preview));
if (child && gtk_widget_get_visible (child))
@ -289,7 +286,7 @@ meta_preview_get_preferred_height (GtkWidget *widget,
ensure_info (preview);
*minimum = *natural = preview->top_height + preview->bottom_height;
*minimum = *natural = preview->borders.visible.top + preview->borders.visible.bottom;
child = gtk_bin_get_child (GTK_BIN (preview));
if (child && gtk_widget_get_visible (child))
@ -326,11 +323,11 @@ meta_preview_size_allocate (GtkWidget *widget,
if (child && gtk_widget_get_visible (child))
{
gtk_widget_get_allocation (widget, &widget_allocation);
child_allocation.x = widget_allocation.x + preview->left_width;
child_allocation.y = widget_allocation.y + preview->top_height;
child_allocation.x = widget_allocation.x + preview->borders.visible.left;
child_allocation.y = widget_allocation.y + preview->borders.visible.top;
child_allocation.width = MAX (1, widget_allocation.width - preview->left_width - preview->right_width);
child_allocation.height = MAX (1, widget_allocation.height - preview->top_height - preview->bottom_height);
child_allocation.width = MAX (1, widget_allocation.width - preview->borders.visible.left - preview->borders.visible.right);
child_allocation.height = MAX (1, widget_allocation.height - preview->borders.visible.top - preview->borders.visible.bottom);
gtk_widget_size_allocate (child, &child_allocation);
}
@ -345,10 +342,10 @@ clear_cache (MetaPreview *preview)
preview->layout = NULL;
}
preview->left_width = -1;
preview->right_width = -1;
preview->top_height = -1;
preview->bottom_height = -1;
preview->borders.visible.left = -1;
preview->borders.visible.right = -1;
preview->borders.visible.top = -1;
preview->borders.visible.bottom = -1;
}
void

View File

@ -928,10 +928,7 @@ void meta_frame_layout_unref (MetaFrameLayout *layout)
void meta_frame_layout_get_borders (const MetaFrameLayout *layout,
int text_height,
MetaFrameFlags flags,
int *top_height,
int *bottom_height,
int *left_width,
int *right_width);
MetaFrameBorders *borders);
void meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
int text_height,
MetaFrameFlags flags,
@ -1124,10 +1121,8 @@ void meta_theme_get_frame_borders (MetaTheme *theme,
MetaFrameType type,
int text_height,
MetaFrameFlags flags,
int *top_height,
int *bottom_height,
int *left_width,
int *right_width);
MetaFrameBorders *borders);
void meta_theme_calc_geometry (MetaTheme *theme,
MetaFrameType type,
int text_height,

View File

@ -959,7 +959,7 @@ run_theme_benchmark (void)
{
GtkWidget* widget;
cairo_surface_t *pixmap;
int top_height, bottom_height, left_width, right_width;
MetaFrameBorders borders;
MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
{
META_BUTTON_STATE_NORMAL,
@ -986,10 +986,7 @@ run_theme_benchmark (void)
META_FRAME_TYPE_NORMAL,
get_text_height (widget),
get_flags (widget),
&top_height,
&bottom_height,
&left_width,
&right_width);
&borders);
layout = create_title_layout (widget);
@ -1024,8 +1021,8 @@ run_theme_benchmark (void)
*/
pixmap = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
CAIRO_CONTENT_COLOR,
client_width + left_width + right_width,
client_height + top_height + bottom_height);
client_width + borders.visible.left + borders.visible.right,
client_height + borders.visible.top + borders.visible.bottom);
cr = cairo_create (pixmap);

View File

@ -400,10 +400,7 @@ void
meta_frame_layout_get_borders (const MetaFrameLayout *layout,
int text_height,
MetaFrameFlags flags,
int *top_height,
int *bottom_height,
int *left_width,
int *right_width)
MetaFrameBorders *borders)
{
int buttons_height, title_height;
@ -418,34 +415,20 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout,
layout->title_vertical_pad +
layout->title_border.top + layout->title_border.bottom;
if (top_height)
{
*top_height = MAX (buttons_height, title_height);
}
if (left_width)
*left_width = layout->left_width;
if (right_width)
*right_width = layout->right_width;
if (bottom_height)
{
if (flags & META_FRAME_SHADED)
*bottom_height = 0;
else
*bottom_height = layout->bottom_height;
}
borders->visible.top = MAX (buttons_height, title_height);
borders->visible.left = layout->left_width;
borders->visible.right = layout->right_width;
if (flags & META_FRAME_SHADED)
borders->visible.bottom = 0;
else
borders->visible.bottom = layout->bottom_height;
if (flags & META_FRAME_FULLSCREEN)
{
if (top_height)
*top_height = 0;
if (bottom_height)
*bottom_height = 0;
if (left_width)
*left_width = 0;
if (right_width)
*right_width = 0;
borders->visible.top = 0;
borders->visible.bottom = 0;
borders->visible.left = 0;
borders->visible.right = 0;
}
}
@ -635,12 +618,17 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
GdkRectangle *right_bg_rects[MAX_BUTTONS_PER_CORNER];
gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
MetaFrameBorders borders;
meta_frame_layout_get_borders (layout, text_height,
flags,
&fgeom->top_height,
&fgeom->bottom_height,
&fgeom->left_width,
&fgeom->right_width);
&borders);
fgeom->left_width = borders.visible.left;
fgeom->right_width = borders.visible.right;
fgeom->top_height = borders.visible.top;
fgeom->bottom_height = borders.visible.bottom;
width = client_width + fgeom->left_width + fgeom->right_width;
@ -5585,30 +5573,23 @@ meta_theme_draw_frame_by_name (MetaTheme *theme,
}
void
meta_theme_get_frame_borders (MetaTheme *theme,
MetaFrameType type,
int text_height,
MetaFrameFlags flags,
int *top_height,
int *bottom_height,
int *left_width,
int *right_width)
meta_theme_get_frame_borders (MetaTheme *theme,
MetaFrameType type,
int text_height,
MetaFrameFlags flags,
MetaFrameBorders *borders)
{
MetaFrameStyle *style;
g_return_if_fail (type < META_FRAME_TYPE_LAST);
if (top_height)
*top_height = 0;
if (bottom_height)
*bottom_height = 0;
if (left_width)
*left_width = 0;
if (right_width)
*right_width = 0;
style = theme_get_style (theme, type, flags);
borders->visible.top = 0;
borders->visible.left = 0;
borders->visible.right = 0;
borders->visible.bottom = 0;
/* Parser is not supposed to allow this currently */
if (style == NULL)
return;
@ -5616,8 +5597,7 @@ meta_theme_get_frame_borders (MetaTheme *theme,
meta_frame_layout_get_borders (style->layout,
text_height,
flags,
top_height, bottom_height,
left_width, right_width);
borders);
}
void

View File

@ -306,14 +306,12 @@ meta_ui_free (MetaUI *ui)
}
void
meta_ui_get_frame_geometry (MetaUI *ui,
Window frame_xwindow,
int *top_height, int *bottom_height,
int *left_width, int *right_width)
meta_ui_get_frame_borders (MetaUI *ui,
Window frame_xwindow,
MetaFrameBorders *borders)
{
meta_frames_get_geometry (ui->frames, frame_xwindow,
top_height, bottom_height,
left_width, right_width);
meta_frames_get_borders (ui->frames, frame_xwindow,
borders);
}
Window
@ -712,10 +710,7 @@ void
meta_ui_theme_get_frame_borders (MetaUI *ui,
MetaFrameType type,
MetaFrameFlags flags,
int *top_height,
int *bottom_height,
int *left_width,
int *right_width)
MetaFrameBorders *borders)
{
int text_height;
GtkStyleContext *style = NULL;
@ -737,12 +732,14 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
meta_theme_get_frame_borders (meta_theme_get_current (),
type, text_height, flags,
top_height, bottom_height,
left_width, right_width);
borders);
}
else
{
*top_height = *bottom_height = *left_width = *right_width = 0;
borders->visible.top = 0;
borders->visible.bottom = 0;
borders->visible.left = 0;
borders->visible.right = 0;
}
if (style != NULL)

View File

@ -60,14 +60,10 @@ void meta_ui_free (MetaUI *ui);
void meta_ui_theme_get_frame_borders (MetaUI *ui,
MetaFrameType type,
MetaFrameFlags flags,
int *top_height,
int *bottom_height,
int *left_width,
int *right_width);
void meta_ui_get_frame_geometry (MetaUI *ui,
Window frame_xwindow,
int *top_height, int *bottom_height,
int *left_width, int *right_width);
MetaFrameBorders *borders);
void meta_ui_get_frame_borders (MetaUI *ui,
Window frame_xwindow,
MetaFrameBorders *borders);
Window meta_ui_create_frame_window (MetaUI *ui,
Display *xdisplay,
Visual *xvisual,