1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-10-03 07:29:10 +00:00

Clean up x11.c a bit.

This commit is contained in:
Brenden Matthews 2009-07-27 15:34:06 -06:00
parent 57f65ec30c
commit 87dfc68374

235
src/x11.c
View File

@ -120,14 +120,14 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop)
XQueryTree(display, root, &troot, &parent, &children, &n); XQueryTree(display, root, &troot, &parent, &children, &n);
for (i = 0; i < (int) n; i++) { for (i = 0; i < (int) n; i++) {
if (XGetWindowProperty(display, children[i], ATOM(__SWM_VROOT), 0, 1, if (XGetWindowProperty(display, children[i], ATOM(__SWM_VROOT), 0, 1,
False, XA_WINDOW, &type, &format, &nitems, &bytes, &buf) False, XA_WINDOW, &type, &format, &nitems, &bytes, &buf)
== Success && type == XA_WINDOW) { == Success && type == XA_WINDOW) {
win = *(Window *) buf; win = *(Window *) buf;
XFree(buf); XFree(buf);
XFree(children); XFree(children);
fprintf(stderr, fprintf(stderr,
PACKAGE_NAME": desktop window (%lx) found from __SWM_VROOT property\n", PACKAGE_NAME": desktop window (%lx) found from __SWM_VROOT property\n",
win); win);
fflush(stderr); fflush(stderr);
*p_root = win; *p_root = win;
*p_desktop = win; *p_desktop = win;
@ -155,8 +155,8 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop)
if (win != root) { if (win != root) {
fprintf(stderr, fprintf(stderr,
PACKAGE_NAME": desktop window (%lx) is subwindow of root window (%lx)\n", PACKAGE_NAME": desktop window (%lx) is subwindow of root window (%lx)\n",
win, root); win, root);
} else { } else {
fprintf(stderr, PACKAGE_NAME": desktop window (%lx) is root window\n", win); fprintf(stderr, PACKAGE_NAME": desktop window (%lx) is root window\n", win);
} }
@ -230,8 +230,8 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
/* Parent is desktop window (which might be a child of root) */ /* Parent is desktop window (which might be a child of root) */
window.window = XCreateWindow(display, window.desktop, window.x, window.window = XCreateWindow(display, window.desktop, window.x,
window.y, w, h, 0, CopyFromParent, InputOutput, CopyFromParent, window.y, w, h, 0, CopyFromParent, InputOutput, CopyFromParent,
CWBackPixel | CWOverrideRedirect, &attrs); CWBackPixel | CWOverrideRedirect, &attrs);
XLowerWindow(display, window.window); XLowerWindow(display, window.window);
@ -243,7 +243,7 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
* Process hints and buttons. */ * Process hints and buttons. */
XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0, XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0,
Always, 0L, 0L, False, StructureNotifyMask | ExposureMask | Always, 0L, 0L, False, StructureNotifyMask | ExposureMask |
ButtonPressMask | ButtonReleaseMask, 0L, False, 0, 0 }; ButtonPressMask | ButtonReleaseMask, 0L, False, 0, 0 };
XClassHint classHint; XClassHint classHint;
XWMHints wmHint; XWMHints wmHint;
@ -254,8 +254,8 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
} }
/* Parent is root window so WM can take control */ /* Parent is root window so WM can take control */
window.window = XCreateWindow(display, window.root, window.x, window.window = XCreateWindow(display, window.root, window.x,
window.y, w, h, 0, CopyFromParent, InputOutput, CopyFromParent, window.y, w, h, 0, CopyFromParent, InputOutput, CopyFromParent,
CWBackPixel | CWOverrideRedirect, &attrs); CWBackPixel | CWOverrideRedirect, &attrs);
classHint.res_name = window.class_name; classHint.res_name = window.class_name;
classHint.res_class = classHint.res_name; classHint.res_class = classHint.res_name;
@ -264,14 +264,14 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
/* allow decorated windows to be given input focus by WM */ /* allow decorated windows to be given input focus by WM */
wmHint.input = wmHint.input =
TEST_HINT(window.hints, HINT_UNDECORATED) ? False : True; TEST_HINT(window.hints, HINT_UNDECORATED) ? False : True;
if (window.type == TYPE_DOCK || window.type == TYPE_PANEL) { if (window.type == TYPE_DOCK || window.type == TYPE_PANEL) {
wmHint.initial_state = WithdrawnState; wmHint.initial_state = WithdrawnState;
} else { } else {
wmHint.initial_state = NormalState; wmHint.initial_state = NormalState;
} }
XmbSetWMProperties(display, window.window, window.title, NULL, argv, XmbSetWMProperties(display, window.window, window.title, NULL, argv,
argc, NULL, &wmHint, &classHint); argc, NULL, &wmHint, &classHint);
/* Sets an empty WM_PROTOCOLS property */ /* Sets an empty WM_PROTOCOLS property */
XSetWMProtocols(display, window.window, NULL, 0); XSetWMProtocols(display, window.window, NULL, 0);
@ -304,7 +304,7 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
break; break;
} }
XChangeProperty(display, window.window, xa, XA_ATOM, 32, XChangeProperty(display, window.window, xa, XA_ATOM, 32,
PropModeReplace, (unsigned char *) &prop, 1); PropModeReplace, (unsigned char *) &prop, 1);
} }
/* Set desired hints */ /* Set desired hints */
@ -312,27 +312,27 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
/* Window decorations */ /* Window decorations */
if (TEST_HINT(window.hints, HINT_UNDECORATED)) { if (TEST_HINT(window.hints, HINT_UNDECORATED)) {
/* fprintf(stderr, PACKAGE_NAME": hint - undecorated\n"); /* fprintf(stderr, PACKAGE_NAME": hint - undecorated\n");
fflush(stderr); */ fflush(stderr); */
xa = ATOM(_MOTIF_WM_HINTS); xa = ATOM(_MOTIF_WM_HINTS);
if (xa != None) { if (xa != None) {
long prop[5] = { 2, 0, 0, 0, 0 }; long prop[5] = { 2, 0, 0, 0, 0 };
XChangeProperty(display, window.window, xa, xa, 32, XChangeProperty(display, window.window, xa, xa, 32,
PropModeReplace, (unsigned char *) prop, 5); PropModeReplace, (unsigned char *) prop, 5);
} }
} }
/* Below other windows */ /* Below other windows */
if (TEST_HINT(window.hints, HINT_BELOW)) { if (TEST_HINT(window.hints, HINT_BELOW)) {
/* fprintf(stderr, PACKAGE_NAME": hint - below\n"); /* fprintf(stderr, PACKAGE_NAME": hint - below\n");
fflush(stderr); */ fflush(stderr); */
xa = ATOM(_WIN_LAYER); xa = ATOM(_WIN_LAYER);
if (xa != None) { if (xa != None) {
long prop = 0; long prop = 0;
XChangeProperty(display, window.window, xa, XA_CARDINAL, 32, XChangeProperty(display, window.window, xa, XA_CARDINAL, 32,
PropModeAppend, (unsigned char *) &prop, 1); PropModeAppend, (unsigned char *) &prop, 1);
} }
xa = ATOM(_NET_WM_STATE); xa = ATOM(_NET_WM_STATE);
@ -340,21 +340,21 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
Atom xa_prop = ATOM(_NET_WM_STATE_BELOW); Atom xa_prop = ATOM(_NET_WM_STATE_BELOW);
XChangeProperty(display, window.window, xa, XA_ATOM, 32, XChangeProperty(display, window.window, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1); PropModeAppend, (unsigned char *) &xa_prop, 1);
} }
} }
/* Above other windows */ /* Above other windows */
if (TEST_HINT(window.hints, HINT_ABOVE)) { if (TEST_HINT(window.hints, HINT_ABOVE)) {
/* fprintf(stderr, PACKAGE_NAME": hint - above\n"); /* fprintf(stderr, PACKAGE_NAME": hint - above\n");
fflush(stderr); */ fflush(stderr); */
xa = ATOM(_WIN_LAYER); xa = ATOM(_WIN_LAYER);
if (xa != None) { if (xa != None) {
long prop = 6; long prop = 6;
XChangeProperty(display, window.window, xa, XA_CARDINAL, 32, XChangeProperty(display, window.window, xa, XA_CARDINAL, 32,
PropModeAppend, (unsigned char *) &prop, 1); PropModeAppend, (unsigned char *) &prop, 1);
} }
xa = ATOM(_NET_WM_STATE); xa = ATOM(_NET_WM_STATE);
@ -362,21 +362,21 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
Atom xa_prop = ATOM(_NET_WM_STATE_ABOVE); Atom xa_prop = ATOM(_NET_WM_STATE_ABOVE);
XChangeProperty(display, window.window, xa, XA_ATOM, 32, XChangeProperty(display, window.window, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1); PropModeAppend, (unsigned char *) &xa_prop, 1);
} }
} }
/* Sticky */ /* Sticky */
if (TEST_HINT(window.hints, HINT_STICKY)) { if (TEST_HINT(window.hints, HINT_STICKY)) {
/* fprintf(stderr, PACKAGE_NAME": hint - sticky\n"); /* fprintf(stderr, PACKAGE_NAME": hint - sticky\n");
fflush(stderr); */ fflush(stderr); */
xa = ATOM(_NET_WM_DESKTOP); xa = ATOM(_NET_WM_DESKTOP);
if (xa != None) { if (xa != None) {
CARD32 xa_prop = 0xFFFFFFFF; CARD32 xa_prop = 0xFFFFFFFF;
XChangeProperty(display, window.window, xa, XA_CARDINAL, 32, XChangeProperty(display, window.window, xa, XA_CARDINAL, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1); PropModeAppend, (unsigned char *) &xa_prop, 1);
} }
xa = ATOM(_NET_WM_STATE); xa = ATOM(_NET_WM_STATE);
@ -384,48 +384,47 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
Atom xa_prop = ATOM(_NET_WM_STATE_STICKY); Atom xa_prop = ATOM(_NET_WM_STATE_STICKY);
XChangeProperty(display, window.window, xa, XA_ATOM, 32, XChangeProperty(display, window.window, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1); PropModeAppend, (unsigned char *) &xa_prop, 1);
} }
} }
/* Skip taskbar */ /* Skip taskbar */
if (TEST_HINT(window.hints, HINT_SKIP_TASKBAR)) { if (TEST_HINT(window.hints, HINT_SKIP_TASKBAR)) {
/* fprintf(stderr, PACKAGE_NAME": hint - skip_taskbar\n"); /* fprintf(stderr, PACKAGE_NAME": hint - skip_taskbar\n");
fflush(stderr); */ fflush(stderr); */
xa = ATOM(_NET_WM_STATE); xa = ATOM(_NET_WM_STATE);
if (xa != None) { if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_TASKBAR); Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_TASKBAR);
XChangeProperty(display, window.window, xa, XA_ATOM, 32, XChangeProperty(display, window.window, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1); PropModeAppend, (unsigned char *) &xa_prop, 1);
} }
} }
/* Skip pager */ /* Skip pager */
if (TEST_HINT(window.hints, HINT_SKIP_PAGER)) { if (TEST_HINT(window.hints, HINT_SKIP_PAGER)) {
/* fprintf(stderr, PACKAGE_NAME": hint - skip_pager\n"); /* fprintf(stderr, PACKAGE_NAME": hint - skip_pager\n");
fflush(stderr); */ fflush(stderr); */
xa = ATOM(_NET_WM_STATE); xa = ATOM(_NET_WM_STATE);
if (xa != None) { if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_PAGER); Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_PAGER);
XChangeProperty(display, window.window, xa, XA_ATOM, 32, XChangeProperty(display, window.window, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1); PropModeAppend, (unsigned char *) &xa_prop, 1);
} }
} }
} /* else { window.type != TYPE_OVERRIDE */ }
fprintf(stderr, PACKAGE_NAME": drawing to created window (0x%lx)\n", fprintf(stderr, PACKAGE_NAME": drawing to created window (0x%lx)\n",
window.window); window.window);
fflush(stderr); fflush(stderr);
XMapWindow(display, window.window); XMapWindow(display, window.window);
} else /* if (own_window) { */ } else
#endif #endif /* OWN_WINDOW */
/* root / desktop window */
{ {
XWindowAttributes attrs; XWindowAttributes attrs;
@ -452,7 +451,7 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
use_xdbe = 0; use_xdbe = 0;
} else { } else {
window.back_buffer = XdbeAllocateBackBufferName(display, window.back_buffer = XdbeAllocateBackBufferName(display,
window.window, XdbeBackground); window.window, XdbeBackground);
if (window.back_buffer != None) { if (window.back_buffer != None) {
window.drawable = window.back_buffer; window.drawable = window.back_buffer;
fprintf(stderr, PACKAGE_NAME": drawing to double buffer\n"); fprintf(stderr, PACKAGE_NAME": drawing to double buffer\n");
@ -481,17 +480,17 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
* must be done after double buffer stuff? */ * must be done after double buffer stuff? */
#ifdef OWN_WINDOW #ifdef OWN_WINDOW
/* if (own_window) { /* if (own_window) {
set_transparent_background(window.window); set_transparent_background(window.window);
XClearWindow(display, window.window); XClearWindow(display, window.window);
} */ } */
#endif #endif
XSelectInput(display, window.window, ExposureMask | PropertyChangeMask XSelectInput(display, window.window, ExposureMask | PropertyChangeMask
#ifdef OWN_WINDOW #ifdef OWN_WINDOW
| (own_window ? (StructureNotifyMask | | (own_window ? (StructureNotifyMask |
ButtonPressMask | ButtonReleaseMask) : 0) ButtonPressMask | ButtonReleaseMask) : 0)
#endif #endif
); );
} }
static Window find_subwindow(Window win, int w, int h) static Window find_subwindow(Window win, int w, int h)
@ -512,8 +511,8 @@ static Window find_subwindow(Window win, int w, int h)
/* Window must be mapped and same size as display or /* Window must be mapped and same size as display or
* work space */ * work space */
if (attrs.map_state != 0 && ((attrs.width == display_width if (attrs.map_state != 0 && ((attrs.width == display_width
&& attrs.height == display_height) && attrs.height == display_height)
|| (attrs.width == w && attrs.height == h))) { || (attrs.width == w && attrs.height == h))) {
win = children[j]; win = children[j];
break; break;
} }
@ -543,7 +542,7 @@ long get_x11_color(const char *name)
strncpy(&newname[1], name, DEFAULT_TEXT_BUFFER_SIZE - 1); strncpy(&newname[1], name, DEFAULT_TEXT_BUFFER_SIZE - 1);
/* now lets try again */ /* now lets try again */
if (!XParseColor(display, DefaultColormap(display, screen), &newname[0], if (!XParseColor(display, DefaultColormap(display, screen), &newname[0],
&color)) { &color)) {
ERR("can't parse X color '%s'", name); ERR("can't parse X color '%s'", name);
return 0xFF00FF; return 0xFF00FF;
} }
@ -562,13 +561,13 @@ void create_gc(void)
values.graphics_exposures = 0; values.graphics_exposures = 0;
values.function = GXcopy; values.function = GXcopy;
window.gc = XCreateGC(display, window.drawable, window.gc = XCreateGC(display, window.drawable,
GCFunction | GCGraphicsExposures, &values); GCFunction | GCGraphicsExposures, &values);
} }
//Get current desktop number //Get current desktop number
static inline void get_x11_desktop_current(Display *current_display, Window root, Atom atom) static inline void get_x11_desktop_current(Display *current_display, Window root, Atom atom)
{ {
Atom actual_type; Atom actual_type;
int actual_format; int actual_format;
unsigned long nitems; unsigned long nitems;
unsigned long bytes_after; unsigned long bytes_after;
@ -576,22 +575,22 @@ static inline void get_x11_desktop_current(Display *current_display, Window root
struct information *current_info = &info; struct information *current_info = &info;
if ( (XGetWindowProperty( current_display, root, atom, if ( (XGetWindowProperty( current_display, root, atom,
0, 1L, False, XA_CARDINAL, 0, 1L, False, XA_CARDINAL,
&actual_type, &actual_format, &nitems, &actual_type, &actual_format, &nitems,
&bytes_after, &prop ) == Success ) && &bytes_after, &prop ) == Success ) &&
(actual_type == XA_CARDINAL) && (actual_type == XA_CARDINAL) &&
(nitems == 1L) && (actual_format == 32) ) { (nitems == 1L) && (actual_format == 32) ) {
current_info->x11.desktop.current = prop[0]+1; current_info->x11.desktop.current = prop[0]+1;
} }
if(prop) { if(prop) {
XFree(prop); XFree(prop);
} }
} }
//Get total number of available desktops //Get total number of available desktops
static inline void get_x11_desktop_number(Display *current_display, Window root, Atom atom) static inline void get_x11_desktop_number(Display *current_display, Window root, Atom atom)
{ {
Atom actual_type; Atom actual_type;
int actual_format; int actual_format;
unsigned long nitems; unsigned long nitems;
unsigned long bytes_after; unsigned long bytes_after;
@ -599,22 +598,22 @@ static inline void get_x11_desktop_number(Display *current_display, Window root,
struct information *current_info = &info; struct information *current_info = &info;
if ( (XGetWindowProperty( current_display, root, atom, if ( (XGetWindowProperty( current_display, root, atom,
0, 1L, False, XA_CARDINAL, 0, 1L, False, XA_CARDINAL,
&actual_type, &actual_format, &nitems, &actual_type, &actual_format, &nitems,
&bytes_after, &prop ) == Success ) && &bytes_after, &prop ) == Success ) &&
(actual_type == XA_CARDINAL) && (actual_type == XA_CARDINAL) &&
(nitems == 1L) && (actual_format == 32) ) { (nitems == 1L) && (actual_format == 32) ) {
current_info->x11.desktop.number = prop[0]; current_info->x11.desktop.number = prop[0];
} }
if(prop) { if(prop) {
XFree(prop); XFree(prop);
} }
} }
//Get all desktop names //Get all desktop names
static inline void get_x11_desktop_names(Display *current_display, Window root, Atom atom) static inline void get_x11_desktop_names(Display *current_display, Window root, Atom atom)
{ {
Atom actual_type; Atom actual_type;
int actual_format; int actual_format;
unsigned long nitems; unsigned long nitems;
unsigned long bytes_after; unsigned long bytes_after;
@ -622,22 +621,22 @@ static inline void get_x11_desktop_names(Display *current_display, Window root,
struct information *current_info = &info; struct information *current_info = &info;
if ( (XGetWindowProperty( current_display, root, atom, if ( (XGetWindowProperty( current_display, root, atom,
0, (~0L), False, ATOM(UTF8_STRING), 0, (~0L), False, ATOM(UTF8_STRING),
&actual_type, &actual_format, &nitems, &actual_type, &actual_format, &nitems,
&bytes_after, &prop ) == Success ) && &bytes_after, &prop ) == Success ) &&
(actual_type == ATOM(UTF8_STRING)) && (actual_type == ATOM(UTF8_STRING)) &&
(nitems > 0L) && (actual_format == 8) ) { (nitems > 0L) && (actual_format == 8) ) {
if(current_info->x11.desktop.all_names) { if(current_info->x11.desktop.all_names) {
free(current_info->x11.desktop.all_names); free(current_info->x11.desktop.all_names);
current_info->x11.desktop.all_names = NULL; current_info->x11.desktop.all_names = NULL;
} }
current_info->x11.desktop.all_names = malloc(nitems*sizeof(char)); current_info->x11.desktop.all_names = malloc(nitems*sizeof(char));
memcpy(current_info->x11.desktop.all_names, prop, nitems); memcpy(current_info->x11.desktop.all_names, prop, nitems);
current_info->x11.desktop.nitems = nitems; current_info->x11.desktop.nitems = nitems;
} }
if(prop) { if(prop) {
XFree(prop); XFree(prop);
} }
} }
@ -649,25 +648,25 @@ static inline void get_x11_desktop_current_name(char *names)
int k = 0; int k = 0;
while ( i < current_info->x11.desktop.nitems ) { while ( i < current_info->x11.desktop.nitems ) {
if ( names[i++] == '\0' ) { if ( names[i++] == '\0' ) {
if ( ++k == current_info->x11.desktop.current ) { if ( ++k == current_info->x11.desktop.current ) {
if (current_info->x11.desktop.name) { if (current_info->x11.desktop.name) {
free(current_info->x11.desktop.name); free(current_info->x11.desktop.name);
current_info->x11.desktop.name = NULL; current_info->x11.desktop.name = NULL;
} }
current_info->x11.desktop.name = malloc((i-j)*sizeof(char)); current_info->x11.desktop.name = malloc((i-j)*sizeof(char));
//desktop names can be empty but should always be not null //desktop names can be empty but should always be not null
strcpy( current_info->x11.desktop.name, (char *)&names[j] ); strcpy( current_info->x11.desktop.name, (char *)&names[j] );
break; break;
} }
j = i; j = i;
} }
} }
} }
void get_x11_desktop_info(Display *current_display, Atom atom) void get_x11_desktop_info(Display *current_display, Atom atom)
{ {
Window root; Window root;
static Atom atom_current, atom_number, atom_names; static Atom atom_current, atom_number, atom_names;
struct information *current_info = &info; struct information *current_info = &info;
XWindowAttributes window_attributes; XWindowAttributes window_attributes;
@ -676,32 +675,32 @@ void get_x11_desktop_info(Display *current_display, Atom atom)
//Check if we initialise else retrieve changed property //Check if we initialise else retrieve changed property
if (atom == 0) { if (atom == 0) {
atom_current = XInternAtom(current_display, "_NET_CURRENT_DESKTOP", True); atom_current = XInternAtom(current_display, "_NET_CURRENT_DESKTOP", True);
atom_number = XInternAtom(current_display, "_NET_NUMBER_OF_DESKTOPS", True); atom_number = XInternAtom(current_display, "_NET_NUMBER_OF_DESKTOPS", True);
atom_names = XInternAtom(current_display, "_NET_DESKTOP_NAMES", True); atom_names = XInternAtom(current_display, "_NET_DESKTOP_NAMES", True);
get_x11_desktop_current(current_display, root, atom_current); get_x11_desktop_current(current_display, root, atom_current);
get_x11_desktop_number(current_display, root, atom_number); get_x11_desktop_number(current_display, root, atom_number);
get_x11_desktop_names(current_display, root, atom_names); get_x11_desktop_names(current_display, root, atom_names);
get_x11_desktop_current_name(current_info->x11.desktop.all_names); get_x11_desktop_current_name(current_info->x11.desktop.all_names);
//Set the PropertyChangeMask on the root window, if not set //Set the PropertyChangeMask on the root window, if not set
XGetWindowAttributes(display, root, &window_attributes); XGetWindowAttributes(display, root, &window_attributes);
if (!(window_attributes.your_event_mask & PropertyChangeMask)) { if (!(window_attributes.your_event_mask & PropertyChangeMask)) {
XSetWindowAttributes attributes; XSetWindowAttributes attributes;
attributes.event_mask = window_attributes.your_event_mask | PropertyChangeMask; attributes.event_mask = window_attributes.your_event_mask | PropertyChangeMask;
XChangeWindowAttributes(display, root, CWEventMask, &attributes); XChangeWindowAttributes(display, root, CWEventMask, &attributes);
XGetWindowAttributes(display, root, &window_attributes); XGetWindowAttributes(display, root, &window_attributes);
} }
} else { } else {
if (atom == atom_current) { if (atom == atom_current) {
get_x11_desktop_current(current_display, root, atom_current); get_x11_desktop_current(current_display, root, atom_current);
get_x11_desktop_current_name(current_info->x11.desktop.all_names); get_x11_desktop_current_name(current_info->x11.desktop.all_names);
} else if (atom == atom_number) { } else if (atom == atom_number) {
get_x11_desktop_number(current_display, root, atom_number); get_x11_desktop_number(current_display, root, atom_number);
} else if (atom == atom_names) { } else if (atom == atom_names) {
get_x11_desktop_names(current_display, root, atom_names); get_x11_desktop_names(current_display, root, atom_names);
get_x11_desktop_current_name(current_info->x11.desktop.all_names); get_x11_desktop_current_name(current_info->x11.desktop.all_names);
} }
} }
} }
@ -725,29 +724,21 @@ void set_struts(int sidenum)
/* define strut depth */ /* define strut depth */
switch (sidenum) { switch (sidenum) {
case 0: case 0:
{
/* left side */ /* left side */
sizes[0] = window.x + window.width; sizes[0] = window.x + window.width;
break; break;
}
case 1: case 1:
{
/* right side */ /* right side */
sizes[1] = display_width - window.x; sizes[1] = display_width - window.x;
break; break;
}
case 2: case 2:
{
/* top side */ /* top side */
sizes[2] = window.y + window.height; sizes[2] = window.y + window.height;
break; break;
}
case 3: case 3:
{
/* bottom side */ /* bottom side */
sizes[3] = display_height - window.y; sizes[3] = display_height - window.y;
break; break;
}
} }
/* define partial strut length */ /* define partial strut length */