add new MetaButtonSpace struct; use it for close_rect, max_rect, min_rect

2006-08-07  Thomas Thurman  <thomas@thurman.org.uk>

        * src/frames.h: add new MetaButtonSpace struct; use it for
        close_rect, max_rect, min_rect and menu_rect.

        * src/frames.c (control_rect, get_control): modify to support
        the new fields in MetaButtonSpace.

        * src/theme.c (meta_frame_layout_get_borders, rect_for_function,
        meta_frame_layout_calc_geometry, button_rect): add support for
        the new fields in MetaButtonSpace.
This commit is contained in:
Thomas Thurman 2006-08-07 18:01:21 +00:00 committed by Thomas James Alexander Thurman
parent 77a331a1e3
commit cc5def1021
4 changed files with 92 additions and 37 deletions

View File

@ -1,3 +1,15 @@
2006-08-07 Thomas Thurman <thomas@thurman.org.uk>
* src/frames.h: add new MetaButtonSpace struct; use it for
close_rect, max_rect, min_rect and menu_rect.
* src/frames.c (control_rect, get_control): modify to support
the new fields in MetaButtonSpace.
* src/theme.c (meta_frame_layout_get_borders, rect_for_function,
meta_frame_layout_calc_geometry, button_rect): add support for
the new fields in MetaButtonSpace.
2006-08-07 Elijah Newren <newren gmail com>
* src/screen.c (meta_screen_resize_func): patch from Dmitry

View File

