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 */
27 # define WINWIDTH scr_width
32 /* don't edit these */
34 #define GRILL_WIDTH 10
36 #include <openbox/render.h>
37 #include <openbox/theme.h>
54 RrAppearance *background;
55 RrAppearance *focused_task;
56 RrAppearance *iconified_task;
57 RrAppearance *unfocused_task;
58 RrAppearance *normal_text;
59 RrAppearance *iconified_text;
60 RrAppearance *shaded_text;
61 RrAppearance *focused_text;
64 /* we draw stuff to this guy then set him as a window
65 * background pixmap, yay no flickering! */
68 char *atom_names[] = {
74 "_NET_WM_STATE_SKIP_TASKBAR",
75 "_NET_WM_STATE_SHADED",
76 "_NET_WM_STATE_BELOW",
77 "_NET_WM_STATE_HIDDEN",
79 "_NET_WM_WINDOW_TYPE",
80 "_NET_WM_WINDOW_TYPE_DOCK",
85 "_NET_CLIENT_LIST_STACKING",
86 "_NET_NUMBER_OF_DESKTOPS",
87 "_NET_CURRENT_DESKTOP",
92 "_NET_RESTACK_WINDOW",
94 "_NET_WM_ICON_GEOMETRY",
103 _NET_WM_STATE_SKIP_TASKBAR,
104 _NET_WM_STATE_SHADED,
106 _NET_WM_STATE_HIDDEN,
109 _NET_WM_WINDOW_TYPE_DOCK,
113 _NET_CLIENT_LIST_STACKING,
114 _NET_NUMBER_OF_DESKTOPS,
115 _NET_CURRENT_DESKTOP,
122 _NET_WM_ICON_GEOMETRY,
127 Atom atoms[ATOM_COUNT];
135 static void *get_prop_data(Window win, Atom prop, Atom type, int *items)
139 unsigned long items_ret;
140 unsigned long after_ret;
141 unsigned char *prop_data;
145 XGetWindowProperty(dd, win, prop, 0, 0x7fffffff, False, type, &type_ret,
146 &format_ret, &items_ret, &after_ret, &prop_data);
153 static int generic_get_int(Window win, Atom at)
158 data = get_prop_data(win, at, XA_CARDINAL, 0);
166 static int find_desktop(Window win)
168 return generic_get_int(win, atoms[_NET_WM_DESKTOP]);
171 static int find_state(Window win, atom_t atom)
177 data = get_prop_data(win, atoms[_NET_WM_STATE], XA_ATOM, &num);
180 if ((data[num]) == atoms[atom])
188 /* this naming is very confusing :) */
189 static int is_hidden(Window win)
191 return find_state(win, _NET_WM_STATE_SKIP_TASKBAR);
194 static int is_iconified(Window win)
196 return find_state(win, _NET_WM_STATE_HIDDEN);
199 static int is_shaded(Window win)
201 return find_state(win, _NET_WM_STATE_SHADED);
204 static int get_current_desktop(void)
206 return generic_get_int(root_win, atoms[_NET_CURRENT_DESKTOP]);
210 static int get_number_of_desktops(void)
212 return generic_get_int(root_win, atoms[_NET_NUMBER_OF_DESKTOPS]);
216 static void free_icons(task *tk)
220 for (i = 0; i < tk->nicons; ++i)
221 free(tk->icons[i].data);
227 static void task_update_icon(task *tk)
229 /* these bits are borrowed from openbox' client.c::client_update_icons */
232 unsigned int w, h, i, j;
236 data = get_prop_data(tk->win, atoms[_NET_WM_ICON], XA_CARDINAL, &num);
238 /* figure out how many valid icons are in here */
240 while (num - i > 2) {
244 if (i > num || w*h == 0) break;
248 tk->icons = calloc(tk->nicons, sizeof(icon));
250 /* store the icons */
252 for (j = 0; j < tk->nicons; ++j) {
255 w = tk->icons[j].width = data[i++];
256 h = tk->icons[j].height = data[i++];
258 if (w*h == 0) continue;
260 tk->icons[j].data = g_new(RrPixel32, w * h);
261 for (x = 0, y = 0, t = 0; t < w * h; ++t, ++x, ++i) {
266 tk->icons[j].data[t] =
267 (((data[i] >> 24) & 0xff) << RrDefaultAlphaOffset) +
268 (((data[i] >> 16) & 0xff) << RrDefaultRedOffset) +
269 (((data[i] >> 8) & 0xff) << RrDefaultGreenOffset) +
270 (((data[i] >> 0) & 0xff) << RrDefaultBlueOffset);
279 if ((hints = XGetWMHints(dd, tk->win))) {
280 if (hints->flags & IconPixmapHint) {
282 tk->icons = g_new(icon, tk->nicons);
283 // xerror_set_ignore(TRUE);
284 if (!RrPixmapToRGBA(inst,
286 (hints->flags & IconMaskHint ?
287 hints->icon_mask : None),
288 &tk->icons[tk->nicons-1].width,
289 &tk->icons[tk->nicons-1].height,
290 &tk->icons[tk->nicons-1].data)){
291 g_free(&tk->icons[tk->nicons-1]);
294 // xerror_set_ignore(FALSE);
301 static void add_task(Window win, int focus)
309 /* is this window on a different desktop? */
310 /* XXX add even if is_hidden, but don't show it later, so we can
311 * unhide it when the prop is removed */
312 desk = find_desktop(win);
313 if ((desk != 0xffffffff && tb.my_desktop != desk))
316 XSelectInput(dd, win, PropertyChangeMask | StructureNotifyMask);
318 tk = calloc(1, sizeof(task));
321 tk->name = get_prop_data(tk->win, atoms[_NET_WM_NAME], atoms[STRING_UTF8], 0) ?:
322 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
324 //tk->locale = get_prop_data(win, XA_WM_LOCALE_NAME, XA_STRING, 0);
325 tk->iconified = is_iconified(win);
326 tk->shaded = is_shaded(win);
327 tk->hidden = is_hidden(win);
328 task_update_icon(tk);
330 /* now append it to our linked list */
346 static void set_prop(Window win, Atom at, Atom type, long val)
348 XChangeProperty(dd, win, at, type, 32,
349 PropModeReplace, (unsigned char *)&val, 1);
352 static Window gui_create_taskbar(void)
355 XSizeHints size_hints;
356 XSetWindowAttributes att;
359 att.event_mask = ButtonPressMask;
362 tb.y = scr_height - WINHEIGHT;
364 win = rspanelwin = XCreateWindow(/* display */ dd,
365 /* parent */ root_win,
368 /* XXX Maybe just use scr_width here? */
369 /* width */ WINWIDTH,
370 /* height */ WINHEIGHT,
372 /* depth */ CopyFromParent,
373 /* class */ InputOutput,
374 /* visual */ CopyFromParent,
375 /*value mask*/ CWEventMask,
378 /* reside on ALL desktops */
379 set_prop(win, atoms[_NET_WM_DESKTOP], XA_CARDINAL, 0xFFFFFFFF);
380 set_prop(win, atoms[_NET_WM_WINDOW_TYPE], XA_ATOM,
381 atoms[_NET_WM_WINDOW_TYPE_DOCK]);
382 set_prop(win, atoms[_NET_WM_STATE], XA_ATOM, atoms[_NET_WM_STATE_BELOW]);
383 XChangeProperty(dd, win, XA_WM_NAME, XA_STRING, 8, PropModeReplace,
384 (unsigned char *)"rspanel", 7);
386 /* make sure the WM obays our window position */
387 size_hints.flags = PPosition;
388 /*XSetWMNormalHints (dd, win, &size_hints); */
389 XChangeProperty(dd, win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32,
390 PropModeReplace, (unsigned char *)&size_hints,
391 sizeof(XSizeHints) / 4);
393 xclhints.res_name = "rspanel";
394 xclhints.res_class = "RSPanel";
395 XSetClassHint(dd, win, &xclhints);
402 #define SURF(x) with->surface.x
403 #define TEXT(x) with->texture[0].data.text.x
404 #define USE(x) (with = x)
405 #define SETTEXT(x, y, z) with->texture[0].type = RR_TEXTURE_TEXT; \
406 with->texture[0].data.text.font = x; \
407 with->texture[0].data.text.justify = y; \
408 with->texture[0].data.text.ellipsize = z;
409 #define SETSHADOW(y, z, u, v) with->texture[0].data.text.shadow_offset_x = y; \
410 with->texture[0].data.text.shadow_offset_y = z; \
411 with->texture[0].data.text.shadow_alpha = u; \
412 with->texture[0].data.text.shadow_color = v;
413 static void gui_init(void)
419 gcv.graphics_exposures = False;
421 fore_gc = XCreateGC(dd, root_win, GCGraphicsExposures, &gcv);
423 inst = RrInstanceNew(dd, scr_screen);
425 /* We don't allow different fonts for various window states... */
426 font = RrFontOpen(inst, "Candara, sans", 10, RR_FONTWEIGHT_NORMAL, RR_FONTSLANT_NORMAL);
428 /* this appearance will be used to draw icons, we don't
429 * set the type of the texture to RGBA here, because we toggle
430 * that so obrender doesn't try to draw an icon when the app
431 * doesn't have one */
432 /* XXX don't do that */
433 a_icon = RrAppearanceNew(inst, 1);
435 SURF(grad) = RR_SURFACE_PARENTREL;
437 /* this is the appearance for the background of the panel */
438 background = RrAppearanceNew(inst, 0);
440 SURF(grad) = RR_SURFACE_DIAGONAL;
441 SURF(primary) = RrColorNew(inst, 170, 170, 190);
442 SURF(secondary) = RrColorNew(inst, 100, 100, 160);
444 /* this is the appearance for unfocused tasks,
445 * text needs to be separate appearances so we can align it correctly */
446 unfocused_task = RrAppearanceNew(inst, 0);
448 SURF(parent) = background;
449 SURF(grad) = RR_SURFACE_PARENTREL;
451 SURF(border_color) = RrColorNew(inst, 0, 0, 80);
453 /* ... for iconified tasks, also used for shaded ones currently */
454 iconified_task = RrAppearanceCopy(unfocused_task);
456 SURF(relief) = RR_RELIEF_SUNKEN;
457 SURF(border) = FALSE;
458 SURF(parent) = background; /* RrAppearanceCopy doesn't copy .parent */
460 /* ... for focused tasks */
461 focused_task = RrAppearanceNew(inst, 0);
463 SURF(grad) = RR_SURFACE_CROSS_DIAGONAL;
464 SURF(secondary) = RrColorNew(inst, 70, 80, 110);
465 SURF(primary) = RrColorNew(inst, 130, 160, 250);
466 SURF(relief) = RR_RELIEF_RAISED;
468 /* this is the text used for all normal unfocused tasks */
469 /* we don't set .parent here, but in draw_task, since we
470 * want to combine _task and _text semirandomly.
471 * XXX plz not when themes are here */
472 normal_text = RrAppearanceNew(inst, 1);
474 SURF(grad) = RR_SURFACE_PARENTREL;
475 SETTEXT(font, RR_JUSTIFY_LEFT, RR_ELLIPSIZE_END);
477 /* ... for iconified tasks */
478 iconified_text = RrAppearanceCopy(normal_text);
479 /* ... and for focused tasks, we copy this here (ie not 5 lines down)
480 * so the color isn't copied i actually don't know if that would
481 * hurt so XXX on that */
482 focused_text = RrAppearanceCopy(normal_text);
484 TEXT(color) = RrColorNew(inst, 230, 230, 255);
487 TEXT(color) = RrColorNew(inst, 20, 20, 40);
490 SETSHADOW(2, 2, 100, RrColorNew(inst, 0, 0, 0));
491 TEXT(color) = RrColorNew(inst, 200, 200, 200);
493 shaded_text = RrAppearanceCopy(normal_text);
495 TEXT(color) = RrColorNew(inst, 50, 60, 90);
498 const icon* best_task_icon(task *tk, gint w, gint h)
502 gulong min_diff, min_i;
504 min_diff = ABS(tk->icons[0].width - w) + ABS(tk->icons[0].height - h);
507 for (i = 1; i < tk->nicons; ++i) {
510 diff = ABS(tk->icons[i].width - w) + ABS(tk->icons[i].height - h);
511 if (diff < min_diff) {
516 return &tk->icons[min_i];
520 #define ICON_SIZE WINHEIGHT-2*PADDING
521 static void gui_draw_task(task *tk, int redraw)
529 else if (tk->focused)
540 else if (tk->focused)
545 i = best_task_icon(tk, ICON_SIZE, ICON_SIZE);
548 RrTexture *c = &a_icon->texture[0];
549 RrTextureRGBA *d = &c->data.rgba;
550 c->type = RR_TEXTURE_RGBA;
551 a_icon->surface.parent = b;
552 a_icon->surface.parentx = PADDING;
553 a_icon->surface.parenty = PADDING;
555 d->height = i->height;
556 d->alpha = tk->iconified ? 0x80 : tk->shaded ? 0xB0 : 0xff;
560 a->surface.parent = b;
561 a->surface.parentx = ICON_SIZE+2*PADDING;
562 a->texture[0].data.text.string = tk->name;
563 b->surface.parentx = tk->pos_x;
565 RrPaintPixmap(b, tk->width, WINHEIGHT);
566 RrPaintPixmap(a, tk->width-3*PADDING-ICON_SIZE, WINHEIGHT);
567 RrPaintPixmap(a_icon, ICON_SIZE, ICON_SIZE);
569 XCopyArea(dd, a_icon->pixmap, b->pixmap, fore_gc, 0, 0,
570 ICON_SIZE, ICON_SIZE, PADDING, PADDING);
571 XCopyArea(dd, a->pixmap, b->pixmap, fore_gc, 0, 0,
572 tk->width-3*PADDING-ICON_SIZE, WINHEIGHT, ICON_SIZE+2*PADDING, 0);
573 XCopyArea(dd, b->pixmap, bgpixmap, fore_gc, 0, 0,
574 tk->width, WINHEIGHT, tk->pos_x, 0);
576 a_icon->texture[1].type = RR_TEXTURE_NONE;
577 XFreePixmap(dd, a->pixmap);
578 XFreePixmap(dd, b->pixmap);
579 XFreePixmap(dd, a_icon->pixmap);
581 XSetWindowBackgroundPixmap(dd, tb.win, bgpixmap);
582 XClearWindow(dd, tb.win);
586 static void netwm_action(Window win, atom_t atom, Time time, long l)
588 XClientMessageEvent xev = {
589 .type = ClientMessage,
593 .message_type = atoms[atom]
596 if (atom == _NET_ACTIVE_WINDOW) {
598 xev.data.l[1] = time;
600 } else if (atom == _NET_CURRENT_DESKTOP) {
602 xev.data.l[1] = time;
603 } else if (atom == _NET_RESTACK_WINDOW) {
606 } else if (atom == _OB_FOCUS) {
608 xev.message_type = atoms[_NET_WM_STATE];
610 xev.data.l[1] = atoms[atom];
614 XSendEvent(dd, root_win, False, SubstructureNotifyMask
615 |SubstructureRedirectMask, (XEvent *)&xev);
618 static void set_icon_geometry(task *tk)
622 coords[0] = tb.x + tk->pos_x;
624 coords[2] = MAX(tk->width, 1);
625 coords[3] = WINHEIGHT;
627 XChangeProperty(dd, tk->win,
628 atoms[_NET_WM_ICON_GEOMETRY], XA_CARDINAL,
629 32, PropModeReplace, (unsigned char*) &coords, 4);
635 static void switch_desk(int new_desk, Time time)
637 if (get_number_of_desktops() <= new_desk)
640 netwm_action(None, _NET_CURRENT_DESKTOP, time, new_desk);
643 /* This doesn't work with obrender yet */
644 static void pager_draw_button(int x, int num)
651 if (num == tb.my_desktop) {
652 /* current desktop */
653 draw_box(x, PAGER_BUTTON_WIDTH);
656 fill_rect(x, 1, PAGER_BUTTON_WIDTH + 1, WINHEIGHT - 2);
662 col.color.alpha = 0xffff;
663 col.color.red = cols[5].red;
664 col.color.green = cols[5].green;
665 col.color.blue = cols[5].blue;
666 XftDrawString8(xftdraw, &col, xfs,
667 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2), text_y,
671 XDrawString(dd, tb.win, fore_gc,
672 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2) - 1,
677 static void pager_draw(void)
679 int desks, i, x = GRILL_WIDTH;
681 desks = get_number_of_desktops();
683 for (i = 0; i < desks; i++) {
684 pager_draw_button(x, i);
687 x += PAGER_BUTTON_WIDTH;
695 static inline int dont_show_task(task *tk)
697 return !tk->focused && tk->hidden;
700 static void gui_draw_taskbar(void)
709 pager_size = TEXTPAD;
713 width = WINWIDTH - (pager_size + GRILL_WIDTH);
714 #warning only rerender if width changed!
715 if (bgpixmap) XFreePixmap(dd, bgpixmap);
716 bgpixmap = XCreatePixmap(dd, root_win, WINWIDTH, WINHEIGHT, RrDepth(inst));
718 XFreePixmap(dd, RrPaintPixmap(background, WINWIDTH, WINHEIGHT));
719 XCopyArea(dd, background->pixmap, bgpixmap, fore_gc, 0, 0, WINWIDTH, WINHEIGHT, 0, 0);
721 /* find the number of visible tasks */
722 for (tk = tb.task_list; tk; tk = tk->next) {
723 if (dont_show_task(tk))
731 taskw = width / num_tasks;
732 if (taskw > MAX_TASK_WIDTH)
733 taskw = MAX_TASK_WIDTH;
735 for (tk = tb.task_list; tk; tk = tk->next) {
736 if (dont_show_task(tk))
739 tk->width = taskw - 1;
740 gui_draw_task(tk, FALSE);
741 set_icon_geometry(tk);
746 XSetWindowBackgroundPixmap(dd, tb.win, bgpixmap);
747 XClearWindow(dd, tb.win);
750 static task *find_task(Window win)
752 task *list = tb.task_list;
754 if (list->win == win)
761 static void del_task(Window win)
763 task *next, *prev = 0, *list = tb.task_list;
767 if (list->win == win) {
768 /* unlink and free this task */
784 static void move_taskbar(void)
789 tb.x = TEXTPAD - WINWIDTH;
792 tb.y = scr_height - WINHEIGHT;
794 XMoveWindow(dd, tb.win, tb.x, tb.y);
797 static void taskbar_read_clientlist(void)
799 Window *win, focus_win = 0;
800 int num, i, desk, new_desk = 0;
802 desk = get_current_desktop();
810 XResizeWindow(dd, rspanelwin, WINWIDTH, WINHEIGHT);
813 if (desk != tb.my_desktop) {
815 tb.my_desktop = desk;
818 win = get_prop_data(root_win, atoms[_NET_ACTIVE_WINDOW], XA_WINDOW, &num);
819 if (win && num > 0) {
824 win = get_prop_data(root_win, atoms[_NET_CLIENT_LIST], XA_WINDOW, &num);
828 /* remove windows that arn't in the _NET_CLIENT_LIST anymore */
831 list->focused = (focus_win == list->win);
835 for (i = num - 1; i >= 0; i--)
836 if (list->win == win[i])
844 /* add any new windows */
845 for (i = 0; i < num; i++) {
846 if (!find_task(win[i]))
847 add_task(win[i], (win[i] == focus_win));
853 static void handle_press(int x, int y, int button, Time time)
858 if ((y > 2 && y < WINHEIGHT - 2 && x > GRILL_WIDTH) && button == 1)
859 switch_desk((x - GRILL_WIDTH) / PAGER_BUTTON_WIDTH, time);
862 /* clicked left grill */
865 tb.at_top = 1 - tb.at_top;
867 } else if (button == 4) {
873 /* clicked right grill */
874 else if (x + TEXTPAD > WINWIDTH) {
875 if (tb.hidden && (button == 1 || button == 5)) {
878 } else if (!tb.hidden && (button == 1 || button == 4)) {
885 /* clicked on a task button */
886 /* XXX Make this configureable */
887 if (!dont_show_task(tk)
888 && (x > tk->pos_x && x < tk->pos_x + tk->width))
892 netwm_action(tk->win, _NET_ACTIVE_WINDOW, time, 0);
896 netwm_action(tk->win, _NET_WM_STATE_HIDDEN, time, REMOVE);
898 netwm_action(tk->win, _NET_WM_STATE_HIDDEN, time, ADD);
901 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Opposite);
904 if (is_shaded(tk->win))
905 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Below);
907 netwm_action(tk->win, _NET_WM_STATE_SHADED, time, ADD);
910 if (is_shaded(tk->win))
911 netwm_action(tk->win, _NET_WM_STATE_SHADED, time, REMOVE);
913 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Above);
917 netwm_action(tk->win, _NET_WM_STATE_HIDDEN, time, REMOVE);
919 netwm_action(tk->win, _OB_FOCUS, 0, 0);
922 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Below);
925 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Above);
931 } /* clicked on the background */
934 netwm_action(tb.win, _NET_RESTACK_WINDOW, time, Above);
937 netwm_action(tb.win, _NET_RESTACK_WINDOW, time, Below);
940 netwm_action(tb.win, _NET_RESTACK_WINDOW, time, Opposite);
955 static void handle_focusin(Window win)
962 if (tk->win != win) {
967 if (tk->win == win) {
977 static Bool look_for_duplicate_property(Display *d, XEvent *e, XPointer arg)
979 Atom at = *(Atom*)arg;
980 return (e->type == PropertyNotify && e->xproperty.atom == at);
983 static void handle_propertynotify(Window win, Atom at)
987 if (win == root_win) {
988 /* XXX only redraw the task that got focused/unfocused
989 * when _NET_ACTIVE_WINDOW triggers this,
990 * redraw everything if that task was hidden before though */
991 if (at == atoms[_NET_CLIENT_LIST] || at == atoms[_NET_CURRENT_DESKTOP]
992 || at == atoms[_NET_ACTIVE_WINDOW])
997 check = atoms[_NET_CLIENT_LIST];
998 while (XCheckIfEvent(dd, &ce, look_for_duplicate_property, (XPointer)&check));
999 check = atoms[_NET_CURRENT_DESKTOP];
1000 while (XCheckIfEvent(dd, &ce, look_for_duplicate_property, (XPointer)&check));
1001 check = atoms[_NET_ACTIVE_WINDOW];
1002 while (XCheckIfEvent(dd, &ce, look_for_duplicate_property, (XPointer)&check));
1004 taskbar_read_clientlist();
1010 /* XXX make this work when SKIP_TASKBAR is toggled too */
1011 /* show skip_taskbar tasks if they're focused */
1012 tk = find_task(win);
1016 if (at == XA_WM_NAME || at == atoms[_NET_WM_NAME]) {
1017 /* window's title changed */
1018 /* XXX make a function for this and use from here and add_task */
1020 newname = get_prop_data(tk->win, atoms[_NET_WM_NAME], atoms[STRING_UTF8], 0) ?:
1021 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
1023 /* It didn't change */
1024 if (tk->name && !strcmp(newname, tk->name)) {
1032 gui_draw_task(tk, TRUE);
1033 } else if (at == atoms[_NET_WM_ICON]) {
1034 task_update_icon(tk);
1035 gui_draw_task(tk, TRUE);
1036 } else if (at == atoms[_NET_WM_STATE]) {
1037 /* iconified state changed? */
1038 if (is_iconified(tk->win) != tk->iconified) {
1039 tk->iconified = !tk->iconified;
1041 gui_draw_task(tk, TRUE);
1043 /* shaded state changed? */
1044 if (is_shaded(tk->win) != tk->shaded) {
1045 tk->shaded = !tk->shaded;
1046 gui_draw_task(tk, TRUE);
1048 if (is_hidden(tk->win) != tk->hidden) {
1049 tk->hidden = !tk->hidden;
1052 } else if (at == atoms[_NET_WM_DESKTOP]) {
1053 if (find_desktop(win) != get_current_desktop())
1058 static void handle_error(Display * d, XErrorEvent * ev)
1066 main(int argc, char *argv[])
1073 dd = XOpenDisplay(NULL);
1076 scr_screen = DefaultScreen(dd);
1077 scr_depth = DefaultDepth(dd, scr_screen);
1078 scr_height = DisplayHeight(dd, scr_screen);
1079 scr_width = DisplayWidth(dd, scr_screen);
1080 root_win = RootWindow(dd, scr_screen);
1082 /* helps us catch windows closing/opening */
1083 XSelectInput(dd, root_win, PropertyChangeMask);
1085 XSetErrorHandler((XErrorHandler) handle_error);
1087 XInternAtoms(dd, atom_names, ATOM_COUNT, False, atoms);
1090 memset(&tb, 0, sizeof(tb));
1091 tb.win = gui_create_taskbar();
1092 xfd = ConnectionNumber(dd);
1094 taskbar_read_clientlist();
1100 select(xfd + 1, &fd, 0, 0, 0);
1102 while (XPending(dd)) {
1103 XNextEvent(dd, &ev);
1106 handle_press(ev.xbutton.x, ev.xbutton.y, ev.xbutton.button, ev.xbutton.time);
1108 case PropertyNotify:
1109 handle_propertynotify(ev.xproperty.window, ev.xproperty.atom);
1112 printf ("unknown evt type: %d\n", ev.type); */
1116 /* RrInstanceFree(inst);
1117 * XCloseDisplay (dd);