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>
25 /* you can edit these */
26 #define MAX_TASK_WIDTH 500
31 # define WINWIDTH 1280
35 #define FONT_NAME "-*-Technical*-m*-r-*-*-14-*-*"
36 #define XFT_FONT "Arial Unicode MS-12"
37 #define PANGO_FONT_PREF "Utopia"
38 //#define PANGO_FONT_PREF "Technical"
39 #define PANGO_FONT_SIZE 13
40 //#define PAGER /* use a desktop pager? */
41 #define PAGER_DIGIT_WIDTH 6
42 #define PAGER_BUTTON_WIDTH 20
44 /* don't edit these */
46 #define GRILL_WIDTH 10
51 #include <pango/pango.h>
52 #include <pango/pangoxft.h>
55 #include <X11/Xft/Xft.h>
86 unsigned short red, green, blue;
88 {0xd75c, 0xd75c, 0xe75c}, /* 0. light gray */
89 {0xbefb, 0xbaea, 0xcefb}, /* 1. mid gray */
90 {0xaefb, 0xaaea, 0xfefb}, /* 2. dark gray */
91 {0xefbe, 0xefbe, 0xffbe}, /* 3. white */
92 {0x8617, 0x8207, 0x9617}, /* 4. darkest gray */
93 {0x0000, 0x0000, 0x1000}, /* 5. black */
96 #define PALETTE_COUNT (sizeof (cols) / sizeof (cols[0].red) / 3)
98 unsigned long palette[PALETTE_COUNT];
100 char *atom_names[] = {
106 "_NET_WM_STATE_SKIP_TASKBAR",
107 "_NET_WM_STATE_SHADED",
108 "_NET_WM_STATE_BELOW",
109 "_NET_WM_STATE_HIDDEN",
111 "_NET_WM_WINDOW_TYPE",
112 "_NET_WM_WINDOW_TYPE_DOCK",
117 "_NET_CLIENT_LIST_STACKING",
118 "_NET_NUMBER_OF_DESKTOPS",
119 "_NET_CURRENT_DESKTOP",
125 #define ATOM_COUNT (sizeof (atom_names) / sizeof (atom_names[0]))
127 Atom atoms[ATOM_COUNT];
129 #define atom_KWM_WIN_ICON atoms[0]
130 #define atom_WM_STATE atoms[1]
131 #define atom__MOTIF_WM_HINTS atoms[2]
132 #define atom__NET_WM_STATE atoms[3]
133 #define atom__NET_WM_STATE_SKIP_TASKBAR atoms[4]
134 #define atom__NET_WM_STATE_SHADED atoms[5]
135 #define atom__NET_WM_STATE_BELOW atoms[6]
136 #define atom__NET_WM_STATE_HIDDEN atoms[7]
137 #define atom__NET_WM_DESKTOP atoms[8]
138 #define atom__NET_WM_WINDOW_TYPE atoms[9]
139 #define atom__NET_WM_WINDOW_TYPE_DOCK atoms[10]
140 #define atom__NET_WM_STRUT atoms[11]
141 #define atom__WIN_HINTS atoms[12]
142 #define atom__NET_CLIENT_LIST atoms[13]
143 #define atom__NET_CLIENT_LIST_STACKING atoms[14]
144 #define atom__NET_NUMBER_OF_DESKTOPS atoms[15]
145 #define atom__NET_CURRENT_DESKTOP atoms[16]
146 #define atom__OB_WM_ACTION atoms[17]
147 #define atom__NET_WM_NAME atoms[18]
148 #define atom_STRING_UTF8 atoms[19]
151 void *get_prop_data(Window win, Atom prop, Atom type, int *items)
155 unsigned long items_ret;
156 unsigned long after_ret;
157 unsigned char *prop_data;
161 XGetWindowProperty(dd, win, prop, 0, 0x7fffffff, False, type, &type_ret,
162 &format_ret, &items_ret, &after_ret, &prop_data);
169 void set_foreground(int index)
171 XSetForeground(dd, fore_gc, palette[index]);
174 void draw_line(int x, int y, int a, int b)
176 XDrawLine(dd, tb.win, fore_gc, x, y, a, b);
179 void fill_rect(int x, int y, int a, int b)
181 XFillRectangle(dd, tb.win, fore_gc, x, y, a, b);
184 void scale_icon(task * tk)
187 unsigned int w, h, d, bw;
188 Pixmap pix, mk = None;
192 XGetGeometry(dd, tk->icon, &pix, &x, &y, &w, &h, &bw, &d);
193 pix = XCreatePixmap(dd, tk->win, ICONWIDTH, ICONHEIGHT, scr_depth);
195 if (tk->mask != None) {
196 mk = XCreatePixmap(dd, tk->win, ICONWIDTH, ICONHEIGHT, 1);
197 gcv.subwindow_mode = IncludeInferiors;
198 gcv.graphics_exposures = False;
199 mgc = XCreateGC(dd, mk, GCGraphicsExposures | GCSubwindowMode, &gcv);
204 /* this is my simple & dirty scaling routine */
205 for (y = ICONHEIGHT - 1; y >= 0; y--) {
206 yy = (y * h) / ICONHEIGHT;
207 for (x = ICONWIDTH - 1; x >= 0; x--) {
208 xx = (x * w) / ICONWIDTH;
210 XCopyPlane(dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y, 1);
212 XCopyArea(dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y);
214 XCopyArea(dd, tk->mask, mk, mgc, xx, yy, 1, 1, x, y);
226 void get_task_hinticon(task * tk)
230 if (tk->icon != None && tk->icon != generic_icon)
231 if (tk->icon_copied) {
232 XFreePixmap(dd, tk->icon);
233 if (tk->mask != None && tk->mask != generic_mask)
234 XFreePixmap(dd, tk->mask);
240 hin = (XWMHints *)get_prop_data(tk->win, XA_WM_HINTS, XA_WM_HINTS, 0);
242 if ((hin->flags & IconPixmapHint)) {
243 if ((hin->flags & IconMaskHint)) {
244 tk->mask = hin->icon_mask;
247 tk->icon = hin->icon_pixmap;
254 if (tk->icon == None) {
255 tk->icon = generic_icon;
256 if (tk->mask != None)
257 XFreePixmap(dd, tk->mask);
258 tk->mask = generic_mask;
262 void get_task_kdeicon(task * tk)
266 data = get_prop_data(tk->win, atom_KWM_WIN_ICON, atom_KWM_WIN_ICON, 0);
274 int generic_get_int(Window win, Atom at)
279 data = get_prop_data(win, at, XA_CARDINAL, 0);
287 int find_desktop(Window win)
289 return generic_get_int(win, atom__NET_WM_DESKTOP);
292 int is_hidden(Window win)
298 data = get_prop_data(win, atom__NET_WM_STATE, XA_ATOM, &num);
302 if ((data[num]) == atom__NET_WM_STATE_SKIP_TASKBAR)
310 int is_iconified(Window win)
316 data = get_prop_data(win, atom__NET_WM_STATE, XA_ATOM, &num);
320 if ((data[num]) == atom__NET_WM_STATE_HIDDEN)
328 int is_shaded(Window win)
334 data = get_prop_data(win, atom__NET_WM_STATE, XA_ATOM, &num);
338 if ((data[num]) == atom__NET_WM_STATE_SHADED)
346 int get_current_desktop(void)
348 return generic_get_int(root_win, atom__NET_CURRENT_DESKTOP);
351 int get_number_of_desktops(void)
353 return generic_get_int(root_win, atom__NET_NUMBER_OF_DESKTOPS);
356 void add_task(Window win, int focus)
364 /* is this window on a different desktop? */
365 desk = find_desktop(win);
366 if ((desk != 0xffffffff && tb.my_desktop != desk) || is_hidden(win))
369 tk = calloc(1, sizeof(task));
372 tk->name = get_prop_data(tk->win, atom__NET_WM_NAME, atom_STRING_UTF8, 0) ?:
373 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
374 // tk->name = get_prop_data(win, XA_WM_NAME, XA_STRING, 0);
375 //tk->locale = get_prop_data(win, XA_WM_LOCALE_NAME, XA_STRING, 0);
376 tk->iconified = is_iconified(win);
377 tk->shaded = is_shaded(win);
379 get_task_kdeicon(tk);
380 if (tk->icon == None)
381 get_task_hinticon(tk);
383 XSelectInput(dd, win, PropertyChangeMask | FocusChangeMask
384 | StructureNotifyMask);
386 /* now append it to our linked list */
408 void set_prop(Window win, Atom at, Atom type, long val)
410 XChangeProperty(dd, win, at, type, 32,
411 PropModeReplace, (unsigned char *)&val, 1);
414 Window gui_create_taskbar(void)
418 XSizeHints size_hints;
420 XSetWindowAttributes att;
422 att.background_pixel = palette[0];
423 att.event_mask = ButtonPressMask | ExposureMask;
425 win = rspanelwin = XCreateWindow(/* display */ dd,
426 /* parent */ root_win,
428 /* y */ scr_height - WINHEIGHT,
429 /* width */ WINWIDTH,
430 /* height */ WINHEIGHT,
432 /* depth */ CopyFromParent,
433 /* class */ InputOutput,
434 /* visual */ CopyFromParent,
435 /*value mask*/ CWBackPixel | CWEventMask,
438 /* reside on ALL desktops */
439 set_prop(win, atom__NET_WM_DESKTOP, XA_CARDINAL, 0xFFFFFFFF);
440 set_prop(win, atom__NET_WM_WINDOW_TYPE, XA_ATOM,
441 atom__NET_WM_WINDOW_TYPE_DOCK);
442 set_prop(win, atom__NET_WM_STATE, XA_ATOM, atom__NET_WM_STATE_BELOW);
443 /* use old gnome hint since sawfish doesn't support _NET_WM_STRUT */
444 set_prop(win, atom__WIN_HINTS, XA_CARDINAL,
445 WIN_HINTS_SKIP_FOCUS | WIN_HINTS_SKIP_WINLIST |
446 WIN_HINTS_SKIP_TASKBAR | WIN_HINTS_DO_NOT_COVER);
447 XChangeProperty(dd, win, XA_WM_NAME, XA_STRING, 8, PropModeReplace,
448 (unsigned char *)"rspanel", 7);
450 /* borderless motif hint */
451 bzero(&mwm, sizeof(mwm));
452 mwm.flags = MWM_HINTS_DECORATIONS;
453 XChangeProperty(dd, win, atom__MOTIF_WM_HINTS, atom__MOTIF_WM_HINTS, 32,
454 PropModeReplace, (unsigned char *)&mwm,
455 sizeof(MWMHints) / 4);
457 /* make sure the WM obays our window position */
458 size_hints.flags = PPosition;
459 /*XSetWMNormalHints (dd, win, &size_hints); */
460 XChangeProperty(dd, win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32,
461 PropModeReplace, (unsigned char *)&size_hints,
462 sizeof(XSizeHints) / 4);
464 /* make our window unfocusable */
465 wmhints.flags = InputHint;
466 wmhints.input = False;
467 /*XSetWMHints (dd, win, &wmhints); */
468 XChangeProperty(dd, win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace,
469 (unsigned char *)&wmhints, sizeof(XWMHints) / 4);
474 xftdraw = XftDrawCreate(dd, win, DefaultVisual(dd, scr_screen),
475 DefaultColormap(dd, scr_screen));
491 PangoContext *context;
492 PangoFontDescription *pfd;
497 xcl.red = cols[i].red;
498 xcl.green = cols[i].green;
499 xcl.blue = cols[i].blue;
500 XAllocColor(dd, DefaultColormap(dd, scr_screen), &xcl);
501 palette[i] = xcl.pixel;
503 } while (i < PALETTE_COUNT);
507 xfs = XftFontOpenName(dd, scr_screen, XFT_FONT);
509 fontname = FONT_NAME;
511 xfs = XLoadQueryFont(dd, fontname);
516 gcv.graphics_exposures = False;
519 text_y = xfs->ascent + ((WINHEIGHT - (xfs->ascent + xfs->descent)) / 2);
520 fore_gc = XCreateGC(dd, root_win, GCGraphicsExposures, &gcv);
522 text_y = xfs->ascent + ((WINHEIGHT - xfs->ascent) / 2);
524 fore_gc = XCreateGC(dd, root_win, GCFont | GCGraphicsExposures, &gcv);
527 pfd = pango_font_description_new();
528 pango_font_description_set_absolute_size(pfd, PANGO_FONT_SIZE*PANGO_SCALE);
529 pango_font_description_set_family(pfd, PANGO_FONT_PREF);
530 context = pango_xft_get_context(dd, root_win);
531 pango_context_set_font_description(context, pfd);
532 pl = pango_layout_new(context);
534 pango_layout_set_single_paragraph_mode(pl, TRUE);
535 pango_layout_set_ellipsize(pl, PANGO_ELLIPSIZE_END);
537 text_y = (WINHEIGHT*PANGO_SCALE-7*PANGO_SCALE);
538 pango_font_description_free(pfd);
539 g_object_unref(context);
541 fore_gc = XCreateGC(dd, root_win, GCGraphicsExposures, &gcv);
545 XpmCreatePixmapFromData(dd, root_win, icon_xpm, &generic_icon,
546 &generic_mask, NULL);
552 void gui_draw_vline(int x)
555 draw_line(x, 0, x, WINHEIGHT);
557 draw_line(x + 1, 0, x + 1, WINHEIGHT);
560 void draw_box(int x, int width)
562 set_foreground(1); /* mid gray */
563 fill_rect(x + 3, 2, width - 2, WINHEIGHT - 4);
565 set_foreground(3); /* white */
566 draw_line(x + 3, WINHEIGHT - 2, x + width - 1, WINHEIGHT - 2);
567 draw_line(x + width - 1, 1, x + width - 1, WINHEIGHT - 2);
569 set_foreground(4); /* darkest gray */
570 draw_line(x + 3, 1, x + width - 1, 1);
571 draw_line(x + 3, 2, x + 3, WINHEIGHT - 3);
574 void gui_draw_task(task * tk)
577 int taskw = tk->width;
591 set_foreground(0); /* mid gray */
592 fill_rect(x + 2, 0, taskw - 1, WINHEIGHT);
596 int text_x = x + TEXTPAD + TEXTPAD + ICONWIDTH;
597 #define SETCOL(x) col.color.red = cols[x].red;\
598 col.color.green = cols[x].green;\
599 col.color.blue = cols[x].blue;
602 pango_layout_set_width(pl, /*-1);*/(taskw - text_x + x) * PANGO_SCALE);
603 pango_layout_set_text(pl, tk->name, -1);
604 col.color.alpha = 0xffff;
608 pango_xft_render_layout_line(xftdraw, &col, pango_layout_get_line(pl, 0), (text_x+2)*PANGO_SCALE, text_y + 2);
610 } else if (tk->shaded) {
612 pango_xft_render_layout_line(xftdraw, &col, pango_layout_get_line(pl, 0), (text_x-2)*PANGO_SCALE, text_y - 2);
617 pango_xft_render_layout_line(xftdraw, &col, pango_layout_get_line(pl, 0), text_x*PANGO_SCALE, text_y);
621 /* check how many chars can fit */
622 len = strlen(tk->name);
624 XftTextExtentsUtf8(dd, xfs, tk->name, len, &ext);
625 if (ext.width < taskw - (text_x - x) - 2 || len <= 0)
630 col.color.alpha = 0xffff;
633 /* draw task's name dark (iconified) */
635 XftDrawStringUtf8(xftdraw, &col, xfs, text_x, text_y + 1, tk->name,
638 } else if (tk->shaded) {
639 /* draw task's name dark (shaded) */
641 XftDrawStringUtf8(xftdraw, &col, xfs, text_x, text_y - 1, tk->name,
649 /* draw task's name here */
650 XftDrawStringUtf8(xftdraw, &col, xfs, text_x, text_y, tk->name, len);
653 /* check how many chars can fit */
654 len = strlen(tk->name);
656 while (XTextWidth(xfs, tk->name, len) >= taskw - (text_x - x) - 2
661 /* draw task's name dark (iconified) */
663 XDrawString(dd, tb.win, fore_gc, text_x, text_y + 1, tk->name,
666 } else if (tk->shaded) {
667 /* draw task's name dark (shaded) */
669 XDrawString(dd, tb.win, fore_gc, text_x, text_y - 1, tk->name,
676 /* draw task's name here */
677 XDrawString(dd, tb.win, fore_gc, text_x, text_y, tk->name, len);
686 /* draw the task's icon */
687 XSetClipMask(dd, fore_gc, tk->mask);
688 XSetClipOrigin(dd, fore_gc, x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2);
689 XCopyArea(dd, tk->icon, tb.win, fore_gc, 0, 0, ICONWIDTH, ICONHEIGHT,
690 x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2);
691 XSetClipMask(dd, fore_gc, None);
694 void draw_dot(int x, int y)
697 XDrawPoint(dd, tb.win, fore_gc, x, y);
699 XDrawPoint(dd, tb.win, fore_gc, x + 1, y + 1);
702 void draw_grill(int x)
705 while (y < WINHEIGHT - 4) {
712 void ob_action(Window win, char *action)
714 XClientMessageEvent xev;
715 char act_name[14+strlen(action)];
716 sprintf(act_name, "_OB_WM_ACTION_%s", action);
718 xev.type = ClientMessage;
720 xev.message_type = atom__OB_WM_ACTION;
722 /*strncpy(xev.data.b, action, 20);*/
723 xev.data.l[0] = XInternAtom(dd, act_name, False);
724 XSendEvent(dd, root_win, False, SubstructureRedirectMask, (XEvent *)&xev);
729 void switch_desk(int new_desk)
731 XClientMessageEvent xev;
733 if (get_number_of_desktops() <= new_desk)
736 xev.type = ClientMessage;
737 xev.window = root_win;
738 xev.message_type = atom__NET_CURRENT_DESKTOP;
740 xev.data.l[0] = new_desk;
741 XSendEvent(dd, root_win, False, SubstructureRedirectMask, (XEvent *)&xev);
744 void pager_draw_button(int x, int num)
751 if (num == tb.my_desktop) {
752 /* current desktop */
753 draw_box(x, PAGER_BUTTON_WIDTH);
756 fill_rect(x, 1, PAGER_BUTTON_WIDTH + 1, WINHEIGHT - 2);
762 col.color.alpha = 0xffff;
763 col.color.red = cols[5].red;
764 col.color.green = cols[5].green;
765 col.color.blue = cols[5].blue;
766 XftDrawString8(xftdraw, &col, xfs,
767 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2), text_y,
771 XDrawString(dd, tb.win, fore_gc,
772 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2) - 1,
777 void pager_draw(void)
779 int desks, i, x = GRILL_WIDTH;
781 desks = get_number_of_desktops();
783 for (i = 0; i < desks; i++) {
784 pager_draw_button(x, i);
787 x += PAGER_BUTTON_WIDTH;
795 void gui_draw_taskbar(void)
803 pager_size = TEXTPAD;
806 width = WINWIDTH - (pager_size + GRILL_WIDTH + GRILL_WIDTH);
809 if (tb.num_tasks == 0)
812 taskw = width / tb.num_tasks;
813 if (taskw > MAX_TASK_WIDTH)
814 taskw = MAX_TASK_WIDTH;
819 tk->width = taskw - 1;
825 if (x < (width + pager_size + 2)) {
829 fill_rect(x + 2, 0, WINWIDTH, WINHEIGHT);
833 gui_draw_vline(WINWIDTH - 8);
836 draw_grill(WINWIDTH - 6);
839 task *find_task(Window win)
841 task *list = tb.task_list;
843 if (list->win == win)
850 void del_task(Window win)
852 task *next, *prev = 0, *list = tb.task_list;
856 if (list->win == win) {
857 /* unlink and free this task */
859 if (list->icon_copied) {
860 XFreePixmap(dd, list->icon);
861 if (list->mask != None)
862 XFreePixmap(dd, list->mask);
878 void move_taskbar(void)
885 x = TEXTPAD - WINWIDTH;
888 y = scr_height - WINHEIGHT;
890 XMoveWindow(dd, tb.win, x, y);
893 void taskbar_read_clientlist(void)
895 Window *win, focus_win;
896 int num, i, rev, desk, new_desk = 0;
898 desk = get_current_desktop();
905 XResizeWindow(dd, rspanelwin, WINWIDTH, WINHEIGHT);
908 if (desk != tb.my_desktop) {
910 tb.my_desktop = desk;
913 XGetInputFocus(dd, &focus_win, &rev);
915 win = get_prop_data(root_win, atom__NET_CLIENT_LIST, XA_WINDOW, &num);
919 /* remove windows that arn't in the _NET_CLIENT_LIST anymore */
922 //list->focused = (focus_win == list->win);
926 for (i = num - 1; i >= 0; i--)
927 if (list->win == win[i] && !is_hidden(win[i]))
935 /* add any new windows */
936 for (i = 0; i < num; i++) {
937 if (!find_task(win[i]))
938 add_task(win[i], (win[i] == focus_win));
944 void handle_press(int x, int y, int button)
949 if ((y > 2 && y < WINHEIGHT - 2 && x > GRILL_WIDTH) && button == 1)
950 switch_desk((x - GRILL_WIDTH) / PAGER_BUTTON_WIDTH);
953 /* clicked left grill */
956 tb.at_top = 1 - tb.at_top;
958 } else if (button == 4) {
964 /* clicked right grill */
965 else if (x + TEXTPAD > WINWIDTH) {
966 if (tb.hidden && (button == 1 || button == 5)) {
969 } else if (!tb.hidden && (button == 1 || button == 4)) {
976 /* clicked on a task button */
977 if (x > tk->pos_x && x < tk->pos_x + tk->width) {
980 if (tk->iconified && tk->shaded)
981 ob_action(tk->win, "unshade");
982 ob_action(tk->win, "activate");
986 ob_action(tk->win, "deiconify");
988 ob_action(tk->win, "iconify");
991 ob_action(tk->win, "raiselower");
994 ob_action(tk->win, "shadelower");
997 ob_action(tk->win, "unshaderaise");
1001 ob_action(tk->win, "deiconify");
1002 ob_action(tk->win, "focus");
1005 ob_action(tk->win, "lower");
1008 ob_action(tk->win, "raise");
1014 } /* clicked on the background */
1017 ob_action(tb.win, "raise");
1020 ob_action(tb.win, "lower");
1023 ob_action(tb.win, "raiselower");
1037 void handle_focusin(Window win)
1044 if (tk->win != win) {
1049 if (tk->win == win) {
1058 void handle_propertynotify(Window win, Atom at)
1062 if (win == root_win) {
1063 if (at == atom__NET_CLIENT_LIST || at == atom__NET_CURRENT_DESKTOP || at == atom__NET_CLIENT_LIST_STACKING) {
1064 taskbar_read_clientlist();
1070 tk = find_task(win);
1074 if (at == XA_WM_NAME || at == atom__NET_WM_NAME) {
1075 /* window's title changed */
1077 newname = get_prop_data(tk->win, atom__NET_WM_NAME, atom_STRING_UTF8, 0) ?:
1078 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
1080 if (tk->name && !strcmp(newname, tk->name)) {
1089 } else if (at == atom__NET_WM_STATE) {
1090 /* iconified state changed? */
1091 if (is_iconified(tk->win) != tk->iconified) {
1092 tk->iconified = !tk->iconified;
1095 /* shaded state changed? */
1096 if (is_shaded(tk->win) != tk->shaded) {
1097 tk->shaded = !tk->shaded;
1100 } else if (at == XA_WM_HINTS) {
1101 /* some windows set their WM_HINTS icon after mapping */
1102 //if (tk->icon == generic_icon) {
1103 get_task_hinticon(tk);
1106 } else if (at == atom__NET_WM_DESKTOP) {
1107 if (find_desktop(win) != get_current_desktop())
1112 void handle_error(Display * d, XErrorEvent * ev)
1120 main(int argc, char *argv[])
1127 dd = XOpenDisplay(NULL);
1130 scr_screen = DefaultScreen(dd);
1131 scr_depth = DefaultDepth(dd, scr_screen);
1132 scr_height = DisplayHeight(dd, scr_screen);
1133 scr_width = DisplayWidth(dd, scr_screen);
1134 root_win = RootWindow(dd, scr_screen);
1136 /* helps us catch windows closing/opening */
1137 XSelectInput(dd, root_win, PropertyChangeMask);
1139 XSetErrorHandler((XErrorHandler) handle_error);
1141 XInternAtoms(dd, atom_names, ATOM_COUNT, False, atoms);
1144 bzero(&tb, sizeof(struct taskbar));
1145 tb.win = gui_create_taskbar();
1146 xfd = ConnectionNumber(dd);
1152 select(xfd + 1, &fd, 0, 0, 0);
1154 while (XPending(dd)) {
1155 XNextEvent(dd, &ev);
1158 handle_press(ev.xbutton.x, ev.xbutton.y, ev.xbutton.button);
1161 del_task(ev.xdestroywindow.window);
1166 case PropertyNotify:
1167 handle_propertynotify(ev.xproperty.window, ev.xproperty.atom);
1170 handle_focusin(ev.xfocus.window);
1173 printf ("unknown evt type: %d\n", ev.type); */
1178 /*XCloseDisplay (dd);