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)
418 gcv.graphics_exposures = False;
420 fore_gc = XCreateGC(dd, root_win, GCGraphicsExposures, &gcv);
422 inst = RrInstanceNew(dd, scr_screen);
424 /* this appearance will be used to draw icons, we don't
425 * set the type of the texture to RGBA here, because we toggle
426 * that so obrender doesn't try to draw an icon when the app
427 * doesn't have one */
428 /* XXX don't do that */
429 a_icon = RrAppearanceNew(inst, 1);
431 SURF(grad) = RR_SURFACE_PARENTREL;
433 /* this is the appearance for the background of the panel */
434 background = RrAppearanceNew(inst, 0);
436 SURF(grad) = RR_SURFACE_DIAGONAL;
437 SURF(primary) = RrColorNew(inst, 170, 170, 190);
438 SURF(secondary) = RrColorNew(inst, 100, 100, 160);
440 /* this is the appearance for unfocused tasks,
441 * text needs to be separate appearances so we can align it correctly */
442 unfocused_task = RrAppearanceNew(inst, 0);
444 SURF(parent) = background;
445 SURF(grad) = RR_SURFACE_PARENTREL;
447 SURF(border_color) = RrColorNew(inst, 0, 0, 80);
449 /* ... for iconified tasks, also used for shaded ones currently */
450 iconified_task = RrAppearanceCopy(unfocused_task);
452 SURF(relief) = RR_RELIEF_SUNKEN;
453 SURF(parent) = background;
455 /* ... for focused tasks */
456 focused_task = RrAppearanceNew(inst, 0);
458 SURF(grad) = RR_SURFACE_CROSS_DIAGONAL;
459 SURF(secondary) = RrColorNew(inst, 70, 80, 110);
460 SURF(primary) = RrColorNew(inst, 130, 160, 250);
461 SURF(relief) = RR_RELIEF_RAISED;
463 /* this is the text used for all normal unfocused tasks */
464 normal_text = RrAppearanceNew(inst, 1);
466 SURF(grad) = RR_SURFACE_PARENTREL;
467 SETTEXT(RrFontOpen(inst, "Candara, sans", 10, RR_FONTWEIGHT_NORMAL, RR_FONTSLANT_NORMAL),
468 RR_JUSTIFY_LEFT, RR_ELLIPSIZE_END);
470 /* ... for iconified tasks */
471 iconified_text = RrAppearanceCopy(normal_text);
472 /* ... and for focused tasks, we copy this here (ie not 5 lines down)
473 * so the color isn't copied i actually don't know if that would
474 * hurt so XXX on that */
475 focused_text = RrAppearanceCopy(normal_text);
477 TEXT(color) = RrColorNew(inst, 230, 230, 255);
480 TEXT(color) = RrColorNew(inst, 20, 20, 40);
483 SETSHADOW(2, 2, 100, RrColorNew(inst, 0, 0, 0));
484 TEXT(color) = RrColorNew(inst, 200, 200, 200);
486 shaded_text = RrAppearanceCopy(normal_text);
488 TEXT(color) = RrColorNew(inst, 50, 60, 90);
491 const icon* best_task_icon(task *tk, gint w, gint h)
495 gulong min_diff, min_i;
497 min_diff = ABS(tk->icons[0].width - w) + ABS(tk->icons[0].height - h);
500 for (i = 1; i < tk->nicons; ++i) {
503 diff = ABS(tk->icons[i].width - w) + ABS(tk->icons[i].height - h);
504 if (diff < min_diff) {
509 return &tk->icons[min_i];
513 #define ICON_SIZE WINHEIGHT-2*PADDING
514 static void gui_draw_task(task *tk, int redraw)
522 else if (tk->focused)
533 else if (tk->focused)
538 i = best_task_icon(tk, ICON_SIZE, ICON_SIZE);
541 RrTexture *c = &a_icon->texture[0];
542 RrTextureRGBA *d = &c->data.rgba;
543 c->type = RR_TEXTURE_RGBA;
544 a_icon->surface.parent = b;
545 a_icon->surface.parentx = PADDING;
546 a_icon->surface.parenty = PADDING;
548 d->height = i->height;
549 d->alpha = tk->iconified ? 0x80 : tk->shaded ? 0xB0 : 0xff;
553 a->surface.parent = b;
554 a->surface.parentx = ICON_SIZE+2*PADDING;
555 a->texture[0].data.text.string = tk->name;
556 b->surface.parentx = tk->pos_x;
558 RrPaintPixmap(b, tk->width, WINHEIGHT);
559 RrPaintPixmap(a, tk->width-3*PADDING-ICON_SIZE, WINHEIGHT);
560 RrPaintPixmap(a_icon, ICON_SIZE, ICON_SIZE);
562 XCopyArea(dd, a_icon->pixmap, b->pixmap, fore_gc, 0, 0,
563 ICON_SIZE, ICON_SIZE, PADDING, PADDING);
564 XCopyArea(dd, a->pixmap, b->pixmap, fore_gc, 0, 0,
565 tk->width-3*PADDING-ICON_SIZE, WINHEIGHT, ICON_SIZE+2*PADDING, 0);
566 XCopyArea(dd, b->pixmap, bgpixmap, fore_gc, 0, 0,
567 tk->width, WINHEIGHT, tk->pos_x, 0);
569 a_icon->texture[1].type = RR_TEXTURE_NONE;
570 XFreePixmap(dd, a->pixmap);
571 XFreePixmap(dd, b->pixmap);
572 XFreePixmap(dd, a_icon->pixmap);
574 XSetWindowBackgroundPixmap(dd, tb.win, bgpixmap);
575 XClearWindow(dd, tb.win);
579 static void netwm_action(Window win, atom_t atom, Time time, long l)
581 XClientMessageEvent xev = {
582 .type = ClientMessage,
586 .message_type = atoms[atom]
589 if (atom == _NET_ACTIVE_WINDOW) {
591 xev.data.l[1] = time;
593 } else if (atom == _NET_CURRENT_DESKTOP) {
595 xev.data.l[1] = time;
596 } else if (atom == _NET_RESTACK_WINDOW) {
599 } else if (atom == _OB_FOCUS) {
601 xev.message_type = atoms[_NET_WM_STATE];
603 xev.data.l[1] = atoms[atom];
607 XSendEvent(dd, root_win, False, SubstructureNotifyMask
608 |SubstructureRedirectMask, (XEvent *)&xev);
611 static void set_icon_geometry(task *tk)
615 coords[0] = tb.x + tk->pos_x;
617 coords[2] = MAX(tk->width, 1);
618 coords[3] = WINHEIGHT;
620 XChangeProperty(dd, tk->win,
621 atoms[_NET_WM_ICON_GEOMETRY], XA_CARDINAL,
622 32, PropModeReplace, (unsigned char*) &coords, 4);
628 static void switch_desk(int new_desk, Time time)
630 if (get_number_of_desktops() <= new_desk)
633 netwm_action(None, _NET_CURRENT_DESKTOP, time, new_desk);
636 /* This doesn't work with obrender yet */
637 static void pager_draw_button(int x, int num)
644 if (num == tb.my_desktop) {
645 /* current desktop */
646 draw_box(x, PAGER_BUTTON_WIDTH);
649 fill_rect(x, 1, PAGER_BUTTON_WIDTH + 1, WINHEIGHT - 2);
655 col.color.alpha = 0xffff;
656 col.color.red = cols[5].red;
657 col.color.green = cols[5].green;
658 col.color.blue = cols[5].blue;
659 XftDrawString8(xftdraw, &col, xfs,
660 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2), text_y,
664 XDrawString(dd, tb.win, fore_gc,
665 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2) - 1,
670 static void pager_draw(void)
672 int desks, i, x = GRILL_WIDTH;
674 desks = get_number_of_desktops();
676 for (i = 0; i < desks; i++) {
677 pager_draw_button(x, i);
680 x += PAGER_BUTTON_WIDTH;
688 static inline int dont_show_task(task *tk)
690 return !tk->focused && tk->hidden;
693 static void gui_draw_taskbar(void)
702 pager_size = TEXTPAD;
706 width = WINWIDTH - (pager_size + GRILL_WIDTH);
707 #warning only rerender if width changed!
708 if (bgpixmap) XFreePixmap(dd, bgpixmap);
709 bgpixmap = XCreatePixmap(dd, root_win, WINWIDTH, WINHEIGHT, RrDepth(inst));
711 XFreePixmap(dd, RrPaintPixmap(background, WINWIDTH, WINHEIGHT));
712 XCopyArea(dd, background->pixmap, bgpixmap, fore_gc, 0, 0, WINWIDTH, WINHEIGHT, 0, 0);
714 /* find the number of visible tasks */
715 for (tk = tb.task_list; tk; tk = tk->next) {
716 if (dont_show_task(tk))
724 taskw = width / num_tasks;
725 if (taskw > MAX_TASK_WIDTH)
726 taskw = MAX_TASK_WIDTH;
728 for (tk = tb.task_list; tk; tk = tk->next) {
729 if (dont_show_task(tk))
732 tk->width = taskw - 1;
733 gui_draw_task(tk, FALSE);
734 set_icon_geometry(tk);
739 XSetWindowBackgroundPixmap(dd, tb.win, bgpixmap);
740 XClearWindow(dd, tb.win);
743 static task *find_task(Window win)
745 task *list = tb.task_list;
747 if (list->win == win)
754 static void del_task(Window win)
756 task *next, *prev = 0, *list = tb.task_list;
760 if (list->win == win) {
761 /* unlink and free this task */
777 static void move_taskbar(void)
782 tb.x = TEXTPAD - WINWIDTH;
785 tb.y = scr_height - WINHEIGHT;
787 XMoveWindow(dd, tb.win, tb.x, tb.y);
790 static void taskbar_read_clientlist(void)
792 Window *win, focus_win = 0;
793 int num, i, desk, new_desk = 0;
795 desk = get_current_desktop();
803 XResizeWindow(dd, rspanelwin, WINWIDTH, WINHEIGHT);
806 if (desk != tb.my_desktop) {
808 tb.my_desktop = desk;
811 win = get_prop_data(root_win, atoms[_NET_ACTIVE_WINDOW], XA_WINDOW, &num);
812 if (win && num > 0) {
817 win = get_prop_data(root_win, atoms[_NET_CLIENT_LIST], XA_WINDOW, &num);
821 /* remove windows that arn't in the _NET_CLIENT_LIST anymore */
824 list->focused = (focus_win == list->win);
828 for (i = num - 1; i >= 0; i--)
829 if (list->win == win[i])
837 /* add any new windows */
838 for (i = 0; i < num; i++) {
839 if (!find_task(win[i]))
840 add_task(win[i], (win[i] == focus_win));
846 static void handle_press(int x, int y, int button, Time time)
851 if ((y > 2 && y < WINHEIGHT - 2 && x > GRILL_WIDTH) && button == 1)
852 switch_desk((x - GRILL_WIDTH) / PAGER_BUTTON_WIDTH, time);
855 /* clicked left grill */
858 tb.at_top = 1 - tb.at_top;
860 } else if (button == 4) {
866 /* clicked right grill */
867 else if (x + TEXTPAD > WINWIDTH) {
868 if (tb.hidden && (button == 1 || button == 5)) {
871 } else if (!tb.hidden && (button == 1 || button == 4)) {
878 /* clicked on a task button */
879 /* XXX Make this configureable */
880 if (!dont_show_task(tk)
881 && (x > tk->pos_x && x < tk->pos_x + tk->width))
885 netwm_action(tk->win, _NET_ACTIVE_WINDOW, time, 0);
889 netwm_action(tk->win, _NET_WM_STATE_HIDDEN, time, REMOVE);
891 netwm_action(tk->win, _NET_WM_STATE_HIDDEN, time, ADD);
894 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Opposite);
897 if (is_shaded(tk->win))
898 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Below);
900 netwm_action(tk->win, _NET_WM_STATE_SHADED, time, ADD);
903 if (is_shaded(tk->win))
904 netwm_action(tk->win, _NET_WM_STATE_SHADED, time, REMOVE);
906 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Above);
910 netwm_action(tk->win, _NET_WM_STATE_HIDDEN, time, REMOVE);
912 netwm_action(tk->win, _OB_FOCUS, 0, 0);
915 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Below);
918 netwm_action(tk->win, _NET_RESTACK_WINDOW, time, Above);
924 } /* clicked on the background */
927 netwm_action(tb.win, _NET_RESTACK_WINDOW, time, Above);
930 netwm_action(tb.win, _NET_RESTACK_WINDOW, time, Below);
933 netwm_action(tb.win, _NET_RESTACK_WINDOW, time, Opposite);
948 static void handle_focusin(Window win)
955 if (tk->win != win) {
960 if (tk->win == win) {
970 static Bool look_for_duplicate_property(Display *d, XEvent *e, XPointer arg)
972 Atom at = *(Atom*)arg;
973 return (e->type == PropertyNotify && e->xproperty.atom == at);
976 static void handle_propertynotify(Window win, Atom at)
980 if (win == root_win) {
981 /* XXX only redraw the task that got focused/unfocused
982 * when _NET_ACTIVE_WINDOW triggers this,
983 * redraw everything if that task was hidden before though */
984 if (at == atoms[_NET_CLIENT_LIST] || at == atoms[_NET_CURRENT_DESKTOP]
985 || at == atoms[_NET_ACTIVE_WINDOW])
990 check = atoms[_NET_CLIENT_LIST];
991 while (XCheckIfEvent(dd, &ce, look_for_duplicate_property, (XPointer)&check));
992 check = atoms[_NET_CURRENT_DESKTOP];
993 while (XCheckIfEvent(dd, &ce, look_for_duplicate_property, (XPointer)&check));
994 check = atoms[_NET_ACTIVE_WINDOW];
995 while (XCheckIfEvent(dd, &ce, look_for_duplicate_property, (XPointer)&check));
997 taskbar_read_clientlist();
1003 /* XXX make this work when SKIP_TASKBAR is toggled too */
1004 /* show skip_taskbar tasks if they're focused */
1005 tk = find_task(win);
1009 if (at == XA_WM_NAME || at == atoms[_NET_WM_NAME]) {
1010 /* window's title changed */
1011 /* XXX make a function for this and use from here and add_task */
1013 newname = get_prop_data(tk->win, atoms[_NET_WM_NAME], atoms[STRING_UTF8], 0) ?:
1014 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
1016 /* It didn't change */
1017 if (tk->name && !strcmp(newname, tk->name)) {
1025 gui_draw_task(tk, TRUE);
1026 } else if (at == atoms[_NET_WM_ICON]) {
1027 task_update_icon(tk);
1028 gui_draw_task(tk, TRUE);
1029 } else if (at == atoms[_NET_WM_STATE]) {
1030 /* iconified state changed? */
1031 if (is_iconified(tk->win) != tk->iconified) {
1032 tk->iconified = !tk->iconified;
1034 gui_draw_task(tk, TRUE);
1036 /* shaded state changed? */
1037 if (is_shaded(tk->win) != tk->shaded) {
1038 tk->shaded = !tk->shaded;
1039 gui_draw_task(tk, TRUE);
1041 if (is_hidden(tk->win) != tk->hidden) {
1042 tk->hidden = !tk->hidden;
1045 } else if (at == atoms[_NET_WM_DESKTOP]) {
1046 if (find_desktop(win) != get_current_desktop())
1051 static void handle_error(Display * d, XErrorEvent * ev)
1059 main(int argc, char *argv[])
1066 dd = XOpenDisplay(NULL);
1069 scr_screen = DefaultScreen(dd);
1070 scr_depth = DefaultDepth(dd, scr_screen);
1071 scr_height = DisplayHeight(dd, scr_screen);
1072 scr_width = DisplayWidth(dd, scr_screen);
1073 root_win = RootWindow(dd, scr_screen);
1075 /* helps us catch windows closing/opening */
1076 XSelectInput(dd, root_win, PropertyChangeMask);
1078 XSetErrorHandler((XErrorHandler) handle_error);
1080 XInternAtoms(dd, atom_names, ATOM_COUNT, False, atoms);
1083 memset(&tb, 0, sizeof(tb));
1084 tb.win = gui_create_taskbar();
1085 xfd = ConnectionNumber(dd);
1087 taskbar_read_clientlist();
1093 select(xfd + 1, &fd, 0, 0, 0);
1095 while (XPending(dd)) {
1096 XNextEvent(dd, &ev);
1099 handle_press(ev.xbutton.x, ev.xbutton.y, ev.xbutton.button, ev.xbutton.time);
1101 case PropertyNotify:
1102 handle_propertynotify(ev.xproperty.window, ev.xproperty.atom);
1105 printf ("unknown evt type: %d\n", ev.type); */
1109 /* RrInstanceFree(inst);
1110 * XCloseDisplay (dd);