Sync up to upstream 2.25.144

Conflicts:

	configure.in
	src/core/main.c
	src/core/prefs.c
	src/core/window.c
	src/include/prefs.h
This commit is contained in:
Tomas Frydrych
2009-02-12 17:14:12 +00:00
36 changed files with 25793 additions and 18572 deletions

View File

@ -50,7 +50,6 @@
typedef struct _MetaStack MetaStack;
typedef struct _MetaUISlave MetaUISlave;
typedef struct _MetaWindowPropHooks MetaWindowPropHooks;
typedef struct _MetaGroupPropHooks MetaGroupPropHooks;
typedef struct MetaEdgeResistanceData MetaEdgeResistanceData;
@ -233,7 +232,8 @@ struct _MetaDisplay
MetaWindow *window_with_menu;
/* Managed by window-props.c */
MetaWindowPropHooks *prop_hooks;
gpointer *prop_hooks_table;
GHashTable *prop_hooks;
/* Managed by group-props.c */
MetaGroupPropHooks *group_prop_hooks;

View File

@ -1682,7 +1682,7 @@ event_callback (XEvent *event,
if (!unmodified)
begin_move = TRUE;
}
else if (!unmodified && event->xbutton.button == 2)
else if (!unmodified && event->xbutton.button == meta_prefs_get_mouse_button_resize())
{
if (window->has_resize_func)
{
@ -1731,7 +1731,7 @@ event_callback (XEvent *event,
event->xbutton.y_root);
}
}
else if (event->xbutton.button == 3)
else if (event->xbutton.button == meta_prefs_get_mouse_button_menu())
{
if (meta_prefs_get_raise_on_click ())
meta_window_raise (window);

View File

@ -985,8 +985,8 @@ meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display)
cur_window_iter = cur_window_iter->next;
}
/* Put 'em in bottom to top order */
rem_windows = g_slist_reverse (obscuring_windows);
rem_win_stacking = g_slist_reverse (window_stacking);
rem_windows = obscuring_windows = g_slist_reverse (obscuring_windows);
rem_win_stacking = window_stacking = g_slist_reverse (window_stacking);
/*
* 3rd: loop over the windows again, this time getting the edges from

View File

@ -479,6 +479,9 @@ main (int argc, char **argv)
guint i;
GOptionContext *ctx;
if (!g_thread_supported ())
g_thread_init (NULL);
if (setlocale (LC_ALL, "") == NULL)
meta_warning ("Locale not understood by C library, internationalization will not work\n");

View File

@ -102,6 +102,7 @@ static gboolean gnome_animations = TRUE;
static char *cursor_theme = NULL;
static int cursor_size = 24;
static gboolean compositing_manager = FALSE;
static gboolean resize_with_right_button = FALSE;
static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_FULLSCREEN_FLASH;
static MetaButtonLayout button_layout;
@ -421,6 +422,11 @@ static MetaBoolPreference preferences_bool[] =
&compositing_manager,
FALSE,
},
{ "/apps/metacity/general/resize_with_right_button",
META_PREF_RESIZE_WITH_RIGHT_BUTTON,
&resize_with_right_button,
FALSE,
},
#ifdef WITH_CLUTTER
{ "/apps/metacity/general/clutter_disabled",
META_PREF_CLUTTER_DISABLED,
@ -1395,6 +1401,8 @@ theme_name_handler (MetaPreference pref,
const gchar *string_value,
gboolean *inform_listeners)
{
g_free (current_theme);
/* Fallback crackrock */
if (string_value == NULL)
current_theme = g_strdup ("Atlanta");
@ -1808,6 +1816,9 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_COMPOSITING_MANAGER:
return "COMPOSITING_MANAGER";
case META_PREF_RESIZE_WITH_RIGHT_BUTTON:
return "RESIZE_WITH_RIGHT_BUTTON";
#ifdef WITH_CLUTTER
case META_PREF_CLUTTER_DISABLED:
return "CLUTTER_DISABLED";
@ -2792,6 +2803,18 @@ meta_prefs_get_compositing_manager (void)
return compositing_manager;
}
guint
meta_prefs_get_mouse_button_resize (void)
{
return resize_with_right_button ? 3: 2;
}
guint
meta_prefs_get_mouse_button_menu (void)
{
return resize_with_right_button ? 2: 3;
}
void
meta_prefs_set_compositing_manager (gboolean whether)
{

View File

@ -623,4 +623,7 @@ void meta_window_unset_demands_attention (MetaWindow *window);
void meta_window_update_icon_now (MetaWindow *window);
void meta_window_update_role (MetaWindow *window);
void meta_window_update_net_wm_type (MetaWindow *window);
#endif

View File

@ -9,13 +9,15 @@
* Note that all the meta_window_reload_propert* functions require a
* round trip to the server.
*
* \bug Not all the properties have moved over from their original
* handler in window.c yet.
* The guts of this system are in meta_display_init_window_prop_hooks().
* Reading this function will give you insight into how this all fits
* together.
*/
/*
* Copyright (C) 2001, 2002, 2003 Red Hat, Inc.
* Copyright (C) 2004, 2005 Elijah Newren
* Copyright (C) 2009 Thomas Thurman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@ -50,59 +52,64 @@
#define HOST_NAME_MAX 255
#endif
typedef void (* InitValueFunc) (MetaDisplay *display,
Atom property,
MetaPropValue *value);
typedef void (* ReloadValueFunc) (MetaWindow *window,
MetaPropValue *value);
MetaPropValue *value,
gboolean initial);
struct _MetaWindowPropHooks
typedef struct MetaWindowPropHooks
{
Atom property;
InitValueFunc init_func;
MetaPropValueType type;
ReloadValueFunc reload_func;
};
} MetaWindowPropHooks;
static void init_prop_value (MetaDisplay *display,
Atom property,
MetaPropValue *value);
static void reload_prop_value (MetaWindow *window,
MetaPropValue *value);
MetaPropValue *value,
gboolean initial);
static MetaWindowPropHooks* find_hooks (MetaDisplay *display,
Atom property);
void
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
meta_window_reload_properties (MetaWindow *window,
const Atom *properties,
int n_properties)
int n_properties,
gboolean initial)
{
meta_window_reload_properties_from_xwindow (window,
window->xwindow,
properties,
n_properties);
n_properties,
initial);
}
void
meta_window_reload_property_from_xwindow (MetaWindow *window,
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
meta_window_reload_properties_from_xwindow (MetaWindow *window,
Window xwindow,
const Atom *properties,
int n_properties)
int n_properties,
gboolean initial)
{
int i;
MetaPropValue *values;
@ -125,7 +132,7 @@ meta_window_reload_properties_from_xwindow (MetaWindow *window,
i = 0;
while (i < n_properties)
{
reload_prop_value (window, &values[i]);
reload_prop_value (window, &values[i], initial);
++i;
}
@ -141,39 +148,35 @@ init_prop_value (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
MetaWindowPropHooks *hooks;
MetaWindowPropHooks *hooks = find_hooks (display, property);
if (!hooks || hooks->type == META_PROP_VALUE_INVALID)
{
value->type = META_PROP_VALUE_INVALID;
value->atom = None;
hooks = find_hooks (display, property);
if (hooks && hooks->init_func != NULL)
(* hooks->init_func) (display, property, value);
}
else
{
value->type = hooks->type;
value->atom = property;
}
}
static void
reload_prop_value (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
MetaWindowPropHooks *hooks;
MetaWindowPropHooks *hooks = find_hooks (window->display, value->atom);
hooks = find_hooks (window->display, value->atom);
if (hooks && hooks->reload_func != NULL)
(* hooks->reload_func) (window, value);
}
static void
init_wm_client_machine (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_STRING;
value->atom = display->atom_WM_CLIENT_MACHINE;
(* hooks->reload_func) (window, value, initial);
}
static void
reload_wm_client_machine (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
g_free (window->wm_client_machine);
window->wm_client_machine = NULL;
@ -186,17 +189,68 @@ reload_wm_client_machine (MetaWindow *window,
}
static void
init_net_wm_pid (MetaDisplay *display,
Atom property,
MetaPropValue *value)
complain_about_broken_client (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
value->type = META_PROP_VALUE_CARDINAL;
value->atom = display->atom__NET_WM_PID;
meta_warning ("Broken client! Window %s changed client leader window or SM client ID\n",
window->desc);
}
static void
reload_net_wm_window_type (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
meta_window_update_net_wm_type (window);
}
static void
reload_icon (MetaWindow *window,
Atom atom)
{
meta_icon_cache_property_changed (&window->icon_cache,
window->display,
atom);
meta_window_queue(window, META_QUEUE_UPDATE_ICON);
}
static void
reload_net_wm_icon (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
reload_icon (window, window->display->atom__NET_WM_ICON);
}
static void
reload_kwm_win_icon (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
reload_icon (window, window->display->atom__KWM_WIN_ICON);
}
static void
reload_struts (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
meta_window_update_struts (window);
}
static void
reload_wm_window_role (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
meta_window_update_role (window);
}
static void
reload_net_wm_pid (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (value->type != META_PROP_VALUE_INVALID)
{
@ -214,18 +268,10 @@ reload_net_wm_pid (MetaWindow *window,
}
}
static void
init_net_wm_user_time (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_CARDINAL;
value->atom = display->atom__NET_WM_USER_TIME;
}
static void
reload_net_wm_user_time (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (value->type != META_PROP_VALUE_INVALID)
{
@ -234,18 +280,10 @@ reload_net_wm_user_time (MetaWindow *window,
}
}
static void
init_net_wm_user_time_window (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_WINDOW;
value->atom = display->atom__NET_WM_USER_TIME_WINDOW;
}
static void
reload_net_wm_user_time_window (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (value->type != META_PROP_VALUE_INVALID)
{
@ -293,7 +331,8 @@ reload_net_wm_user_time_window (MetaWindow *window,
meta_window_reload_property_from_xwindow (
window,
window->user_time_window,
window->display->atom__NET_WM_USER_TIME);
window->display->atom__NET_WM_USER_TIME,
initial);
}
}
}
@ -388,18 +427,10 @@ set_window_title (MetaWindow *window,
g_object_notify (G_OBJECT (window), "title");
}
static void
init_net_wm_name (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_UTF8;
value->atom = display->atom__NET_WM_NAME;
}
static void
reload_net_wm_name (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (value->type != META_PROP_VALUE_INVALID)
{
@ -413,22 +444,15 @@ reload_net_wm_name (MetaWindow *window,
{
set_window_title (window, NULL);
window->using_net_wm_name = FALSE;
if (!initial)
meta_window_reload_property (window, XA_WM_NAME, FALSE);
}
}
static void
init_wm_name (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_TEXT_PROPERTY;
value->atom = XA_WM_NAME;
}
static void
reload_wm_name (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (window->using_net_wm_name)
{
@ -463,18 +487,10 @@ set_icon_title (MetaWindow *window,
window->using_net_wm_visible_icon_name = modified;
}
static void
init_net_wm_icon_name (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_UTF8;
value->atom = display->atom__NET_WM_ICON_NAME;
}
static void
reload_net_wm_icon_name (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (value->type != META_PROP_VALUE_INVALID)
{
@ -488,22 +504,15 @@ reload_net_wm_icon_name (MetaWindow *window,
{
set_icon_title (window, NULL);
window->using_net_wm_icon_name = FALSE;
if (!initial)
meta_window_reload_property (window, XA_WM_ICON_NAME, FALSE);
}
}
static void
init_wm_icon_name (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_TEXT_PROPERTY;
value->atom = XA_WM_ICON_NAME;
}
static void
reload_wm_icon_name (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (window->using_net_wm_icon_name)
{
@ -525,18 +534,10 @@ reload_wm_icon_name (MetaWindow *window,
}
}
static void
init_net_wm_state (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_ATOM_LIST;
value->atom = display->atom__NET_WM_STATE;
}
static void
reload_net_wm_state (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
int i;
@ -544,6 +545,13 @@ reload_net_wm_state (MetaWindow *window,
* clients don't change the property.
*/
if (!initial) {
/* no, they DON'T change the property */
meta_verbose ("Ignoring _NET_WM_STATE: we should be the one who set "
"the property in the first place\n");
return;
}
window->shaded = FALSE;
window->maximized_horizontally = FALSE;
window->maximized_vertically = FALSE;
@ -594,18 +602,10 @@ reload_net_wm_state (MetaWindow *window,
meta_window_recalc_window_type (window);
}
static void
init_mwm_hints (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_MOTIF_HINTS;
value->atom = display->atom__MOTIF_WM_HINTS;
}
static void
reload_mwm_hints (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
MotifWmHints *hints;
gboolean old_decorated = window->decorated;
@ -731,18 +731,10 @@ reload_mwm_hints (MetaWindow *window,
}
}
static void
init_wm_class (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_CLASS_HINT;
value->atom = XA_WM_CLASS;
}
static void
reload_wm_class (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (window->res_class)
g_free (window->res_class);
@ -767,18 +759,10 @@ reload_wm_class (MetaWindow *window,
window->res_name ? window->res_name : "none");
}
static void
init_net_wm_desktop (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_CARDINAL;
value->atom = display->atom__NET_WM_DESKTOP;
}
static void
reload_net_wm_desktop (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (value->type != META_PROP_VALUE_INVALID)
{
@ -790,18 +774,10 @@ reload_net_wm_desktop (MetaWindow *window,
}
}
static void
init_net_startup_id (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_UTF8;
value->atom = display->atom__NET_STARTUP_ID;
}
static void
reload_net_startup_id (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
guint32 timestamp = window->net_wm_user_time;
MetaWorkspace *workspace = NULL;
@ -836,18 +812,10 @@ reload_net_startup_id (MetaWindow *window,
window->desc);
}
static void
init_update_counter (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_SYNC_COUNTER;
value->atom = display->atom__NET_WM_SYNC_REQUEST_COUNTER;
}
static void
reload_update_counter (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (value->type != META_PROP_VALUE_INVALID)
{
@ -861,17 +829,6 @@ reload_update_counter (MetaWindow *window,
}
}
static void
init_normal_hints (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_SIZE_HINTS;
value->atom = XA_WM_NORMAL_HINTS;
}
#define FLAG_TOGGLED_ON(old,new,flag) \
(((old)->flags & (flag)) == 0 && \
((new)->flags & (flag)) != 0)
@ -1276,7 +1233,8 @@ meta_set_normal_hints (MetaWindow *window,
static void
reload_normal_hints (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
if (value->type != META_PROP_VALUE_INVALID)
{
@ -1291,22 +1249,16 @@ reload_normal_hints (MetaWindow *window,
spew_size_hints_differences (&old_hints, &window->size_hints);
meta_window_recalc_features (window);
if (!initial)
meta_window_queue(window, META_QUEUE_MOVE_RESIZE);
}
}
static void
init_wm_protocols (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_ATOM_LIST;
value->atom = display->atom_WM_PROTOCOLS;
}
static void
reload_wm_protocols (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
int i;
@ -1337,18 +1289,10 @@ reload_wm_protocols (MetaWindow *window,
window->desc);
}
static void
init_wm_hints (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_WM_HINTS;
value->atom = XA_WM_HINTS;
}
static void
reload_wm_hints (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
Window old_group_leader;
@ -1402,18 +1346,10 @@ reload_wm_hints (MetaWindow *window,
meta_window_queue (window, META_QUEUE_UPDATE_ICON | META_QUEUE_MOVE_RESIZE);
}
static void
init_transient_for (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_WINDOW;
value->atom = XA_WM_TRANSIENT_FOR;
}
static void
reload_transient_for (MetaWindow *window,
MetaPropValue *value)
MetaPropValue *value,
gboolean initial)
{
window->xtransient_for = None;
@ -1459,184 +1395,90 @@ reload_transient_for (MetaWindow *window,
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
}
#define N_HOOKS 26
/**
* Initialises the property hooks system. Each row in the table named "hooks"
* represents an action to take when a property is found on a newly-created
* window, or when a property changes its value.
*
* The first column shows which atom the row concerns.
* The second gives the type of the property data. The property will be
* queried for its new value, unless the type is given as
* META_PROP_VALUE_INVALID, in which case nothing will be queried.
* The third column gives the name of a callback which gets called with the
* new value. (If the new value was not retrieved because the second column
* was META_PROP_VALUE_INVALID, the callback still gets called anyway.)
* This value may be NULL, in which case no callback will be called.
*/
void
meta_display_init_window_prop_hooks (MetaDisplay *display)
{
int i;
MetaWindowPropHooks *hooks;
MetaWindowPropHooks hooks[] = {
{ display->atom_WM_STATE, META_PROP_VALUE_INVALID, NULL },
{ display->atom_WM_CLIENT_MACHINE, META_PROP_VALUE_STRING, reload_wm_client_machine },
{ display->atom__NET_WM_PID, META_PROP_VALUE_CARDINAL, reload_net_wm_pid },
{ display->atom__NET_WM_USER_TIME, META_PROP_VALUE_CARDINAL, reload_net_wm_user_time },
{ display->atom__NET_WM_NAME, META_PROP_VALUE_UTF8, reload_net_wm_name },
{ XA_WM_NAME, META_PROP_VALUE_TEXT_PROPERTY, reload_wm_name },
{ display->atom__NET_WM_ICON, META_PROP_VALUE_INVALID, reload_net_wm_icon },
{ display->atom__KWM_WIN_ICON, META_PROP_VALUE_INVALID, reload_kwm_win_icon },
{ display->atom__NET_WM_ICON_NAME, META_PROP_VALUE_UTF8, reload_net_wm_icon_name },
{ XA_WM_ICON_NAME, META_PROP_VALUE_TEXT_PROPERTY, reload_wm_icon_name },
{ display->atom__NET_WM_STATE, META_PROP_VALUE_ATOM_LIST, reload_net_wm_state },
{ display->atom__MOTIF_WM_HINTS, META_PROP_VALUE_MOTIF_HINTS, reload_mwm_hints },
{ display->atom__NET_WM_ICON_GEOMETRY, META_PROP_VALUE_INVALID, NULL },
{ XA_WM_CLASS, META_PROP_VALUE_CLASS_HINT, reload_wm_class },
{ display->atom_WM_CLIENT_LEADER, META_PROP_VALUE_INVALID, complain_about_broken_client },
{ display->atom_SM_CLIENT_ID, META_PROP_VALUE_INVALID, complain_about_broken_client },
{ display->atom_WM_WINDOW_ROLE, META_PROP_VALUE_INVALID, reload_wm_window_role },
{ display->atom__NET_WM_WINDOW_TYPE, META_PROP_VALUE_INVALID, reload_net_wm_window_type },
{ display->atom__NET_WM_DESKTOP, META_PROP_VALUE_CARDINAL, reload_net_wm_desktop },
{ display->atom__NET_WM_STRUT, META_PROP_VALUE_INVALID, reload_struts },
{ display->atom__NET_WM_STRUT_PARTIAL, META_PROP_VALUE_INVALID, reload_struts },
{ display->atom__NET_STARTUP_ID, META_PROP_VALUE_UTF8, reload_net_startup_id },
{ display->atom__NET_WM_SYNC_REQUEST_COUNTER, META_PROP_VALUE_SYNC_COUNTER, reload_update_counter },
{ XA_WM_NORMAL_HINTS, META_PROP_VALUE_SIZE_HINTS, reload_normal_hints },
{ display->atom_WM_PROTOCOLS, META_PROP_VALUE_ATOM_LIST, reload_wm_protocols },
{ XA_WM_HINTS, META_PROP_VALUE_WM_HINTS, reload_wm_hints },
{ XA_WM_TRANSIENT_FOR, META_PROP_VALUE_WINDOW, reload_transient_for },
{ display->atom__NET_WM_USER_TIME_WINDOW, META_PROP_VALUE_WINDOW, reload_net_wm_user_time_window },
{ 0 },
};
MetaWindowPropHooks *table = g_memdup (hooks, sizeof (hooks)),
*cursor = table;
g_assert (display->prop_hooks == NULL);
display->prop_hooks = g_new0 (MetaWindowPropHooks, N_HOOKS);
hooks = display->prop_hooks;
i = 0;
display->prop_hooks_table = (gpointer) table;
display->prop_hooks = g_hash_table_new (NULL, NULL);
hooks[i].property = display->atom_WM_STATE;
hooks[i].init_func = NULL;
hooks[i].reload_func = NULL;
++i;
hooks[i].property = display->atom_WM_CLIENT_MACHINE;
hooks[i].init_func = init_wm_client_machine;
hooks[i].reload_func = reload_wm_client_machine;
++i;
hooks[i].property = display->atom__NET_WM_PID;
hooks[i].init_func = init_net_wm_pid;
hooks[i].reload_func = reload_net_wm_pid;
++i;
hooks[i].property = display->atom__NET_WM_USER_TIME;
hooks[i].init_func = init_net_wm_user_time;
hooks[i].reload_func = reload_net_wm_user_time;
++i;
hooks[i].property = display->atom__NET_WM_NAME;
hooks[i].init_func = init_net_wm_name;
hooks[i].reload_func = reload_net_wm_name;
++i;
hooks[i].property = XA_WM_NAME;
hooks[i].init_func = init_wm_name;
hooks[i].reload_func = reload_wm_name;
++i;
hooks[i].property = display->atom__NET_WM_ICON_NAME;
hooks[i].init_func = init_net_wm_icon_name;
hooks[i].reload_func = reload_net_wm_icon_name;
++i;
hooks[i].property = XA_WM_ICON_NAME;
hooks[i].init_func = init_wm_icon_name;
hooks[i].reload_func = reload_wm_icon_name;
++i;
hooks[i].property = display->atom__NET_WM_STATE;
hooks[i].init_func = init_net_wm_state;
hooks[i].reload_func = reload_net_wm_state;
++i;
hooks[i].property = display->atom__MOTIF_WM_HINTS;
hooks[i].init_func = init_mwm_hints;
hooks[i].reload_func = reload_mwm_hints;
++i;
hooks[i].property = display->atom__NET_WM_ICON_GEOMETRY;
hooks[i].init_func = NULL;
hooks[i].reload_func = NULL;
++i;
hooks[i].property = XA_WM_CLASS;
hooks[i].init_func = init_wm_class;
hooks[i].reload_func = reload_wm_class;
++i;
hooks[i].property = display->atom_WM_CLIENT_LEADER;
hooks[i].init_func = NULL;
hooks[i].reload_func = NULL;
++i;
hooks[i].property = display->atom_SM_CLIENT_ID;
hooks[i].init_func = NULL;
hooks[i].reload_func = NULL;
++i;
hooks[i].property = display->atom_WM_WINDOW_ROLE;
hooks[i].init_func = NULL;
hooks[i].reload_func = NULL;
++i;
hooks[i].property = display->atom__NET_WM_WINDOW_TYPE;
hooks[i].init_func = NULL;
hooks[i].reload_func = NULL;
++i;
hooks[i].property = display->atom__NET_WM_DESKTOP;
hooks[i].init_func = init_net_wm_desktop;
hooks[i].reload_func = reload_net_wm_desktop;
++i;
hooks[i].property = display->atom__NET_WM_STRUT;
hooks[i].init_func = NULL;
hooks[i].reload_func = NULL;
++i;
hooks[i].property = display->atom__NET_WM_STRUT_PARTIAL;
hooks[i].init_func = NULL;
hooks[i].reload_func = NULL;
++i;
hooks[i].property = display->atom__NET_STARTUP_ID;
hooks[i].init_func = init_net_startup_id;
hooks[i].reload_func = reload_net_startup_id;
++i;
hooks[i].property = display->atom__NET_WM_SYNC_REQUEST_COUNTER;
hooks[i].init_func = init_update_counter;
hooks[i].reload_func = reload_update_counter;
++i;
hooks[i].property = XA_WM_NORMAL_HINTS;
hooks[i].init_func = init_normal_hints;
hooks[i].reload_func = reload_normal_hints;
++i;
hooks[i].property = display->atom_WM_PROTOCOLS;
hooks[i].init_func = init_wm_protocols;
hooks[i].reload_func = reload_wm_protocols;
++i;
hooks[i].property = XA_WM_HINTS;
hooks[i].init_func = init_wm_hints;
hooks[i].reload_func = reload_wm_hints;
++i;
hooks[i].property = XA_WM_TRANSIENT_FOR;
hooks[i].init_func = init_transient_for;
hooks[i].reload_func = reload_transient_for;
++i;
hooks[i].property = display->atom__NET_WM_USER_TIME_WINDOW;
hooks[i].init_func = init_net_wm_user_time_window;
hooks[i].reload_func = reload_net_wm_user_time_window;
++i;
if (i != N_HOOKS)
while (cursor->property)
{
g_error ("Initialized %d hooks should have been %d\n", i, N_HOOKS);
/* Atoms are safe to use with GINT_TO_POINTER because it's safe with
* anything 32 bits or less, and atoms are 32 bits with the top three
* bits clear. (Scheifler & Gettys, 2e, p372)
*/
g_hash_table_insert (display->prop_hooks,
GINT_TO_POINTER (cursor->property),
cursor);
cursor++;
}
}
void
meta_display_free_window_prop_hooks (MetaDisplay *display)
{
g_assert (display->prop_hooks != NULL);
g_free (display->prop_hooks);
g_hash_table_unref (display->prop_hooks);
display->prop_hooks = NULL;
g_free (display->prop_hooks_table);
display->prop_hooks_table = NULL;
}
static MetaWindowPropHooks*
find_hooks (MetaDisplay *display,
Atom property)
{
int i;
/* FIXME we could sort the array and do binary search or
* something
*/
i = 0;
while (i < N_HOOKS)
{
if (display->prop_hooks[i].property == property)
return &display->prop_hooks[i];
++i;
}
return NULL;
return g_hash_table_lookup (display->prop_hooks,
GINT_TO_POINTER (property));
}

View File

@ -43,7 +43,8 @@
* \param property A single X atom.
*/
void meta_window_reload_property (MetaWindow *window,
Atom property);
Atom property,
gboolean initial);
/**
@ -57,7 +58,8 @@ void meta_window_reload_property (MetaWindow *window,
*/
void meta_window_reload_properties (MetaWindow *window,
const Atom *properties,
int n_properties);
int n_properties,
gboolean initial);
/**
* Requests the current values of a single property for a given
@ -72,7 +74,8 @@ void meta_window_reload_properties (MetaWindow *window,
void meta_window_reload_property_from_xwindow
(MetaWindow *window,
Window xwindow,
Atom property);
Atom property,
gboolean initial);
/**
* Requests the current values of a set of properties for a given
@ -89,7 +92,8 @@ void meta_window_reload_properties_from_xwindow
(MetaWindow *window,
Window xwindow,
const Atom *properties,
int n_properties);
int n_properties,
gboolean initial);
/**
* Initialises the hooks used for the reload_propert* functions

View File

@ -61,8 +61,6 @@ static int destroying_windows_disallowed = 0;
static void update_sm_hints (MetaWindow *window);
static void update_role (MetaWindow *window);
static void update_net_wm_type (MetaWindow *window);
static void update_net_frame_extents (MetaWindow *window);
static void recalc_window_type (MetaWindow *window);
static void recalc_window_features (MetaWindow *window);
@ -795,12 +793,14 @@ meta_window_new_with_attrs (MetaDisplay *display,
initial_props[i++] = display->atom__NET_WM_FULLSCREEN_MONITORS;
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);
if (!window->override_redirect)
update_sm_hints (window); /* must come after transient_for */
update_role (window);
update_net_wm_type (window);
meta_window_update_role (window);
meta_window_update_net_wm_type (window);
if (!window->override_redirect)
meta_window_update_icon_now (window);
@ -3269,8 +3269,23 @@ window_activate (MetaWindow *window,
/* Get window on current or given workspace */
if (workspace == NULL)
workspace = window->screen->active_workspace;
if (!meta_window_located_on_workspace (window, workspace))
/* For non-transient windows, we just set up a pulsing indicator,
rather than move windows or workspaces.
See http://bugzilla.gnome.org/show_bug.cgi?id=482354 */
if (window->xtransient_for == None &&
!meta_window_located_on_workspace (window, workspace))
{
meta_window_set_demands_attention (window);
/* We've marked it as demanding, don't need to do anything else. */
return;
}
else if (window->xtransient_for != None)
{
/* Move transients to current workspace - preference dialogs should appear over
the source window. */
meta_window_change_workspace (window, workspace);
}
if (window->shaded)
meta_window_unshade (window, timestamp);
@ -5135,6 +5150,7 @@ meta_window_change_workspace_by_index (MetaWindow *window,
#define _NET_WM_MOVERESIZE_MOVE 8
#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9
#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10
#define _NET_WM_MOVERESIZE_CANCEL 11
gboolean
meta_window_client_message (MetaWindow *window,
@ -5467,11 +5483,18 @@ meta_window_client_message (MetaWindow *window,
case _NET_WM_MOVERESIZE_MOVE_KEYBOARD:
op = META_GRAB_OP_KEYBOARD_MOVING;
break;
case _NET_WM_MOVERESIZE_CANCEL:
/* handled below */
break;
default:
break;
}
if (op != META_GRAB_OP_NONE &&
if (action == _NET_WM_MOVERESIZE_CANCEL)
{
meta_display_end_grab_op (window->display, timestamp);
}
else if (op != META_GRAB_OP_NONE &&
((window->has_move_func && op == META_GRAB_OP_KEYBOARD_MOVING) ||
(window->has_resize_func && op == META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN)))
{
@ -5799,21 +5822,7 @@ static gboolean
process_property_notify (MetaWindow *window,
XPropertyEvent *event)
{
/* First, property notifies to ignore because we shouldn't honor
* 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
* can just call reload on the property in the event and get rid of
* this if-else chain.
*/
Window xid = window->xwindow;
if (meta_is_verbose ()) /* avoid looking up the name if we don't have to */
{
@ -5825,123 +5834,14 @@ process_property_notify (MetaWindow *window,
XFree (property_name);
}
if (event->atom == XA_WM_NAME)
if (event->atom == window->display->atom__NET_WM_USER_TIME &&
window->user_time_window)
{
/* 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);
}
else if (event->atom ==
window->display->atom_WM_CLIENT_LEADER ||
event->atom ==
window->display->atom_SM_CLIENT_ID)
{
meta_warning ("Broken client! Window %s changed client leader window or SM client ID\n", window->desc);
}
else if (event->atom ==
window->display->atom__NET_WM_WINDOW_TYPE)
{
update_net_wm_type (window);
}
else if (event->atom == window->display->atom__NET_WM_ICON)
{
meta_icon_cache_property_changed (&window->icon_cache,
window->display,
event->atom);
meta_window_queue(window, META_QUEUE_UPDATE_ICON);
}
else if (event->atom == window->display->atom__KWM_WIN_ICON)
{
meta_icon_cache_property_changed (&window->icon_cache,
window->display,
event->atom);
meta_window_queue(window, META_QUEUE_UPDATE_ICON);
}
else if ((event->atom == window->display->atom__NET_WM_STRUT) ||
(event->atom == window->display->atom__NET_WM_STRUT_PARTIAL))
{
meta_window_update_struts (window);
}
else if (event->atom == window->display->atom__NET_STARTUP_ID)
{
meta_window_reload_property (window,
window->display->atom__NET_STARTUP_ID);
}
else if (event->atom == window->display->atom__NET_WM_SYNC_REQUEST_COUNTER)
{
meta_window_reload_property (window,
window->display->atom__NET_WM_SYNC_REQUEST_COUNTER);
}
else if (event->atom == window->display->atom__NET_WM_USER_TIME)
{
Window xid;
Atom atom__NET_WM_USER_TIME;
atom__NET_WM_USER_TIME = window->display->atom__NET_WM_USER_TIME;
if (window->user_time_window)
xid = window->user_time_window;
else
xid = window->xwindow;
meta_window_reload_property_from_xwindow (window,
xid,
atom__NET_WM_USER_TIME);
}
meta_window_reload_property (window, event->atom, FALSE);
return TRUE;
}
@ -6130,8 +6030,8 @@ update_sm_hints (MetaWindow *window)
window->sm_client_id ? window->sm_client_id : "none");
}
static void
update_role (MetaWindow *window)
void
meta_window_update_role (MetaWindow *window)
{
char *str;
@ -6151,8 +6051,8 @@ update_role (MetaWindow *window)
window->desc, window->role ? window->role : "null");
}
static void
update_net_wm_type (MetaWindow *window)
void
meta_window_update_net_wm_type (MetaWindow *window)
{
int n_atoms;
Atom *atoms;
@ -6217,7 +6117,7 @@ update_net_wm_type (MetaWindow *window)
meta_XFree (str);
}
recalc_window_type (window);
meta_window_recalc_window_type (window);
}
static void