2 /**********************************************************
3 ** Rather Small Panel 0.8beta1 Copyright (c) 2006 **
4 ** By Mikael Magnusson **
5 ** See file COPYING for license details. **
6 **********************************************************/
12 #include <sys/types.h>
16 #include <X11/Xutil.h>
17 #include <X11/Xatom.h>
20 /* you can edit these */
21 #define MAX_TASK_WIDTH 500
24 /* XXX get this from the font - i think it should be user configurable, most
25 panels provide an option for this */
28 # define WINWIDTH scr_width
33 /* don't edit these */
35 #define GRILL_WIDTH 10
37 #include <openbox/render.h>
38 #include <openbox/theme.h>
55 RrAppearance *background;
56 RrAppearance *focused_task;
57 RrAppearance *iconified_task;
58 RrAppearance *unfocused_task;
59 RrAppearance *normal_text;
60 RrAppearance *iconified_text;
61 RrAppearance *shaded_text;
62 RrAppearance *focused_text;
65 /* we draw stuff to this guy then set him as a window
66 * background pixmap, yay no flickering! */
69 char *atom_names[] = {
75 "_NET_WM_STATE_SKIP_TASKBAR",
76 "_NET_WM_STATE_SHADED",
77 "_NET_WM_STATE_BELOW",
78 "_NET_WM_STATE_HIDDEN",
80 "_NET_WM_WINDOW_TYPE",
81 "_NET_WM_WINDOW_TYPE_DOCK",
86 "_NET_CLIENT_LIST_STACKING",
87 "_NET_NUMBER_OF_DESKTOPS",
88 "_NET_CURRENT_DESKTOP",
93 "_NET_RESTACK_WINDOW",
95 "_NET_WM_ICON_GEOMETRY",
104 _NET_WM_STATE_SKIP_TASKBAR,
105 _NET_WM_STATE_SHADED,
107 _NET_WM_STATE_HIDDEN,
110 _NET_WM_WINDOW_TYPE_DOCK,
114 _NET_CLIENT_LIST_STACKING,
115 _NET_NUMBER_OF_DESKTOPS,
116 _NET_CURRENT_DESKTOP,
123 _NET_WM_ICON_GEOMETRY,
128 Atom atoms[ATOM_COUNT];
136 static void *get_prop_data(Window win, Atom prop, Atom type, int *items)
140 unsigned long items_ret;
141 unsigned long after_ret;
142 unsigned char *prop_data;
146 XGetWindowProperty(dd, win, prop, 0, 0x7fffffff, False, type, &type_ret,
147 &format_ret, &items_ret, &after_ret, &prop_data);
154 static int generic_get_int(Window win, Atom at)
159 data = get_prop_data(win, at, XA_CARDINAL, 0);
167 static int find_desktop(Window win)
169 return generic_get_int(win, atoms[_NET_WM_DESKTOP]);
172 static int find_state(Window win, atom_t atom)
178 data = get_prop_data(win, atoms[_NET_WM_STATE], XA_ATOM, &num);
181 if ((data[num]) == atoms[atom])
189 /* this naming is very confusing :) */
190 static int is_hidden(Window win)
192 return find_state(win, _NET_WM_STATE_SKIP_TASKBAR);
195 static int is_iconified(Window win)
197 return find_state(win, _NET_WM_STATE_HIDDEN);
200 static int is_shaded(Window win)
202 return find_state(win, _NET_WM_STATE_SHADED);
205 static int get_current_desktop(void)
207 return generic_get_int(root_win, atoms[_NET_CURRENT_DESKTOP]);
211 static int get_number_of_desktops(void)
213 return generic_get_int(root_win, atoms[_NET_NUMBER_OF_DESKTOPS]);
217 static void free_icons(task *tk)
221 for (i = 0; i < tk->nicons; ++i)
222 free(tk->icons[i].data);
228 static void task_update_icon(task *tk)
230 /* these bits are borrowed from openbox' client.c::client_update_icons */
233 unsigned int w, h, i, j;
237 data = get_prop_data(tk->win, atoms[_NET_WM_ICON], XA_CARDINAL, &num);
239 /* figure out how many valid icons are in here */
241 while (num - i > 2) {
245 if (i > num || w*h == 0) break;
249 tk->icons = calloc(tk->nicons, sizeof(icon));
251 /* store the icons */
253 for (j = 0; j < tk->nicons; ++j) {
256 w = tk->icons[j].width = data[i++];
257 h = tk->icons[j].height = data[i++];
259 if (w*h == 0) continue;
261 tk->icons[j].data = g_new(RrPixel32, w * h);
262 for (x = 0, y = 0, t = 0; t < w * h; ++t, ++x, ++i) {
267 tk->icons[j].data[t] =
268 (((data[i] >> 24) & 0xff) << RrDefaultAlphaOffset) +
269 (((data[i] >> 16) & 0xff) << RrDefaultRedOffset) +
270 (((data[i] >> 8) & 0xff) << RrDefaultGreenOffset) +
271 (((data[i] >> 0) & 0xff) << RrDefaultBlueOffset);
280 if ((hints = XGetWMHints(dd, tk->win))) {
281 if (hints->flags & IconPixmapHint) {
283 tk->icons = g_new(icon, tk->nicons);
284 // xerror_set_ignore(TRUE);
285 if (!RrPixmapToRGBA(inst,
287 (hints->flags & IconMaskHint ?
288 hints->icon_mask : None),
289 &tk->icons[tk->nicons-1].width,
290 &tk->icons[tk->nicons-1].height,
291 &tk->icons[tk->nicons-1].data)){
292 g_free(&tk->icons[tk->nicons-1]);
295 // xerror_set_ignore(FALSE);
302 static void add_task(Window win, int focus)
310 /* is this window on a different desktop? */
311 /* XXX add even if is_hidden, but don't show it later, so we can
312 * unhide it when the prop is removed */
313 desk = find_desktop(win);
314 if ((desk != 0xffffffff && tb.my_desktop != desk))
317 XSelectInput(dd, win, PropertyChangeMask);
319 tk = calloc(1, sizeof(task));
322 tk->name = get_prop_data(tk->win, atoms[_NET_WM_NAME], atoms[STRING_UTF8], 0) ?:
323 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
325 //tk->locale = get_prop_data(win, XA_WM_LOCALE_NAME, XA_STRING, 0);
326 tk->iconified = is_iconified(win);
327 tk->shaded = is_shaded(win);
328 tk->hidden = is_hidden(win);
329 task_update_icon(tk);
331 /* now append it to our linked list */
347 static void set_prop(Window win, Atom at, Atom type, long val)
349 XChangeProperty(dd, win, at, type, 32,
350 PropModeReplace, (unsigned char *)&val, 1);
353 static Window gui_create_taskbar(void)
356 XSizeHints size_hints;
357 XSetWindowAttributes att;
360 att.event_mask = ButtonPressMask;
363 tb.y = scr_height - WINHEIGHT;
365 win = rspanelwin = XCreateWindow(/* display */ dd,
366 /* parent */ root_win,
369 /* XXX Maybe just use scr_width here? */
370 /* width */ WINWIDTH,
371 /* height */ WINHEIGHT,
373 /* depth */ CopyFromParent,
374 /* class */ InputOutput,
375 /* visual */ CopyFromParent,
376 /*value mask*/ CWEventMask,
379 /* reside on ALL desktops */
380 set_prop(win, atoms[_NET_WM_DESKTOP], XA_CARDINAL, 0xFFFFFFFF);
381 set_prop(win, atoms[_NET_WM_WINDOW_TYPE], XA_ATOM,
382 atoms[_NET_WM_WINDOW_TYPE_DOCK]);
383 set_prop(win, atoms[_NET_WM_STATE], XA_ATOM, atoms[_NET_WM_STATE_BELOW]);
384 XChangeProperty(dd, win, XA_WM_NAME, XA_STRING, 8, PropModeReplace,
385 (unsigned char *)"rspanel", 7);
387 /* make sure the WM obays our window position */
388 size_hints.flags = PPosition;
389 /*XSetWMNormalHints (dd, win, &size_hints); */
390 XChangeProperty(dd, win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32,
391 PropModeReplace, (unsigned char *)&size_hints,
392 sizeof(XSizeHints) / 4);
394 xclhints.res_name = "rspanel";
395 xclhints.res_class = "RSPanel";
396 XSetClassHint(dd, win, &xclhints);
403 #define SURF(x) with->surface.x
404 #define TEXT(x) with->texture[0].data.text.x
405 #define USE(x) (with = x)
406 #define SETTEXT(x, y, z) with->texture[0].type = RR_TEXTURE_TEXT; \
407 with->texture[0].data.text.font = x; \
408 with->texture[0].data.text.justify = y; \
409 with->texture[0].data.text.ellipsize = z;
410 #define SETSHADOW(y, z, u, v) with->texture[0].data.text.shadow_offset_x = y; \
411 with->texture[0].data.text.shadow_offset_y = z; \
412 with->texture[0].data.text.shadow_alpha = u; \
413 with->texture[0].data.text.shadow_color = v;
414 static void gui_init(void)
420 gcv.graphics_exposures = False;
422 fore_gc = XCreateGC(dd, root_win, GCGraphicsExposures, &gcv);
424 inst = RrInstanceNew(dd, scr_screen);
426 /* We don't allow different fonts for various window states... */
427 font = RrFontOpen(inst, "Candara, sans", 10, RR_FONTWEIGHT_NORMAL, RR_FONTSLANT_NORMAL);
429 /* this appearance will be used to draw icons, we don't
430 * set the type of the texture to RGBA here, because we toggle
431 * that so obrender doesn't try to draw an icon when the app
432 * doesn't have one */
433 /* XXX don't do that */
434 a_icon = RrAppearanceNew(inst, 1);
436 SURF(grad) = RR_SURFACE_PARENTREL;
438 /* this is the appearance for the background of the panel */
439 background = RrAppearanceNew(inst, 0);
441 SURF(grad) = RR_SURFACE_DIAGONAL;
442 SURF(primary) = RrColorNew(inst, 170, 170, 190);
443 SURF(secondary) = RrColorNew(inst, 100, 100, 160);
445 /* this is the appearance for unfocused tasks,
446 * text needs to be separate appearances so we can align it correctly */
447 unfocused_task = RrAppearanceNew(inst, 0);
449 SURF(parent) = background;
450 SURF(grad) = RR_SURFACE_PARENTREL;
452 SURF(border_color) = RrColorNew(inst, 0, 0, 80);
454 /* ... for iconified tasks, also used for shaded ones currently */
455 iconified_task = RrAppearanceCopy(unfocused_task);
457 SURF(relief) = RR_RELIEF_SUNKEN;
458 SURF(border) = FALSE;
459 SURF(parent) = background; /* RrAppearanceCopy doesn't copy .parent */
461 /* ... for focused tasks */
462 focused_task = RrAppearanceNew(inst, 0);
464 SURF(grad) = RR_SURFACE_CROSS_DIAGONAL;
465 SURF(secondary) = RrColorNew(inst, 70, 80, 110);
466 SURF(primary) = RrColorNew(inst, 130, 160, 250);
467 SURF(relief) = RR_RELIEF_RAISED;
469 /* this is the text used for all normal unfocused tasks */
470 /* we don't set .parent here, but in draw_task, since we
471 * want to combine _task and _text semirandomly.
472 * XXX plz not when themes are here */
473 normal_text = RrAppearanceNew(inst, 1);
475 SURF(grad) = RR_SURFACE_PARENTREL;
476 SETTEXT(font, RR_JUSTIFY_LEFT, RR_ELLIPSIZE_END);
478 /* ... for iconified tasks */
479 iconified_text = RrAppearanceCopy(normal_text);
480 /* ... and for focused tasks, we copy this here (ie not 5 lines down)
481 * so the color isn't copied i actually don't know if that would
482 * hurt so XXX on that */
483 focused_text = RrAppearanceCopy(normal_text);
485 TEXT(color) = RrColorNew(inst, 230, 230, 255);
488 TEXT(color) = RrColorNew(inst, 20, 20, 40);
491 SETSHADOW(2, 2, 100, RrColorNew(inst, 0, 0, 0));
492 TEXT(color) = RrColorNew(inst, 200, 200, 200);
494 shaded_text = RrAppearanceCopy(normal_text);
496 TEXT(color) = RrColorNew(inst, 50, 60, 90);
499 const icon* best_task_icon(task *tk, gint w, gint h)
503 gulong min_diff, min_i;
505 min_diff = ABS(tk->icons[0].width - w) + ABS(tk->icons[0].height - h);
508 for (i = 1; i < tk->nicons; ++i) {
511 diff = ABS(tk->icons[i].width - w) + ABS(tk->icons[i].height - h);
512 if (diff < min_diff) {
517 return &tk->icons[min_i];
521 #define ICON_SIZE WINHEIGHT-2*PADDING
522 static void gui_draw_task(task *tk, int redraw)
530 else if (tk->focused)
541 else if (tk->focused)
546 i = best_task_icon(tk, ICON_SIZE, ICON_SIZE);
549 RrTexture *c = &a_icon->texture[0];
550 RrTextureRGBA *d = &c->data.rgba;
551 c->type = RR_TEXTURE_RGBA;
552 a_icon->surface.parent = b;
553 a_icon->surface.parentx = PADDING;
554 a_icon->surface.parenty = PADDING;
556 d->height = i->height;
557 d->alpha = tk->iconified ? 0x80 : tk->shaded ? 0xB0 : 0xff;
561 a->surface.parent = b;
562 a->surface.parentx = ICON_SIZE+2*PADDING;
563 a->texture[0].data.text.string = tk->name;
564 b->surface.parentx = tk->pos_x;
566 RrPaintPixmap(b, tk->width, WINHEIGHT);
567 RrPaintPixmap(a, tk->width-3*PADDING-ICON_SIZE, WINHEIGHT);
568 RrPaintPixmap(a_icon, ICON_SIZE, ICON_SIZE);
570 XCopyArea(dd, a_icon->pixmap, b->pixmap, fore_gc, 0, 0,
571 ICON_SIZE, ICON_SIZE, PADDING, PADDING);
572 XCopyArea(dd, a->pixmap, b->pixmap, fore_gc, 0, 0,
573 tk->width-3*PADDING-ICON_SIZE, WINHEIGHT, ICON_SIZE+2*PADDING, 0);
574 XCopyArea(dd, b->pixmap, bgpixmap, fore_gc, 0, 0,
575 tk->width, WINHEIGHT, tk->pos_x, 0);
577 a_icon->texture[1].type = RR_TEXTURE_NONE;
578 XFreePixmap(dd, a->pixmap);
579 XFreePixmap(dd, b->pixmap);
580 XFreePixmap(dd, a_icon->pixmap);
582 XSetWindowBackgroundPixmap(dd, tb.win, bgpixmap);
583 XClearWindow(dd, tb.win);
587 static void netwm_action(Window win, atom_t atom, Time time, long l)
589 XClientMessageEvent xev = {
590 .type = ClientMessage,
594 .message_type = atoms[atom]
597 if (atom == _NET_ACTIVE_WINDOW) {
599 xev.data.l[1] = time;
601 } else if (atom == _NET_CURRENT_DESKTOP) {
603 xev.data.l[1] = time;
604 } else if (atom == _NET_RESTACK_WINDOW) {
607 } else if (atom == _OB_FOCUS) {
609 xev.message_type = atoms[_NET_WM_STATE];
611 xev.data.l[1] = atoms[atom];
615 XSendEvent(dd, root_win, False, SubstructureNotifyMask
616 |SubstructureRedirectMask, (XEvent *)&xev);
619 static void set_icon_geometry(task *tk)
623 coords[0] = tb.x + tk->pos_x;
625 coords[2] = MAX(tk->width, 1);
626 coords[3] = WINHEIGHT;
628 XChangeProperty(dd, tk->win,
629 atoms[_NET_WM_ICON_GEOMETRY], XA_CARDINAL,
630 32, PropModeReplace, (unsigned char*) &coords, 4);
636 static void switch_desk(int new_desk, Time time)
638 if (get_number_of_desktops() <= new_desk)
641 netwm_action(None, _NET_CURRENT_DESKTOP, time, new_desk);
644 /* This doesn't work with obrender yet */
645 static void pager_draw_button(int x, int num)
652 if (num == tb.my_desktop) {
653 /* current desktop */
654 draw_box(x, PAGER_BUTTON_WIDTH);
657 fill_rect(x, 1, PAGER_BUTTON_WIDTH + 1, WINHEIGHT - 2);
663 col.color.alpha = 0xffff;
664 col.color.red = cols[5].red;
665 col.color.green = cols[5].green;
666 col.color.blue = cols[5].blue;
667 XftDrawString8(xftdraw, &col, xfs,
668 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2), text_y,
672 XDrawString(dd, tb.win, fore_gc,
673 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2) - 1,
678 static void pager_draw(void)
680 int desks, i, x = GRILL_WIDTH;
682 desks = get_number_of_desktops();
684 for (i = 0; i < desks; i++) {
685 pager_draw_button(x, i);
688 x += PAGER_BUTTON_WIDTH;
696 static inline int dont_show_task(task *tk)
698 return !tk->focused && tk->hidden;
701 static void gui_draw_taskbar(void)
710 pager_size = TEXTPAD;
714 width = WINWIDTH - (pager_size + GRILL_WIDTH);
715 #warning only rerender if width changed!
716 if (bgpixmap) XFreePixmap(dd, bgpixmap);
717 bgpixmap = XCreatePixmap(dd, root_win, WINWIDTH, WINHEIGHT, RrDepth(inst));
719 XFreePixmap(dd, RrPaintPixmap(background, WINWIDTH, WINHEIGHT));
720 XCopyArea(dd, background->pixmap, bgpixmap, fore_gc, 0, 0, WINWIDTH, WINHEIGHT, 0, 0);
722 /* find the number of visible tasks */
723 for (tk = tb.task_list; tk; tk = tk->next) {
724 if (dont_show_task(tk))
732 taskw = width / num_tasks;
733 if (taskw > MAX_TASK_WIDTH)
734 taskw = MAX_TASK_WIDTH;
736 for (tk = tb.task_list; tk; tk = tk->next) {
737 if (dont_show_task(tk))
740 tk->width = taskw - 1;
741 gui_draw_task(tk, FALSE);
742 set_icon_geometry(tk);
747 XSetWindowBackgroundPixmap(dd, tb.win, bgpixmap);
748 XClearWindow(dd, tb.win);
752 static task *find_task(Window win)
754 task *list = tb.task_list;
756 if (list->win == win)
763 static void del_task(Window win)
765 task *next, *prev = 0, *list = tb.task_list;
769 if (list->win == win) {
770 /* unlink and free this task */
786 static void move_taskbar(void)
791 tb.x = TEXTPAD - WINWIDTH;
794 tb.y = scr_height - WINHEIGHT;
796 XMoveWindow(dd, tb.win, tb.x, tb.y);
799 static void taskbar_read_clientlist(void)
801 Window *win, focus_win = 0;
802 int num, i, desk, new_desk = 0;
804 desk = get_current_desktop();
812 XResizeWindow(dd, rspanelwin, WINWIDTH, WINHEIGHT);
815 if (desk != tb.my_desktop) {
817 tb.my_desktop = desk;
820 win = get_prop_data(root_win, atoms[_NET_ACTIVE_WINDOW], XA_WINDOW, &num);
821 if (win && num > 0) {
826 win = get_prop_data(root_win, atoms[_NET_CLIENT_LIST], XA_WINDOW, &num);
830 /* remove windows that arn't in the _NET_CLIENT_LIST anymore */
833 list->focused = (focus_win == list->win);
837 for (i = num - 1; i >= 0; i--)
838 if (list->win == win[i])
846 /* add any new windows */
847 for (i = 0; i < num; i++) {
848 if (!find_task(win[i]))
849 add_task(win[i], (win[i] == focus_win));
855 static void handle_press(int x, int y, int button, Time time)
860 if ((y > 2 && y < WINHEIGHT - 2 && x > GRILL_WIDTH) && button == 1)
861 switch_desk((x - GRILL_WIDTH) / PAGER_BUTTON_WIDTH, time);
864 /* clicked left grill */
867 tb.at_top = 1 - tb.at_top;
869 } else if (button == 4) {
875 /* clicked right grill */
876 else if (x + TEXTPAD > WINWIDTH) {
877 if (tb.hidden && (button == 1 || button == 5)) {
880 } else if (!tb.hidden && (button == 1 || button == 4)) {
887 /* clicked on a task button */
888 /* XXX Make this configureable */
889 if (!dont_show_task(tk)
890 && (x > tk->pos_x && x < tk->pos_x + tk->width))
894 netwm_action(tk->win, _NET_ACTIVE_WINDOW, time, 0);
898 netwm_action(tk->win, _NET_WM_STATE_HIDDEN, time, REMOVE);
900 netwm_action(tk->win, _NET_WM_STATE_HIDDEN, time, ADD);
903 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Opposite);
906 if (is_shaded(tk->win))
907 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Below);
909 netwm_action(tk->win, _NET_WM_STATE_SHADED, time, ADD);
912 if (is_shaded(tk->win))
913 netwm_action(tk->win, _NET_WM_STATE_SHADED, time, REMOVE);
915 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Above);
919 netwm_action(tk->win, _NET_WM_STATE_HIDDEN, time, REMOVE);
921 netwm_action(tk->win, _OB_FOCUS, 0, 0);
924 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Below);
927 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Above);
933 } /* clicked on the background */
936 netwm_action(tb.win, _NET_RESTACK_WINDOW, time, Above);
939 netwm_action(tb.win, _NET_RESTACK_WINDOW, time, Below);
942 netwm_action(tb.win, _NET_RESTACK_WINDOW, time, Opposite);
957 static void handle_focusin(Window win)
964 if (tk->win != win) {
969 if (tk->win == win) {
979 static Bool look_for_duplicate_property(Display *d, XEvent *e, XPointer arg)
981 Atom at = *(Atom*)arg;
982 return (e->type == PropertyNotify && e->xproperty.atom == at);
985 static void handle_propertynotify(Window win, Atom at)
989 if (win == root_win) {
990 /* XXX only redraw the task that got focused/unfocused
991 * when _NET_ACTIVE_WINDOW triggers this,
992 * redraw everything if that task was hidden before though */
993 if (at == atoms[_NET_CLIENT_LIST] || at == atoms[_NET_CURRENT_DESKTOP]
994 || at == atoms[_NET_ACTIVE_WINDOW])
999 check = atoms[_NET_CLIENT_LIST];
1000 while (XCheckIfEvent(dd, &ce, look_for_duplicate_property, (XPointer)&check));
1001 check = atoms[_NET_CURRENT_DESKTOP];
1002 while (XCheckIfEvent(dd, &ce, look_for_duplicate_property, (XPointer)&check));
1003 check = atoms[_NET_ACTIVE_WINDOW];
1004 while (XCheckIfEvent(dd, &ce, look_for_duplicate_property, (XPointer)&check));
1006 taskbar_read_clientlist();
1012 /* XXX make this work when SKIP_TASKBAR is toggled too */
1013 /* show skip_taskbar tasks if they're focused */
1014 tk = find_task(win);
1018 if (at == XA_WM_NAME || at == atoms[_NET_WM_NAME]) {
1019 /* window's title changed */
1020 /* XXX make a function for this and use from here and add_task */
1022 newname = get_prop_data(tk->win, atoms[_NET_WM_NAME], atoms[STRING_UTF8], 0) ?:
1023 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
1025 /* It didn't change */
1026 if (tk->name && !strcmp(newname, tk->name)) {
1034 gui_draw_task(tk, TRUE);
1035 } else if (at == atoms[_NET_WM_ICON]) {
1036 task_update_icon(tk);
1037 gui_draw_task(tk, TRUE);
1038 } else if (at == atoms[_NET_WM_STATE]) {
1039 /* iconified state changed? */
1040 if (is_iconified(tk->win) != tk->iconified) {
1041 tk->iconified = !tk->iconified;
1043 gui_draw_task(tk, TRUE);
1045 /* shaded state changed? */
1046 if (is_shaded(tk->win) != tk->shaded) {
1047 tk->shaded = !tk->shaded;
1048 gui_draw_task(tk, TRUE);
1050 if (is_hidden(tk->win) != tk->hidden) {
1051 tk->hidden = !tk->hidden;
1054 } else if (at == atoms[_NET_WM_DESKTOP]) {
1055 if (find_desktop(win) != get_current_desktop())
1060 static void handle_error(Display * d, XErrorEvent * ev)
1068 main(int argc, char *argv[])
1074 dd = XOpenDisplay(NULL);
1077 xfd = ConnectionNumber(dd);
1079 scr_screen = DefaultScreen(dd);
1080 scr_depth = DefaultDepth(dd, scr_screen);
1081 scr_height = DisplayHeight(dd, scr_screen);
1082 scr_width = DisplayWidth(dd, scr_screen);
1083 root_win = RootWindow(dd, scr_screen);
1085 /* helps us catch windows closing/opening */
1086 XSelectInput(dd, root_win, PropertyChangeMask | SubstructureNotifyMask);
1088 XSetErrorHandler((XErrorHandler) handle_error);
1090 XInternAtoms(dd, atom_names, ATOM_COUNT, False, atoms);
1093 memset(&tb, 0, sizeof(tb));
1094 tb.win = gui_create_taskbar();
1096 taskbar_read_clientlist();
1104 select(xfd + 1, &fd, 0, 0, 0);
1106 while (XPending(dd)) {
1107 XNextEvent(dd, &ev);
1110 handle_press(ev.xbutton.x, ev.xbutton.y, ev.xbutton.button, ev.xbutton.time);
1112 case PropertyNotify:
1113 handle_propertynotify(ev.xproperty.window, ev.xproperty.atom);
1116 printf ("unknown evt type: %d\n", ev.type); */
1120 /* RrInstanceFree(inst);
1121 * XCloseDisplay (dd);