summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/theme-format.txt6
-rw-r--r--src/ui/theme-parser.c2
-rw-r--r--src/ui/theme.c59
-rw-r--r--src/ui/theme.h8
4 files changed, 53 insertions, 22 deletions
diff --git a/doc/theme-format.txt b/doc/theme-format.txt
index 541998d0..cec70290 100644
--- a/doc/theme-format.txt
+++ b/doc/theme-format.txt
@@ -22,6 +22,12 @@ This document has separate sections for each format version. You may
want to read the document in reverse order, since the base features
are discussed under version 1.
+New Features in Theme Format Version 3.3
+========================================
+
+Add two additional button background functions - left_single_background and
+right_single_background - for button groups with just a single button.
+
New Features in Theme Format Version 3.2
========================================
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c
index 49fcd732..b4186594 100644
--- a/src/ui/theme-parser.c
+++ b/src/ui/theme-parser.c
@@ -38,7 +38,7 @@
* look out for.
*/
#define THEME_MAJOR_VERSION 3
-#define THEME_MINOR_VERSION 2
+#define THEME_MINOR_VERSION 3
#define THEME_VERSION (1000 * THEME_MAJOR_VERSION + THEME_MINOR_VERSION)
#define MARCO_THEME_FILENAME_FORMAT "metacity-theme-%d.xml"
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;
diff --git a/src/ui/theme.h b/src/ui/theme.h
index 6d0b4d16..e248b3b3 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -185,7 +185,7 @@ struct _MetaFrameGeometry
/* used for a memset hack */
#define ADDRESS_OF_BUTTON_RECTS(fgeom) (((char*)(fgeom)) + 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))
+#define LENGTH_OF_BUTTON_RECTS (G_STRUCT_OFFSET (MetaFrameGeometry, right_single_background) + sizeof (GdkRectangle) - G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
/* The button rects (if changed adjust memset hack) */
MetaButtonSpace close_rect;
@@ -200,14 +200,14 @@ 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 left_single_background;
GdkRectangle right_left_background;
GdkRectangle right_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
GdkRectangle right_right_background;
+ GdkRectangle right_single_background;
/* End of button rects (if changed adjust memset hack) */
/* Saved button layout */
@@ -595,9 +595,11 @@ typedef enum
META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND,
META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND,
META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND,
+ META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND,
META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND,
META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND,
META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND,
+ META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND,
META_BUTTON_TYPE_CLOSE,
META_BUTTON_TYPE_MAXIMIZE,
META_BUTTON_TYPE_MINIMIZE,