Acquire the WM_Sn selection during startup

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2015-10-10 21:51:04 +02:00
parent b34a653448
commit 5a17b3978c
2 changed files with 42 additions and 0 deletions

View File

@ -47,6 +47,7 @@
#include <xcb/bigreq.h> #include <xcb/bigreq.h>
#include <xcb/randr.h> #include <xcb/randr.h>
#include <xcb/xcb_atom.h>
#include <xcb/xcb_aux.h> #include <xcb/xcb_aux.h>
#include <xcb/xcb_event.h> #include <xcb/xcb_event.h>
#include <xcb/xinerama.h> #include <xcb/xinerama.h>
@ -221,6 +222,42 @@ scan(xcb_query_tree_cookie_t tree_c)
restore_client_order(prop_cookie); restore_client_order(prop_cookie);
} }
static void
acquire_WM_Sn(void)
{
xcb_intern_atom_cookie_t atom_q;
xcb_intern_atom_reply_t *atom_r;
xcb_atom_t atom;
char *atom_name;
/* Get the WM_Sn atom */
globalconf.selection_owner_window = xcb_generate_id(globalconf.connection);
xcb_create_window(globalconf.connection, globalconf.screen->root_depth,
globalconf.selection_owner_window, globalconf.screen->root,
-1, -1, 1, 1, 0,
XCB_COPY_FROM_PARENT, globalconf.screen->root_visual,
0, NULL);
atom_name = xcb_atom_name_by_screen("WM_S", globalconf.default_screen);
if(!atom_name)
fatal("error getting WM_Sn atom name");
atom_q = xcb_intern_atom_unchecked(globalconf.connection, false,
a_strlen(atom_name), atom_name);
p_delete(&atom_name);
atom_r = xcb_intern_atom_reply(globalconf.connection, atom_q, NULL);
if(!atom_r)
fatal("error getting WM_Sn atom");
atom = atom_r->atom;
p_delete(&atom_r);
/* Acquire the selection */
xcb_set_selection_owner(globalconf.connection, globalconf.selection_owner_window, atom, XCB_CURRENT_TIME);
}
static void static void
a_xcb_check(void) a_xcb_check(void)
{ {
@ -506,6 +543,9 @@ main(int argc, char **argv)
/* Did we get some usable data from the above X11 setup? */ /* Did we get some usable data from the above X11 setup? */
draw_test_cairo_xcb(); draw_test_cairo_xcb();
/* Acquire the WM_Sn selection */
acquire_WM_Sn();
/* initialize dbus */ /* initialize dbus */
a_dbus_init(); a_dbus_init();

View File

@ -84,6 +84,8 @@ typedef struct
key_array_t keys; key_array_t keys;
/** Root window mouse bindings */ /** Root window mouse bindings */
button_array_t buttons; button_array_t buttons;
/** Window owning the WM_Sn selection */
xcb_window_t selection_owner_window;
/** Modifiers masks */ /** Modifiers masks */
uint16_t numlockmask, shiftlockmask, capslockmask, modeswitchmask; uint16_t numlockmask, shiftlockmask, capslockmask, modeswitchmask;
/** Check for XTest extension */ /** Check for XTest extension */