diff options
-rw-r--r-- | gdk/gdk.symbols | 2 | ||||
-rw-r--r-- | gdk/gdkdisplay.c | 45 | ||||
-rw-r--r-- | gdk/x11/gdkdisplay-x11.c | 57 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 22 | ||||
-rw-r--r-- | gdk/x11/gdkx.h | 2 |
5 files changed, 55 insertions, 73 deletions
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 7040bfc4c6..d47c4e25dd 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -321,7 +321,6 @@ gdk_set_locale gdk_set_pointer_hooks gdk_set_program_class gdk_set_show_events -gdk_set_sm_client_id gdk_setting_action_get_type G_GNUC_CONST gdk_setting_get gdk_spawn_command_line_on_screen @@ -566,6 +565,7 @@ gdk_x11_screen_get_window_manager_name gdk_x11_screen_get_xscreen gdk_x11_screen_lookup_visual gdk_x11_screen_supports_net_wm_hint +gdk_x11_set_sm_client_id gdk_x11_ungrab_server gdk_x11_visual_get_xvisual gdk_x11_window_get_xid diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index d398dc8c45..fb9e591e6e 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -136,8 +136,6 @@ static GdkAppLaunchContext *gdk_display_real_get_app_launch_context (GdkDisplay static guint signals[LAST_SIGNAL] = { 0 }; -static char *gdk_sm_client_id; - static const GdkDisplayDeviceHooks default_device_hooks = { _gdk_windowing_get_device_state, gdk_window_real_window_get_device_position, @@ -661,49 +659,6 @@ gdk_event_send_clientmessage_toall (GdkEvent *event) gdk_screen_broadcast_client_message (gdk_screen_get_default (), event); } -/** - * gdk_set_sm_client_id: - * @sm_client_id: the client id assigned by the session manager when the - * connection was opened, or %NULL to remove the property. - * - * Sets the <literal>SM_CLIENT_ID</literal> property on the application's leader window so that - * the window manager can save the application's state using the X11R6 ICCCM - * session management protocol. - * - * See the X Session Management Library documentation for more information on - * session management and the Inter-Client Communication Conventions Manual - * (ICCCM) for information on the <literal>WM_CLIENT_LEADER</literal> property. - * (Both documents are part of the X Window System distribution.) - **/ -void -gdk_set_sm_client_id (const gchar* sm_client_id) -{ - GSList *displays, *tmp_list; - - g_free (gdk_sm_client_id); - gdk_sm_client_id = g_strdup (sm_client_id); - - displays = gdk_display_manager_list_displays (gdk_display_manager_get ()); - for (tmp_list = displays; tmp_list; tmp_list = tmp_list->next) - _gdk_windowing_display_set_sm_client_id (tmp_list->data, sm_client_id); - - g_slist_free (displays); -} - -/** - * _gdk_get_sm_client_id: - * - * Gets the client ID set with gdk_set_sm_client_id(), if any. - * - * Return value: Session ID, or %NULL if gdk_set_sm_client_id() - * has never been called. - **/ -const char * -_gdk_get_sm_client_id (void) -{ - return gdk_sm_client_id; -} - void _gdk_display_enable_motion_hints (GdkDisplay *display, GdkDevice *device) diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index f90554010e..84d0b5a8ad 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -157,6 +157,8 @@ static const char *const precache_atoms[] = { "_NET_VIRTUAL_ROOTS" }; +static char *gdk_sm_client_id; + G_DEFINE_TYPE_WITH_CODE (GdkDisplayX11, _gdk_display_x11, GDK_TYPE_DISPLAY, G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR, gdk_display_x11_event_translator_init)) @@ -1165,6 +1167,25 @@ gdk_input_init (GdkDisplay *display) g_list_free (list); } +static void +set_sm_client_id (GdkDisplay *display, + const gchar *sm_client_id) +{ + GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display); + + if (gdk_display_is_closed (display)) + return; + + if (sm_client_id && strcmp (sm_client_id, "")) + XChangeProperty (display_x11->xdisplay, display_x11->leader_window, + gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID"), + XA_STRING, 8, PropModeReplace, (guchar *)sm_client_id, + strlen (sm_client_id)); + else + XDeleteProperty (display_x11->xdisplay, display_x11->leader_window, + gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID")); +} + /** * gdk_display_open: * @display_name: the name of the display to open @@ -1185,8 +1206,7 @@ _gdk_x11_display_open (const gchar *display_name) GdkWindowAttr attr; gint argc; gchar *argv[1]; - const char *sm_client_id; - + XClassHint *class_hint; gulong pid; gint i; @@ -1357,9 +1377,8 @@ _gdk_x11_display_open (const gchar *display_name) class_hint); XFree (class_hint); - sm_client_id = _gdk_get_sm_client_id (); - if (sm_client_id) - _gdk_windowing_display_set_sm_client_id (display, sm_client_id); + if (gdk_sm_client_id) + set_sm_client_id (display, gdk_sm_client_id); pid = getpid (); XChangeProperty (display_x11->xdisplay, @@ -2665,6 +2684,34 @@ extern GdkNativeWindow _gdk_x11_display_get_drag_protocol (GdkDisplay GdkDragProtocol *protocol, guint *version); + +/** + * gdk_x11_set_sm_client_id: + * @sm_client_id: the client id assigned by the session manager when the + * connection was opened, or %NULL to remove the property. + * + * Sets the <literal>SM_CLIENT_ID</literal> property on the application's leader window so that + * the window manager can save the application's state using the X11R6 ICCCM + * session management protocol. + * + * See the X Session Management Library documentation for more information on + * session management and the Inter-Client Communication Conventions Manual + */ +void +gdk_x11_set_sm_client_id (const gchar *sm_client_id) +{ + GSList *displays, *l; + + g_free (gdk_sm_client_id); + gdk_sm_client_id = g_strdup (sm_client_id); + + displays = gdk_display_manager_list_displays (gdk_display_manager_get ()); + for (l = displays; l; l = l->next) + set_sm_client_id (l->data, sm_client_id); + + g_slist_free (displays); +} + static void _gdk_display_x11_class_init (GdkDisplayX11Class * class) { diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 57aedf542c..6424aab56b 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -49,7 +49,6 @@ #include <X11/XKBlib.h> #endif - typedef struct _GdkPredicate GdkPredicate; typedef struct _GdkGlobalErrorTrap GdkGlobalErrorTrap; @@ -203,27 +202,6 @@ _gdk_xgrab_check_destroy (GdkWindow *window) g_list_free (devices); } -void -_gdk_windowing_display_set_sm_client_id (GdkDisplay *display, - const gchar *sm_client_id) -{ - GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display); - - if (gdk_display_is_closed (display)) - return; - - if (sm_client_id && strcmp (sm_client_id, "")) - { - XChangeProperty (display_x11->xdisplay, display_x11->leader_window, - gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID"), - XA_STRING, 8, PropModeReplace, (guchar *)sm_client_id, - strlen (sm_client_id)); - } - else - XDeleteProperty (display_x11->xdisplay, display_x11->leader_window, - gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID")); -} - /* *-------------------------------------------------------------- * gdk_x_io_error diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 51aae0dad1..7e5dd1b574 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -248,6 +248,8 @@ void gdk_x11_register_standard_event_type (GdkDisplay *display, gint n_events); +void gdk_x11_set_sm_client_id (const gchar *sm_client_id); + G_END_DECLS #endif /* __GDK_X_H__ */ |