From 393a80d434e338980fe6a41c9ab2c4aff54565fb Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Mon, 5 Dec 2011 12:52:35 -0500 Subject: [PATCH] Add _DBUS_UNIQUE_NAME and _OBJECT_PATH properties https://bugzilla.gnome.org/show_bug.cgi?id=664851 --- src/core/window-private.h | 2 ++ src/core/window-props.c | 50 +++++++++++++++++++++++++++++++++++++ src/core/window.c | 52 ++++++++++++++++++++++++++++++++++++++- src/meta/atomnames.h | 2 ++ src/meta/window.h | 2 ++ 5 files changed, 107 insertions(+), 1 deletion(-) diff --git a/src/core/window-private.h b/src/core/window-private.h index 08df05c92..ce0d3fafd 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -102,6 +102,8 @@ struct _MetaWindow char *mutter_hints; char *gtk_theme_variant; char *dbus_application_id; + char *dbus_unique_name; + char *dbus_object_path; int net_wm_pid; diff --git a/src/core/window-props.c b/src/core/window-props.c index 2f97a26ca..ba096268a 100644 --- a/src/core/window-props.c +++ b/src/core/window-props.c @@ -1616,6 +1616,54 @@ reload_dbus_application_id (MetaWindow *window, } } +static void +reload_dbus_unique_name (MetaWindow *window, + MetaPropValue *value, + gboolean initial) +{ + char *new_id = NULL; + char *current_id = window->dbus_unique_name; + + 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_unique_name = g_strdup (new_id); + else + window->dbus_unique_name = NULL; + + g_object_notify ((GObject*)window, "dbus-unique-name"); + } +} + +static void +reload_dbus_object_path (MetaWindow *window, + MetaPropValue *value, + gboolean initial) +{ + char *new_path = NULL; + char *current_path = window->dbus_object_path; + + if (value->type != META_PROP_VALUE_INVALID) + new_path = value->v.str; + + if (g_strcmp0 (new_path, current_path)) + { + g_free (current_path); + + if (new_path) + window->dbus_object_path = g_strdup (new_path); + else + window->dbus_object_path = NULL; + + g_object_notify ((GObject*)window, "dbus-object-path"); + } +} + /** * 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 @@ -1670,6 +1718,8 @@ meta_display_init_window_prop_hooks (MetaDisplay *display) { 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__DBUS_APPLICATION_ID, META_PROP_VALUE_UTF8, reload_dbus_application_id, TRUE, FALSE }, + { display->atom__DBUS_UNIQUE_NAME, META_PROP_VALUE_UTF8, reload_dbus_unique_name, TRUE, FALSE }, + { display->atom__DBUS_OBJECT_PATH, META_PROP_VALUE_UTF8, reload_dbus_object_path, 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__NET_WM_ICON, META_PROP_VALUE_INVALID, reload_net_wm_icon, FALSE, FALSE }, diff --git a/src/core/window.c b/src/core/window.c index 7bf216030..bacacfbda 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -165,7 +165,9 @@ enum { PROP_RESIZEABLE, PROP_ABOVE, PROP_WM_CLASS, - PROP_DBUS_APPLICATION_ID + PROP_DBUS_APPLICATION_ID, + PROP_DBUS_UNIQUE_NAME, + PROP_DBUS_OBJECT_PATH }; enum @@ -223,6 +225,8 @@ meta_window_finalize (GObject *object) g_free (window->desc); g_free (window->gtk_theme_variant); g_free (window->dbus_application_id); + g_free (window->dbus_unique_name); + g_free (window->dbus_object_path); } static void @@ -289,6 +293,12 @@ meta_window_get_property(GObject *object, case PROP_DBUS_APPLICATION_ID: g_value_set_string (value, win->dbus_application_id); break; + case PROP_DBUS_UNIQUE_NAME: + g_value_set_string (value, win->dbus_unique_name); + break; + case PROP_DBUS_OBJECT_PATH: + g_value_set_string (value, win->dbus_object_path); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -463,6 +473,22 @@ meta_window_class_init (MetaWindowClass *klass) NULL, G_PARAM_READABLE)); + g_object_class_install_property (object_class, + PROP_DBUS_UNIQUE_NAME, + g_param_spec_string ("dbus-unique-name", + "_DBUS_UNIQUE_NAME", + "Contents of the _DBUS_UNIQUE_NAME property of this window", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, + PROP_DBUS_OBJECT_PATH, + g_param_spec_string ("dbus-object-path", + "_DBUS_OBJECT_PATH", + "Contents of the _DBUS_OBJECT_PATH property of this window", + NULL, + G_PARAM_READABLE)); + window_signals[WORKSPACE_CHANGED] = g_signal_new ("workspace-changed", G_TYPE_FROM_CLASS (object_class), @@ -10236,6 +10262,30 @@ meta_window_get_dbus_application_id (MetaWindow *window) return window->dbus_application_id; } +/** + * meta_window_get_dbus_unique_name: + * @window: a #MetaWindow + * + * Return value: (transfer none): the unique name + **/ +const char * +meta_window_get_dbus_unique_name (MetaWindow *window) +{ + return window->dbus_unique_name; +} + +/** + * meta_window_get_dbus_object_path: + * @window: a #MetaWindow + * + * Return value: (transfer none): the object path + **/ +const char * +meta_window_get_dbus_object_path (MetaWindow *window) +{ + return window->dbus_object_path; +} + /** * meta_window_get_compositor_private: * @window: a #MetaWindow diff --git a/src/meta/atomnames.h b/src/meta/atomnames.h index 514452caf..268c0978b 100644 --- a/src/meta/atomnames.h +++ b/src/meta/atomnames.h @@ -60,6 +60,8 @@ item(_MUTTER_TOGGLE_VERBOSE) item(_MUTTER_HINTS) item(_GTK_THEME_VARIANT) item(_DBUS_APPLICATION_ID) +item(_DBUS_UNIQUE_NAME) +item(_DBUS_OBJECT_PATH) item(_GNOME_WM_KEYBINDINGS) item(_GNOME_PANEL_ACTION) item(_GNOME_PANEL_ACTION_MAIN_MENU) diff --git a/src/meta/window.h b/src/meta/window.h index bf493f59d..fbb9a3f16 100644 --- a/src/meta/window.h +++ b/src/meta/window.h @@ -96,6 +96,8 @@ const char * meta_window_get_wm_class_instance (MetaWindow *window); gboolean meta_window_showing_on_its_workspace (MetaWindow *window); const char * meta_window_get_dbus_application_id (MetaWindow *window); +const char * meta_window_get_dbus_unique_name (MetaWindow *window); +const char * meta_window_get_dbus_object_path (MetaWindow *window); 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);