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>
26 /* you can edit these */
27 #define MAX_TASK_WIDTH 500
32 # define WINWIDTH 1280
36 #define FONT_NAME "-*-Technical*-m*-r-*-*-14-*-*"
37 #define XFT_FONT "Arial Unicode MS-12"
38 #define PANGO_FONT_PREF "Utopia"
39 //#define PANGO_FONT_PREF "Technical"
40 #define PANGO_FONT_SIZE 13
41 //#define PAGER /* use a desktop pager? */
42 #define PAGER_DIGIT_WIDTH 6
43 #define PAGER_BUTTON_WIDTH 20
45 /* don't edit these */
47 #define GRILL_WIDTH 10
52 #include <pango/pango.h>
53 #include <pango/pangoxft.h>
56 #include <X11/Xft/Xft.h>
87 unsigned short red, green, blue;
89 {0xd75c, 0xd75c, 0xe75c}, /* 0. light gray */
90 {0xbefb, 0xbaea, 0xcefb}, /* 1. mid gray */
91 {0xaefb, 0xaaea, 0xfefb}, /* 2. dark gray */
92 {0xefbe, 0xefbe, 0xffbe}, /* 3. white */
93 {0x8617, 0x8207, 0x9617}, /* 4. darkest gray */
94 {0x0000, 0x0000, 0x1000}, /* 5. black */
97 #define PALETTE_COUNT (sizeof (cols) / sizeof (cols[0].red) / 3)
99 unsigned long palette[PALETTE_COUNT];
101 char *atom_names[] = {
107 "_NET_WM_STATE_SKIP_TASKBAR",
108 "_NET_WM_STATE_SHADED",
109 "_NET_WM_STATE_BELOW",
110 "_NET_WM_STATE_HIDDEN",
112 "_NET_WM_WINDOW_TYPE",
113 "_NET_WM_WINDOW_TYPE_DOCK",
118 "_NET_CLIENT_LIST_STACKING",
119 "_NET_NUMBER_OF_DESKTOPS",
120 "_NET_CURRENT_DESKTOP",
124 "_NET_ACTIVE_WINDOW",
127 #define ATOM_COUNT (sizeof (atom_names) / sizeof (atom_names[0]))
129 Atom atoms[ATOM_COUNT];
131 #define atom_KWM_WIN_ICON atoms[0]
132 #define atom_WM_STATE atoms[1]
133 #define atom__MOTIF_WM_HINTS atoms[2]
134 #define atom__NET_WM_STATE atoms[3]
135 #define atom__NET_WM_STATE_SKIP_TASKBAR atoms[4]
136 #define atom__NET_WM_STATE_SHADED atoms[5]
137 #define atom__NET_WM_STATE_BELOW atoms[6]
138 #define atom__NET_WM_STATE_HIDDEN atoms[7]
139 #define atom__NET_WM_DESKTOP atoms[8]
140 #define atom__NET_WM_WINDOW_TYPE atoms[9]
141 #define atom__NET_WM_WINDOW_TYPE_DOCK atoms[10]
142 #define atom__NET_WM_STRUT atoms[11]
143 #define atom__WIN_HINTS atoms[12]
144 #define atom__NET_CLIENT_LIST atoms[13]
145 #define atom__NET_CLIENT_LIST_STACKING atoms[14]
146 #define atom__NET_NUMBER_OF_DESKTOPS atoms[15]
147 #define atom__NET_CURRENT_DESKTOP atoms[16]
148 #define atom__OB_WM_ACTION atoms[17]
149 #define atom__NET_WM_NAME atoms[18]
150 #define atom_STRING_UTF8 atoms[19]
151 #define atom__NET_ACTIVE_WINDOW atoms[20]
153 void *get_prop_data(Window win, Atom prop, Atom type, int *items)
157 unsigned long items_ret;
158 unsigned long after_ret;
159 unsigned char *prop_data;
163 XGetWindowProperty(dd, win, prop, 0, 0x7fffffff, False, type, &type_ret,
164 &format_ret, &items_ret, &after_ret, &prop_data);
171 void set_foreground(int index)
173 XSetForeground(dd, fore_gc, palette[index]);
176 void draw_line(int x, int y, int a, int b)
178 XDrawLine(dd, tb.win, fore_gc, x, y, a, b);
181 void fill_rect(int x, int y, int a, int b)
183 XFillRectangle(dd, tb.win, fore_gc, x, y, a, b);
186 void scale_icon(task * tk)
189 unsigned int w, h, d, bw;
190 Pixmap pix, mk = None;
194 XGetGeometry(dd, tk->icon, &pix, &x, &y, &w, &h, &bw, &d);
195 pix = XCreatePixmap(dd, tk->win, ICONWIDTH, ICONHEIGHT, scr_depth);
197 if (tk->mask != None) {
198 mk = XCreatePixmap(dd, tk->win, ICONWIDTH, ICONHEIGHT, 1);
199 gcv.subwindow_mode = IncludeInferiors;
200 gcv.graphics_exposures = False;
201 mgc = XCreateGC(dd, mk, GCGraphicsExposures | GCSubwindowMode, &gcv);
206 /* this is my simple & dirty scaling routine */
207 for (y = ICONHEIGHT - 1; y >= 0; y--) {
208 yy = (y * h) / ICONHEIGHT;
209 for (x = ICONWIDTH - 1; x >= 0; x--) {
210 xx = (x * w) / ICONWIDTH;
212 XCopyPlane(dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y, 1);
214 XCopyArea(dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y);
216 XCopyArea(dd, tk->mask, mk, mgc, xx, yy, 1, 1, x, y);
228 void get_task_hinticon(task * tk)
232 if (tk->icon != None && tk->icon != generic_icon)
233 if (tk->icon_copied) {
234 XFreePixmap(dd, tk->icon);
235 if (tk->mask != None && tk->mask != generic_mask)
236 XFreePixmap(dd, tk->mask);
242 hin = (XWMHints *)get_prop_data(tk->win, XA_WM_HINTS, XA_WM_HINTS, 0);
244 if ((hin->flags & IconPixmapHint)) {
245 if ((hin->flags & IconMaskHint)) {
246 tk->mask = hin->icon_mask;
249 tk->icon = hin->icon_pixmap;
256 if (tk->icon == None) {
257 tk->icon = generic_icon;
258 if (tk->mask != None)
259 XFreePixmap(dd, tk->mask);
260 tk->mask = generic_mask;
264 void get_task_kdeicon(task * tk)
268 data = get_prop_data(tk->win, atom_KWM_WIN_ICON, atom_KWM_WIN_ICON, 0);
276 int generic_get_int(Window win, Atom at)
281 data = get_prop_data(win, at, XA_CARDINAL, 0);
289 int find_desktop(Window win)
291 return generic_get_int(win, atom__NET_WM_DESKTOP);
294 int is_hidden(Window win)
300 data = get_prop_data(win, atom__NET_WM_STATE, XA_ATOM, &num);
304 if ((data[num]) == atom__NET_WM_STATE_SKIP_TASKBAR)
312 int is_iconified(Window win)
318 data = get_prop_data(win, atom__NET_WM_STATE, XA_ATOM, &num);
322 if ((data[num]) == atom__NET_WM_STATE_HIDDEN)
330 int is_shaded(Window win)
336 data = get_prop_data(win, atom__NET_WM_STATE, XA_ATOM, &num);
340 if ((data[num]) == atom__NET_WM_STATE_SHADED)
348 int get_current_desktop(void)
350 return generic_get_int(root_win, atom__NET_CURRENT_DESKTOP);
353 int get_number_of_desktops(void)
355 return generic_get_int(root_win, atom__NET_NUMBER_OF_DESKTOPS);
358 void add_task(Window win, int focus)
366 /* is this window on a different desktop? */
367 desk = find_desktop(win);
368 if ((desk != 0xffffffff && tb.my_desktop != desk) || is_hidden(win))
371 tk = calloc(1, sizeof(task));
374 tk->name = get_prop_data(tk->win, atom__NET_WM_NAME, atom_STRING_UTF8, 0) ?:
375 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
376 // tk->name = get_prop_data(win, XA_WM_NAME, XA_STRING, 0);
377 //tk->locale = get_prop_data(win, XA_WM_LOCALE_NAME, XA_STRING, 0);
378 tk->iconified = is_iconified(win);
379 tk->shaded = is_shaded(win);
381 get_task_kdeicon(tk);
382 if (tk->icon == None)
383 get_task_hinticon(tk);
385 XSelectInput(dd, win, PropertyChangeMask | FocusChangeMask
386 | StructureNotifyMask);
388 /* now append it to our linked list */
410 void set_prop(Window win, Atom at, Atom type, long val)
412 XChangeProperty(dd, win, at, type, 32,
413 PropModeReplace, (unsigned char *)&val, 1);
416 Window gui_create_taskbar(void)
420 XSizeHints size_hints;
422 XSetWindowAttributes att;
425 att.background_pixel = palette[0];
426 att.event_mask = ButtonPressMask | ExposureMask;
428 win = rspanelwin = XCreateWindow(/* display */ dd,
429 /* parent */ root_win,
431 /* y */ scr_height - WINHEIGHT,
432 /* width */ WINWIDTH,
433 /* height */ WINHEIGHT,
435 /* depth */ CopyFromParent,
436 /* class */ InputOutput,
437 /* visual */ CopyFromParent,
438 /*value mask*/ CWBackPixel | CWEventMask,
441 /* reside on ALL desktops */
442 set_prop(win, atom__NET_WM_DESKTOP, XA_CARDINAL, 0xFFFFFFFF);
443 set_prop(win, atom__NET_WM_WINDOW_TYPE, XA_ATOM,
444 atom__NET_WM_WINDOW_TYPE_DOCK);
445 set_prop(win, atom__NET_WM_STATE, XA_ATOM, atom__NET_WM_STATE_BELOW);
446 /* use old gnome hint since sawfish doesn't support _NET_WM_STRUT */
447 set_prop(win, atom__WIN_HINTS, XA_CARDINAL,
448 WIN_HINTS_SKIP_FOCUS | WIN_HINTS_SKIP_WINLIST |
449 WIN_HINTS_SKIP_TASKBAR | WIN_HINTS_DO_NOT_COVER);
450 XChangeProperty(dd, win, XA_WM_NAME, XA_STRING, 8, PropModeReplace,
451 (unsigned char *)"rspanel", 7);
453 /* borderless motif hint */
454 bzero(&mwm, sizeof(mwm));
455 mwm.flags = MWM_HINTS_DECORATIONS;
456 XChangeProperty(dd, win, atom__MOTIF_WM_HINTS, atom__MOTIF_WM_HINTS, 32,
457 PropModeReplace, (unsigned char *)&mwm,
458 sizeof(MWMHints) / 4);
460 /* make sure the WM obays our window position */
461 size_hints.flags = PPosition;
462 /*XSetWMNormalHints (dd, win, &size_hints); */
463 XChangeProperty(dd, win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32,
464 PropModeReplace, (unsigned char *)&size_hints,
465 sizeof(XSizeHints) / 4);
467 /* make our window unfocusable */
468 wmhints.flags = InputHint;
469 wmhints.input = False;
470 /*XSetWMHints (dd, win, &wmhints); */
471 XChangeProperty(dd, win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace,
472 (unsigned char *)&wmhints, sizeof(XWMHints) / 4);
474 xclhints.res_name = "rspanel";
475 xclhints.res_class = "RSPanel";
476 XSetClassHint(dd, win, &xclhints);
481 xftdraw = XftDrawCreate(dd, win, DefaultVisual(dd, scr_screen),
482 DefaultColormap(dd, scr_screen));
498 PangoContext *context;
499 PangoFontDescription *pfd;
504 xcl.red = cols[i].red;
505 xcl.green = cols[i].green;
506 xcl.blue = cols[i].blue;
507 XAllocColor(dd, DefaultColormap(dd, scr_screen), &xcl);
508 palette[i] = xcl.pixel;
510 } while (i < PALETTE_COUNT);
514 xfs = XftFontOpenName(dd, scr_screen, XFT_FONT);
516 fontname = FONT_NAME;
518 xfs = XLoadQueryFont(dd, fontname);
523 gcv.graphics_exposures = False;
526 text_y = xfs->ascent + ((WINHEIGHT - (xfs->ascent + xfs->descent)) / 2);
527 fore_gc = XCreateGC(dd, root_win, GCGraphicsExposures, &gcv);
529 text_y = xfs->ascent + ((WINHEIGHT - xfs->ascent) / 2);
531 fore_gc = XCreateGC(dd, root_win, GCFont | GCGraphicsExposures, &gcv);
534 pfd = pango_font_description_new();
535 pango_font_description_set_absolute_size(pfd, PANGO_FONT_SIZE*PANGO_SCALE);
536 pango_font_description_set_family(pfd, PANGO_FONT_PREF);
537 context = pango_xft_get_context(dd, root_win);
538 pango_context_set_font_description(context, pfd);
539 pl = pango_layout_new(context);
541 pango_layout_set_single_paragraph_mode(pl, TRUE);
542 pango_layout_set_ellipsize(pl, PANGO_ELLIPSIZE_END);
544 text_y = (WINHEIGHT*PANGO_SCALE-7*PANGO_SCALE);
545 pango_font_description_free(pfd);
546 g_object_unref(context);
548 fore_gc = XCreateGC(dd, root_win, GCGraphicsExposures, &gcv);
552 XpmCreatePixmapFromData(dd, root_win, icon_xpm, &generic_icon,
553 &generic_mask, NULL);
559 void gui_draw_vline(int x)
562 draw_line(x, 0, x, WINHEIGHT);
564 draw_line(x + 1, 0, x + 1, WINHEIGHT);
567 void draw_box(int x, int width)
569 set_foreground(1); /* mid gray */
570 fill_rect(x + 3, 2, width - 2, WINHEIGHT - 4);
572 set_foreground(3); /* white */
573 draw_line(x + 3, WINHEIGHT - 2, x + width - 1, WINHEIGHT - 2);
574 draw_line(x + width - 1, 1, x + width - 1, WINHEIGHT - 2);
576 set_foreground(4); /* darkest gray */
577 draw_line(x + 3, 1, x + width - 1, 1);
578 draw_line(x + 3, 2, x + 3, WINHEIGHT - 3);
581 void gui_draw_task(task * tk)
584 int taskw = tk->width;
598 set_foreground(0); /* mid gray */
599 fill_rect(x + 2, 0, taskw - 1, WINHEIGHT);
603 int text_x = x + TEXTPAD + TEXTPAD + (tk->icon ? ICONWIDTH : -1*ICONWIDTH/4);
604 #define SETCOL(x) col.color.red = cols[x].red;\
605 col.color.green = cols[x].green;\
606 col.color.blue = cols[x].blue;
609 pango_layout_set_width(pl, /*-1);*/(taskw - text_x + x) * PANGO_SCALE);
610 pango_layout_set_text(pl, tk->name, -1);
611 col.color.alpha = 0xffff;
615 pango_xft_render_layout_line(xftdraw, &col, pango_layout_get_line(pl, 0), (text_x+2)*PANGO_SCALE, text_y + 2);
617 } else if (tk->shaded) {
619 pango_xft_render_layout_line(xftdraw, &col, pango_layout_get_line(pl, 0), (text_x-2)*PANGO_SCALE, text_y - 2);
624 pango_xft_render_layout_line(xftdraw, &col, pango_layout_get_line(pl, 0), text_x*PANGO_SCALE, text_y);
628 /* check how many chars can fit */
629 len = strlen(tk->name);
631 XftTextExtentsUtf8(dd, xfs, tk->name, len, &ext);
632 if (ext.width < taskw - (text_x - x) - 2 || len <= 0)
637 col.color.alpha = 0xffff;
640 /* draw task's name dark (iconified) */
642 XftDrawStringUtf8(xftdraw, &col, xfs, text_x, text_y + 1, tk->name,
645 } else if (tk->shaded) {
646 /* draw task's name dark (shaded) */
648 XftDrawStringUtf8(xftdraw, &col, xfs, text_x, text_y - 1, tk->name,
656 /* draw task's name here */
657 XftDrawStringUtf8(xftdraw, &col, xfs, text_x, text_y, tk->name, len);
660 /* check how many chars can fit */
661 len = strlen(tk->name);
663 while (XTextWidth(xfs, tk->name, len) >= taskw - (text_x - x) - 2
668 /* draw task's name dark (iconified) */
670 XDrawString(dd, tb.win, fore_gc, text_x, text_y + 1, tk->name,
673 } else if (tk->shaded) {
674 /* draw task's name dark (shaded) */
676 XDrawString(dd, tb.win, fore_gc, text_x, text_y - 1, tk->name,
683 /* draw task's name here */
684 XDrawString(dd, tb.win, fore_gc, text_x, text_y, tk->name, len);
693 /* draw the task's icon */
694 XSetClipMask(dd, fore_gc, tk->mask);
695 XSetClipOrigin(dd, fore_gc, x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2);
696 XCopyArea(dd, tk->icon, tb.win, fore_gc, 0, 0, ICONWIDTH, ICONHEIGHT,
697 x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2);
698 XSetClipMask(dd, fore_gc, None);
701 void draw_dot(int x, int y)
704 XDrawPoint(dd, tb.win, fore_gc, x, y);
706 XDrawPoint(dd, tb.win, fore_gc, x + 1, y + 1);
709 void draw_grill(int x)
712 while (y < WINHEIGHT - 4) {
719 void ob_action(Window win, char *action)
721 XClientMessageEvent xev;
722 char act_name[14+strlen(action)];
723 sprintf(act_name, "_OB_WM_ACTION_%s", action);
725 xev.type = ClientMessage;
727 xev.message_type = atom__OB_WM_ACTION;
729 /*strncpy(xev.data.b, action, 20);*/
730 xev.data.l[0] = XInternAtom(dd, act_name, False);
731 XSendEvent(dd, root_win, False, SubstructureRedirectMask, (XEvent *)&xev);
736 void switch_desk(int new_desk)
738 XClientMessageEvent xev;
740 if (get_number_of_desktops() <= new_desk)
743 xev.type = ClientMessage;
744 xev.window = root_win;
745 xev.message_type = atom__NET_CURRENT_DESKTOP;
747 xev.data.l[0] = new_desk;
748 XSendEvent(dd, root_win, False, SubstructureRedirectMask, (XEvent *)&xev);
751 void pager_draw_button(int x, int num)
758 if (num == tb.my_desktop) {
759 /* current desktop */
760 draw_box(x, PAGER_BUTTON_WIDTH);
763 fill_rect(x, 1, PAGER_BUTTON_WIDTH + 1, WINHEIGHT - 2);
769 col.color.alpha = 0xffff;
770 col.color.red = cols[5].red;
771 col.color.green = cols[5].green;
772 col.color.blue = cols[5].blue;
773 XftDrawString8(xftdraw, &col, xfs,
774 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2), text_y,
778 XDrawString(dd, tb.win, fore_gc,
779 x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2) - 1,
784 void pager_draw(void)
786 int desks, i, x = GRILL_WIDTH;
788 desks = get_number_of_desktops();
790 for (i = 0; i < desks; i++) {
791 pager_draw_button(x, i);
794 x += PAGER_BUTTON_WIDTH;
802 void gui_draw_taskbar(void)
810 pager_size = TEXTPAD;
813 width = WINWIDTH - (pager_size + GRILL_WIDTH + GRILL_WIDTH);
816 if (tb.num_tasks == 0)
819 taskw = width / tb.num_tasks;
820 if (taskw > MAX_TASK_WIDTH)
821 taskw = MAX_TASK_WIDTH;
826 tk->width = taskw - 1;
832 if (x < (width + pager_size + 2)) {
836 fill_rect(x + 2, 0, WINWIDTH, WINHEIGHT);
840 gui_draw_vline(WINWIDTH - 8);
843 draw_grill(WINWIDTH - 6);
846 task *find_task(Window win)
848 task *list = tb.task_list;
850 if (list->win == win)
857 void del_task(Window win)
859 task *next, *prev = 0, *list = tb.task_list;
863 if (list->win == win) {
864 /* unlink and free this task */
866 if (list->icon_copied) {
867 XFreePixmap(dd, list->icon);
868 if (list->mask != None)
869 XFreePixmap(dd, list->mask);
885 void move_taskbar(void)
892 x = TEXTPAD - WINWIDTH;
895 y = scr_height - WINHEIGHT;
897 XMoveWindow(dd, tb.win, x, y);
900 void taskbar_read_clientlist(void)
902 Window *win, focus_win = 0;
903 int num, i, desk, new_desk = 0;
905 desk = get_current_desktop();
912 XResizeWindow(dd, rspanelwin, WINWIDTH, WINHEIGHT);
915 if (desk != tb.my_desktop) {
917 tb.my_desktop = desk;
920 win = get_prop_data(root_win, atom__NET_ACTIVE_WINDOW, XA_WINDOW, &num);
924 win = get_prop_data(root_win, atom__NET_CLIENT_LIST, XA_WINDOW, &num);
928 /* remove windows that arn't in the _NET_CLIENT_LIST anymore */
931 list->focused = (focus_win == list->win);
935 for (i = num - 1; i >= 0; i--)
936 if (list->win == win[i] && !is_hidden(win[i]))
944 /* add any new windows */
945 for (i = 0; i < num; i++) {
946 if (!find_task(win[i]))
947 add_task(win[i], (win[i] == focus_win));
953 void handle_press(int x, int y, int button)
958 if ((y > 2 && y < WINHEIGHT - 2 && x > GRILL_WIDTH) && button == 1)
959 switch_desk((x - GRILL_WIDTH) / PAGER_BUTTON_WIDTH);
962 /* clicked left grill */
965 tb.at_top = 1 - tb.at_top;
967 } else if (button == 4) {
973 /* clicked right grill */
974 else if (x + TEXTPAD > WINWIDTH) {
975 if (tb.hidden && (button == 1 || button == 5)) {
978 } else if (!tb.hidden && (button == 1 || button == 4)) {
985 /* clicked on a task button */
986 if (x > tk->pos_x && x < tk->pos_x + tk->width) {
989 if (tk->iconified && tk->shaded)
990 ob_action(tk->win, "unshade");
991 ob_action(tk->win, "activate");
995 ob_action(tk->win, "deiconify");
997 ob_action(tk->win, "iconify");
1000 ob_action(tk->win, "raiselower");
1003 ob_action(tk->win, "shadelower");
1006 ob_action(tk->win, "unshaderaise");
1010 ob_action(tk->win, "deiconify");
1011 ob_action(tk->win, "focus");
1014 ob_action(tk->win, "lower");
1017 ob_action(tk->win, "raise");
1023 } /* clicked on the background */
1026 ob_action(tb.win, "raise");
1029 ob_action(tb.win, "lower");
1032 ob_action(tb.win, "raiselower");
1046 void handle_focusin(Window win)
1053 if (tk->win != win) {
1058 if (tk->win == win) {
1067 void handle_propertynotify(Window win, Atom at)
1071 if (win == root_win) {
1072 if (at == atom__NET_CLIENT_LIST || at == atom__NET_CURRENT_DESKTOP || at == atom__NET_CLIENT_LIST_STACKING) {
1073 taskbar_read_clientlist();
1079 tk = find_task(win);
1083 if (at == XA_WM_NAME || at == atom__NET_WM_NAME) {
1084 /* window's title changed */
1086 newname = get_prop_data(tk->win, atom__NET_WM_NAME, atom_STRING_UTF8, 0) ?:
1087 get_prop_data(tk->win, XA_WM_NAME, XA_STRING, 0);
1089 if (tk->name && !strcmp(newname, tk->name)) {
1098 } else if (at == atom__NET_WM_STATE) {
1099 /* iconified state changed? */
1100 if (is_iconified(tk->win) != tk->iconified) {
1101 tk->iconified = !tk->iconified;
1104 /* shaded state changed? */
1105 if (is_shaded(tk->win) != tk->shaded) {
1106 tk->shaded = !tk->shaded;
1109 } else if (at == XA_WM_HINTS) {
1110 /* some windows set their WM_HINTS icon after mapping */
1111 //if (tk->icon == generic_icon) {
1112 get_task_hinticon(tk);
1115 } else if (at == atom__NET_WM_DESKTOP) {
1116 if (find_desktop(win) != get_current_desktop())
1121 void handle_error(Display * d, XErrorEvent * ev)
1129 main(int argc, char *argv[])
1136 dd = XOpenDisplay(NULL);
1139 scr_screen = DefaultScreen(dd);
1140 scr_depth = DefaultDepth(dd, scr_screen);
1141 scr_height = DisplayHeight(dd, scr_screen);
1142 scr_width = DisplayWidth(dd, scr_screen);
1143 root_win = RootWindow(dd, scr_screen);
1145 /* helps us catch windows closing/opening */
1146 XSelectInput(dd, root_win, PropertyChangeMask);
1148 XSetErrorHandler((XErrorHandler) handle_error);
1150 XInternAtoms(dd, atom_names, ATOM_COUNT, False, atoms);
1153 bzero(&tb, sizeof(struct taskbar));
1154 tb.win = gui_create_taskbar();
1155 xfd = ConnectionNumber(dd);
1161 select(xfd + 1, &fd, 0, 0, 0);
1163 while (XPending(dd)) {
1164 XNextEvent(dd, &ev);
1167 handle_press(ev.xbutton.x, ev.xbutton.y, ev.xbutton.button);
1170 del_task(ev.xdestroywindow.window);
1175 case PropertyNotify:
1176 handle_propertynotify(ev.xproperty.window, ev.xproperty.atom);
1179 if (ev.xfocus.mode != NotifyGrab)
1180 handle_focusin(ev.xfocus.window);
1183 printf ("unknown evt type: %d\n", ev.type); */
1188 /*XCloseDisplay (dd);