Load _DBUS_APPLICATION_ID property, expose it via API

This is used to associate GtkApplication -> X window, and will
be consumed by gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=664851
This commit is contained in:
Colin Walters 2011-11-25 18:42:41 -05:00
parent 35261808a9
commit 8ab5cc8f19
5 changed files with 58 additions and 6 deletions

View File

@ -97,9 +97,11 @@ struct _MetaWindow
char *role; char *role;
char *sm_client_id; char *sm_client_id;
char *wm_client_machine; char *wm_client_machine;
char *startup_id; char *startup_id;
char *mutter_hints; char *mutter_hints;
char *gtk_theme_variant; char *gtk_theme_variant;
char *dbus_application_id;
int net_wm_pid; int net_wm_pid;

View File

@ -1578,20 +1578,41 @@ reload_gtk_theme_variant (MetaWindow *window,
requested_variant, window->desc); requested_variant, window->desc);
} }
if (g_strcmp0 (requested_variant, current_variant)) if (g_strcmp0 (requested_variant, current_variant) != 0)
{ {
g_free (current_variant); g_free (current_variant);
if (requested_variant) window->gtk_theme_variant = g_strdup (requested_variant);
window->gtk_theme_variant = g_strdup (requested_variant);
else
window->gtk_theme_variant = NULL;
if (window->frame) if (window->frame)
meta_ui_update_frame_style (window->screen->ui, window->frame->xwindow); meta_ui_update_frame_style (window->screen->ui, window->frame->xwindow);
} }
} }
static void
reload_dbus_application_id (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
char *new_id = NULL;
char *current_id = window->dbus_application_id;
if (value->type != META_PROP_VALUE_INVALID)
new_id = value->v.str;
if (g_strcmp0 (new_id, current_id))
{
g_free (current_id);
if (new_id)
window->dbus_application_id = g_strdup (new_id);
else
window->dbus_application_id = NULL;
g_object_notify ((GObject*)window, "dbus-application-id");
}
}
/** /**
* Initialises the property hooks system. Each row in the table named "hooks" * 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 * represents an action to take when a property is found on a newly-created
@ -1645,6 +1666,7 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
{ display->atom__MOTIF_WM_HINTS, META_PROP_VALUE_MOTIF_HINTS, reload_mwm_hints, TRUE, FALSE }, { display->atom__MOTIF_WM_HINTS, META_PROP_VALUE_MOTIF_HINTS, reload_mwm_hints, TRUE, FALSE },
{ XA_WM_TRANSIENT_FOR, META_PROP_VALUE_WINDOW, reload_transient_for, TRUE, FALSE }, { XA_WM_TRANSIENT_FOR, META_PROP_VALUE_WINDOW, reload_transient_for, TRUE, FALSE },
{ display->atom__GTK_THEME_VARIANT, META_PROP_VALUE_UTF8, reload_gtk_theme_variant, TRUE, FALSE }, { display->atom__GTK_THEME_VARIANT, META_PROP_VALUE_UTF8, reload_gtk_theme_variant, TRUE, FALSE },
{ display->atom__DBUS_APPLICATION_ID, META_PROP_VALUE_UTF8, reload_dbus_application_id, TRUE, FALSE },
{ display->atom__NET_WM_USER_TIME_WINDOW, META_PROP_VALUE_WINDOW, reload_net_wm_user_time_window, TRUE, FALSE }, { display->atom__NET_WM_USER_TIME_WINDOW, META_PROP_VALUE_WINDOW, reload_net_wm_user_time_window, TRUE, FALSE },
{ display->atom_WM_STATE, META_PROP_VALUE_INVALID, NULL, FALSE, FALSE }, { 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__NET_WM_ICON, META_PROP_VALUE_INVALID, reload_net_wm_icon, FALSE, FALSE },

View File

@ -164,7 +164,8 @@ enum {
PROP_APPEARS_FOCUSED, PROP_APPEARS_FOCUSED,
PROP_RESIZEABLE, PROP_RESIZEABLE,
PROP_ABOVE, PROP_ABOVE,
PROP_WM_CLASS PROP_WM_CLASS,
PROP_DBUS_APPLICATION_ID
}; };
enum enum
@ -221,6 +222,7 @@ meta_window_finalize (GObject *object)
g_free (window->icon_name); g_free (window->icon_name);
g_free (window->desc); g_free (window->desc);
g_free (window->gtk_theme_variant); g_free (window->gtk_theme_variant);
g_free (window->dbus_application_id);
} }
static void static void
@ -284,6 +286,9 @@ meta_window_get_property(GObject *object,
case PROP_ABOVE: case PROP_ABOVE:
g_value_set_boolean (value, win->wm_state_above); g_value_set_boolean (value, win->wm_state_above);
break; break;
case PROP_DBUS_APPLICATION_ID:
g_value_set_string (value, win->dbus_application_id);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -450,6 +455,14 @@ meta_window_class_init (MetaWindowClass *klass)
NULL, NULL,
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property (object_class,
PROP_DBUS_APPLICATION_ID,
g_param_spec_string ("dbus-application-id",
"DBusApplicationID",
"Contents of the _DBUS_APPLICATION_ID property of this window",
NULL,
G_PARAM_READABLE));
window_signals[WORKSPACE_CHANGED] = window_signals[WORKSPACE_CHANGED] =
g_signal_new ("workspace-changed", g_signal_new ("workspace-changed",
G_TYPE_FROM_CLASS (object_class), G_TYPE_FROM_CLASS (object_class),
@ -10211,6 +10224,18 @@ meta_window_get_wm_class_instance (MetaWindow *window)
return window->res_name; return window->res_name;
} }
/**
* meta_window_get_dbus_application_id:
* @window: a #MetaWindow
*
* Return value: (transfer none): the application ID
**/
const char *
meta_window_get_dbus_application_id (MetaWindow *window)
{
return window->dbus_application_id;
}
/** /**
* meta_window_get_compositor_private: * meta_window_get_compositor_private:
* @window: a #MetaWindow * @window: a #MetaWindow

View File

@ -59,6 +59,7 @@ item(_MUTTER_SET_KEYBINDINGS_MESSAGE)
item(_MUTTER_TOGGLE_VERBOSE) item(_MUTTER_TOGGLE_VERBOSE)
item(_MUTTER_HINTS) item(_MUTTER_HINTS)
item(_GTK_THEME_VARIANT) item(_GTK_THEME_VARIANT)
item(_DBUS_APPLICATION_ID)
item(_GNOME_WM_KEYBINDINGS) item(_GNOME_WM_KEYBINDINGS)
item(_GNOME_PANEL_ACTION) item(_GNOME_PANEL_ACTION)
item(_GNOME_PANEL_ACTION_MAIN_MENU) item(_GNOME_PANEL_ACTION_MAIN_MENU)

View File

@ -95,6 +95,8 @@ const char * meta_window_get_wm_class (MetaWindow *window);
const char * meta_window_get_wm_class_instance (MetaWindow *window); const char * meta_window_get_wm_class_instance (MetaWindow *window);
gboolean meta_window_showing_on_its_workspace (MetaWindow *window); gboolean meta_window_showing_on_its_workspace (MetaWindow *window);
const char * meta_window_get_dbus_application_id (MetaWindow *window);
void meta_window_move(MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw); void meta_window_move(MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw);
void meta_window_move_frame(MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw); void meta_window_move_frame(MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw);
void meta_window_move_resize_frame (MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw, int w, int h); void meta_window_move_resize_frame (MetaWindow *window, gboolean user_op, int root_x_nw, int root_y_nw, int w, int h);