koekeishiya / yabai

A tiling window manager for macOS based on binary space partitioning
MIT License
23.08k stars 638 forks source link

FULLSCREEN option: windowed-fullscreen #2221

Closed aspauldingcode closed 3 weeks ago

aspauldingcode commented 5 months ago

Allow a bsp window (or a floating window) to be toggled as fullscreen.

This fullscreen just extends the window to the corners of the display, and toggles ignorance of gaps/bars spacing config to do so.

This way, we can get an alternative to native-fullscreen, which users don't have to script their own gaps/bar toggle respect/ignore keybind to get a bsp window to fullscreen instantly, and it also doesn't require us to write our own toggle for making the window float first and respect the current display dimensions..

Bellavene commented 5 months ago

All options need jq to be installed in the system

Option I This command will make a floating window go full-screen or toggle full-screen for bsp mode yabai -m window --grid 1:1:0:0:1:1 || yabai -m window --toggle zoom-fullscreen

Additionally, add this to .yabairc to automatically restore back from full-screen on focus change in bsp mode.

yabai -m signal --add event=window_focused action='if [[ $(yabai -m query --windows --window | jq ".\"is-floating\"") == "false" ]]; then
win_id=$(yabai -m query --windows --space | jq "map(select(.\"has-fullscreen-zoom\" and (.\"has-focus\" | not)))[0].id")
if [[ $win_id != "null" ]]; then yabai -m window $win_id --toggle zoom-fullscreen; fi
fi'

Option II You can create an executable file to toggle monocle mode (make all apps full-screen and stack them) for a specific space:

  1. Create yabai-monocle file in your PATH
  2. Paste this into it: /opt/homebrew/bin/yabai -m space --layout $( [ "$(/opt/homebrew/bin/yabai -m query --spaces --space | /opt/homebrew/bin/jq -re .type)" = 'bsp' ] && echo 'stack' || echo 'bsp' )
  3. Make it executable chmod +x yabai-monocle
  4. Then this command will toggle it, or make a floating window go full-screen yabai -m window --grid 1:1:0:0:1:1 || yabai-monocle

Option III Send a window to a new space. Then it will be in full-screen anyway, as the only window in it. yabai -m space --create; yabai -m window --space next; yabai -m space --focus next

Additionally, you can add auto-deletion of empty spaces in .yabairc yabai -m signal --add event=space_changed action='RSINDEX=$(yabai -m query --spaces | jq ".[] | select (.id == $YABAI_RECENT_SPACE_ID) | .index") && if [ "$(yabai -m query --spaces --space $RSINDEX | jq -re '.windows')" = "[]" ] ; then yabai -m space $RSINDEX --destroy ; fi'

Additionally Cycle through windows/spaces/displays with 2 directional keys Previous yabai -m window --focus prev || yabai -m space --focus prev || yabai -m space --focus last Next yabai -m window --focus next || yabai -m space --focus next || yabai -m space --focus first

aspauldingcode commented 4 months ago

windowed-fullscreen yabai -m window --grid 1:1:0:0:1:1 || yabai -m window --toggle zoom-fullscreen is already in my setup with alt + f.

However, this obeys my bar and window spacing. What I want is a way to simply toggle a complete fullscreen without the native macOS implementation. This will require changes to yabai itself I am sure, otherwise I can create an advanced bash toggle script to disable all my gaps config and bar spacing temperarily to fullscreen the window, but I don't want that to be for the whole space. I wish I could do this for a single window.

In other words, an instant fullscreen toggle with a command like (yabai -m window --toggle windowed-fullscreen)

Bellavene commented 3 months ago

Why not use native fullscreen for that?

aspauldingcode commented 3 months ago

the issue is still here. I've created a manual fix but it's slow! I think if yabai could just toggle fullscreen as an alternative to zoom fullscreen we would have this: fullscreenvszoomfullscreen

aspauldingcode commented 3 months ago

Why not use native fullscreen for that?

There should be an option that does NOT use macOS's animations. Native Fullscreen fades out, and moves the window to a completely different space.

aspauldingcode commented 3 months ago

I've created a manual fix but it's slow!

This is my second attempt with this.

My first used pheonixwm, before yabai v 7.0.0 and it was like so:

to go back though, it was messed up. I wanted a solution that doesn't use other window managers. All yabai would have to do is:

aspauldingcode commented 3 months ago

I have a working 3rd attempt. Leaving open for those who want this. It is a very nice feature that should already be there.

aspauldingcode commented 3 months ago

This is the functionality I was expecting:

https://github.com/koekeishiya/yabai/assets/10196826/e237b3ea-b6ed-469b-9f72-824b02b9f013

erezsh commented 1 month ago

I have a working 3rd attempt.

@aspauldingcode Where did you publish the attempt? Sorry, couldn't find a link

koekeishiya commented 1 month ago

When a window enters native fullscreen, it changes presentation mode which causes various changes to the window. This behaviour is not something that can be activated by yabai. It is special to the "native fullscreen-space" version.

I have added a command that ignores all configured padding (both padding and external_bar padding). yabai is not able to move the window into the Notch region or "into" the macOS menubar, so that space will always be reserved. It makes no sense to let the window extend into the Dock area either.

If Dock is hidden/has autohide enabled, yabai will extend the window across the Dock region. If the MacOS menubar is hidden/autohide enabled, yabai will attempt to place the window at the topmost coordinate (gated by the notch on newer macbooks).

This works for both managed and unmanaged windows.

yabai -m window --toggle windowed-fullscreen

aspauldingcode commented 1 month ago

yabai -m window --toggle windowed-fullscreen

Wow! I compiled from source and it works.

Thank you for working on this. However, the problem now is I can drag the window around with the mouse modifier.

We still need to implement a way to lock/disable mouse-modifier based on if a window is toggled on for a windowed-fullscreen.

I've done that by using statefiles in my scripts, then setting the at modifier to something ese like fn if I move over the active window. I used sketchybar to check events to calculate this more efficiently.

It would be great (for scripting purposes like this) if you added a new mouse modifier "none" which effectively disables it manually too.

Because right now, dragging a window which is meant to be an instant fullscreen is no longer fullscreen when moved around.

Maybe there could also be a check which sets a window flag to the current window, making sure if a window is-windowed-fullscreen true that the window stays windowed fullscreen until toggled off by the command.

erezsh commented 1 month ago

I got it to work too. But it looks just like the zoom-fullscreen feature. i.e. the title-bar is still visible and draggable.

koekeishiya commented 1 month ago

When a window enters native fullscreen, it changes presentation mode which causes various changes to the window. This behaviour is not something that can be activated by yabai. It is special to the "native fullscreen-space" version.