summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2014-06-09 21:03:51 +0300
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2014-06-09 21:03:51 +0300
commit113b965f8cc260117fc4690be2dcc60b8a77deb1 (patch)
treed89ef66f194f602ff67e0456e2d5208164be8eb3
parent5281f71a23accbdcda8609e8c9a4bb08957b7dee (diff)
downloadmetacity-113b965f8cc260117fc4690be2dcc60b8a77deb1.tar.gz
theme: fix button background
1) Added 'no background' if there is only one button and backgrounds no more overlap if transparency used. 2) Corrected bug with left button clickable region when window is maximized. Origin: Ubuntu Bug: https://bugzilla.gnome.org/show_bug.cgi?id=608511 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/metacity/+bug/535088 Author: Nicolas Desfontaine <noop@free.fr>
-rw-r--r--src/ui/theme.c51
-rw-r--r--src/ui/theme.h2
2 files changed, 27 insertions, 26 deletions
diff --git a/src/ui/theme.c b/src/ui/theme.c
index ed25877d..a13c7734 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -729,8 +729,13 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
for (i = 0; i < n_left; i++)
{
- if (i == 0) /* prefer left background if only one button */
- left_bg_rects[i] = &fgeom->left_left_background;
+ if (i == 0) /* For the first button (From left to right) */
+ {
+ if (n_left > 1) /* Set left_left_background if we have more than one button */
+ left_bg_rects[i] = &fgeom->left_left_background;
+ else /* No background if we have only one single button */
+ left_bg_rects[i] = &fgeom->left_single_background;
+ }
else if (i == (n_left - 1))
left_bg_rects[i] = &fgeom->left_right_background;
else
@@ -739,9 +744,13 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
for (i = 0; i < n_right; i++)
{
- /* prefer right background if only one button */
- if (i == (n_right - 1))
- right_bg_rects[i] = &fgeom->right_right_background;
+ if (i == (n_right - 1)) /* For the first button (From right to left) */
+ {
+ if (n_right > 1) /* Set right_right_background if we have more than one button */
+ right_bg_rects[i] = &fgeom->right_right_background;
+ else /* No background if we have only one single button */
+ right_bg_rects[i] = &fgeom->right_single_background;
+ }
else if (i == 0)
right_bg_rects[i] = &fgeom->right_left_background;
else
@@ -870,9 +879,9 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
flags & META_FRAME_TILED_RIGHT)
{
rect->clickable.x = rect->visible.x;
- rect->clickable.y = 0;
- rect->clickable.width = rect->visible.width;
- rect->clickable.height = button_height + button_y;
+ rect->clickable.y = rect->visible.y;
+ rect->clickable.width = button_width;
+ rect->clickable.height = button_height;
if (i == n_right - 1)
rect->clickable.width += layout->right_titlebar_edge + layout->right_width + layout->button_border.right;
@@ -908,23 +917,13 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
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;
- }
-
- rect->clickable.y = 0;
- rect->clickable.height = button_height + button_y;
- }
- else
- g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
-
+ rect->clickable.x = rect->visible.x;
+ rect->clickable.y = rect->visible.y;
+ rect->clickable.width = button_width;
+ rect->clickable.height = button_height;
+ }
+ else
+ g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
x = rect->visible.x + rect->visible.width + layout->button_border.right;
if (left_buttons_has_spacer[i])
@@ -4655,7 +4654,7 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
/* MIDDLE_BACKGROUND type may get drawn more than once */
if ((j == META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND ||
j == META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND) &&
- middle_bg_offset < MAX_MIDDLE_BACKGROUNDS)
+ (middle_bg_offset < (MAX_MIDDLE_BACKGROUNDS - 1)))
{
++middle_bg_offset;
}
diff --git a/src/ui/theme.h b/src/ui/theme.h
index cea966c6..5a07d549 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -246,9 +246,11 @@ struct _MetaFrameGeometry
MetaButtonSpace unstick_rect;
#define MAX_MIDDLE_BACKGROUNDS (MAX_BUTTONS_PER_CORNER - 2)
+ GdkRectangle left_single_background;
GdkRectangle left_left_background;
GdkRectangle left_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
GdkRectangle left_right_background;
+ GdkRectangle right_single_background;
GdkRectangle right_left_background;
GdkRectangle right_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
GdkRectangle right_right_background;