xbar.c (1301B)
1 #include "shod.h" 2 3 /* fill strut array of bar */ 4 void 5 barstrut(struct Bar *bar) 6 { 7 unsigned long *arr; 8 unsigned long l, i; 9 10 for (i = 0; i < STRUT_LAST; i++) 11 bar->strut[i] = 0; 12 bar->ispartial = 1; 13 l = getcardsprop(bar->obj.win, atoms[_NET_WM_STRUT_PARTIAL], &arr); 14 if (arr == NULL) { 15 bar->ispartial = 0; 16 l = getcardsprop(bar->obj.win, atoms[_NET_WM_STRUT], &arr); 17 if (arr == NULL) { 18 return; 19 } 20 } 21 for (i = 0; i < STRUT_LAST && i < l; i++) 22 bar->strut[i] = arr[i]; 23 XFree(arr); 24 } 25 26 /* map bar window */ 27 void 28 managebar(struct Tab *tab, struct Monitor *mon, int desk, Window win, Window leader, XRectangle rect, int state, int ignoreunmap) 29 { 30 struct Bar *bar; 31 32 (void)tab; 33 (void)mon; 34 (void)desk; 35 (void)leader; 36 (void)rect; 37 (void)state; 38 (void)ignoreunmap; 39 Window wins[2] = {wm.layers[LAYER_DOCK].frame, win}; 40 41 bar = emalloc(sizeof(*bar)); 42 *bar = (struct Bar){ 43 .obj.win = win, 44 .obj.type = TYPE_DOCK, 45 }; 46 TAILQ_INSERT_HEAD(&wm.barq, (struct Object *)bar, entry); 47 XRestackWindows(dpy, wins, 2); 48 XMapWindow(dpy, win); 49 barstrut(bar); 50 monupdatearea(); 51 } 52 53 /* delete bar */ 54 int 55 unmanagebar(struct Object *obj, int dummy) 56 { 57 struct Bar *bar; 58 59 (void)dummy; 60 bar = (struct Bar *)obj; 61 TAILQ_REMOVE(&wm.barq, (struct Object *)bar, entry); 62 free(bar); 63 monupdatearea(); 64 return 0; 65 }