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",
123 "_NET_ACTIVE_WINDOW",
126 #define ATOM_COUNT (sizeof (atom_names) / sizeof (atom_names[0]))
128 Atom atoms[ATOM_COUNT];
130 #define atom_KWM_WIN_ICON atoms[0]
131 #define atom_WM_STATE atoms[1]
132 #define atom__MOTIF_WM_HINTS atoms[2]
133 #define atom__NET_WM_STATE atoms[3]
134 #define atom__NET_WM_STATE_SKIP_TASKBAR atoms[4]
135 #define atom__NET_WM_STATE_SHADED atoms[5]
136 #define atom__NET_WM_STATE_BELOW atoms[6]
137 #define atom__NET_WM_STATE_HIDDEN atoms[7]
138 #define atom__NET_WM_DESKTOP atoms[8]
139 #define atom__NET_WM_WINDOW_TYPE atoms[9]
140 #define atom__NET_WM_WINDOW_TYPE_DOCK atoms[10]
141 #define atom__NET_WM_STRUT atoms[11]
142 #define atom__WIN_HINTS atoms[12]
143 #define atom__NET_CLIENT_LIST atoms[13]
144 #define atom__NET_CLIENT_LIST_STACKING atoms[14]
145 #define atom__NET_NUMBER_OF_DESKTOPS atoms[15]
146 #define atom__NET_CURRENT_DESKTOP atoms[16]
147 #define atom__OB_WM_ACTION atoms[17]
148 #define atom__NET_WM_NAME atoms[18]
149 #define atom_STRING_UTF8 atoms[19]
150 #define atom__NET_ACTIVE_WINDOW atoms[20]
152 void *get_prop_data(Window win, Atom prop, Atom type, int *items)
156 unsigned long items_ret;
157 unsigned long after_ret;
158 unsigned char *prop_data;
162 XGetWindowProperty(dd, win, prop, 0, 0x7fffffff, False, type, &type_ret,
163 &format_ret, &items_ret, &after_ret, &prop_data);
170 void set_foreground(int index)
172 XSetForeground(dd, fore_gc, palette[index]);
175 void draw_line(int x, int y, int a, int b)
177 XDrawLine(dd, tb.win, fore_gc, x, y, a, b);
180 void fill_rect(int x, int y, int a, int b)
182 XFillRectangle(dd, tb.win, fore_gc, x, y, a, b);
185 void scale_icon(task * tk)
188 unsigned int w, h, d, bw;
189 Pixmap pix, mk = None;
193 XGetGeometry(dd, tk->icon, &pix, &x, &y, &w, &h, &bw, &d);
194 pix = XCreatePixmap(dd, tk->win, ICONWIDTH, ICONHEIGHT, scr_depth);
196 if (tk->mask != None) {
197 mk = XCreatePixmap(dd, tk->win, ICONWIDTH, ICONHEIGHT, 1);
198 gcv.subwindow_mode = IncludeInferiors;
199 gcv.graphics_exposures = False;
200 mgc = XCreateGC(dd, mk, GCGraphicsExposures | GCSubwindowMode, &gcv);
205 /* this is my simple & dirty scaling routine */
206 for (y = ICONHEIGHT - 1; y >= 0; y--) {
207 yy = (y * h) / ICONHEIGHT;
208 for (x = ICONWIDTH - 1; x >= 0; x--) {
209 xx = (x * w) / ICONWIDTH;
211 XCopyPlane(dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y, 1);
213 XCopyArea(dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y);
215 XCopyArea(dd, tk->mask, mk, mgc, xx, yy, 1, 1, x, y);
227 void get_task_hinticon(task * tk)
231 if (tk->icon != None && tk->icon != generic_icon)
232 if (tk->icon_copied) {
233 XFreePixmap(dd, tk->icon);
234 if (tk->mask != None && tk->mask != generic_mask)
235 XFreePixmap(dd, tk->mask);
241 hin = (XWMHints *)get_prop_data(tk->win, XA_WM_HINTS, XA_WM_HINTS, 0);
243 if ((hin->flags & IconPixmapHint)) {
244 if ((hin->flags & IconMaskHint)) {
245 tk->mask = hin->icon_mask;
248 tk->icon = hin->icon_pixmap;
255 if (tk->icon == None) {
256 tk->icon = generic_icon;
257 if (tk->mask != None)
258 XFreePixmap(dd, tk->mask);
259 tk->mask = generic_mask;
263 void get_task_kdeicon(task * tk)
267 data = get_prop_data(tk->win, atom_KWM_WIN_ICON, atom_KWM_WIN_ICON, 0);
275 int generic_get_int(Window win, Atom at)
280 data = get_prop_data(win, at, XA_CARDINAL, 0);
288 int find_desktop(Window win)
290 return generic_get_int(win, atom__NET_WM_DESKTOP);
293 int is_hidden(Window win)
299 data = get_prop_data(win, atom__NET_WM_STATE, XA_ATOM, &num);
303 if ((data[num]) == atom__NET_WM_STATE_SKIP_TASKBAR)
311 int is_iconified(Window win)
317 data = get_prop_data(win, atom__NET_WM_STATE, XA_ATOM, &num);
321 if ((data[num]) == atom__NET_WM_STATE_HIDDEN)
329 int is_shaded(Window win)
335 data = get_prop_data(win, atom__NET_WM_STATE, XA_ATOM, &num);
339 if ((data[num]) == atom__NET_WM_STATE_SHADED)
347 int get_current_desktop(void)
349 return generic_get_int(root_win, atom__NET_CURRENT_DESKTOP);
352 int get_number_of_desktops(void)
354 return generic_get_int(root_win, atom__NET_NUMBER_OF_DESKTOPS);
357 void add_task(Window win, int focus)
365 /* is this window on a different desktop? */
366 desk = find_desktop(win);
367 if ((desk != 0xffffffff && tb.my_desktop != desk) || is_hidden(win))
370 tk = calloc(1, sizeof(task));
373 tk->name = get_prop_data(tk->win, atom__NET_WM_NAME, atom_STRING_UTF8, 0) ?:
374 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
375 // tk->name = get_prop_data(win, XA_WM_NAME, XA_STRING, 0);
376 //tk->locale = get_prop_data(win, XA_WM_LOCALE_NAME, XA_STRING, 0);
377 tk->iconified = is_iconified(win);
378 tk->shaded = is_shaded(win);
380 get_task_kdeicon(tk);
381 if (tk->icon == None)
382 get_task_hinticon(tk);
384 XSelectInput(dd, win, PropertyChangeMask | FocusChangeMask
385 | StructureNotifyMask);
387 /* now append it to our linked list */
409 void set_prop(Window win, Atom at, Atom type, long val)
411 XChangeProperty(dd, win, at, type, 32,
412 PropModeReplace, (unsigned char *)&val, 1);
415 Window gui_create_taskbar(void)
419 XSizeHints size_hints;
421 XSetWindowAttributes att;
423 att.background_pixel = palette[0];
424 att.event_mask = ButtonPressMask | ExposureMask;
426 win = rspanelwin = XCreateWindow(/* display */ dd,
427 /* parent */ root_win,
429 /* y */ scr_height - WINHEIGHT,
430 /* width */ WINWIDTH,
431 /* height */ WINHEIGHT,
433 /* depth */ CopyFromParent,
434 /* class */ InputOutput,
435 /* visual */ CopyFromParent,
436 /*value mask*/ CWBackPixel | CWEventMask,
439 /* reside on ALL desktops */
440 set_prop(win, atom__NET_WM_DESKTOP, XA_CARDINAL, 0xFFFFFFFF);
441 set_prop(win, atom__NET_WM_WINDOW_TYPE, XA_ATOM,
442 atom__NET_WM_WINDOW_TYPE_DOCK);
443 set_prop(win, atom__NET_WM_STATE, XA_ATOM, atom__NET_WM_STATE_BELOW);
444 /* use old gnome hint since sawfish doesn't support _NET_WM_STRUT */
445 set_prop(win, atom__WIN_HINTS, XA_CARDINAL,
446 WIN_HINTS_SKIP_FOCUS | WIN_HINTS_SKIP_WINLIST |
447 WIN_HINTS_SKIP_TASKBAR | WIN_HINTS_DO_NOT_COVER);
448 XChangeProperty(dd, win, XA_WM_NAME, XA_STRING, 8, PropModeReplace,
449 (unsigned char *)"rspanel", 7);
451 /* borderless motif hint */
452 bzero(&mwm, sizeof(mwm));
453 mwm.flags = MWM_HINTS_DECORATIONS;
454 XChangeProperty(dd, win, atom__MOTIF_WM_HINTS, atom__MOTIF_WM_HINTS, 32,
455 PropModeReplace, (unsigned char *)&mwm,
456 sizeof(MWMHints) / 4);
458 /* make sure the WM obays our window position */
459 size_hints.flags = PPosition;
460 /*XSetWMNormalHints (dd, win, &size_hints); */
461 XChangeProperty(dd, win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32,
462 PropModeReplace, (unsigned char *)&size_hints,
463 sizeof(XSizeHints) / 4);
465 /* make our window unfocusable */
466 wmhints.flags = InputHint;
467 wmhints.input = False;
468 /*XSetWMHints (dd, win, &wmhints); */
469 XChangeProperty(dd, win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace,
470 (unsigned char *)&wmhints, sizeof(XWMHints) / 4);
475 xftdraw = XftDrawCreate(dd, win, DefaultVisual(dd, scr_screen),
476 DefaultColormap(dd, scr_screen));
492 PangoContext *context;
493 PangoFontDescription *pfd;
498 xcl.red = cols[i].red;
499 xcl.green = cols[i].green;
500 xcl.blue = cols[i].blue;
501 XAllocColor(dd, DefaultColormap(dd, scr_screen), &xcl);
502 palette[i] = xcl.pixel;
504 } while (i < PALETTE_COUNT);
508 xfs = XftFontOpenName(dd, scr_screen, XFT_FONT);
510 fontname = FONT_NAME;
512 xfs = XLoadQueryFont(dd, fontname);
517 gcv.graphics_exposures = False;
520 text_y = xfs->ascent + ((WINHEIGHT - (xfs->ascent + xfs->descent)) / 2);
521 fore_gc = XCreateGC(dd, root_win, GCGraphicsExposures, &gcv);
523 text_y = xfs->ascent + ((WINHEIGHT - xfs->ascent) / 2);
525 fore_gc = XCreateGC(dd, root_win, GCFont | GCGraphicsExposures, &gcv);
528 pfd = pango_font_description_new();
529 pango_font_description_set_absolute_size(pfd, PANGO_FONT_SIZE*PANGO_SCALE);
530 pango_font_description_set_family(pfd, PANGO_FONT_PREF);
531 context = pango_xft_get_context(dd, root_win);
532 pango_context_set_font_description(context, pfd);
533 pl = pango_layout_new(context);
535 pango_layout_set_single_paragraph_mode(pl, TRUE);
536 pango_layout_set_ellipsize(pl, PANGO_ELLIPSIZE_END);
538 text_y = (WINHEIGHT*PANGO_SCALE-7*PANGO_SCALE);
539 pango_font_description_free(pfd);
540 g_object_unref(context);
542 fore_gc = XCreateGC(dd, root_win, GCGraphicsExposures, &gcv);
546 XpmCreatePixmapFromData(dd, root_win, icon_xpm, &generic_icon,
547 &generic_mask, NULL);
553 void gui_draw_vline(int x)
556 draw_line(x, 0, x, WINHEIGHT);
558 draw_line(x + 1, 0, x + 1, WINHEIGHT);
561 void draw_box(int x, int width)
563 set_foreground(1); /* mid gray */
564 fill_rect(x + 3, 2, width - 2, WINHEIGHT - 4);
566 set_foreground(3); /* white */
567 draw_line(x + 3, WINHEIGHT - 2, x + width - 1, WINHEIGHT - 2);
568 draw_line(x + width - 1, 1, x + width - 1, WINHEIGHT - 2);
570 set_foreground(4); /* darkest gray */
571 draw_line(x + 3, 1, x + width - 1, 1);
572 draw_line(x + 3, 2, x + 3, WINHEIGHT - 3);
575 void gui_draw_task(task * tk)
578 int taskw = tk->width;
592 set_foreground(0); /* mid gray */
593 fill_rect(x + 2, 0, taskw - 1, WINHEIGHT);
597 int text_x = x + TEXTPAD + TEXTPAD + ICONWIDTH;
598 #define SETCOL(x) col.color.red = cols[x].red;\
599 col.color.green = cols[x].green;\
600 col.color.blue = cols[x].blue;
603 pango_layout_set_width(pl, /*-1);*/(taskw - text_x + x) * PANGO_SCALE);
604 pango_layout_set_text(pl, tk->name, -1);
605 col.color.alpha = 0xffff;
609 pango_xft_render_layout_line(xftdraw, &col, pango_layout_get_line(pl, 0), (text_x+2)*PANGO_SCALE, text_y + 2);
611 } else if (tk->shaded) {
613 pango_xft_render_layout_line(xftdraw, &col, pango_layout_get_line(pl, 0), (text_x-2)*PANGO_SCALE, text_y - 2);
618 pango_xft_render_layout_line(xftdraw, &col, pango_layout_get_line(pl, 0), text_x*PANGO_SCALE, text_y);
622 /* check how many chars can fit */
623 len = strlen(tk->name);
625 XftTextExtentsUtf8(dd, xfs, tk->name, len, &ext);
626 if (ext.width < taskw - (text_x - x) - 2 || len <= 0)
631 col.color.alpha = 0xffff;
634 /* draw task's name dark (iconified) */
636 XftDrawStringUtf8(xftdraw, &col, xfs, text_x, text_y + 1, tk->name,
639 } else if (tk->shaded) {
640 /* draw task's name dark (shaded) */
642 XftDrawStringUtf8(xftdraw, &col, xfs, text_x, text_y - 1, tk->name,
650 /* draw task's name here */
651 XftDrawStringUtf8(xftdraw, &col, xfs, text_x, text_y, tk->name, len);
654 /* check how many chars can fit */
655 len = strlen(tk->name);
657 while (XTextWidth(xfs, tk->name, len) >= taskw - (text_x - x) - 2
662 /* draw task's name dark (iconified) */
664 XDrawString(dd, tb.win, fore_gc, text_x, text_y + 1, tk->name,
667 } else if (tk->shaded) {
668 /* draw task's name dark (shaded) */
670 XDrawString(dd, tb.win, fore_gc, text_x, text_y - 1, tk->name,
677 /* draw task's name here */
678 XDrawString(dd, tb.win, fore_gc, text_x, text_y, tk->name, len);
687 /* draw the task's icon */
688 XSetClipMask(dd, fore_gc, tk->mask);
689 XSetClipOrigin(dd, fore_gc, x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2);
690 XCopyArea(dd, tk->icon, tb.win, fore_gc, 0, 0, ICONWIDTH, ICONHEIGHT,
691 x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2);
692 XSetClipMask(dd, fore_gc, None);
695 void draw_dot(int x, int y)
698 XDrawPoint(dd, tb.win, fore_gc, x, y);
700 XDrawPoint(dd, tb.win, fore_gc, x + 1, y + 1);
703 void draw_grill(int x)
706 while (y < WINHEIGHT - 4) {
713 void ob_action(Window win, char *action)
715 XClientMessageEvent xev;
716 char act_name[14+strlen(action)];
717 sprintf(act_name, "_OB_WM_ACTION_%s", action);
719 xev.type = ClientMessage;
721 xev.message_type = atom__OB_WM_ACTION;
723 /*strncpy(xev.data.b, action, 20);*/
724 xev.data.l[0] = XInternAtom(dd, act_name, False);
725 XSendEvent(dd, root_win, False, SubstructureRedirectMask, (XEvent *)&xev);
730 void switch_desk(int new_desk)
732 XClientMessageEvent xev;
734 if (get_number_of_desktops() <= new_desk)
737 xev.type = ClientMessage;
738 xev.window = root_win;
739 xev.message_type = atom__NET_CURRENT_DESKTOP;
741 xev.data.l[0] = new_desk;
742 XSendEvent(dd, root_win, False, SubstructureRedirectMask, (XEvent *)&xev);
745 void pager_draw_button(int x, int num)
752 if (num == tb.my_desktop) {
753 /* current desktop */
754 draw_box(x, PAGER_BUTTON_WIDTH);
757 fill_rect(x, 1, PAGER_BUTTON_WIDTH + 1, WINHEIGHT - 2);
763 col.color.alpha = 0xffff;
764 col.color.red = cols[5].red;
765 col.color.green = cols[5].green;
766 col.color.blue = cols[5].blue;
767 XftDrawString8(xftdraw, &col, xfs,
768 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2), text_y,
772 XDrawString(dd, tb.win, fore_gc,
773 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2) - 1,
778 void pager_draw(void)
780 int desks, i, x = GRILL_WIDTH;
782 desks = get_number_of_desktops();
784 for (i = 0; i < desks; i++) {
785 pager_draw_button(x, i);
788 x += PAGER_BUTTON_WIDTH;
796 void gui_draw_taskbar(void)
804 pager_size = TEXTPAD;
807 width = WINWIDTH - (pager_size + GRILL_WIDTH + GRILL_WIDTH);
810 if (tb.num_tasks == 0)
813 taskw = width / tb.num_tasks;
814 if (taskw > MAX_TASK_WIDTH)
815 taskw = MAX_TASK_WIDTH;
820 tk->width = taskw - 1;
826 if (x < (width + pager_size + 2)) {
830 fill_rect(x + 2, 0, WINWIDTH, WINHEIGHT);
834 gui_draw_vline(WINWIDTH - 8);
837 draw_grill(WINWIDTH - 6);
840 task *find_task(Window win)
842 task *list = tb.task_list;
844 if (list->win == win)
851 void del_task(Window win)
853 task *next, *prev = 0, *list = tb.task_list;
857 if (list->win == win) {
858 /* unlink and free this task */
860 if (list->icon_copied) {
861 XFreePixmap(dd, list->icon);
862 if (list->mask != None)
863 XFreePixmap(dd, list->mask);
879 void move_taskbar(void)
886 x = TEXTPAD - WINWIDTH;
889 y = scr_height - WINHEIGHT;
891 XMoveWindow(dd, tb.win, x, y);
894 void taskbar_read_clientlist(void)
896 Window *win, focus_win = 0;
897 int num, i, desk, new_desk = 0;
899 desk = get_current_desktop();
906 XResizeWindow(dd, rspanelwin, WINWIDTH, WINHEIGHT);
909 if (desk != tb.my_desktop) {
911 tb.my_desktop = desk;
914 win = get_prop_data(root_win, atom__NET_ACTIVE_WINDOW, XA_WINDOW, &num);
918 win = get_prop_data(root_win, atom__NET_CLIENT_LIST, XA_WINDOW, &num);
922 /* remove windows that arn't in the _NET_CLIENT_LIST anymore */
925 list->focused = (focus_win == list->win);
929 for (i = num - 1; i >= 0; i--)
930 if (list->win == win[i] && !is_hidden(win[i]))
938 /* add any new windows */
939 for (i = 0; i < num; i++) {
940 if (!find_task(win[i]))
941 add_task(win[i], (win[i] == focus_win));
947 void handle_press(int x, int y, int button)
952 if ((y > 2 && y < WINHEIGHT - 2 && x > GRILL_WIDTH) && button == 1)
953 switch_desk((x - GRILL_WIDTH) / PAGER_BUTTON_WIDTH);
956 /* clicked left grill */
959 tb.at_top = 1 - tb.at_top;
961 } else if (button == 4) {
967 /* clicked right grill */
968 else if (x + TEXTPAD > WINWIDTH) {
969 if (tb.hidden && (button == 1 || button == 5)) {
972 } else if (!tb.hidden && (button == 1 || button == 4)) {
979 /* clicked on a task button */
980 if (x > tk->pos_x && x < tk->pos_x + tk->width) {
983 if (tk->iconified && tk->shaded)
984 ob_action(tk->win, "unshade");
985 ob_action(tk->win, "activate");
989 ob_action(tk->win, "deiconify");
991 ob_action(tk->win, "iconify");
994 ob_action(tk->win, "raiselower");
997 ob_action(tk->win, "shadelower");
1000 ob_action(tk->win, "unshaderaise");
1004 ob_action(tk->win, "deiconify");
1005 ob_action(tk->win, "focus");
1008 ob_action(tk->win, "lower");
1011 ob_action(tk->win, "raise");
1017 } /* clicked on the background */
1020 ob_action(tb.win, "raise");
1023 ob_action(tb.win, "lower");
1026 ob_action(tb.win, "raiselower");
1040 void handle_focusin(Window win)
1047 if (tk->win != win) {
1052 if (tk->win == win) {
1061 void handle_propertynotify(Window win, Atom at)
1065 if (win == root_win) {
1066 if (at == atom__NET_CLIENT_LIST || at == atom__NET_CURRENT_DESKTOP || at == atom__NET_CLIENT_LIST_STACKING) {
1067 taskbar_read_clientlist();
1073 tk = find_task(win);
1077 if (at == XA_WM_NAME || at == atom__NET_WM_NAME) {
1078 /* window's title changed */
1080 newname = get_prop_data(tk->win, atom__NET_WM_NAME, atom_STRING_UTF8, 0) ?:
1081 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
1083 if (tk->name && !strcmp(newname, tk->name)) {
1092 } else if (at == atom__NET_WM_STATE) {
1093 /* iconified state changed? */
1094 if (is_iconified(tk->win) != tk->iconified) {
1095 tk->iconified = !tk->iconified;
1098 /* shaded state changed? */
1099 if (is_shaded(tk->win) != tk->shaded) {
1100 tk->shaded = !tk->shaded;
1103 } else if (at == XA_WM_HINTS) {
1104 /* some windows set their WM_HINTS icon after mapping */
1105 //if (tk->icon == generic_icon) {
1106 get_task_hinticon(tk);
1109 } else if (at == atom__NET_WM_DESKTOP) {
1110 if (find_desktop(win) != get_current_desktop())
1115 void handle_error(Display * d, XErrorEvent * ev)
1123 main(int argc, char *argv[])
1130 dd = XOpenDisplay(NULL);
1133 scr_screen = DefaultScreen(dd);
1134 scr_depth = DefaultDepth(dd, scr_screen);
1135 scr_height = DisplayHeight(dd, scr_screen);
1136 scr_width = DisplayWidth(dd, scr_screen);
1137 root_win = RootWindow(dd, scr_screen);
1139 /* helps us catch windows closing/opening */
1140 XSelectInput(dd, root_win, PropertyChangeMask);
1142 XSetErrorHandler((XErrorHandler) handle_error);
1144 XInternAtoms(dd, atom_names, ATOM_COUNT, False, atoms);
1147 bzero(&tb, sizeof(struct taskbar));
1148 tb.win = gui_create_taskbar();
1149 xfd = ConnectionNumber(dd);
1155 select(xfd + 1, &fd, 0, 0, 0);
1157 while (XPending(dd)) {
1158 XNextEvent(dd, &ev);
1161 handle_press(ev.xbutton.x, ev.xbutton.y, ev.xbutton.button);
1164 del_task(ev.xdestroywindow.window);
1169 case PropertyNotify:
1170 handle_propertynotify(ev.xproperty.window, ev.xproperty.atom);
1173 handle_focusin(ev.xfocus.window);
1176 printf ("unknown evt type: %d\n", ev.type); */
1181 /*XCloseDisplay (dd);