conformal / spectrwm

A small dynamic tiling window manager for X11.
ISC License
1.33k stars 97 forks source link

Please help me implement this feature: Swap window with master if window is sent to the same workspace. #423

Open adityadesaha opened 3 years ago

adityadesaha commented 3 years ago

I want to make it so that if a window is sent to the same workspace that it is in, then the window is swapped to the main window. I am not very familiar with the code base, but I think the function swapwin() does that. I guess I have to add something here, in spectrwm.c, in function void win_to_ws(). I can see that I should add something in the following block, inside win_to_ws(), before the return statement:

    if (win->ws->idx == wsid) {
        DNPRINTF(SWM_D_MOVE, "win %#x already on ws %d\n",
            win->id, wsid);
        return;
    }

Can anyone help me with this? I have already tried the following, and it doesn't work:

    if (win->ws->idx == wsid) {
        DNPRINTF(SWM_D_MOVE, "win %#x already on ws %d\n",
            win->id, wsid);

                union arg a;
                a.id=SWM_ARG_ID_SWAPMAIN;
                swapwin(NULL, win->ws->r, &a);

        return;
    }

Sorry if I'm doing something stupid.

chaibronz commented 3 years ago

couldn't you get the same result with (swap_main), per the defaults?:

bind[swap_main] = MOD+Return