_MUTTER_HINTS

A per-window _MUTTER_HINTS property allowing plugins to use custom hints. The
property holds a colon separated list of key=value pairs; plugin-specific keys
must be suitably namespaced, while 'mutter-' prefix is reserved for internal
Mutter use only.

This commit adds MetaWindow::mutter-hints property, and
meta_window_get_mutter_hints() accessor, as well as the internal machinery for
reading and updating of the hints.

https://bugzilla.gnome.org/show_bug.cgi?id=613123
This commit is contained in:
Tomas Frydrych 2010-01-18 10:12:17 +00:00
parent c6c7b05d7b
commit 28767c4d34
5 changed files with 85 additions and 1 deletions

View File

@ -96,6 +96,7 @@ struct _MetaWindow
char *sm_client_id;
char *wm_client_machine;
char *startup_id;
char *mutter_hints;
int net_wm_pid;

View File

@ -523,6 +523,49 @@ reload_wm_name (MetaWindow *window,
}
}
static void
reload_mutter_hints (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
if (value->type != META_PROP_VALUE_INVALID)
{
char *new_hints = value->v.str;
char *old_hints = window->mutter_hints;
gboolean changed = FALSE;
if (new_hints)
{
if (!old_hints || strcmp (new_hints, old_hints))
changed = TRUE;
}
else
{
if (old_hints)
changed = TRUE;
}
if (changed)
{
g_free (old_hints);
if (new_hints)
window->mutter_hints = g_strdup (new_hints);
else
window->mutter_hints = NULL;
g_object_notify (G_OBJECT (window), "mutter-hints");
}
}
else if (window->mutter_hints)
{
g_free (window->mutter_hints);
window->mutter_hints = NULL;
g_object_notify (G_OBJECT (window), "mutter-hints");
}
}
static void
set_icon_title (MetaWindow *window,
const char *title)
@ -1506,6 +1549,7 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
{ XA_WM_CLASS, META_PROP_VALUE_CLASS_HINT, reload_wm_class, TRUE, TRUE },
{ display->atom__NET_WM_PID, META_PROP_VALUE_CARDINAL, reload_net_wm_pid, TRUE, TRUE },
{ XA_WM_NAME, META_PROP_VALUE_TEXT_PROPERTY, reload_wm_name, TRUE, TRUE },
{ display->atom__MUTTER_HINTS, META_PROP_VALUE_TEXT_PROPERTY, reload_mutter_hints, TRUE, TRUE },
{ display->atom__NET_WM_ICON_NAME, META_PROP_VALUE_UTF8, reload_net_wm_icon_name, TRUE, FALSE },
{ XA_WM_ICON_NAME, META_PROP_VALUE_TEXT_PROPERTY, reload_wm_icon_name, TRUE, FALSE },
{ display->atom__NET_WM_DESKTOP, META_PROP_VALUE_CARDINAL, reload_net_wm_desktop, TRUE, FALSE },

View File

@ -146,7 +146,8 @@ enum {
PROP_WINDOW_TYPE,
PROP_USER_TIME,
PROP_DEMANDS_ATTENTION,
PROP_URGENT
PROP_URGENT,
PROP_MUTTER_HINTS
};
enum
@ -228,6 +229,9 @@ meta_window_get_property(GObject *object,
case PROP_URGENT:
g_value_set_boolean (value, win->wm_hints_urgent);
break;
case PROP_MUTTER_HINTS:
g_value_set_string (value, win->mutter_hints);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -348,6 +352,13 @@ meta_window_class_init (MetaWindowClass *klass)
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class,
PROP_MUTTER_HINTS,
g_param_spec_string ("mutter-hints",
"_MUTTER_HINTS",
"Contents of the _MUTTER_HINTS property of this window",
NULL,
G_PARAM_READABLE));
window_signals[WORKSPACE_CHANGED] =
g_signal_new ("workspace-changed",
G_TYPE_FROM_CLASS (object_class),
@ -9120,3 +9131,29 @@ meta_window_is_modal (MetaWindow *window)
return window->wm_state_modal;
}
/**
* meta_window_get_mutter_hints:
* @window: a #MetaWindow
*
* Gets the current value of the _MUTTER_HINTS property.
*
* The purpose of the hints is to allow fine-tuning of the Window Manager and
* Compositor behaviour on per-window basis, and is intended primarily for
* hints that are plugin-specific.
*
* The property is a list of colon-separated key=value pairs. The key names for
* any plugin-specific hints must be suitably namespaced to allow for shared
* use; 'mutter-' key prefix is reserved for internal use, and must not be used
* by plugins.
*
* Return value: (transfer none): the _MUTTER_HINTS string, or %NULL if no hints
* are set.
*/
const char *
meta_window_get_mutter_hints (MetaWindow *window)
{
g_return_val_if_fail (META_IS_WINDOW (window), NULL);
return window->mutter_hints;
}

View File

@ -58,6 +58,7 @@ item(_MUTTER_RESTART_MESSAGE)
item(_MUTTER_RELOAD_THEME_MESSAGE)
item(_MUTTER_SET_KEYBINDINGS_MESSAGE)
item(_MUTTER_TOGGLE_VERBOSE)
item(_MUTTER_HINTS)
item(_GNOME_WM_KEYBINDINGS)
item(_GNOME_PANEL_ACTION)
item(_GNOME_PANEL_ACTION_MAIN_MENU)

View File

@ -141,4 +141,5 @@ guint32 meta_window_get_user_time (MetaWindow *window);
int meta_window_get_pid (MetaWindow *window);
const char *meta_window_get_client_machine (MetaWindow *window);
gboolean meta_window_is_modal (MetaWindow *window);
const char *meta_window_get_mutter_hints (MetaWindow *window);
#endif