summaryrefslogtreecommitdiffstats
path: root/source/dialogs/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/dialogs/window.c')
-rw-r--r--source/dialogs/window.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index 4eb4bf1b..08dd4a8e 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -35,6 +35,7 @@
#include <string.h>
#include <errno.h>
#include <xcb/xcb.h>
+#include <xcb/xcb_ewmh.h>
#include <X11/X.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
@@ -56,7 +57,10 @@
#define CLIENTWINDOWTYPE 10
#define CLIENTROLE 50
+extern xcb_connection_t *xcb_connection;
+extern xcb_ewmh_connection_t xcb_ewmh;
extern xcb_screen_t *xcb_screen;
+extern int xcb_screen_nbr;
// a manageable window
typedef struct
{
@@ -272,9 +276,17 @@ static client* window_client ( Display *display, Window win )
memmove ( &c->xattr, attr, sizeof ( XWindowAttributes ) );
XGetTransientForHint ( display, win, &c->trans );
- c->states = window_get_atom_prop ( display, win, netatoms[_NET_WM_STATE], c->state, CLIENTSTATE );
-
- c->window_types = window_get_atom_prop ( display, win, netatoms[_NET_WM_WINDOW_TYPE], c->window_type, CLIENTWINDOWTYPE );
+ xcb_get_property_cookie_t cky = xcb_ewmh_get_wm_state(&xcb_ewmh, win);
+ xcb_ewmh_get_atoms_reply_t states;
+ if(xcb_ewmh_get_wm_state_reply( &xcb_ewmh, cky, &states, NULL)){
+ c->states = MIN(CLIENTSTATE,states.atoms_len);
+ memcpy(c->state, states.atoms, MIN(CLIENTSTATE, states.atoms_len));
+ }
+ cky = xcb_ewmh_get_wm_window_type(&xcb_ewmh, win);
+ if(xcb_ewmh_get_wm_window_type_reply( &xcb_ewmh, cky, &states, NULL)){
+ c->window_types= MIN(CLIENTWINDOWTYPE,states.atoms_len);
+ memcpy(c->window_type, states.atoms, MIN(CLIENTWINDOWTYPE, states.atoms_len));
+ }
char *name;
if ( ( name = window_get_text_prop ( display, c->window, netatoms[_NET_WM_NAME] ) ) && name ) {
@@ -399,8 +411,9 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
}
// Get the current desktop.
- unsigned long current_desktop = 0;
- if ( !window_get_cardinal_prop ( display, root, netatoms[_NET_CURRENT_DESKTOP], &current_desktop, 1 ) ) {
+ unsigned int current_desktop = 0;
+ xcb_get_property_cookie_t c = xcb_ewmh_get_current_desktop( &xcb_ewmh, xcb_screen_nbr);
+ if ( !xcb_ewmh_get_current_desktop_reply ( &xcb_ewmh, c, &current_desktop, NULL )){
current_desktop = 0;
}
@@ -418,7 +431,7 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
char pattern[50];
int i;
unsigned int classfield = 0;
- unsigned long desktops = 0;
+ unsigned int desktops = 0;
// windows we actually display. May be slightly different to _NET_CLIENT_LIST_STACKING
// if we happen to have a window destroyed while we're working...
pd->ids = winlist_new ();
@@ -450,9 +463,11 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
}
// Create pattern for printing the line.
- if ( !window_get_cardinal_prop ( display, root, netatoms[_NET_NUMBER_OF_DESKTOPS], &desktops, 1 ) ) {
- desktops = 1;
+ xcb_get_property_cookie_t c = xcb_ewmh_get_number_of_desktops( &xcb_ewmh, xcb_screen_nbr);
+ if ( !xcb_ewmh_get_number_of_desktops_reply ( &xcb_ewmh, c, &desktops, NULL )){
+ desktops= 1;
}
+
if ( pd->config_i3_mode ) {
snprintf ( pattern, 50, "%%-%ds %%s", MAX ( 5, classfield ) );
}
@@ -469,21 +484,31 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
if ( ( c = window_client ( display, w ) ) ) {
// final line format
- unsigned long wmdesktop;
+ unsigned int wmdesktop;
char desktop[5];
desktop[0] = 0;
size_t len = strlen ( c->title ) + strlen ( c->class ) + classfield + 50;
char *line = g_malloc ( len );
if ( !pd->config_i3_mode ) {
// find client's desktop.
- if ( !window_get_cardinal_prop ( display, c->window, netatoms[_NET_WM_DESKTOP], &wmdesktop, 1 ) ) {
+ xcb_get_property_cookie_t cookie;
+ xcb_get_property_reply_t *r;
+
+ cookie = xcb_get_property(xcb_connection, 0, c->window, xcb_ewmh._NET_WM_DESKTOP, XCB_GET_PROPERTY, 0, sizeof(unsigned int));
+ r = xcb_get_property_reply(xcb_connection, cookie, NULL);
+ if ( r->type == XCB_ATOM_INTEGER){
+ wmdesktop = *((int *)xcb_get_property_value(r));
+ }
+ if ( r->type != XCB_ATOM_INTEGER) {
// Assume the client is on all desktops.
wmdesktop = 0xFFFFFFFF;
}
else if ( cd && wmdesktop != current_desktop ) {
g_free ( line );
+ free(r);
continue;
}
+ free(r);
if ( wmdesktop < 0xFFFFFFFF ) {
snprintf ( desktop, 5, "%d", (int) wmdesktop );