X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=0816f0eb1716eb50668bdb033b59f1116103560c;hb=90431ef17b68f5df145128110f0856b1b0b175e2;hp=45666c47622e76b758d2de0f2432056002b264e4;hpb=e03f06a1a587c8d8d62e6f45aecd07376fbdfffc;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 45666c4..0816f0e 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -156,8 +156,16 @@ static const char *buildstr = SPECTRWM_VERSION; #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 @@ -343,6 +351,7 @@ int spawn_position = SWM_STACK_TOP; 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; @@ -1827,7 +1836,7 @@ bar_setup(struct swm_region *r) 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); @@ -1876,10 +1885,12 @@ bar_setup(struct swm_region *r) 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, @@ -4152,7 +4163,7 @@ update_window(struct ws_win *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; @@ -4257,6 +4268,7 @@ resize(struct ws_win *win, union arg *args) return; } + xcb_flush(conn); buttonrelease = 0; while ((evt = xcb_poll_for_event(conn)) && buttonrelease != 1) { /* @@ -4316,8 +4328,8 @@ resize(struct ws_win *win, union arg *args) 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); } @@ -4328,7 +4340,7 @@ resize(struct ws_win *win, union arg *args) } free(evt); } - if (time) { + if (timestamp) { do_sync(); update_window(win); } @@ -4359,7 +4371,7 @@ resize_step(struct swm_region *r, union arg *args) 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; @@ -4450,6 +4462,7 @@ move(struct ws_win *win, union arg *args) return; } + xcb_flush(conn); buttonrelease = 0; while ((evt = xcb_poll_for_event(conn)) && buttonrelease != 1) { /* @@ -4468,8 +4481,8 @@ move(struct ws_win *win, union arg *args) 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); } @@ -4480,7 +4493,7 @@ move(struct ws_win *win, union arg *args) } free(evt); } - if (time) { + if (timestamp) { do_sync(); update_window(win); } @@ -6626,7 +6639,18 @@ focus_magic(struct ws_win *win) 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 @@ -7068,7 +7092,7 @@ clientmessage(xcb_client_message_event_t *e) } DNPRINTF(SWM_D_EVENT, "clientmessage: window: 0x%x, type: %u\n", - e->window, e->response_type); + e->window, e->type); if (e->response_type == ewmh[_NET_ACTIVE_WINDOW].atom) { DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_ACTIVE_WINDOW\n"); @@ -7594,14 +7618,18 @@ main(int argc, char *argv[]) { 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); @@ -7772,6 +7800,7 @@ noconfig: continue; } +#if 0 FD_ZERO(&rd); FD_SET(xfd, &rd); tv.tv_sec = 1; @@ -7779,6 +7808,7 @@ noconfig: 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)