[metacity] libmetacity: don't use MetaFrameStyleSet with GTK+ theme



commit 67d22f3ad831c244941c0e18447c14da9ea3ce4c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Apr 11 13:42:10 2017 +0300

    libmetacity: don't use MetaFrameStyleSet with GTK+ theme

 libmetacity/meta-theme-gtk.c          |   82 ++++++++--------
 libmetacity/meta-theme-impl-private.h |   79 ++++++++---------
 libmetacity/meta-theme-impl.c         |   60 +------------
 libmetacity/meta-theme-metacity.c     |  165 ++++++++++++++++++++++++++-------
 libmetacity/meta-theme.c              |  112 ++--------------------
 5 files changed, 224 insertions(+), 274 deletions(-)
---
diff --git a/libmetacity/meta-theme-gtk.c b/libmetacity/meta-theme-gtk.c
index f80c553..d7daed1 100644
--- a/libmetacity/meta-theme-gtk.c
+++ b/libmetacity/meta-theme-gtk.c
@@ -29,11 +29,33 @@
 
 struct _MetaThemeGtk
 {
-  MetaThemeImpl parent;
+  MetaThemeImpl   parent;
+
+  MetaFrameStyle *styles[META_FRAME_TYPE_LAST];
 };
 
 G_DEFINE_TYPE (MetaThemeGtk, meta_theme_gtk, META_TYPE_THEME_IMPL)
 
+static void
+meta_theme_gtk_dispose (GObject *object)
+{
+  MetaThemeGtk *gtk;
+  gint i;
+
+  gtk = META_THEME_GTK (object);
+
+  for (i = 0; i < META_FRAME_TYPE_LAST; i++)
+    {
+      if (gtk->styles[i] != NULL)
+        {
+          meta_frame_style_unref (gtk->styles[i]);
+          gtk->styles[i] = NULL;
+        }
+    }
+
+  G_OBJECT_CLASS (meta_theme_gtk_parent_class)->dispose (object);
+}
+
 static gboolean
 meta_theme_gtk_load (MetaThemeImpl  *impl,
                      const gchar    *name,
@@ -205,6 +227,18 @@ frame_layout_sync_with_style (MetaFrameLayout *layout,
                                             requisition.height);
 }
 
