From 958cbdf3fd18f2545dcaaa33384b9ad8c16f87f2 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sat, 9 Jun 2012 07:05:56 +0000 Subject: [PATCH] Fix some window flashing on X11 - Update sizes in sys-x11 before showing windows. This prevents mapping a window somewhere where it's not supposed to be mapped right after it is inserted. - Rework the configure request handler to prevent resizing windows that ask to be resized (e.g. when changing font size in urxvt) --- sys-x11.c | 26 ++++++++++++++------------ wm-wmii.c | 18 ++++++++++-------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/sys-x11.c b/sys-x11.c index 98aa326..a0c3e8f 100644 --- a/sys-x11.c +++ b/sys-x11.c @@ -362,17 +362,19 @@ static void process_event(int type, XEvent *xe, win_t *root) printf("configure_req: %d - %x, (0x%lx) %dx%d @ %d,%d\n", type, (int)cre->window, cre->value_mask, cre->height, cre->width, cre->x, cre->y); - XConfigureWindow(dpy, cre->window, cre->value_mask, &(XWindowChanges){ - .x = cre->x, - .y = cre->y, - .width = cre->width, - .height = cre->height, - }); - - /* This seems necessary for, but causes flicker - * there could be a better way to do this */ - if ((win = win_find(dpy,xe->xmaprequest.window,0))) - sys_move(win, win->x, win->y, win->w, win->h); + if ((win = win_find(dpy,xe->xmaprequest.window,1))) { + XSendEvent(dpy, cre->window, False, StructureNotifyMask, &(XEvent){ + .xconfigure.type = ConfigureNotify, + .xconfigure.display = win->sys->dpy, + .xconfigure.event = win->sys->xid, + .xconfigure.window = win->sys->xid, + .xconfigure.x = win->x, + .xconfigure.y = win->y, + .xconfigure.width = win->w, + .xconfigure.height = win->h, + }); + XSync(win->sys->dpy, False); + } } else if (type == MapRequest) { printf("map_req: %d\n", type); @@ -382,7 +384,7 @@ static void process_event(int type, XEvent *xe, win_t *root) else wm_update(); } - XMapWindow(dpy,xe->xmaprequest.window); + XMapWindow(dpy, xe->xmaprequest.window); } else { printf("unknown event: %d\n", type); diff --git a/wm-wmii.c b/wm-wmii.c index 9bf45a9..daa613a 100644 --- a/wm-wmii.c +++ b/wm-wmii.c @@ -678,6 +678,15 @@ static void wm_update_cols(dpy_t *dpy) *******************************/ void wm_update(void) { + /* Updates window sizes */ + for (list_t *ldpy = wm_tag->dpys; ldpy; ldpy = ldpy->next) + wm_update_cols(ldpy->data); + tag_foreach_flt(wm_tag, ldpy, lflt, win) { + flt_t *flt = lflt->data; + sys_move(win, flt->x, flt->y, flt->w, flt->h); + sys_raise(flt->win); + } + /* Show/hide tags */ tag_foreach_col(wm_tag, dpy, col, row, win) sys_show(win, ROW(row)->state); @@ -691,14 +700,7 @@ void wm_update(void) sys_show(win, ST_HIDE); } - /* Refresh the display */ - for (list_t *ldpy = wm_tag->dpys; ldpy; ldpy = ldpy->next) - wm_update_cols(ldpy->data); - tag_foreach_flt(wm_tag, ldpy, lflt, win) { - flt_t *flt = lflt->data; - sys_move(win, flt->x, flt->y, flt->w, flt->h); - sys_raise(flt->win); - } + /* Set focused window */ if (wm_focus) set_focus(wm_focus); } -- 2.43.2