[metacity] add support for _GTK_FRAME_EXTENTS



commit e132e2a700c4b50c93eae064d8fd1769b67baf06
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Oct 5 03:15:56 2014 +0300

    add support for _GTK_FRAME_EXTENTS
    
    Support for _GTK_FRAME_EXTENTS are based on mutter.

 src/core/atomnames.h      |    1 +
 src/core/window-private.h |    3 ++
 src/core/window-props.c   |   68 +++++++++++++++++++++++++++++++++++++++++++++
 src/core/window.c         |   13 ++++++++-
 4 files changed, 84 insertions(+), 1 deletions(-)
---
diff --git a/src/core/atomnames.h b/src/core/atomnames.h
index 7048d63..8f6cd3a 100644
--- a/src/core/atomnames.h
+++ b/src/core/atomnames.h
@@ -57,6 +57,7 @@ item(_METACITY_RELOAD_THEME_MESSAGE)
 item(_METACITY_SET_KEYBINDINGS_MESSAGE)
 item(_METACITY_SET_MOUSEMODS_MESSAGE)
 item(_METACITY_TOGGLE_VERBOSE)
+item(_GTK_FRAME_EXTENTS)
 item(_GNOME_PANEL_ACTION)
 item(_GNOME_PANEL_ACTION_MAIN_MENU)
 item(_GNOME_PANEL_ACTION_RUN_DIALOG)
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 875ccdf..807428f 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -346,6 +346,9 @@ struct _MetaWindow
    */
   MetaRectangle rect;
 
+  gboolean has_custom_frame_extents;
+  GtkBorder custom_frame_extents;
+
   /* The geometry to restore when we unmaximize.  The position is in
    * root window coords, even if there's a frame, which contrasts with
    * window->rect above.  Note that this gives the position and size
diff --git a/src/core/window-props.c b/src/core/window-props.c
index 462dbb8..59eea24 100644
--- a/src/core/window-props.c
+++ b/src/core/window-props.c
@@ -309,6 +309,68 @@ reload_kwm_win_icon (MetaWindow    *window,
   reload_icon (window, window->display->atom__KWM_WIN_ICON);
 }
 
+static gboolean
+gtk_border_equal (GtkBorder *a,
+                  GtkBorder *b)
+{
+  return (a->left == b->left &&
+          a->right == b->right &&
+          a->top == b->top &&
+          a->bottom == b->bottom);
+}
+
+static void
+meta_window_set_custom_frame_extents (MetaWindow *window,
+                                      GtkBorder  *extents)
+{
+  if (extents)
+    {
+      if (window->has_custom_frame_extents && gtk_border_equal (&window->custom_frame_extents, extents))
+        return;
+
+      window->has_custom_frame_extents = TRUE;
+      window->custom_frame_extents = *extents;
+    }
+  else
+    {
+      if (!window->has_custom_frame_extents)
+        return;
+
+      window->has_custom_frame_extents = FALSE;
+      memset (&window->custom_frame_extents, 0, sizeof (window->custom_frame_extents));
+    }
+
+  meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
+}
+
+static void
+reload_gtk_frame_extents (MetaWindow    *window,
+                          MetaPropValue *value,
+                          gboolean       initial)
+{
+  if (value->type != META_PROP_VALUE_INVALID)
+    {
+      if (value->v.cardinal_list.n_cardinals != 4)
+        {
+          meta_verbose ("_GTK_FRAME_EXTENTS on %s has %d values instead of 4\n",
+                        window->desc, value->v.cardinal_list.n_cardinals);
+        }
+      else
+        {
+          GtkBorder extents;
+          extents.left   = (int)value->v.cardinal_list.cardinals[0];
+          extents.right  = (int)value->v.cardinal_list.cardinals[1];
+          extents.top    = (int)value->v.cardinal_list.cardinals[2];
+          extents.bottom = (int)value->v.cardinal_list.cardinals[3];
+          meta_window_set_custom_frame_extents (window, &extents);
+        }
+    }
+  else
+    {
+      meta_window_set_custom_frame_extents (window, NULL);
+    }
+}
+
 static void
 reload_struts (MetaWindow    *window,
                MetaPropValue *value,
@@ -1686,6 +1748,12 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
       LOAD_INIT
     },
     {
+      display->atom__GTK_FRAME_EXTENTS,
+      META_PROP_VALUE_CARDINAL_LIST,
+      reload_gtk_frame_extents,
+      LOAD_INIT
+    },
+    {
       display->atom__NET_WM_USER_TIME_WINDOW,
       META_PROP_VALUE_WINDOW,
       reload_net_wm_user_time_window,
diff --git a/src/core/window.c b/src/core/window.c
index cfb4deb..3eca155 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4006,7 +4006,18 @@ meta_window_get_outer_rect (const MetaWindow *window,
   if (window->frame)
     *rect = window->frame->rect;
   else
-    *rect = window->rect;
+    {
+      *rect = window->rect;
+
+      if (window->has_custom_frame_extents)
+        {
+          const GtkBorder *extents = &window->custom_frame_extents;
+          rect->x += extents->left;
+          rect->y += extents->top;
+          rect->width -= extents->left + extents->right;
+          rect->height -= extents->top + extents->bottom;
+        }
+    }
 }
 
 void


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