@ -2256,17 +2256,17 @@ control_rect (MetaFrameControl control,
rect = &fgeom->title_rect;
break;
case META_FRAME_CONTROL_DELETE:
rect = &fgeom->close_rect;
rect = &fgeom->close_rect.visible;
break;
case META_FRAME_CONTROL_MENU:
rect = &fgeom->menu_rect;
rect = &fgeom->menu_rect.visible;
break;
case META_FRAME_CONTROL_MINIMIZE:
rect = &fgeom->min_rect;
rect = &fgeom->min_rect.visible;
break;
case META_FRAME_CONTROL_MAXIMIZE:
case META_FRAME_CONTROL_UNMAXIMIZE:
rect = &fgeom->max_rect;
rect = &fgeom->max_rect.visible;
break;
case META_FRAME_CONTROL_RESIZE_SE:
break;
@ -2315,13 +2315,13 @@ get_control (MetaFrames *frames,
if (POINT_IN_RECT (x, y, client))
return META_FRAME_CONTROL_CLIENT_AREA;
if (POINT_IN_RECT (x, y, fgeom.close_rect))
if (POINT_IN_RECT (x, y, fgeom.close_rect.clickable))
return META_FRAME_CONTROL_DELETE;
if (POINT_IN_RECT (x, y, fgeom.min_rect))
if (POINT_IN_RECT (x, y, fgeom.min_rect.clickable))
return META_FRAME_CONTROL_MINIMIZE;
if (POINT_IN_RECT (x, y, fgeom.menu_rect))
if (POINT_IN_RECT (x, y, fgeom.menu_rect.clickable))
return META_FRAME_CONTROL_MENU;
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
@ -2337,7 +2337,7 @@ get_control (MetaFrames *frames,
return META_FRAME_CONTROL_TITLE;
}
if (POINT_IN_RECT (x, y, fgeom.max_rect))
if (POINT_IN_RECT (x, y, fgeom.max_rect.clickable))
{
if (flags & META_FRAME_MAXIMIZED)
return META_FRAME_CONTROL_UNMAXIMIZE;

View File

@ -389,7 +389,7 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout,
}
}
static GdkRectangle*
static MetaButtonSpace*
rect_for_function (MetaFrameGeometry *fgeom,
MetaFrameFlags flags,
MetaButtonFunction function)
@ -424,10 +424,10 @@ rect_for_function (MetaFrameGeometry *fgeom,
}
static gboolean
strip_button (GdkRectangle *func_rects[MAX_BUTTONS_PER_CORNER],
GdkRectangle *bg_rects[MAX_BUTTONS_PER_CORNER],
int *n_rects,
GdkRectangle *to_strip)
strip_button (MetaButtonSpace *func_rects[MAX_BUTTONS_PER_CORNER],
GdkRectangle *bg_rects[MAX_BUTTONS_PER_CORNER],
int *n_rects,
MetaButtonSpace *to_strip)
{
int i;
@ -479,8 +479,8 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
/* the left/right rects in order; the max # of rects
* is the number of button functions
*/
GdkRectangle *left_func_rects[MAX_BUTTONS_PER_CORNER];
GdkRectangle *right_func_rects[MAX_BUTTONS_PER_CORNER];
MetaButtonSpace *left_func_rects[MAX_BUTTONS_PER_CORNER];
MetaButtonSpace *right_func_rects[MAX_BUTTONS_PER_CORNER];
GdkRectangle *left_bg_rects[MAX_BUTTONS_PER_CORNER];
GdkRectangle *right_bg_rects[MAX_BUTTONS_PER_CORNER];
@ -652,21 +652,35 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
i = n_right - 1;
while (i >= 0)
{
GdkRectangle *rect;
MetaButtonSpace *rect;
if (x < 0) /* if we go negative, leave the buttons we don't get to as 0-width */
break;
rect = right_func_rects[i];
rect->x = x - layout->button_border.right - button_width;
rect->y = button_y;
rect->width = button_width;
rect->height = button_height;
rect->visible.x = x - layout->button_border.right - button_width;
rect->visible.y = button_y;
rect->visible.width = button_width;
rect->visible.height = button_height;
*(right_bg_rects[i]) = *rect;
if (flags & META_FRAME_MAXIMIZED)
{
rect->clickable.x = rect->visible.x;
rect->clickable.y = 0;
rect->clickable.width = rect->visible.width;
rect->clickable.height = button_height + button_y;
x = rect->x - layout->button_border.left;
if (i == n_right - 1)
rect->clickable.width += layout->right_titlebar_edge + layout->right_width + layout->button_border.right;
}
else
g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
*(right_bg_rects[i]) = rect->visible;
x = rect->visible.x - layout->button_border.left;
--i;
}
@ -680,18 +694,38 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
x = layout->left_titlebar_edge;
for (i = 0; i < n_left; i++)
{
GdkRectangle *rect;
MetaButtonSpace *rect;
rect = left_func_rects[i];
rect->x = x + layout->button_border.left;
rect->y = button_y;
rect->width = button_width;
rect->height = button_height;
rect->visible.x = x + layout->button_border.left;
rect->visible.y = button_y;
rect->visible.width = button_width;
rect->visible.height = button_height;
x = rect->x + rect->width + layout->button_border.right;
if (flags & META_FRAME_MAXIMIZED)
{
if (i==0)
{
rect->clickable.x = 0;
rect->clickable.width = button_width + x;
}
else
{
rect->clickable.x = rect->visible.x;
rect->clickable.width = button_width;
}
*(left_bg_rects[i]) = *rect;
rect->clickable.y = 0;
rect->clickable.height = button_height + button_y;
}
else
g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
x = rect->visible.x + rect->visible.width + layout->button_border.right;
*(left_bg_rects[i]) = rect->visible;
}
/* We always fill as much vertical space as possible with title rect,
@ -3868,19 +3902,19 @@ button_rect (MetaButtonType type,
break;
case META_BUTTON_TYPE_CLOSE:
*rect = fgeom->close_rect;
*rect = fgeom->close_rect.visible;
break;
case META_BUTTON_TYPE_MAXIMIZE:
*rect = fgeom->max_rect;
*rect = fgeom->max_rect.visible;
break;
case META_BUTTON_TYPE_MINIMIZE:
*rect = fgeom->min_rect;
*rect = fgeom->min_rect.visible;
break;
case META_BUTTON_TYPE_MENU:
*rect = fgeom->menu_rect;
*rect = fgeom->menu_rect.visible;
break;
case META_BUTTON_TYPE_LAST:

View File

@ -35,6 +35,7 @@ typedef struct _MetaGradientSpec MetaGradientSpec;
typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec;
typedef struct _MetaColorSpec MetaColorSpec;
typedef struct _MetaFrameLayout MetaFrameLayout;
typedef struct _MetaButtonSpace MetaButtonSpace;
typedef struct _MetaFrameGeometry MetaFrameGeometry;
typedef struct _MetaTheme MetaTheme;
typedef struct _MetaPositionExprEnv MetaPositionExprEnv;
@ -104,6 +105,14 @@ struct _MetaFrameLayout
guint bottom_right_corner_rounded : 1;
};
struct _MetaButtonSpace
{
GdkRectangle visible; /* The area of the screen which has a button's image
drawn on it. */
GdkRectangle clickable; /* The area of the screen which, when clicked,
activates a button. */
};
/* Calculated actual geometry of the frame */
struct _MetaFrameGeometry
{
@ -127,10 +136,10 @@ struct _MetaFrameGeometry
#define LENGTH_OF_BUTTON_RECTS (G_STRUCT_OFFSET (MetaFrameGeometry, right_right_background) + sizeof (GdkRectangle) - G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
/* The button rects (if changed adjust memset hack) */
GdkRectangle close_rect;
GdkRectangle max_rect;
GdkRectangle min_rect;
GdkRectangle menu_rect;
MetaButtonSpace close_rect;
MetaButtonSpace max_rect;
MetaButtonSpace min_rect;
MetaButtonSpace menu_rect;
#define MAX_MIDDLE_BACKGROUNDS (MAX_BUTTONS_PER_CORNER - 2)
GdkRectangle left_left_background;