[mutter] window: Cache _NET_WM_ICON_GEOMETRY
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] window: Cache _NET_WM_ICON_GEOMETRY
- Date: Fri, 1 Feb 2013 16:39:41 +0000 (UTC)
commit 30bdadb519256caa45664168026c768c096dd88c
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 | 29 ++++++++++++++++++++++++++++-
src/core/window.c | 29 +++--------------------------
3 files changed, 37 insertions(+), 27 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 9b7987d..ad8079b 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -220,6 +220,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;
@@ -391,6 +394,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 7442090..d055a39 100644
--- a/src/core/window-props.c
+++ b/src/core/window-props.c
@@ -246,6 +246,33 @@ reload_kwm_win_icon (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)
@@ -1728,7 +1755,7 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
{ display->atom_WM_STATE, META_PROP_VALUE_INVALID, NULL, FALSE, FALSE },
{ display->atom__NET_WM_ICON, META_PROP_VALUE_INVALID, reload_net_wm_icon, FALSE, FALSE },
{ display->atom__KWM_WIN_ICON, META_PROP_VALUE_INVALID, reload_kwm_win_icon, FALSE, FALSE },
- { display->atom__NET_WM_ICON_GEOMETRY, META_PROP_VALUE_INVALID, NULL, FALSE, FALSE },
+ { display->atom__NET_WM_ICON_GEOMETRY, META_PROP_VALUE_CARDINAL_LIST, reload_icon_geometry, FALSE, FALSE },
{ display->atom_WM_CLIENT_LEADER, META_PROP_VALUE_INVALID, complain_about_broken_client, FALSE, FALSE },
{ display->atom_SM_CLIENT_ID, META_PROP_VALUE_INVALID, complain_about_broken_client, FALSE, FALSE },
{ display->atom_WM_WINDOW_ROLE, META_PROP_VALUE_INVALID, reload_wm_window_role, FALSE, FALSE },
diff --git a/src/core/window.c b/src/core/window.c
index 253ce40..660be66 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -7151,9 +7151,7 @@ send_configure_notify (MetaWindow *window)
*
* Gets the location of the icon corresponding to the window. The location
* will be provided set by the task bar or other user interface element
- * displaying the icon, and is relative to the root window. This currently
- * retrieves the icon geometry from the X server as a round trip on every
- * call.
+ * displaying the icon, and is relative to the root window.
*
* Return value: %TRUE if the icon geometry was succesfully retrieved.
*/
@@ -7161,33 +7159,12 @@ gboolean
meta_window_get_icon_geometry (MetaWindow *window,
MetaRectangle *rect)
{
- gulong *geometry = NULL;
- int nitems;
-
g_return_val_if_fail (!window->override_redirect, FALSE);
- 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]