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> 2006-08-07 Elijah Newren <newren gmail com>
* src/screen.c (meta_screen_resize_func): patch from Dmitry * src/screen.c (meta_screen_resize_func): patch from Dmitry

View File

@ -2256,17 +2256,17 @@ control_rect (MetaFrameControl control,
rect = &fgeom->title_rect; rect = &fgeom->title_rect;
break; break;
case META_FRAME_CONTROL_DELETE: case META_FRAME_CONTROL_DELETE:
rect = &fgeom->close_rect; rect = &fgeom->close_rect.visible;
break; break;
case META_FRAME_CONTROL_MENU: case META_FRAME_CONTROL_MENU:
rect = &fgeom->menu_rect; rect = &fgeom->menu_rect.visible;
break; break;
case META_FRAME_CONTROL_MINIMIZE: case META_FRAME_CONTROL_MINIMIZE:
rect = &fgeom->min_rect; rect = &fgeom->min_rect.visible;
break; break;
case META_FRAME_CONTROL_MAXIMIZE: case META_FRAME_CONTROL_MAXIMIZE:
case META_FRAME_CONTROL_UNMAXIMIZE: case META_FRAME_CONTROL_UNMAXIMIZE:
rect = &fgeom->max_rect; rect = &fgeom->max_rect.visible;
break; break;
case META_FRAME_CONTROL_RESIZE_SE: case META_FRAME_CONTROL_RESIZE_SE:
break; break;
@ -2315,13 +2315,13 @@ get_control (MetaFrames *frames,
if (POINT_IN_RECT (x, y, client)) if (POINT_IN_RECT (x, y, client))
return META_FRAME_CONTROL_CLIENT_AREA; 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; 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; 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; return META_FRAME_CONTROL_MENU;
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow); flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
@ -2337,7 +2337,7 @@ get_control (MetaFrames *frames,
return META_FRAME_CONTROL_TITLE; 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) if (flags & META_FRAME_MAXIMIZED)
return META_FRAME_CONTROL_UNMAXIMIZE; 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, rect_for_function (MetaFrameGeometry *fgeom,
MetaFrameFlags flags, MetaFrameFlags flags,
MetaButtonFunction function) MetaButtonFunction function)
@ -424,10 +424,10 @@ rect_for_function (MetaFrameGeometry *fgeom,
} }
static gboolean static gboolean
strip_button (GdkRectangle *func_rects[MAX_BUTTONS_PER_CORNER], strip_button (MetaButtonSpace *func_rects[MAX_BUTTONS_PER_CORNER],
GdkRectangle *bg_rects[MAX_BUTTONS_PER_CORNER], GdkRectangle *bg_rects[MAX_BUTTONS_PER_CORNER],
int *n_rects, int *n_rects,
GdkRectangle *to_strip) MetaButtonSpace *to_strip)
{ {
int i; int i;
@ -479,8 +479,8 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
/* the left/right rects in order; the max # of rects /* the left/right rects in order; the max # of rects
* is the number of button functions * is the number of button functions
*/ */
GdkRectangle *left_func_rects[MAX_BUTTONS_PER_CORNER]; MetaButtonSpace *left_func_rects[MAX_BUTTONS_PER_CORNER];
GdkRectangle *right_func_rects[MAX_BUTTONS_PER_CORNER]; MetaButtonSpace *right_func_rects[MAX_BUTTONS_PER_CORNER];
GdkRectangle *left_bg_rects[MAX_BUTTONS_PER_CORNER]; GdkRectangle *left_bg_rects[MAX_BUTTONS_PER_CORNER];
GdkRectangle *right_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; i = n_right - 1;
while (i >= 0) 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 */ if (x < 0) /* if we go negative, leave the buttons we don't get to as 0-width */
break; break;
rect = right_func_rects[i]; rect = right_func_rects[i];
rect->x = x - layout->button_border.right - button_width; rect->visible.x = x - layout->button_border.right - button_width;
rect->y = button_y; rect->visible.y = button_y;
rect->width = button_width; rect->visible.width = button_width;
rect->height = button_height; 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; --i;
} }
@ -680,18 +694,38 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
x = layout->left_titlebar_edge; x = layout->left_titlebar_edge;
for (i = 0; i < n_left; i++) for (i = 0; i < n_left; i++)
{ {
GdkRectangle *rect; MetaButtonSpace *rect;
rect = left_func_rects[i]; rect = left_func_rects[i];
rect->x = x + layout->button_border.left; rect->visible.x = x + layout->button_border.left;
rect->y = button_y; rect->visible.y = button_y;
rect->width = button_width; rect->visible.width = button_width;
rect->height = button_height; 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, /* We always fill as much vertical space as possible with title rect,
@ -3868,19 +3902,19 @@ button_rect (MetaButtonType type,
break; break;
case META_BUTTON_TYPE_CLOSE: case META_BUTTON_TYPE_CLOSE:
*rect = fgeom->close_rect; *rect = fgeom->close_rect.visible;
break; break;
case META_BUTTON_TYPE_MAXIMIZE: case META_BUTTON_TYPE_MAXIMIZE:
*rect = fgeom->max_rect; *rect = fgeom->max_rect.visible;
break; break;
case META_BUTTON_TYPE_MINIMIZE: case META_BUTTON_TYPE_MINIMIZE:
*rect = fgeom->min_rect; *rect = fgeom->min_rect.visible;
break; break;
case META_BUTTON_TYPE_MENU: case META_BUTTON_TYPE_MENU:
*rect = fgeom->menu_rect; *rect = fgeom->menu_rect.visible;
break; break;
case META_BUTTON_TYPE_LAST: case META_BUTTON_TYPE_LAST:

View File

@ -35,6 +35,7 @@ typedef struct _MetaGradientSpec MetaGradientSpec;
typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec; typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec;
typedef struct _MetaColorSpec MetaColorSpec; typedef struct _MetaColorSpec MetaColorSpec;
typedef struct _MetaFrameLayout MetaFrameLayout; typedef struct _MetaFrameLayout MetaFrameLayout;
typedef struct _MetaButtonSpace MetaButtonSpace;
typedef struct _MetaFrameGeometry MetaFrameGeometry; typedef struct _MetaFrameGeometry MetaFrameGeometry;
typedef struct _MetaTheme MetaTheme; typedef struct _MetaTheme MetaTheme;
typedef struct _MetaPositionExprEnv MetaPositionExprEnv; typedef struct _MetaPositionExprEnv MetaPositionExprEnv;
@ -104,6 +105,14 @@ struct _MetaFrameLayout
guint bottom_right_corner_rounded : 1; 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 */ /* Calculated actual geometry of the frame */
struct _MetaFrameGeometry 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)) #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) */ /* The button rects (if changed adjust memset hack) */
GdkRectangle close_rect; MetaButtonSpace close_rect;
GdkRectangle max_rect; MetaButtonSpace max_rect;
GdkRectangle min_rect; MetaButtonSpace min_rect;
GdkRectangle menu_rect; MetaButtonSpace menu_rect;
#define MAX_MIDDLE_BACKGROUNDS (MAX_BUTTONS_PER_CORNER - 2) #define MAX_MIDDLE_BACKGROUNDS (MAX_BUTTONS_PER_CORNER - 2)
GdkRectangle left_left_background; GdkRectangle left_left_background;