Commit 8cbcbb06 authored by Thomas James Alexander Thurman's avatar Thomas James Alexander Thurman
Browse files

More of the window properties are checked using simple

        window property handlers.  The ones which remain don't
        actually look up the new value in the ordinary way, and
        so are a little trickier to merge.  Added an "initial"
        flag to be on the safe side that the behaviour is the
        same as before (so we don't do things when a window's
        first mapped that we only used to do when a property
        changed).  Partial fix for bug #549886.
	* src/core/window-props.c:
	* src/core/window-props.h:
	* src/core/window.c:


svn path=/trunk/; revision=4089
parent 35d9d286
2009-01-26 Thomas Thurman <tthurman@gnome.org>
More of the window properties are checked using simple
window property handlers. The ones which remain don't
actually look up the new value in the ordinary way, and
so are a little trickier to merge. Added an "initial"
flag to be on the safe side that the behaviour is the
same as before (so we don't do things when a window's
first mapped that we only used to do when a property
changed). Partial fix for bug #549886.
* src/core/window-props.c:
* src/core/window-props.h:
* src/core/window.c:
2009-01-25 Elijah Newren <newren gmail com> 2009-01-25 Elijah Newren <newren gmail com>
* src/core/window.c: add support for _NET_WM_MOVERESIZE_CANCEL. * src/core/window.c: add support for _NET_WM_MOVERESIZE_CANCEL.
......
...@@ -54,7 +54,8 @@ typedef void (* InitValueFunc) (MetaDisplay *display, ...@@ -54,7 +54,8 @@ typedef void (* InitValueFunc) (MetaDisplay *display,
Atom property, Atom property,
MetaPropValue *value); MetaPropValue *value);
typedef void (* ReloadValueFunc) (MetaWindow *window, typedef void (* ReloadValueFunc) (MetaWindow *window,
MetaPropValue *value); MetaPropValue *value,
gboolean initial);
struct _MetaWindowPropHooks struct _MetaWindowPropHooks
{ {
...@@ -67,42 +68,49 @@ static void init_prop_value (MetaDisplay *display, ...@@ -67,42 +68,49 @@ static void init_prop_value (MetaDisplay *display,
Atom property, Atom property,
MetaPropValue *value); MetaPropValue *value);
static void reload_prop_value (MetaWindow *window, static void reload_prop_value (MetaWindow *window,
MetaPropValue *value); MetaPropValue *value,
gboolean initial);
static MetaWindowPropHooks* find_hooks (MetaDisplay *display, static MetaWindowPropHooks* find_hooks (MetaDisplay *display,
Atom property); Atom property);
void void
meta_window_reload_property (MetaWindow *window, meta_window_reload_property (MetaWindow *window,
Atom property) Atom property,
gboolean initial)
{ {
meta_window_reload_properties (window, &property, 1); meta_window_reload_properties (window, &property, 1, initial);
} }
void void
meta_window_reload_properties (MetaWindow *window, meta_window_reload_properties (MetaWindow *window,
const Atom *properties, const Atom *properties,
int n_properties) int n_properties,
gboolean initial)
{ {
meta_window_reload_properties_from_xwindow (window, meta_window_reload_properties_from_xwindow (window,
window->xwindow, window->xwindow,
properties, properties,
n_properties); n_properties,
initial);
} }
void void
meta_window_reload_property_from_xwindow (MetaWindow *window, meta_window_reload_property_from_xwindow (MetaWindow *window,
Window xwindow, Window xwindow,
Atom property) Atom property,
gboolean initial)
{ {
meta_window_reload_properties_from_xwindow (window, xwindow, &property, 1); meta_window_reload_properties_from_xwindow (window, xwindow, &property, 1,
initial);
} }
void void
meta_window_reload_properties_from_xwindow (MetaWindow *window, meta_window_reload_properties_from_xwindow (MetaWindow *window,
Window xwindow, Window xwindow,
const Atom *properties, const Atom *properties,
int n_properties) int n_properties,
gboolean initial)
{ {
int i; int i;
MetaPropValue *values; MetaPropValue *values;
...@@ -125,7 +133,7 @@ meta_window_reload_properties_from_xwindow (MetaWindow *window, ...@@ -125,7 +133,7 @@ meta_window_reload_properties_from_xwindow (MetaWindow *window,
i = 0; i = 0;
while (i < n_properties) while (i < n_properties)
{ {
reload_prop_value (window, &values[i]); reload_prop_value (window, &values[i], initial);
++i; ++i;
} }
...@@ -153,13 +161,14 @@ init_prop_value (MetaDisplay *display, ...@@ -153,13 +161,14 @@ init_prop_value (MetaDisplay *display,
static void static void
reload_prop_value (MetaWindow *window, reload_prop_value (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
MetaWindowPropHooks *hooks; MetaWindowPropHooks *hooks;
hooks = find_hooks (window->display, value->atom); hooks = find_hooks (window->display, value->atom);
if (hooks && hooks->reload_func != NULL) if (hooks && hooks->reload_func != NULL)
(* hooks->reload_func) (window, value); (* hooks->reload_func) (window, value, initial);
} }
static void static void
...@@ -173,7 +182,8 @@ init_wm_client_machine (MetaDisplay *display, ...@@ -173,7 +182,8 @@ init_wm_client_machine (MetaDisplay *display,
static void static void
reload_wm_client_machine (MetaWindow *window, reload_wm_client_machine (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
g_free (window->wm_client_machine); g_free (window->wm_client_machine);
window->wm_client_machine = NULL; window->wm_client_machine = NULL;
...@@ -196,7 +206,8 @@ init_net_wm_pid (MetaDisplay *display, ...@@ -196,7 +206,8 @@ init_net_wm_pid (MetaDisplay *display,
static void static void
reload_net_wm_pid (MetaWindow *window, reload_net_wm_pid (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (value->type != META_PROP_VALUE_INVALID) if (value->type != META_PROP_VALUE_INVALID)
{ {
...@@ -225,7 +236,8 @@ init_net_wm_user_time (MetaDisplay *display, ...@@ -225,7 +236,8 @@ init_net_wm_user_time (MetaDisplay *display,
static void static void
reload_net_wm_user_time (MetaWindow *window, reload_net_wm_user_time (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (value->type != META_PROP_VALUE_INVALID) if (value->type != META_PROP_VALUE_INVALID)
{ {
...@@ -245,7 +257,8 @@ init_net_wm_user_time_window (MetaDisplay *display, ...@@ -245,7 +257,8 @@ init_net_wm_user_time_window (MetaDisplay *display,
static void static void
reload_net_wm_user_time_window (MetaWindow *window, reload_net_wm_user_time_window (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (value->type != META_PROP_VALUE_INVALID) if (value->type != META_PROP_VALUE_INVALID)
{ {
...@@ -293,7 +306,8 @@ reload_net_wm_user_time_window (MetaWindow *window, ...@@ -293,7 +306,8 @@ reload_net_wm_user_time_window (MetaWindow *window,
meta_window_reload_property_from_xwindow ( meta_window_reload_property_from_xwindow (
window, window,
window->user_time_window, window->user_time_window,
window->display->atom__NET_WM_USER_TIME); window->display->atom__NET_WM_USER_TIME,
initial);
} }
} }
} }
...@@ -397,7 +411,8 @@ init_net_wm_name (MetaDisplay *display, ...@@ -397,7 +411,8 @@ init_net_wm_name (MetaDisplay *display,
static void static void
reload_net_wm_name (MetaWindow *window, reload_net_wm_name (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (value->type != META_PROP_VALUE_INVALID) if (value->type != META_PROP_VALUE_INVALID)
{ {
...@@ -411,6 +426,8 @@ reload_net_wm_name (MetaWindow *window, ...@@ -411,6 +426,8 @@ reload_net_wm_name (MetaWindow *window,
{ {
set_window_title (window, NULL); set_window_title (window, NULL);
window->using_net_wm_name = FALSE; window->using_net_wm_name = FALSE;
if (!initial)
meta_window_reload_property (window, XA_WM_NAME, FALSE);
} }
} }
...@@ -426,7 +443,8 @@ init_wm_name (MetaDisplay *display, ...@@ -426,7 +443,8 @@ init_wm_name (MetaDisplay *display,
static void static void
reload_wm_name (MetaWindow *window, reload_wm_name (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (window->using_net_wm_name) if (window->using_net_wm_name)
{ {
...@@ -472,7 +490,8 @@ init_net_wm_icon_name (MetaDisplay *display, ...@@ -472,7 +490,8 @@ init_net_wm_icon_name (MetaDisplay *display,
static void static void
reload_net_wm_icon_name (MetaWindow *window, reload_net_wm_icon_name (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (value->type != META_PROP_VALUE_INVALID) if (value->type != META_PROP_VALUE_INVALID)
{ {
...@@ -486,6 +505,8 @@ reload_net_wm_icon_name (MetaWindow *window, ...@@ -486,6 +505,8 @@ reload_net_wm_icon_name (MetaWindow *window,
{ {
set_icon_title (window, NULL); set_icon_title (window, NULL);
window->using_net_wm_icon_name = FALSE; window->using_net_wm_icon_name = FALSE;
if (!initial)
meta_window_reload_property (window, XA_WM_ICON_NAME, FALSE);
} }
} }
...@@ -501,7 +522,8 @@ init_wm_icon_name (MetaDisplay *display, ...@@ -501,7 +522,8 @@ init_wm_icon_name (MetaDisplay *display,
static void static void
reload_wm_icon_name (MetaWindow *window, reload_wm_icon_name (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (window->using_net_wm_icon_name) if (window->using_net_wm_icon_name)
{ {
...@@ -534,7 +556,8 @@ init_net_wm_state (MetaDisplay *display, ...@@ -534,7 +556,8 @@ init_net_wm_state (MetaDisplay *display,
static void static void
reload_net_wm_state (MetaWindow *window, reload_net_wm_state (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
int i; int i;
...@@ -603,7 +626,8 @@ init_mwm_hints (MetaDisplay *display, ...@@ -603,7 +626,8 @@ init_mwm_hints (MetaDisplay *display,
static void static void
reload_mwm_hints (MetaWindow *window, reload_mwm_hints (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
MotifWmHints *hints; MotifWmHints *hints;
...@@ -736,7 +760,8 @@ init_wm_class (MetaDisplay *display, ...@@ -736,7 +760,8 @@ init_wm_class (MetaDisplay *display,
static void static void
reload_wm_class (MetaWindow *window, reload_wm_class (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (window->res_class) if (window->res_class)
g_free (window->res_class); g_free (window->res_class);
...@@ -772,7 +797,8 @@ init_net_wm_desktop (MetaDisplay *display, ...@@ -772,7 +797,8 @@ init_net_wm_desktop (MetaDisplay *display,
static void static void
reload_net_wm_desktop (MetaWindow *window, reload_net_wm_desktop (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (value->type != META_PROP_VALUE_INVALID) if (value->type != META_PROP_VALUE_INVALID)
{ {
...@@ -795,7 +821,8 @@ init_net_startup_id (MetaDisplay *display, ...@@ -795,7 +821,8 @@ init_net_startup_id (MetaDisplay *display,
static void static void
reload_net_startup_id (MetaWindow *window, reload_net_startup_id (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
guint32 timestamp = window->net_wm_user_time; guint32 timestamp = window->net_wm_user_time;
MetaWorkspace *workspace = NULL; MetaWorkspace *workspace = NULL;
...@@ -841,7 +868,8 @@ init_update_counter (MetaDisplay *display, ...@@ -841,7 +868,8 @@ init_update_counter (MetaDisplay *display,
static void static void
reload_update_counter (MetaWindow *window, reload_update_counter (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (value->type != META_PROP_VALUE_INVALID) if (value->type != META_PROP_VALUE_INVALID)
{ {
...@@ -1270,7 +1298,8 @@ meta_set_normal_hints (MetaWindow *window, ...@@ -1270,7 +1298,8 @@ meta_set_normal_hints (MetaWindow *window,
static void static void
reload_normal_hints (MetaWindow *window, reload_normal_hints (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
if (value->type != META_PROP_VALUE_INVALID) if (value->type != META_PROP_VALUE_INVALID)
{ {
...@@ -1285,6 +1314,9 @@ reload_normal_hints (MetaWindow *window, ...@@ -1285,6 +1314,9 @@ reload_normal_hints (MetaWindow *window,
spew_size_hints_differences (&old_hints, &window->size_hints); spew_size_hints_differences (&old_hints, &window->size_hints);
meta_window_recalc_features (window); meta_window_recalc_features (window);
if (!initial)
meta_window_queue(window, META_QUEUE_MOVE_RESIZE);
} }
} }
...@@ -1300,7 +1332,8 @@ init_wm_protocols (MetaDisplay *display, ...@@ -1300,7 +1332,8 @@ init_wm_protocols (MetaDisplay *display,
static void static void
reload_wm_protocols (MetaWindow *window, reload_wm_protocols (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
int i; int i;
...@@ -1342,7 +1375,8 @@ init_wm_hints (MetaDisplay *display, ...@@ -1342,7 +1375,8 @@ init_wm_hints (MetaDisplay *display,
static void static void
reload_wm_hints (MetaWindow *window, reload_wm_hints (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
Window old_group_leader; Window old_group_leader;
...@@ -1407,7 +1441,8 @@ init_transient_for (MetaDisplay *display, ...@@ -1407,7 +1441,8 @@ init_transient_for (MetaDisplay *display,
static void static void
reload_transient_for (MetaWindow *window, reload_transient_for (MetaWindow *window,
MetaPropValue *value) MetaPropValue *value,
gboolean initial)
{ {
window->xtransient_for = None; window->xtransient_for = None;
......
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
* \param property A single X atom. * \param property A single X atom.
*/ */
void meta_window_reload_property (MetaWindow *window, void meta_window_reload_property (MetaWindow *window,
Atom property); Atom property,
gboolean initial);
/** /**
...@@ -57,7 +58,8 @@ void meta_window_reload_property (MetaWindow *window, ...@@ -57,7 +58,8 @@ void meta_window_reload_property (MetaWindow *window,
*/ */
void meta_window_reload_properties (MetaWindow *window, void meta_window_reload_properties (MetaWindow *window,
const Atom *properties, const Atom *properties,
int n_properties); int n_properties,
gboolean initial);
/** /**
* Requests the current values of a single property for a given * Requests the current values of a single property for a given
...@@ -72,7 +74,8 @@ void meta_window_reload_properties (MetaWindow *window, ...@@ -72,7 +74,8 @@ void meta_window_reload_properties (MetaWindow *window,
void meta_window_reload_property_from_xwindow void meta_window_reload_property_from_xwindow
(MetaWindow *window, (MetaWindow *window,
Window xwindow, Window xwindow,
Atom property); Atom property,
gboolean initial);
/** /**
* Requests the current values of a set of properties for a given * Requests the current values of a set of properties for a given
...@@ -89,7 +92,8 @@ void meta_window_reload_properties_from_xwindow ...@@ -89,7 +92,8 @@ void meta_window_reload_properties_from_xwindow
(MetaWindow *window, (MetaWindow *window,
Window xwindow, Window xwindow,
const Atom *properties, const Atom *properties,
int n_properties); int n_properties,
gboolean initial);
/** /**
* Initialises the hooks used for the reload_propert* functions * Initialises the hooks used for the reload_propert* functions
......
...@@ -595,7 +595,7 @@ meta_window_new_with_attrs (MetaDisplay *display, ...@@ -595,7 +595,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
initial_props[i++] = display->atom__NET_WM_FULLSCREEN_MONITORS; initial_props[i++] = display->atom__NET_WM_FULLSCREEN_MONITORS;
g_assert (N_INITIAL_PROPS == i); g_assert (N_INITIAL_PROPS == i);
meta_window_reload_properties (window, initial_props, N_INITIAL_PROPS); meta_window_reload_properties (window, initial_props, N_INITIAL_PROPS, TRUE);
update_sm_hints (window); /* must come after transient_for */ update_sm_hints (window); /* must come after transient_for */
update_role (window); update_role (window);
...@@ -5431,17 +5431,7 @@ static gboolean ...@@ -5431,17 +5431,7 @@ static gboolean
process_property_notify (MetaWindow *window, process_property_notify (MetaWindow *window,
XPropertyEvent *event) XPropertyEvent *event)
{ {
/* First, property notifies to ignore because we shouldn't honor /* Property notifies we want to use.
* new values
*/
if (event->atom == window->display->atom__NET_WM_STATE)
{
meta_verbose ("Property notify on %s for _NET_WM_STATE, ignoring (we should be the one who set the property in the first place)\n",
window->desc);
return TRUE;
}
/* Second, property notifies we want to use.
* FIXME once we move entirely to the window-props.h framework, we * FIXME once we move entirely to the window-props.h framework, we
* can just call reload on the property in the event and get rid of * can just call reload on the property in the event and get rid of
* this if-else chain. * this if-else chain.
...@@ -5457,64 +5447,7 @@ process_property_notify (MetaWindow *window, ...@@ -5457,64 +5447,7 @@ process_property_notify (MetaWindow *window,
XFree (property_name); XFree (property_name);
} }
if (event->atom == XA_WM_NAME) if (event->atom == window->display->atom_WM_WINDOW_ROLE)
{
/* don't bother reloading WM_NAME if using _NET_WM_NAME already */
if (!window->using_net_wm_name)
meta_window_reload_property (window, XA_WM_NAME);
}
else if (event->atom == window->display->atom__NET_WM_NAME)
{
meta_window_reload_property (window, window->display->atom__NET_WM_NAME);
/* if _NET_WM_NAME was unset, reload WM_NAME */
if (!window->using_net_wm_name)
meta_window_reload_property (window, XA_WM_NAME);
}
else if (event->atom == XA_WM_ICON_NAME)
{
/* don't bother reloading WM_ICON_NAME if using _NET_WM_ICON_NAME already */
if (!window->using_net_wm_icon_name)
meta_window_reload_property (window, XA_WM_ICON_NAME);
}
else if (event->atom == window->display->atom__NET_WM_ICON_NAME)
{
meta_window_reload_property (window, window->display->atom__NET_WM_ICON_NAME);
/* if _NET_WM_ICON_NAME was unset, reload WM_ICON_NAME */
if (!window->using_net_wm_icon_name)
meta_window_reload_property (window, XA_WM_ICON_NAME);
}
else if (event->atom == XA_WM_NORMAL_HINTS)
{
meta_window_reload_property (window, XA_WM_NORMAL_HINTS);
/* See if we need to constrain current size */
meta_window_queue(window, META_QUEUE_MOVE_RESIZE);
}
else if (event->atom == window->display->atom_WM_PROTOCOLS)
{
meta_window_reload_property (window, window->display->atom_WM_PROTOCOLS);
}
else if (event->atom == XA_WM_HINTS)
{
meta_window_reload_property (window, XA_WM_HINTS);
}
else if (event->atom == window->display->atom__MOTIF_WM_HINTS)
{
meta_window_reload_property (window,
window->display->atom__MOTIF_WM_HINTS);
}
else if (event->atom == XA_WM_CLASS)
{
meta_window_reload_property (window, XA_WM_CLASS);
}
else if (event->atom == XA_WM_TRANSIENT_FOR)
{
meta_window_reload_property (window, XA_WM_TRANSIENT_FOR);
}
else if (event->atom ==
window->display->atom_WM_WINDOW_ROLE)
{ {
update_role (window); update_role (window);
} }
...@@ -5525,6 +5458,11 @@ process_property_notify (MetaWindow *window, ...@@ -5525,6 +5458,11 @@ process_property_notify (MetaWindow *window,
{ {
meta_warning ("Broken client! Window %s changed client leader window or SM client ID\n", window->desc); meta_warning ("Broken client! Window %s changed client leader window or SM client ID\n", window->desc);
} }