Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spawned windows appears at the top left corner and causes flicker when moving it to the stack. #114

Open
toniz4 opened this issue Apr 1, 2021 · 7 comments

Comments

@toniz4
Copy link

toniz4 commented Apr 1, 2021

When spawning new windows, it spawns it at the top left corner, and quickly moves it to the stack, causing flickering. This is the only thing stopping me from using frankenwm, because I'm quite sensitive to flickering.

@sulami
Copy link
Owner

sulami commented Apr 20, 2021 via email

@toniz4
Copy link
Author

toniz4 commented May 1, 2021

In dwm that doesn't happen, this is because frankenwm is in xcb and dwm uses xlib?

@toniz4
Copy link
Author

toniz4 commented May 1, 2021

I saw #34 and tested on the branch 34-fix. And the flickering is gone

@toniz4
Copy link
Author

toniz4 commented May 1, 2021

Since the branch didn't change nothing relevant it was probably in the previous commits. So I bisect it and found that in 9b108ec was the first commit that started showing this behaviour. in 991f191 there is no flickering. I don't understand enough c to know why that would happen.

@sulami
Copy link
Owner

sulami commented May 4, 2021

That's incredibly helpful information, thank you for taking the time to bisect this. I'll have a look at the code shortly and see if I can figure out what's happening there.

@toniz4
Copy link
Author

toniz4 commented May 16, 2021

I had the time to tinker with it and found a interesting thing. By the nature of the problem it must be inside maprequest, so I tried to see what changed between the commits. So I tried reverting parts of the function in the problematic repo, aaand i found where is the problem, in the end of maprequest. In the "working" commit it is like this:

...
    if (cd != newdsk)
        select_desktop(cd);
    if (cd == newdsk) {
        xcb_move(dis, c, -2 * M_WW, 0);
        xcb_map_window(dis, c->win);
        if (show)
            update_current(c);
    }
    else
        if (follow) {
        change_desktop(&(Arg){.i = newdsk});
        update_current(c);
    }
    grabbuttons(c);
    xcb_ewmh_set_wm_desktop(ewmh, c->win, cd);
    desktopinfo();

    if (c->isfloating && AUTOCENTER)
        centerfloating(c);
...

and by using this part of the function in the buggy commit it fixes things. But I found a workaround:

...
    int wmdsk = cd;
    bool visible = True;
    xcb_move(dis, c->win, -2 * M_WW, 0, &c->position_info);
    xcb_map_window(dis, c->win);
    if (cd != newdsk) {
        visible = False;
        rem_node(&c->link);
        select_desktop(newdsk);
        add_tail(&current_display->clients, &c->link);
        select_desktop(cd);
        wmdsk = newdsk;
        if (follow) {
            visible = True;
            change_desktop(&(Arg){.i = newdsk});
        }
    }
    if (visible && show) {
        update_current(c); // remove flicker
        xcb_move(dis, c->win, c->position_info.previous_x,
                              c->position_info.previous_y, NULL);
        c->position_info.previous_x = c->position_info.current_x;
        c->position_info.previous_y = c->position_info.current_y;
        update_current(c);
        if (c->isfloating && AUTOCENTER)
            centerfloating(c);
    }
    xcb_ewmh_set_wm_desktop(ewmh, c->win, wmdsk);
    grabbuttons(c);
    desktopinfo();
...

By running update_current(c); before and after xcb_move makes the flickering disappear, I don't have an idea why, but it works!

@qsmodo
Copy link
Contributor

qsmodo commented Jun 12, 2021

The problem with that workaround is that it messes up the focus history by always returning to the master window (in a tiled mode). Try tile() instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants