Skip to content

Commit 728f002

Browse files
owtaylorvkareh
authored andcommitted
Add frame_x_center/frame_y_center variables for themes
Sometimes you want to position something (usually the title) to be centered with respect to the entire frame instead of centered with respect to the individual piece currently being drawn. This patch adds frame_x_center and frame_y_center variables that represent the X/Y centers of the frame in the coordinate system of the piece being drawn. The theme version is bumped from 3.0 to 3.1 (3.0 is just the new version system, 3.1 will have all the features we add for Mutter-2.28.) position expressions https://bugzilla.gnome.org/show_bug.cgi?id=591842 NOTE: Patch is copied from mutter and is adapted for metacity.
1 parent ed3004d commit 728f002

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

‎doc/theme-format.txt‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ This document has separate sections for each format version. You may
2222
want to read the document in reverse order, since the base features
2323
are discussed under version 1.
2424

25+
New Features in Theme Format Version 3.1
26+
========================================
27+
28+
Additional predefined variables are added for positioning expressions:
29+
30+
frame_x_center: the X center of the entire frame, with respect to the
31+
piece currently being drawn.
32+
frame_y_center: the Y center of the entire frame, with respect to the
33+
piece currently being drawn.
34+
2535
New Features in Theme Format Version 3
2636
======================================
2737

‎src/ui/theme-parser.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* look out for.
3939
*/
4040
#define THEME_MAJOR_VERSION 3
41-
#define THEME_MINOR_VERSION 0
41+
#define THEME_MINOR_VERSION 1
4242
#define THEME_VERSION (1000 * THEME_MAJOR_VERSION + THEME_MINOR_VERSION)
4343

4444
#define MARCO_THEME_FILENAME_FORMAT "metacity-theme-%d.xml"

‎src/ui/theme.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,6 +2312,10 @@ pos_eval_get_variable (PosToken *t,
23122312
*result = env->title_width;
23132313
else if (t->d.v.name_quark == env->theme->quark_title_height)
23142314
*result = env->title_height;
2315+
else if (t->d.v.name_quark == env->theme->quark_frame_x_center)
2316+
*result = env->frame_x_center;
2317+
else if (t->d.v.name_quark == env->theme->quark_frame_y_center)
2318+
*result = env->frame_y_center;
23152319
else
23162320
{
23172321
g_set_error (err, META_THEME_ERROR,
@@ -2353,6 +2357,10 @@ pos_eval_get_variable (PosToken *t,
23532357
*result = env->title_width;
23542358
else if (strcmp (t->d.v.name, "title_height") == 0)
23552359
*result = env->title_height;
2360+
else if (strcmp (t->d.v.name, "frame_x_center") == 0)
2361+
*result = env->frame_x_center;
2362+
else if (strcmp (t->d.v.name, "frame_y_center") == 0)
2363+
*result = env->frame_y_center;
23562364
else
23572365
{
23582366
g_set_error (err, META_THEME_ERROR,
@@ -3485,13 +3493,17 @@ fill_env (MetaPositionExprEnv *env,
34853493
env->right_width = info->fgeom->right_width;
34863494
env->top_height = info->fgeom->top_height;
34873495
env->bottom_height = info->fgeom->bottom_height;
3496+
env->frame_x_center = info->fgeom->width / 2 - logical_region.x;
3497+
env->frame_y_center = info->fgeom->height / 2 - logical_region.y;
34883498
}
34893499
else
34903500
{
34913501
env->left_width = 0;
34923502
env->right_width = 0;
34933503
env->top_height = 0;
34943504
env->bottom_height = 0;
3505+
env->frame_x_center = 0;
3506+
env->frame_y_center = 0;
34953507
}
34963508

34973509
env->mini_icon_width = info->mini_icon ? gdk_pixbuf_get_width (info->mini_icon) : 0;
@@ -5047,6 +5059,8 @@ meta_theme_new (void)
50475059
theme->quark_icon_height = g_quark_from_static_string ("icon_height");
50485060
theme->quark_title_width = g_quark_from_static_string ("title_width");
50495061
theme->quark_title_height = g_quark_from_static_string ("title_height");
5062+
theme->quark_frame_x_center = g_quark_from_static_string ("frame_x_center");
5063+
theme->quark_frame_y_center = g_quark_from_static_string ("frame_y_center");
50505064
return theme;
50515065
}
50525066

‎src/ui/theme.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,8 @@ struct _MetaTheme
830830
GQuark quark_icon_height;
831831
GQuark quark_title_width;
832832
GQuark quark_title_height;
833+
GQuark quark_frame_x_center;
834+
GQuark quark_frame_y_center;
833835
};
834836

835837
struct _MetaPositionExprEnv
@@ -845,6 +847,8 @@ struct _MetaPositionExprEnv
845847
int bottom_height;
846848
int title_width;
847849
int title_height;
850+
int frame_x_center;
851+
int frame_y_center;
848852
int mini_icon_width;
849853
int mini_icon_height;
850854
int icon_width;

0 commit comments

Comments
 (0)