]> Pileus Git - wmpus/commitdiff
Fix some window flashing on X11
authorAndy Spencer <andy753421@gmail.com>
Sat, 9 Jun 2012 07:05:56 +0000 (07:05 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 9 Jun 2012 08:31:41 +0000 (08:31 +0000)
- 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
wm-wmii.c

index 98aa326138196936b601698ba8d38670976cb885..a0c3e8fe98c85a2b646ff98ad5c3006fac3f081f 100644 (file)
--- 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);
index 9bf45a93f8a4589896cc774c9a01a47aeec8fba2..daa613aa98ee1ed794b5d855b84708acc616e446 100644 (file)
--- 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);
 }