#define xcb_icccm_get_wm_transient_for xcb_get_wm_transient_for
#define xcb_icccm_get_wm_transient_for_reply xcb_get_wm_transient_for_reply
#define xcb_icccm_wm_hints_t xcb_wm_hints_t
-#define XCB_REQUEST XCB_EVENT_ERROR_BAD_REQUEST
-#define XCB_VALUE XCB_EVENT_ERROR_BAD_VALUE
-#define XCB_WINDOW XCB_EVENT_ERROR_BAD_WINDOW
-#define XCB_PIXMAP XCB_EVENT_ERROR_BAD_PIXMAP
-#define XCB_ATOM XCB_EVENT_ERROR_BAD_ATOM
-#define XCB CURSOR XCB_EVENT_ERROR_BAD_CURSOR
-#define XCB_FONT XCB_EVENT_ERROR_BAD_FONT
-#define XCB_MATCH XCB_EVENT_ERROR_BAD_MATCH
-#define XCB_DRAWABLE XCB_EVENT_ERROR_BAD_DRAWABLE
-#define XCB_ACCESS XCB_EVENT_ERROR_BAD_ACCESS
-#define XCB_ALLOC XCB_EVENT_ERROR_BAD_ALLOC
-#define XCB_COLORMAP XCB_EVENT_ERROR_BAD_COLOR
-#define XCB_G_CONTEXT XCB_EVENT_ERROR_BAD_GC
-#define XCB_ID_CHOICE XCB_EVENT_ERROR_BAD_ID_CHOICE
-#define XCB_NAME XCB_EVENT_ERROR_BAD_NAME
-#define XCB_LENGTH XCB_EVENT_ERROR_BAD_LENGTH
-#define XCB_IMPLEMENTATION XCB_EVENT_ERROR_BAD_IMPLEMENTATION
#endif
#define SWM_DEBUG
#ifdef SWM_DEBUG
-#define DPRINTF(x...) do { if (swm_debug) fprintf(stderr, x); } while (0)
-#define DNPRINTF(n,x...) do { if (swm_debug & n) fprintf(stderr, x); } while (0)
+#define DPRINTF(x...) do { \
+ if (swm_debug) \
+ fprintf(stderr, x); \
+} while (0)
+#define DNPRINTF(n,x...) do { \
+ if (swm_debug & n) { \
+ fprintf(stderr, "%ld ", (long)(time(NULL) - time_started)); \
+ fprintf(stderr, x); \
+ } \
+} while (0)
#define SWM_D_MISC 0x0001
#define SWM_D_EVENT 0x0002
#define SWM_D_WS 0x0004
volatile sig_atomic_t running = 1;
volatile sig_atomic_t restart_wm = 0;
int outputs = 0;
-int last_focus_event = FocusOut;
+/*int last_focus_event = FocusOut;*/
int (*xerrorxlib)(Display *, XErrorEvent *);
int other_wm;
int ss_enabled = 0;
int disable_border = 0;
int border_width = 1;
int verbose_layout = 0;
+time_t time_started;
pid_t bar_pid;
XFontSet bar_fs;
XFontSetExtents *bar_fs_extents;
/* events */
#ifdef SWM_DEBUG
-char *
-geteventname(xcb_generic_event_t *e)
-{
- char *name = NULL;
-
- switch (XCB_EVENT_RESPONSE_TYPE(e)) {
- case XCB_KEY_PRESS:
- name = "KeyPress";
- break;
- case XCB_KEY_RELEASE:
- name = "KeyRelease";
- break;
- case XCB_BUTTON_PRESS:
- name = "ButtonPress";
- break;
- case XCB_BUTTON_RELEASE:
- name = "ButtonRelease";
- break;
- case XCB_MOTION_NOTIFY:
- name = "MotionNotify";
- break;
- case XCB_ENTER_NOTIFY:
- name = "EnterNotify";
- break;
- case XCB_LEAVE_NOTIFY:
- name = "LeaveNotify";
- break;
- case XCB_FOCUS_IN:
- name = "FocusIn";
- break;
- case XCB_FOCUS_OUT:
- name = "FocusOut";
- break;
- case XCB_KEYMAP_NOTIFY:
- name = "KeymapNotify";
- break;
- case XCB_EXPOSE:
- name = "Expose";
- break;
- case XCB_GRAPHICS_EXPOSURE:
- name = "GraphicsExposure";
- break;
- case XCB_NO_EXPOSURE:
- name = "NoExposure";
- break;
- case XCB_VISIBILITY_NOTIFY:
- name = "VisibilityNotify";
- break;
- case XCB_CREATE_NOTIFY:
- name = "CreateNotify";
- break;
- case XCB_DESTROY_NOTIFY:
- name = "DestroyNotify";
- break;
- case XCB_UNMAP_NOTIFY:
- name = "UnmapNotify";
- break;
- case XCB_MAP_NOTIFY:
- name = "MapNotify";
- break;
- case XCB_MAP_REQUEST:
- name = "MapRequest";
- break;
- case XCB_REPARENT_NOTIFY:
- name = "ReparentNotify";
- break;
- case XCB_CONFIGURE_NOTIFY:
- name = "ConfigureNotify";
- break;
- case XCB_CONFIGURE_REQUEST:
- name = "ConfigureRequest";
- break;
- case XCB_GRAVITY_NOTIFY:
- name = "GravityNotify";
- break;
- case XCB_RESIZE_REQUEST:
- name = "ResizeRequest";
- break;
- case XCB_CIRCULATE_NOTIFY:
- name = "CirculateNotify";
- break;
- case XCB_CIRCULATE_REQUEST:
- name = "CirculateRequest";
- break;
- case XCB_PROPERTY_NOTIFY:
- name = "PropertyNotify";
- break;
- case XCB_SELECTION_CLEAR:
- name = "SelectionClear";
- break;
- case XCB_SELECTION_REQUEST:
- name = "SelectionRequest";
- break;
- case XCB_SELECTION_NOTIFY:
- name = "SelectionNotify";
- break;
- case XCB_COLORMAP_NOTIFY:
- name = "ColormapNotify";
- break;
- case XCB_CLIENT_MESSAGE:
- name = "ClientMessage";
- break;
- case XCB_MAPPING_NOTIFY:
- name = "MappingNotify";
- break;
- default:
- name = "Unknown";
- break;
- }
-
- return (name);
-}
-
void
dumpwins(struct swm_region *r, union arg *args)
{
int num_missing_charsets = 0;
int i;
xcb_screen_t *screen = get_screen(r->s->idx);
- uint32_t wa[2];
+ uint32_t wa[3];
if (bar_fs) {
XFreeFontSet(display, bar_fs);
r->bar->id = xcb_generate_id(conn);
wa[0] = r->s->c[SWM_S_COLOR_BAR].color;
wa[1] = r->s->c[SWM_S_COLOR_BAR_BORDER].color;
+ wa[2] = XCB_EVENT_MASK_EXPOSURE;
xcb_create_window(conn, XCB_COPY_FROM_PARENT, r->bar->id, r->s->root,
X(r->bar), Y(r->bar), WIDTH(r->bar), HEIGHT(r->bar),
bar_border_width, XCB_WINDOW_CLASS_INPUT_OUTPUT,
- XCB_COPY_FROM_PARENT, XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL, wa);
+ XCB_COPY_FROM_PARENT, XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL
+ | XCB_CW_EVENT_MASK, wa);
r->bar->buffer = xcb_generate_id(conn);
xcb_create_pixmap(conn, screen->root_depth, r->bar->buffer, r->bar->id,
unfocus_win(cfw);
else {
/* use larger hammer since the window was killed somehow */
- TAILQ_FOREACH(cfw, &win->ws->winlist, entry)
+ /* TAILQ_FOREACH(cfw, &win->ws->winlist, entry)
if (cfw->ws && cfw->ws->r && cfw->ws->r->s)
xcb_change_window_attributes(conn, cfw->id,
XCB_CW_BORDER_PIXEL,
- &cfw->ws->r->s->c[SWM_S_COLOR_UNFOCUS].color);
+ &cfw->ws->r->s->c[SWM_S_COLOR_UNFOCUS].color);*/
}
win->ws->focus = win;
void
resize(struct ws_win *win, union arg *args)
{
- xcb_timestamp_t time = 0;
+ xcb_timestamp_t timestamp = 0;
struct swm_region *r = NULL;
int resize_step = 0;
struct swm_geometry g;
return;
}
+ xcb_flush(conn);
buttonrelease = 0;
while ((evt = xcb_poll_for_event(conn)) && buttonrelease != 1) {
/*
constrain_window(win, r, 1);
/* not free, don't sync more than 120 times / second */
- if ((mne->time - time) > (1000 / 120) ) {
- time = mne->time;
+ if ((mne->time - timestamp) > (1000 / 120) ) {
+ timestamp = mne->time;
do_sync();
update_window(win);
}
}
free(evt);
}
- if (time) {
+ if (timestamp) {
do_sync();
update_window(win);
}
void
move(struct ws_win *win, union arg *args)
{
- xcb_timestamp_t time = 0;
+ xcb_timestamp_t timestamp = 0;
int move_step = 0, buttonrelease;
struct swm_region *r = NULL;
xcb_font_t cursor_font;
return;
}
+ xcb_flush(conn);
buttonrelease = 0;
while ((evt = xcb_poll_for_event(conn)) && buttonrelease != 1) {
/*
constrain_window(win, r, 0);
/* not free, don't sync more than 120 times / second */
- if ((mne->time - time) > (1000 / 120) ) {
- time = mne->time;
+ if ((mne->time - timestamp) > (1000 / 120) ) {
+ timestamp = mne->time;
do_sync();
update_window(win);
}
}
free(evt);
}
- if (time) {
+ if (timestamp) {
do_sync();
update_window(win);
}
if (win == NULL)
return;
- /* needed for restart wm */
- set_win_state(win, XCB_ICCCM_WM_STATE_WITHDRAWN);
-
TAILQ_REMOVE(&win->ws->unmanagedlist, win, entry);
if (win->wa)
memset(win, 0xff, sizeof *win); /* XXX kill later */
free(win);
+ DNPRINTF(SWM_D_MISC, "free_window: done\n");
}
void
void
expose(xcb_expose_event_t *e)
{
+ int i, num_screens;
+ struct swm_region *r;
+
DNPRINTF(SWM_D_EVENT, "expose: window: 0x%x\n", e->window);
+
+ num_screens = xcb_setup_roots_length(xcb_get_setup(conn));
+ for (i = 0; i < num_screens; i++)
+ TAILQ_FOREACH(r, &screens[i].rl, entry)
+ if (e->window == WINID(r->bar))
+ bar_update();
+
+ xcb_flush(conn);
}
void
void
event_error(xcb_generic_error_t *e)
{
- const char *estr;
-
- switch (e->error_code) {
- case 0:
- estr = "Success";
- break;
- case XCB_REQUEST:
- estr = "BadRequest";
- break;
- case XCB_VALUE:
- estr = "BadValue";
- break;
- case XCB_WINDOW:
- estr = "BadWindow";
- break;
- case XCB_PIXMAP:
- estr = "BadPixmap";
- break;
- case XCB_ATOM:
- estr = "BadAtom";
- break;
- case XCB_CURSOR:
- estr = "BadCursor";
- break;
- case XCB_FONT:
- estr = "BadFont";
- break;
- case XCB_MATCH:
- estr = "BadMatch";
- break;
- case XCB_DRAWABLE:
- estr = "BadDrawable";
- break;
- case XCB_ACCESS:
- estr = "BadAccess";
- break;
- case XCB_ALLOC:
- estr = "BadAlloc";
- break;
- case XCB_COLORMAP:
- estr = "BadColor";
- break;
- case XCB_G_CONTEXT:
- estr = "BadGC";
- break;
- case XCB_ID_CHOICE:
- estr = "BadIdChoice";
- break;
- case XCB_NAME:
- estr = "BadName";
- break;
- case XCB_LENGTH:
- estr = "BadLength";
- break;
- case XCB_IMPLEMENTATION:
- estr = "BadImplementation";
- break;
- default:
- estr = "Unknown";
- break;
- }
-
- DNPRINTF(SWM_D_EVENT, "event_error: %s: response_type:%u error_code:%u "
- "sequence:%u resource_id:%u minor_code:%u major_code:%u\n", estr,
- e->response_type, e->error_code, e->sequence, e->resource_id,
- e->minor_code, e->major_code
- );
+ DNPRINTF(SWM_D_EVENT, "event_error: %s(%u) from %s(%u), sequence: %u, "
+ "resource_id: %u, minor_code: %u\n",
+ xcb_event_get_error_label(e->error_code), e->error_code,
+ xcb_event_get_request_label(e->major_code), e->major_code,
+ e->sequence, e->resource_id, e->minor_code);
}
void
EVENT(0, event_error);
EVENT(XCB_BUTTON_PRESS, buttonpress);
/*EVENT(XCB_BUTTON_RELEASE, buttonpress);*/
+ /*EVENT(XCB_CIRCULATE_NOTIFY, );*/
+ /*EVENT(XCB_CIRCULATE_REQUEST, );*/
EVENT(XCB_CLIENT_MESSAGE, clientmessage);
+ /*EVENT(XCB_COLORMAP_NOTIFY, );*/
EVENT(XCB_CONFIGURE_NOTIFY, configurenotify);
EVENT(XCB_CONFIGURE_REQUEST, configurerequest);
+ /*EVENT(XCB_CREATE_NOTIFY, );*/
EVENT(XCB_DESTROY_NOTIFY, destroynotify);
EVENT(XCB_ENTER_NOTIFY, enternotify);
EVENT(XCB_EXPOSE, expose);
+ /*EVENT(XCB_FOCUS_IN, );*/
+ /*EVENT(XCB_FOCUS_OUT, );*/
+ /*EVENT(XCB_GRAPHICS_EXPOSURE, );*/
+ /*EVENT(XCB_GRAVITY_NOTIFY, );*/
EVENT(XCB_KEY_PRESS, keypress);
/*EVENT(XCB_KEY_RELEASE, keypress);*/
+ /*EVENT(XCB_KEYMAP_NOTIFY, );*/
+ /*EVENT(XCB_LEAVE_NOTIFY, );*/
EVENT(XCB_MAP_NOTIFY, mapnotify);
EVENT(XCB_MAP_REQUEST, maprequest);
EVENT(XCB_MAPPING_NOTIFY, mappingnotify);
+ /*EVENT(XCB_MOTION_NOTIFY, );*/
+ /*EVENT(XCB_NO_EXPOSURE, );*/
EVENT(XCB_PROPERTY_NOTIFY, propertynotify);
+ /*EVENT(XCB_REPARENT_NOTIFY, );*/
+ /*EVENT(XCB_RESIZE_REQUEST, );*/
+ /*EVENT(XCB_SELECTION_CLEAR, );*/
+ /*EVENT(XCB_SELECTION_NOTIFY, );*/
+ /*EVENT(XCB_SELECTION_REQUEST, );*/
EVENT(XCB_UNMAP_NOTIFY, unmapnotify);
EVENT(XCB_VISIBILITY_NOTIFY, visibilitynotify);
#undef EVENT
{
struct swm_region *r, *rr;
struct ws_win *winfocus = NULL;
- struct timeval tv;
union arg a;
char conf[PATH_MAX], *cfile = NULL;
struct stat sb;
int xfd, i, num_screens;
- fd_set rd;
struct sigaction sact;
xcb_generic_event_t *evt;
+#if 0
+ struct timeval tv;
+ fd_set rd;
+#endif
+
+ time_started = time(NULL);
start_argv = argv;
warnx("Welcome to spectrwm V%s Build: %s", SPECTRWM_VERSION, buildstr);
while (running) {
while ((evt = xcb_poll_for_event(conn))) {
- DNPRINTF(SWM_D_EVENT, "XCB Event: %s\n",
- geteventname(evt));
+ DNPRINTF(SWM_D_EVENT, "XCB Event: %s(%d)\n",
+ xcb_event_get_label(XCB_EVENT_RESPONSE_TYPE(evt)),
+ XCB_EVENT_RESPONSE_TYPE(evt));
if (running == 0)
goto done;
event_handle(evt);
continue;
}
+#if 0
FD_ZERO(&rd);
FD_SET(xfd, &rd);
tv.tv_sec = 1;
if (select(xfd + 1, &rd, NULL, NULL, &tv) == -1)
if (errno != EINTR)
DNPRINTF(SWM_D_MISC, "select failed");
+#endif
if (restart_wm == 1)
restart(NULL, NULL);
if (search_resp == 1)