[metacity] Add frame_x_center/frame_y_center variables for themes



commit 6ab5aa932870bac6447e08630c6de03da4febbbb
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Sep 27 16:21:16 2014 +0300

    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.

 doc/theme-format.txt  |   10 ++++++++++
 src/ui/theme-parser.c |    2 +-
 src/ui/theme.c        |   14 ++++++++++++++
 src/ui/theme.h        |    4 ++++
 4 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/doc/theme-format.txt b/doc/theme-format.txt
index bb79d45..bacc6e4 100644
--- a/doc/theme-format.txt
+++ b/doc/theme-format.txt
@@ -22,6 +22,16 @@ 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.1
+========================================
+
+Additional predefined variables are added for positioning expressions:
+
+  frame_x_center: the X center of the entire frame, with respect to the
+      piece currently being drawn.
+  frame_y_center: the Y center of the entire frame, with respect to the
+      piece currently being drawn.
+
 New Features in Theme Format Version 3
 ======================================
 
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c
index 7db6448..9098e7c 100644
--- a/src/ui/theme-parser.c
+++ b/src/ui/theme-parser.c
@@ -36,7 +36,7 @@
  * look out for.
  */
 #define THEME_MAJOR_VERSION 3
-#define THEME_MINOR_VERSION 0
+#define THEME_MINOR_VERSION 1
 #define THEME_VERSION (1000 * THEME_MAJOR_VERSION + THEME_MINOR_VERSION)
 
 #define METACITY_THEME_FILENAME_FORMAT "metacity-theme-%d.xml"
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 7eac89d..8e8e22d 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -2303,6 +2303,10 @@ pos_eval_get_variable (PosToken                  *t,
         *result = env->title_width;
       else if (t->d.v.name_quark == env->theme->quark_title_height)
         *result = env->title_height;
+      else if (t->d.v.name_quark == env->theme->quark_frame_x_center)
+        *result = env->frame_x_center;
+      else if (t->d.v.name_quark == env->theme->quark_frame_y_center)
+        *result = env->frame_y_center;
       else
         {
           g_set_error (err, META_THEME_ERROR,
@@ -2344,6 +2348,10 @@ pos_eval_get_variable (PosToken                  *t,
         *result = env->title_width;
       else if (strcmp (t->d.v.name, "title_height") == 0)
         *result = env->title_height;
+      else if (strcmp (t->d.v.name, "frame_x_center") == 0)
+        *result = env->frame_x_center;
+      else if (strcmp (t->d.v.name, "frame_y_center") == 0)
+        *result = env->frame_y_center;
       else
         {
           g_set_error (err, META_THEME_ERROR,
@@ -3476,6 +3484,8 @@ fill_env (MetaPositionExprEnv *env,
       env->right_width = info->fgeom->right_width;
       env->top_height = info->fgeom->top_height;
       env->bottom_height = info->fgeom->bottom_height;
+      env->frame_x_center = info->fgeom->width / 2 - logical_region.x;
+      env->frame_y_center = info->fgeom->height / 2 - logical_region.y;
     }
   else
     {
@@ -3483,6 +3493,8 @@ fill_env (MetaPositionExprEnv *env,
       env->right_width = 0;
       env->top_height = 0;
       env->bottom_height = 0;
+      env->frame_x_center = 0;
+      env->frame_y_center = 0;
     }
   
   env->mini_icon_width = info->mini_icon ? gdk_pixbuf_get_width (info->mini_icon) : 0;
@@ -4991,6 +5003,8 @@ meta_theme_new (void)
   theme->quark_icon_height = g_quark_from_static_string ("icon_height");
   theme->quark_title_width = g_quark_from_static_string ("title_width");
   theme->quark_title_height = g_quark_from_static_string ("title_height");
+  theme->quark_frame_x_center = g_quark_from_static_string ("frame_x_center");
+  theme->quark_frame_y_center = g_quark_from_static_string ("frame_y_center");
   return theme;
 }
 
diff --git a/src/ui/theme.h b/src/ui/theme.h
index 5a07d54..7c47657 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -886,6 +886,8 @@ struct _MetaTheme
   GQuark quark_icon_height;
   GQuark quark_title_width;
   GQuark quark_title_height;
+  GQuark quark_frame_x_center;
+  GQuark quark_frame_y_center;
 };
 
 struct _MetaPositionExprEnv
@@ -901,6 +903,8 @@ struct _MetaPositionExprEnv
   int bottom_height;
   int title_width;
   int title_height;
+  int frame_x_center;
+  int frame_y_center;
   int mini_icon_width;
   int mini_icon_height;
   int icon_width;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]