+static MetaFrameStyle *
+meta_theme_gtk_get_frame_style (MetaThemeImpl  *impl,
+                                MetaFrameType   type,
+                                MetaFrameFlags  flags)
+{
+  MetaThemeGtk *gtk;
+
+  gtk = META_THEME_GTK (impl);
+
+  return gtk->styles[type];
+}
+
 static void
 meta_theme_gtk_get_frame_borders (MetaThemeImpl    *impl,
                                   MetaFrameLayout  *layout,
@@ -869,11 +903,16 @@ meta_theme_gtk_draw_frame (MetaThemeImpl           *impl,
 static void
 meta_theme_gtk_class_init (MetaThemeGtkClass *gtk_class)
 {
+  GObjectClass *object_class;
   MetaThemeImplClass *impl_class;
 
+  object_class = G_OBJECT_CLASS (gtk_class);
   impl_class = META_THEME_IMPL_CLASS (gtk_class);
 
+  object_class->dispose = meta_theme_gtk_dispose;
+
   impl_class->load = meta_theme_gtk_load;
+  impl_class->get_frame_style = meta_theme_gtk_get_frame_style;
   impl_class->get_frame_borders = meta_theme_gtk_get_frame_borders;
   impl_class->calc_geometry = meta_theme_gtk_calc_geometry;
   impl_class->draw_frame = meta_theme_gtk_draw_frame;
@@ -882,19 +921,11 @@ meta_theme_gtk_class_init (MetaThemeGtkClass *gtk_class)
 static void
 meta_theme_gtk_init (MetaThemeGtk *gtk)
 {
-  MetaThemeImpl *impl;
   MetaFrameType type;
 
-  impl = META_THEME_IMPL (gtk);
-
   for (type = 0; type < META_FRAME_TYPE_LAST; type++)
     {
-      MetaFrameStyleSet *style_set;
       MetaFrameStyle *style;
-      gint i;
-      gint j;
-
-      style_set = meta_frame_style_set_new (NULL);
 
       style = meta_frame_style_new (NULL);
       style->layout = meta_frame_layout_new ();
@@ -922,37 +953,6 @@ meta_theme_gtk_init (MetaThemeGtk *gtk)
             g_assert_not_reached ();
         }
 
-      for (i = 0; i < META_FRAME_FOCUS_LAST; i++)
-        {
-          for (j = 0; j < META_FRAME_RESIZE_LAST; j++)
-            {
-              meta_frame_style_ref (style);
-              style_set->normal_styles[j][i] = style;
-
-              meta_frame_style_ref (style);
-              style_set->shaded_styles[j][i] = style;
-            }
-
-          meta_frame_style_ref (style);
-          style_set->maximized_styles[i] = style;
-
-          meta_frame_style_ref (style);
-          style_set->tiled_left_styles[i] = style;
-
-          meta_frame_style_ref (style);
-          style_set->tiled_right_styles[i] = style;
-
-          meta_frame_style_ref (style);
-          style_set->maximized_and_shaded_styles[i] = style;
-
-          meta_frame_style_ref (style);
-          style_set->tiled_left_and_shaded_styles[i] = style;
-
-          meta_frame_style_ref (style);
-          style_set->tiled_right_and_shaded_styles[i] = style;
-        }
-
-      meta_frame_style_unref (style);
-      meta_theme_impl_add_style_set (impl, type, style_set);
+      gtk->styles[type] = style;
     }
 }
diff --git a/libmetacity/meta-theme-impl-private.h b/libmetacity/meta-theme-impl-private.h
index 0a0ce20..7155d33 100644
--- a/libmetacity/meta-theme-impl-private.h
+++ b/libmetacity/meta-theme-impl-private.h
@@ -37,39 +37,43 @@ struct _MetaThemeImplClass
 {
   GObjectClass parent_class;
 
-  gboolean   (* load)              (MetaThemeImpl            *impl,
-                                    const gchar              *name,
-                                    GError                  **error);
-
-  void       (* get_frame_borders) (MetaThemeImpl            *impl,
-                                    MetaFrameLayout          *layout,
-                                    MetaStyleInfo            *style_info,
-                                    gint                      text_height,
-                                    MetaFrameFlags            flags,
-                                    MetaFrameType             type,
-                                    MetaFrameBorders         *borders);
-
-  void       (* calc_geometry)     (MetaThemeImpl            *impl,
-                                    MetaFrameLayout          *layout,
-                                    MetaStyleInfo            *style_info,
-                                    gint                      text_height,
-                                    MetaFrameFlags            flags,
-                                    gint                      client_width,
-                                    gint                      client_height,
-                                    MetaButtonLayout         *button_layout,
-                                    MetaFrameType             type,
-                                    MetaFrameGeometry        *fgeom);
-
-  void       (* draw_frame)        (MetaThemeImpl            *impl,
-                                    MetaFrameStyle           *style,
-                                    MetaStyleInfo            *style_info,
-                                    cairo_t                  *cr,
-                                    const MetaFrameGeometry  *fgeom,
-                                    PangoLayout              *title_layout,
-                                    MetaFrameFlags            flags,
-                                    const MetaButtonLayout   *button_layout,
-                                    GdkPixbuf                *mini_icon,
-                                    GdkPixbuf                *icon);
+  gboolean         (* load)              (MetaThemeImpl            *impl,
+                                          const gchar              *name,
+                                          GError                  **error);
+
+  MetaFrameStyle * (* get_frame_style)   (MetaThemeImpl            *impl,
+                                          MetaFrameType             type,
+                                          MetaFrameFlags            flags);
+
+  void             (* get_frame_borders) (MetaThemeImpl            *impl,
+                                          MetaFrameLayout          *layout,
+                                          MetaStyleInfo            *style_info,
+                                          gint                      text_height,
+                                          MetaFrameFlags            flags,
+                                          MetaFrameType             type,
+                                          MetaFrameBorders         *borders);
+
+  void             (* calc_geometry)     (MetaThemeImpl            *impl,
+                                          MetaFrameLayout          *layout,
+                                          MetaStyleInfo            *style_info,
+                                          gint                      text_height,
+                                          MetaFrameFlags            flags,
+                                          gint                      client_width,
+                                          gint                      client_height,
+                                          MetaButtonLayout         *button_layout,
+                                          MetaFrameType             type,
+                                          MetaFrameGeometry        *fgeom);
+
+  void             (* draw_frame)        (MetaThemeImpl            *impl,
+                                          MetaFrameStyle           *style,
+                                          MetaStyleInfo            *style_info,
+                                          cairo_t                  *cr,
+                                          const MetaFrameGeometry  *fgeom,
+                                          PangoLayout              *title_layout,
+                                          MetaFrameFlags            flags,
+                                          const MetaButtonLayout   *button_layout,
+                                          GdkPixbuf                *mini_icon,
+                                          GdkPixbuf                *icon);
 };
 
 G_GNUC_INTERNAL
@@ -87,15 +91,6 @@ G_GNUC_INTERNAL
 gint               meta_theme_impl_get_scale      (MetaThemeImpl           *impl);
 
 G_GNUC_INTERNAL
-void               meta_theme_impl_add_style_set  (MetaThemeImpl           *impl,
-                                                   MetaFrameType            type,
-                                                   MetaFrameStyleSet       *style_set);
-
-G_GNUC_INTERNAL
-MetaFrameStyleSet *meta_theme_impl_get_style_set  (MetaThemeImpl           *impl,
-                                                   MetaFrameType            type);
-
-G_GNUC_INTERNAL
 void               scale_border                   (GtkBorder               *border,
                                                    double                   factor);
 
diff --git a/libmetacity/meta-theme-impl.c b/libmetacity/meta-theme-impl.c
index cee3c75..568844a 100644
--- a/libmetacity/meta-theme-impl.c
+++ b/libmetacity/meta-theme-impl.c
@@ -24,36 +24,12 @@
 
 typedef struct
 {
-  gboolean           composited;
-  gint               scale;
-
-  MetaFrameStyleSet *style_sets_by_type[META_FRAME_TYPE_LAST];
+  gboolean composited;
+  gint     scale;
 } MetaThemeImplPrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE (MetaThemeImpl, meta_theme_impl, G_TYPE_OBJECT)
 
-static void
-meta_theme_impl_dispose (GObject *object)
-{
-  MetaThemeImpl *impl;
-  MetaThemeImplPrivate *priv;
-  gint i;
-
-  impl = META_THEME_IMPL (object);
-  priv = meta_theme_impl_get_instance_private (impl);
-
-  for (i = 0; i < META_FRAME_TYPE_LAST; i++)
-    {
-      if (priv->style_sets_by_type[i])
-        {
-          meta_frame_style_set_unref (priv->style_sets_by_type[i]);
-          priv->style_sets_by_type[i] = NULL;
-        }
-    }
-
-  G_OBJECT_CLASS (meta_theme_impl_parent_class)->dispose (object);
-}
-
 static gboolean
 meta_theme_impl_real_load (MetaThemeImpl  *impl,
                            const gchar    *name,
@@ -71,12 +47,6 @@ meta_theme_impl_real_load (MetaThemeImpl  *impl,
 static void
 meta_theme_impl_class_init (MetaThemeImplClass *impl_class)
 {
-  GObjectClass *object_class;
-
-  object_class = G_OBJECT_CLASS (impl_class);
-
-  object_class->dispose = meta_theme_impl_dispose;
-
   impl_class->load = meta_theme_impl_real_load;
 }
 
@@ -128,32 +98,6 @@ meta_theme_impl_get_scale (MetaThemeImpl *impl)
 }
 
 void
-meta_theme_impl_add_style_set (MetaThemeImpl     *impl,
-                               MetaFrameType      type,
-                               MetaFrameStyleSet *style_set)
-{
-  MetaThemeImplPrivate *priv;
-
-  priv = meta_theme_impl_get_instance_private (impl);
-
-  if (priv->style_sets_by_type[type])
-    meta_frame_style_set_unref (priv->style_sets_by_type[type]);
-
-  priv->style_sets_by_type[type] = style_set;
-}
-
-MetaFrameStyleSet *
-meta_theme_impl_get_style_set (MetaThemeImpl *impl,
-                               MetaFrameType  type)
-{
-  MetaThemeImplPrivate *priv;
-
-  priv = meta_theme_impl_get_instance_private (impl);
-
-  return priv->style_sets_by_type[type];
-}
-
-void
 scale_border (GtkBorder *border,
               double     factor)
 {
diff --git a/libmetacity/meta-theme-metacity.c b/libmetacity/meta-theme-metacity.c
index c43433d..8ab93be 100644
--- a/libmetacity/meta-theme-metacity.c
+++ b/libmetacity/meta-theme-metacity.c
@@ -63,28 +63,30 @@
 
 struct _MetaThemeMetacity
 {
-  MetaThemeImpl  parent;
+  MetaThemeImpl      parent;
 
-  gchar         *name;
-  gchar         *dirname;
+  MetaFrameStyleSet *style_sets_by_type[META_FRAME_TYPE_LAST];
 
-  guint          format_version;
+  gchar             *name;
+  gchar             *dirname;
 
-  gchar         *readable_name;
-  gchar         *author;
-  gchar         *copyright;
-  gchar         *date;
-  gchar         *description;
+  guint              format_version;
 
-  GHashTable    *integers;
-  GHashTable    *floats;
-  GHashTable    *colors;
+  gchar             *readable_name;
+  gchar             *author;
+  gchar             *copyright;
+  gchar             *date;
+  gchar             *description;
 
-  GHashTable    *draw_op_lists;
-  GHashTable    *frame_layouts;
-  GHashTable    *styles;
-  GHashTable    *style_sets;
-  GHashTable    *images;
+  GHashTable        *integers;
+  GHashTable        *floats;
+  GHashTable        *colors;
+
+  GHashTable        *draw_op_lists;
+  GHashTable        *frame_layouts;
+  GHashTable        *styles;
+  GHashTable        *style_sets;
+  GHashTable        *images;
 };
 
 typedef enum
@@ -1300,7 +1302,6 @@ parse_toplevel_element (GMarkupParseContext  *context,
       const char *style_set_name = NULL;
       MetaFrameStyleSet *style_set;
       MetaFrameType type;
-      MetaThemeImpl *impl;
 
       if (!locate_attributes (context, element_name, attribute_names,
                               attribute_values, error,
@@ -1328,8 +1329,7 @@ parse_toplevel_element (GMarkupParseContext  *context,
           return;
         }
 
-      impl = META_THEME_IMPL (info->metacity);
-      if (meta_theme_impl_get_style_set (impl, type) != NULL)
+      if (info->metacity->style_sets_by_type[type] != NULL)
         {
           set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
                      _("Window type '%s' has already been assigned a style set"),
@@ -1338,7 +1338,7 @@ parse_toplevel_element (GMarkupParseContext  *context,
         }
 
       meta_frame_style_set_ref (style_set);
-      meta_theme_impl_add_style_set (impl, type, style_set);
+      info->metacity->style_sets_by_type[type] = style_set;
 
       push_state (info, STATE_WINDOW);
     }
@@ -3872,13 +3872,7 @@ theme_validate (MetaThemeMetacity  *metacity,
 
   for (i = 0; i < META_FRAME_TYPE_LAST; i++)
     {
-      MetaThemeImpl *impl;
-      MetaFrameStyleSet *style_set;
-
-      impl = META_THEME_IMPL (metacity);
-      style_set = meta_theme_impl_get_style_set (impl, i);
-
-      if (i != META_FRAME_TYPE_ATTACHED && style_set == NULL)
+      if (i != META_FRAME_TYPE_ATTACHED && metacity->style_sets_by_type[i] == NULL)
         {
           g_set_error (error, META_THEME_ERROR, META_THEME_ERROR_FAILED,
                        _("No frame style set for window type '%s' in theme '%s', add a <window type='%s' 
style_set='whatever' /> element"),
@@ -4394,9 +4388,6 @@ static void
 clear_theme (MetaThemeMetacity *metacity)
 {
   MetaFrameType type;
-  MetaThemeImpl *impl;
-
-  impl = META_THEME_IMPL (metacity);
 
   g_free (metacity->name);
   metacity->name = NULL;
@@ -4430,7 +4421,13 @@ clear_theme (MetaThemeMetacity *metacity)
   g_hash_table_remove_all (metacity->images);
 
   for (type = 0; type < META_FRAME_TYPE_LAST; type++)
-    meta_theme_impl_add_style_set (impl, type, NULL);
+    {
+      if (metacity->style_sets_by_type[type] != NULL)
+        {
+          meta_frame_style_set_unref (metacity->style_sets_by_type[type]);
+          metacity->style_sets_by_type[type] = NULL;
+        }
+    }
 }
 
 static GMarkupParser metacity_theme_parser =
@@ -4518,9 +4515,19 @@ static void
 meta_theme_metacity_dispose (GObject *object)
 {
   MetaThemeMetacity *metacity;
+  gint i;
 
   metacity = META_THEME_METACITY (object);
 
+  for (i = 0; i < META_FRAME_TYPE_LAST; i++)
+    {
+      if (metacity->style_sets_by_type[i] != NULL)
+        {
+          meta_frame_style_set_unref (metacity->style_sets_by_type[i]);
+          metacity->style_sets_by_type[i] = NULL;
+        }
+    }
+
   g_clear_pointer (&metacity->integers, g_hash_table_destroy);
   g_clear_pointer (&metacity->floats, g_hash_table_destroy);
   g_clear_pointer (&metacity->colors, g_hash_table_destroy);
@@ -4620,6 +4627,99 @@ out:
   return retval;
 }
 
+static MetaFrameStyle *
+meta_theme_metacity_get_frame_style (MetaThemeImpl  *impl,
+                                     MetaFrameType   type,
+                                     MetaFrameFlags  flags)
+{
+  MetaThemeMetacity *metacity;
+  MetaFrameState state;
+  MetaFrameResize resize;
+  MetaFrameFocus focus;
+  MetaFrameStyle *style;
+  MetaFrameStyleSet *style_set;
+
+  g_return_val_if_fail (type < META_FRAME_TYPE_LAST, NULL);
+
+  metacity = META_THEME_METACITY (impl);
+  style_set = metacity->style_sets_by_type[type];
+
+  if (style_set == NULL && type == META_FRAME_TYPE_ATTACHED)
+    style_set = metacity->style_sets_by_type[META_FRAME_TYPE_BORDER];
+
+  /* Right now the parser forces a style set for all other types,
+   * but this fallback code is here in case I take that out.
+   */
+  if (style_set == NULL)
+    style_set = metacity->style_sets_by_type[META_FRAME_TYPE_NORMAL];
+
+  if (style_set == NULL)
+    return NULL;
+
+  switch (flags & (META_FRAME_MAXIMIZED | META_FRAME_SHADED | META_FRAME_TILED_LEFT | 
META_FRAME_TILED_RIGHT))
+    {
+    case 0:
+      state = META_FRAME_STATE_NORMAL;
+      break;
+    case META_FRAME_MAXIMIZED:
+      state = META_FRAME_STATE_MAXIMIZED;
+      break;
+    case META_FRAME_TILED_LEFT:
+      state = META_FRAME_STATE_TILED_LEFT;
+      break;
+    case META_FRAME_TILED_RIGHT:
+      state = META_FRAME_STATE_TILED_RIGHT;
+      break;
+    case META_FRAME_SHADED:
+      state = META_FRAME_STATE_SHADED;
+      break;
+    case (META_FRAME_MAXIMIZED | META_FRAME_SHADED):
+      state = META_FRAME_STATE_MAXIMIZED_AND_SHADED;
+      break;
+    case (META_FRAME_TILED_LEFT | META_FRAME_SHADED):
+      state = META_FRAME_STATE_TILED_LEFT_AND_SHADED;
+      break;
+    case (META_FRAME_TILED_RIGHT | META_FRAME_SHADED):
+      state = META_FRAME_STATE_TILED_RIGHT_AND_SHADED;
+      break;
+    default:
+      g_assert_not_reached ();
+      state = META_FRAME_STATE_LAST; /* compiler */
+      break;
+    }
+
+  switch (flags & (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE))
+    {
+    case 0:
+      resize = META_FRAME_RESIZE_NONE;
+      break;
+    case META_FRAME_ALLOWS_VERTICAL_RESIZE:
+      resize = META_FRAME_RESIZE_VERTICAL;
+      break;
+    case META_FRAME_ALLOWS_HORIZONTAL_RESIZE:
+      resize = META_FRAME_RESIZE_HORIZONTAL;
+      break;
+    case (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE):
+      resize = META_FRAME_RESIZE_BOTH;
+      break;
+    default:
+      g_assert_not_reached ();
+      resize = META_FRAME_RESIZE_LAST; /* compiler */
+      break;
+    }
+
+  /* re invert the styles used for focus/unfocussed while flashing a frame */
+  if (((flags & META_FRAME_HAS_FOCUS) && !(flags & META_FRAME_IS_FLASHING))
+      || (!(flags & META_FRAME_HAS_FOCUS) && (flags & META_FRAME_IS_FLASHING)))
+    focus = META_FRAME_FOCUS_YES;
+  else
+    focus = META_FRAME_FOCUS_NO;
+
+  style = meta_frame_style_set_get_style (style_set, state, resize, focus);
+
+  return style;
+}
+
 static void
 meta_theme_metacity_get_frame_borders (MetaThemeImpl    *impl,
                                        MetaFrameLayout  *layout,
@@ -5585,6 +5685,7 @@ meta_theme_metacity_class_init (MetaThemeMetacityClass *metacity_class)
   object_class->finalize = meta_theme_metacity_finalize;
 
   impl_class->load = meta_theme_metacity_load;
+  impl_class->get_frame_style = meta_theme_metacity_get_frame_style;
   impl_class->get_frame_borders = meta_theme_metacity_get_frame_borders;
   impl_class->calc_geometry = meta_theme_metacity_calc_geometry;
   impl_class->draw_frame = meta_theme_metacity_draw_frame;
diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c
index 3227d6a..0003e89 100644
--- a/libmetacity/meta-theme.c
+++ b/libmetacity/meta-theme.c
@@ -123,97 +123,6 @@ get_style_info (MetaTheme   *theme,
   return style_info;
 }
 
-static MetaFrameStyle *
-get_frame_style (MetaTheme      *theme,
-                 MetaFrameType   type,
-                 MetaFrameFlags  flags)
-{
-  MetaFrameState state;
-  MetaFrameResize resize;
-  MetaFrameFocus focus;
-  MetaFrameStyle *style;
-  MetaFrameStyleSet *style_set;
-
-  g_return_val_if_fail (type < META_FRAME_TYPE_LAST, NULL);
-
-  style_set = meta_theme_impl_get_style_set (theme->impl, type);
-
-  if (style_set == NULL && type == META_FRAME_TYPE_ATTACHED)
-    style_set = meta_theme_impl_get_style_set (theme->impl, META_FRAME_TYPE_BORDER);
-
-  /* Right now the parser forces a style set for all other types,
-   * but this fallback code is here in case I take that out.
-   */
-  if (style_set == NULL)
-    style_set = meta_theme_impl_get_style_set (theme->impl, META_FRAME_TYPE_NORMAL);
-
-  if (style_set == NULL)
-    return NULL;
-
-  switch (flags & (META_FRAME_MAXIMIZED | META_FRAME_SHADED | META_FRAME_TILED_LEFT | 
META_FRAME_TILED_RIGHT))
-    {
-    case 0:
-      state = META_FRAME_STATE_NORMAL;
-      break;
-    case META_FRAME_MAXIMIZED:
-      state = META_FRAME_STATE_MAXIMIZED;
-      break;
-    case META_FRAME_TILED_LEFT:
-      state = META_FRAME_STATE_TILED_LEFT;
-      break;
-    case META_FRAME_TILED_RIGHT:
-      state = META_FRAME_STATE_TILED_RIGHT;
-      break;
-    case META_FRAME_SHADED:
-      state = META_FRAME_STATE_SHADED;
-      break;
-    case (META_FRAME_MAXIMIZED | META_FRAME_SHADED):
-      state = META_FRAME_STATE_MAXIMIZED_AND_SHADED;
-      break;
-    case (META_FRAME_TILED_LEFT | META_FRAME_SHADED):
-      state = META_FRAME_STATE_TILED_LEFT_AND_SHADED;
-      break;
-    case (META_FRAME_TILED_RIGHT | META_FRAME_SHADED):
-      state = META_FRAME_STATE_TILED_RIGHT_AND_SHADED;
-      break;
-    default:
-      g_assert_not_reached ();
-      state = META_FRAME_STATE_LAST; /* compiler */
-      break;
-    }
-
-  switch (flags & (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE))
-    {
-    case 0:
-      resize = META_FRAME_RESIZE_NONE;
-      break;
-    case META_FRAME_ALLOWS_VERTICAL_RESIZE:
-      resize = META_FRAME_RESIZE_VERTICAL;
-      break;
-    case META_FRAME_ALLOWS_HORIZONTAL_RESIZE:
-      resize = META_FRAME_RESIZE_HORIZONTAL;
-      break;
-    case (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE):
-      resize = META_FRAME_RESIZE_BOTH;
-      break;
-    default:
-      g_assert_not_reached ();
-      resize = META_FRAME_RESIZE_LAST; /* compiler */
-      break;
-    }
-
-  /* re invert the styles used for focus/unfocussed while flashing a frame */
-  if (((flags & META_FRAME_HAS_FOCUS) && !(flags & META_FRAME_IS_FLASHING))
-      || (!(flags & META_FRAME_HAS_FOCUS) && (flags & META_FRAME_IS_FLASHING)))
-    focus = META_FRAME_FOCUS_YES;
-  else
-    focus = META_FRAME_FOCUS_NO;
-
-  style = meta_frame_style_set_get_style (style_set, state, resize, focus);
-
-  return style;
-}
-
 static void
 font_desc_apply_scale (PangoFontDescription *font_desc,
                        MetaTheme            *theme,
@@ -225,7 +134,8 @@ font_desc_apply_scale (PangoFontDescription *font_desc,
   gint new_size;
 
   old_size = pango_font_description_get_size (font_desc);
-  style = get_frame_style (theme, type, flags);
+  style = META_THEME_IMPL_GET_CLASS (theme->impl)->get_frame_style (theme->impl,
+                                                                    type, flags);
 
   new_size = MAX (old_size * (style->layout->title_scale / theme->scale), 1);
 
@@ -858,8 +768,8 @@ meta_theme_get_frame_borders (MetaTheme        *theme,
                               MetaFrameFlags    flags,
                               MetaFrameBorders *borders)
 {
-  MetaFrameStyle *style;
   MetaThemeImplClass *impl_class;
+  MetaFrameStyle *style;
   MetaStyleInfo *style_info;
   gint title_height;
 
@@ -867,13 +777,13 @@ meta_theme_get_frame_borders (MetaTheme        *theme,
 
   meta_frame_borders_clear (borders);
 
-  style = get_frame_style (theme, type, flags);
+  impl_class = META_THEME_IMPL_GET_CLASS (theme->impl);
+  style = impl_class->get_frame_style (theme->impl, type, flags);
 
   /* Parser is not supposed to allow this currently */
   if (style == NULL)
     return;
 
-  impl_class = META_THEME_IMPL_GET_CLASS (theme->impl);
   style_info = get_style_info (theme, variant);
   title_height = get_title_height (theme, variant, type, flags);
 
@@ -890,20 +800,20 @@ meta_theme_calc_geometry (MetaTheme         *theme,
                           gint               client_height,
                           MetaFrameGeometry *fgeom)
 {
-  MetaFrameStyle *style;
   MetaThemeImplClass *impl_class;
+  MetaFrameStyle *style;
   MetaStyleInfo *style_info;
   gint title_height;
 
   g_return_if_fail (type < META_FRAME_TYPE_LAST);
 
-  style = get_frame_style (theme, type, flags);
+  impl_class = META_THEME_IMPL_GET_CLASS (theme->impl);
+  style = impl_class->get_frame_style (theme->impl, type, flags);
 
   /* Parser is not supposed to allow this currently */
   if (style == NULL)
     return;
 
-  impl_class = META_THEME_IMPL_GET_CLASS (theme->impl);
   style_info = get_style_info (theme, variant);
   title_height = get_title_height (theme, variant, type, flags);
 
@@ -926,8 +836,8 @@ meta_theme_draw_frame (MetaTheme           *theme,
                        GdkPixbuf           *mini_icon,
                        GdkPixbuf           *icon)
 {
-  MetaFrameStyle *style;
   MetaThemeImplClass *impl_class;
+  MetaFrameStyle *style;
   MetaStyleInfo *style_info;
   gint title_height;
   PangoLayout *title_layout;
@@ -936,13 +846,13 @@ meta_theme_draw_frame (MetaTheme           *theme,
 
   g_return_if_fail (type < META_FRAME_TYPE_LAST);
 
-  style = get_frame_style (theme, type, flags);
+  impl_class = META_THEME_IMPL_GET_CLASS (theme->impl);
+  style = impl_class->get_frame_style (theme->impl, type, flags);
 
   /* Parser is not supposed to allow this currently */
   if (style == NULL)
     return;
 
-  impl_class = META_THEME_IMPL_GET_CLASS (theme->impl);
   style_info = get_style_info (theme, variant);
   title_height = get_title_height (theme, variant, type, flags);
   title_layout = create_title_layout (theme, variant, type, flags, title);


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