summaryrefslogtreecommitdiff
path: root/src/ui/theme.c
diff options
context:
space:
mode:
authorFlorian Müllner <[email protected]>2014-09-27 18:04:20 +0300
committerVictor Kareh <[email protected]>2018-08-28 09:38:37 -0400
commit997488f903cef76143e5b0f19a906cbb549d5761 (patch)
treefad0a52ca3f6c00f332be467acbc3cf2ad4e8f3b /src/ui/theme.c
parent33c75c2a39c2f6da4a76a556e55f4a4a57aa7cd4 (diff)
downloadmarco-997488f903cef76143e5b0f19a906cbb549d5761.tar.bz2
marco-997488f903cef76143e5b0f19a906cbb549d5761.tar.xz
theme: Add background functions for single buttons
With the existing background functions, single buttons can not be styled separately - on the left side, the style of the left button is picked, and the right button's style on the right side. As theme authors may want to add rounded corners to button groups as a whole, it makes sense to treat the case of a single button in a group differently. https://bugzilla.gnome.org/show_bug.cgi?id=635683 NOTE: Patch copied from mutter and adapted for metacity.
Diffstat (limited to 'src/ui/theme.c')
-rw-r--r--src/ui/theme.c59
1 files changed, 41 insertions, 18 deletions
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 667e60ff..eb20285d 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -731,14 +731,10 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
for (i = 0; i < n_left; i++)
{
- 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;
- }
+ if (n_left == 1)
+ left_bg_rects[i] = &fgeom->left_single_background;
+ else if (i == 0)
+ left_bg_rects[i] = &fgeom->left_left_background;
else if (i == (n_left - 1))
left_bg_rects[i] = &fgeom->left_right_background;
else
@@ -747,14 +743,10 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
for (i = 0; i < n_right; i++)
{
- 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;
- }
+ if (n_right == 1)
+ right_bg_rects[i] = &fgeom->right_single_background;
+ else if (i == (n_right - 1))
+ right_bg_rects[i] = &fgeom->right_right_background;
else if (i == 0)
right_bg_rects[i] = &fgeom->right_left_background;
else
@@ -4342,6 +4334,7 @@ map_button_state (MetaButtonType button_type,
/* Map position buttons to the corresponding function */
case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
+ case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
if (fgeom->n_right_buttons > 0)
function = fgeom->button_layout.right_buttons[0];
break;
@@ -4354,6 +4347,7 @@ map_button_state (MetaButtonType button_type,
function = fgeom->button_layout.right_buttons[middle_bg_offset + 1];
break;
case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
+ case META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND:
if (fgeom->n_left_buttons > 0)
function = fgeom->button_layout.left_buttons[0];
break;
@@ -4391,11 +4385,20 @@ get_button (MetaFrameStyle *style,
parent = parent->parent;
}
- /* We fall back to middle button backgrounds if we don't
- * have the ones on the sides
+ /* We fall back to the side buttons if we don't have
+ * single button backgrounds, and to middle button
+ * backgrounds if we don't have the ones on the sides
*/
if (op_list == NULL &&
+ type == META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND)
+ return get_button (style, META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND, state);
+
+ if (op_list == NULL &&
+ type == META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND)
+ return get_button (style, META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND, state);
+
+ if (op_list == NULL &&
(type == META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND ||
type == META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND))
return get_button (style, META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND,
@@ -4470,6 +4473,10 @@ get_button_rect (MetaButtonType type,
*rect = fgeom->left_right_background;
break;
+ case META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND:
+ *rect = fgeom->left_single_background;
+ break;
+
case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
*rect = fgeom->right_left_background;
break;
@@ -4482,6 +4489,10 @@ get_button_rect (MetaButtonType type,
*rect = fgeom->right_right_background;
break;
+ case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
+ *rect = fgeom->right_single_background;
+ break;
+
case META_BUTTON_TYPE_CLOSE:
*rect = fgeom->close_rect.visible;
break;
@@ -5983,12 +5994,16 @@ meta_button_type_from_string (const char *str, MetaTheme *theme)
return META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND;
else if (strcmp ("left_right_background", str) == 0)
return META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND;
+ else if (strcmp ("left_single_background", str) == 0)
+ return META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND;
else if (strcmp ("right_left_background", str) == 0)
return META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND;
else if (strcmp ("right_middle_background", str) == 0)
return META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND;
else if (strcmp ("right_right_background", str) == 0)
return META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND;
+ else if (strcmp ("right_single_background", str) == 0)
+ return META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND;
else
return META_BUTTON_TYPE_LAST;
}
@@ -6024,12 +6039,16 @@ meta_button_type_to_string (MetaButtonType type)
return "left_middle_background";
case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND:
return "left_right_background";
+ case META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND:
+ return "left_single_background";
case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
return "right_left_background";
case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND:
return "right_middle_background";
case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND:
return "right_right_background";
+ case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
+ return "right_single_background";
case META_BUTTON_TYPE_LAST:
break;
}
@@ -6889,6 +6908,10 @@ meta_theme_earliest_version_with_button (MetaButtonType type)
case META_BUTTON_TYPE_UNSTICK:
return 2000;
+ case META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND:
+ case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
+ return 3003;
+
default:
meta_warning("Unknown button %d\n", type);
return 1000;