int managed; // window is managed by wm
};
-typedef enum {
- CLR_FOCUS,
- CLR_UNFOCUS,
- CLR_URGENT,
- NCOLORS
-} color_t;
-
/* Global data */
static xcb_connection_t *conn;
static xcb_ewmh_connection_t ewmh;
static xcb_window_t root;
static xcb_event_mask_t events;
static list_t *screens;
+static list_t *struts;
static void *cache;
-static xcb_pixmap_t colors[NCOLORS];
static unsigned int grabbed;
static int running;
static xcb_window_t control;
+
+static xcb_pixmap_t clr_focus;
+static xcb_pixmap_t clr_unfocus;
+static xcb_pixmap_t clr_urgent;
+
static xcb_atom_t wm_protos;
static xcb_atom_t wm_delete;
free(win);
}
+static void win_add_strut(win_t *win)
+{
+ win->type = TYPE_TOOLBAR;
+ for (list_t *cur = screens; cur; cur = cur->next) {
+ win_t *screen = cur->data;
+ strut_t *strut = &win->sys->strut;
+ screen->x += strut->left;
+ screen->y += strut->top;
+ screen->w -= strut->left + strut->right;
+ screen->h -= strut->top + strut->bottom;
+ }
+ struts = list_insert(struts, win);
+
+}
+
+static void win_del_strut(win_t *win)
+{
+ list_t *link = list_find(struts, win);
+ if (!link)
+ return;
+ for (list_t *cur = screens; cur; cur = cur->next) {
+ win_t *screen = cur->data;
+ strut_t *strut = &win->sys->strut;
+ screen->x -= strut->left;
+ screen->y -= strut->top;
+ screen->w += strut->left + strut->right;
+ screen->h += strut->top + strut->bottom;
+ }
+ struts = list_remove(struts, link, 0);
+}
+
/****************
* XCB Wrappers *
****************/
return;
printf("on_focus_in: xcb=%-8u mode=%d\n", event->event, event->mode);
xcb_change_window_attributes(conn, event->event,
- XCB_CW_BORDER_PIXEL, &colors[CLR_FOCUS]);
+ XCB_CW_BORDER_PIXEL, &clr_focus);
if (event->mode == XCB_NOTIFY_MODE_NORMAL)
send_event(EV_FOCUS, event->event);
}
return;
printf("on_focus_out: xcb=%-8u mode=%d\n", event->event, event->mode);
xcb_change_window_attributes(conn, event->event,
- XCB_CW_BORDER_PIXEL, &colors[CLR_UNFOCUS]);
+ XCB_CW_BORDER_PIXEL, &clr_unfocus);
if (event->mode == XCB_NOTIFY_MODE_NORMAL)
send_event(EV_UNFOCUS, event->event);
}
event->window, win);
if (!win) return;
+ win_del_strut(win);
send_state(win, ST_HIDE);
}
if (!win) return;
if (do_get_strut(win->sys->xcb, &win->sys->strut))
- printf("Map: Got a strut!\n");
- else
- printf("Map: No struts here!\n");
-
+ win_add_strut(win);
send_state(win, ST_SHOW);
xcb_map_window(conn, win->sys->xcb);
sys_move(win, win->x, win->y, win->w, win->h);
error("cannot allocate key symbols");
/* Read color information */
- colors[CLR_FOCUS] = do_alloc_color(0xFF6060);
- colors[CLR_UNFOCUS] = do_alloc_color(0xD8D8FF);
- colors[CLR_URGENT] = do_alloc_color(0xFF0000);
+ clr_focus = do_alloc_color(0xFF6060);
+ clr_unfocus = do_alloc_color(0xD8D8FF);
+ clr_urgent = do_alloc_color(0xFF0000);
}
void sys_run(void)
if (kids[i] == control)
continue;
win_t *win = win_new(kids[i]);
+ if (do_get_strut(win->sys->xcb, &win->sys->strut))
+ win_add_strut(win);
do_get_geometry(kids[i], &win->x, &win->y, &win->w, &win->h);
do_get_window_attributes(kids[i], &override, &mapped);
printf(" found %-8u %dx%d @ %d,%d --%s%s\n", kids[i],