raboof / notion

Tiling tabbed window manager
https://notionwm.net/
GNU Lesser General Public License v2.1
268 stars 63 forks source link

Hide scratchpad when switching window to full-screen #340

Open wilhelmy opened 2 years ago

wilhelmy commented 2 years ago

When switching a window from the scratchpad to fullscreen-mode, the scratchpad stays in front of the freshly full-screened window. It should be hidden.

Furthermore when switching fullscreened scratchpad window back to its normal size, the scratchpad gets focused correctly but is put in front of the wrong desktop, rather than the last active one.

wilhelmy commented 1 year ago

About the first point:

lua> mod_sp.is_scratchpad(ioncore.current():manager():manager())
true

This seems to identify scratchpad windows. Now my approach would be to put a check like this into ioncore/fullscreen.c, but it shouldn't include code from mod_sp. So what's the alternative? Wrap the keybinding for Mod+f or whatever is the fullscreen keybinding in a lua wrapper? @raboof

wilhelmy commented 1 year ago

I've come up with the following code:

function toggle_fullscreen(arg)
    local parent = arg:parent()
    local r = WGroup.set_fullscreen(arg, 'toggle')
    if mod_sp and mod_sp.is_scratchpad(parent) then
        mod_sp.set_shown_on(arg:manager(), 'toggle')
    end
    return r
end

defbindings("WGroupCW", {
    bdoc("Toggle client window group full-screen mode"),
    kpress_wait(META.."F", "toggle_fullscreen(_)"),
})

Opinions?

Edit: It does however not solve the second half of my issue, namely that returning a scratchpad window from fullscreen returns it to the right scratchpad but in front of the wrong workspace.

mjf commented 1 year ago

@wilhelmy This solves the case when you use specific key binding to toggle full-screen mode of a window but it does not solve the cases when the application toggles to full-screen itself such as Alt-Enter in XTerm of F in MPlayer etc.

wilhelmy commented 1 year ago

Thanks, I guess fixing it correctly is a bit more involved. The main problem I haven't solved is that I want to avoid adding a dependency to mod_sp to the core code handling fullscreen.

raboof commented 1 year ago

Thanks, I guess fixing it correctly is a bit more involved. The main problem I haven't solved is that I want to avoid adding a dependency to mod_sp to the core code handling fullscreen.

Do you think it's still a net improvement to merge it?

wilhelmy commented 1 year ago

I wouldn't want to merge this snippet into the default config in this state, because everyone would need to edit their config in order to use it and the real fix would then make all those config changes obsolete again. I think it can live in this issue until we have a complete fix, and people who care about it can use it locally?

mjf commented 1 year ago

I've come up with the following code:

Opinions?

Hello @wilhelmy, have you tried it with multiple workspaces? I've just tried it on a screen with 2 workspaces, one tiled and the second one "empty". When I open a scratch pad and a terminal in it, then press META+F, the terminal gets fullscreen but when I pres META+F again to "unfullscreen" it I end up in the second workspace (the scratchpad shows OK with the terminal "swallowed" again in it, but it appears on a wrong workspace). I am not sure why this is... The issue occurs only if META+F toggled application is in scratchpad, otherwise it seems to work correctly.

wilhelmy commented 1 year ago

Furthermore when switching fullscreened scratchpad window back to its normal size, the scratchpad gets focused correctly but is put in front of the wrong desktop, rather than the last active one.

@mjf that's the second part of this issue for which I unfortunately haven't had the time to diagnose it yet.