[metacity] window: cache _NET_WM_ICON_GEOMETRY
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] window: cache _NET_WM_ICON_GEOMETRY
- Date: Sun, 26 Feb 2017 22:23:26 +0000 (UTC)
commit 5646b941170de227ee81ecbcd5bde51c533a5fed
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Feb 1 11:32:53 2013 +0100
window: cache _NET_WM_ICON_GEOMETRY
Rather than doing a server round trip each time when retrieving the
icon geometry, use the existing property mechanism to cache it.
https://bugzilla.gnome.org/show_bug.cgi?id=692997
src/core/window-private.h | 6 ++++++
src/core/window-props.c | 33 +++++++++++++++++++++++++++++++++
src/core/window.c | 25 ++-----------------------
3 files changed, 41 insertions(+), 23 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index afe4b2d..d54d03f 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -204,6 +204,9 @@ struct _MetaWindow
/* whether net_wm_user_time has been set yet */
guint net_wm_user_time_set : 1;
+ /* whether net_wm_icon_geometry has been set */
+ guint icon_geometry_set : 1;
+
/* These are the flags from WM_PROTOCOLS */
guint take_focus : 1;
guint delete_window : 1;
@@ -369,6 +372,9 @@ struct _MetaWindow
*/
MetaRectangle user_rect;
+ /* Cached net_wm_icon_geometry */
+ MetaRectangle icon_geometry;
+
/* Requested geometry */
int border_width;
/* x/y/w/h here get filled with ConfigureRequest values */
diff --git a/src/core/window-props.c b/src/core/window-props.c
index 77741ed..c9a972e 100644
--- a/src/core/window-props.c
+++ b/src/core/window-props.c
@@ -346,6 +346,33 @@ reload_gtk_frame_extents (MetaWindow *window,
}
static void
+reload_icon_geometry (MetaWindow *window,
+ MetaPropValue *value,
+ gboolean initial)
+{
+ if (value->type != META_PROP_VALUE_INVALID)
+ {
+ if (value->v.cardinal_list.n_cardinals != 4)
+ {
+ meta_verbose ("_NET_WM_ICON_GEOMETRY on %s has %d values instead of 4\n",
+ window->desc, value->v.cardinal_list.n_cardinals);
+ }
+ else
+ {
+ window->icon_geometry.x = (int)value->v.cardinal_list.cardinals[0];
+ window->icon_geometry.y = (int)value->v.cardinal_list.cardinals[1];
+ window->icon_geometry.width = (int)value->v.cardinal_list.cardinals[2];
+ window->icon_geometry.height = (int)value->v.cardinal_list.cardinals[3];
+ window->icon_geometry_set = TRUE;
+ }
+ }
+ else
+ {
+ window->icon_geometry_set = FALSE;
+ }
+}
+
+static void
reload_struts (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
@@ -1715,6 +1742,12 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
NONE
},
{
+ display->atom__NET_WM_ICON_GEOMETRY,
+ META_PROP_VALUE_CARDINAL_LIST,
+ reload_icon_geometry,
+ LOAD_INIT
+ },
+ {
display->atom_WM_CLIENT_LEADER,
META_PROP_VALUE_INVALID,
complain_about_broken_client,
diff --git a/src/core/window.c b/src/core/window.c
index 64c759b..506ad15 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -5807,31 +5807,10 @@ gboolean
meta_window_get_icon_geometry (MetaWindow *window,
MetaRectangle *rect)
{
- gulong *geometry = NULL;
- int nitems;
-
- if (meta_prop_get_cardinal_list (window->display,
- window->xwindow,
- window->display->atom__NET_WM_ICON_GEOMETRY,
- &geometry, &nitems))
+ if (window->icon_geometry_set)
{
- if (nitems != 4)
- {
- meta_verbose ("_NET_WM_ICON_GEOMETRY on %s has %d values instead of 4\n",
- window->desc, nitems);
- meta_XFree (geometry);
- return FALSE;
- }
-
if (rect)
- {
- rect->x = geometry[0];
- rect->y = geometry[1];
- rect->width = geometry[2];
- rect->height = geometry[3];
- }
-
- meta_XFree (geometry);
+ *rect = window->icon_geometry;
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]