Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dorota Czaplejewicz
gtk
Commits
4a74060d
Commit
4a74060d
authored
Dec 13, 2010
by
Matthias Clasen
Browse files
Make gdk_set_sm_client_id X11-specific
This is really not a cross-platform API
parent
ccb6edeb
Changes
5
Hide whitespace changes
Inline
Side-by-side
gdk/gdk.symbols
View file @
4a74060d
...
...
@@ -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
...
...
gdk/gdkdisplay.c
View file @
4a74060d
...
...
@@ -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
)
...
...
gdk/x11/gdkdisplay-x11.c
View file @
4a74060d
...
...
@@ -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
)
{
...
...
gdk/x11/gdkmain-x11.c
View file @
4a74060d
...
...
@@ -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
...
...
gdk/x11/gdkx.h
View file @
4a74060d
...
...
@@ -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__ */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment