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

[BUG]: Windows in native fullscreen minimise when switching workspaces #1191

Open
flipfloppy1 opened this issue Dec 19, 2024 · 6 comments
Open
Labels
bug Something isn't working

Comments

@flipfloppy1
Copy link

Summary

Windows in native fullscreen mode minimise when switching between workspaces. The behaviour I would expect is that the workspace maintains the state it was left in (as is the case in i3/sway), hence ensuring the window is maximised when the user returns to the workspace that had the maximised window.

This has happened with apps using many different graphics frameworks for window handling (SDL, GLFW, Unity, etc.) which is why I assume it's an issue with komorebi.

I run komorebi with administrator privileges so it can manage almost all windows, but the issue happens whether it's run in administrator mode or not. I've tried changing the window_hiding_behaviour to hide and minimize but both of them exhibit the same behaviour.

This is tangentially related to #805 and the workaround I mentioned there

Version Information

OS Name: Microsoft Windows 11 Pro
OS Version: 10.0.22631 N/A Build 22631

komorebic 0.1.31
tag:v0.1.31
commit_hash:40c55dec
build_time:2024-12-14 00:54:06 +00:00
build_env:rustc 1.83.0 (90b35a623 2024-11-26),stable-x86_64-pc-windows-msvc

Komorebi Configuration

{
  "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.30/schema.json",
  "window_hiding_behaviour": "Cloak",
  "app_specific_configuration_path": "$Env:USERPROFILE/applications.json",
  "cross_monitor_move_behaviour": "Insert",
  "default_workspace_padding": 1,
  "default_container_padding": 1,
  "border": true,
  "border_width": 1,
  "border_offset": 0,
  "theme": {
    "palette": "Base16",
    "name": "Ashes",
    "unfocused_border": "Base03",
    "bar_accent": "Base0D"
  },
  "stackbar": {
    "height": 20,
    "mode": "OnStack",
    "tabs": {
      "width": 200
    }
  },
  "ignore_rules": [
    {
      "kind": "Title",
      "id": "Default IME",
      "matching_strategy": "Equals"
    },
    {
      "kind": "Title",
      "id": "MSCTFIME UI",
      "matching_strategy": "Equals"
    },
    {
      "kind": "Title",
      "id": "Output Timer",
      "matching_strategy": "Equals"
    },
    {
      "kind": "Title",
      "id": "WebSocket Server Settings",
      "matching_strategy": "Equals"
    },
    {
      "kind": "Title",
      "id": "Stats",
      "matching_strategy": "Equals"
    }
  ]

}

Hotkey Configuration

#Requires AutoHotkey v2.0.2
#SingleInstance Force

Komorebic(cmd) {
RunWait(format("komorebic.exe {}", cmd), , "Hide")
}

#+q::Komorebic("close")
#m::Komorebic("minimize")

; Focus windows
#h::Komorebic("focus left")
#j::Komorebic("focus down")
#k::Komorebic("focus up")
#l::Komorebic("focus right")

#+[::Komorebic("cycle-focus previous")
#+]::Komorebic("cycle-focus next")

; Move windows
#+h::Komorebic("move left")
#+j::Komorebic("move down")
#+k::Komorebic("move up")
#+l::Komorebic("move right")

; Stack windows
#Left::Komorebic("stack left")
#Down::Komorebic("stack down")
#Up::Komorebic("stack up")
#Right::Komorebic("stack right")
#;::Komorebic("unstack")
#[::Komorebic("cycle-stack previous")
#]::Komorebic("cycle-stack next")

; Resize
#=::Komorebic("resize-axis horizontal increase")
#-::Komorebic("resize-axis horizontal decrease")
#+=::Komorebic("resize-axis vertical increase")
#+_::Komorebic("resize-axis vertical decrease")

; Manipulate windows
#+Space::Komorebic("toggle-float")
#Space::

#f::
{
Komorebic("toggle-maximize")
}

; Window manager options
#+r::Komorebic("retile")
#p::Komorebic("toggle-pause")

; Create windows
#Enter::Run "wt"
#c::Run "chrome"
#e::Run "devenv"
#d::!Space

; Layouts
#x::Komorebic("flip-layout horizontal")
#y::Komorebic("flip-layout vertical")

; Workspaces
#1::Komorebic("focus-workspace 0")
#2::Komorebic("focus-workspace 1")
#3::Komorebic("focus-workspace 2")
#4::Komorebic("focus-workspace 3")
#5::Komorebic("focus-workspace 4")
#6::Komorebic("focus-workspace 5")
#7::Komorebic("focus-workspace 6")
#8::Komorebic("focus-workspace 7")

; Move windows across workspaces
#+1::Komorebic("move-to-workspace 0")
#+2::Komorebic("move-to-workspace 1")
#+3::Komorebic("move-to-workspace 2")
#+4::Komorebic("move-to-workspace 3")
#+5::Komorebic("move-to-workspace 4")
#+6::Komorebic("move-to-workspace 5")
#+7::Komorebic("move-to-workspace 6")
#+8::Komorebic("move-to-workspace 7")

Output of komorebic check

No KOMOREBI_CONFIG_HOME detected, defaulting to %USERPROFILE%

Looking for configuration files in %USERPROFILE%

Found komorebi.json; this file can be passed to the start command with the --config flag

No ~/.config/whkdrc found; you may not be able to control komorebi with your keyboard

@flipfloppy1 flipfloppy1 added the bug Something isn't working label Dec 19, 2024
@alex-ds13
Copy link
Contributor

alex-ds13 commented Dec 19, 2024

If you set a window to maximize by using the command komorebic toggle-maximize then komorebi will know about it and will keep the window maximized when you move back to that workspace. If you however maximize the window by any other means (like pressing the maximize button) then komorebi won't know the window is actually maximized and will tile it again when you move back to the workspace.

Also is that really your komorebi configuration? Because you don't have any "monitors": with any "workspaces": set and you are talking about moving between workspaces...

Another thing, this part from your AHK config seems weird, I don't know anything about AHK so it might be ok though:

; Manipulate windows
#+Space::Komorebic("toggle-float")
#Space::

#f::
{
Komorebic("toggle-maximize")
}

#Space:: doesn't have anything to run apparently and #f has the command between {}, I don't know if that is normal or not...

EDIT: Ok apparently that is for having multiple hotkeys do the same action, so both #Space and #f will do the same... TIL 😄

@flipfloppy1
Copy link
Author

If you set a window to maximize by using the command komorebic toggle-maximize then komorebi will know about it and will keep the window maximized when you move back to that workspace. If you however maximize the window by any other means (like pressing the maximize button) then komorebi won't know the window is actually maximized and will tile it again when you move back to the workspace.

I understand using komorebi's toggle-maximise is a workaround for this, but the title bar of the window still shows when maximising the window that way. Sorry I didn’t make this clear in the bug report 😅

Also is that really your komorebi configuration? Because you don't have any "monitors": with any "workspaces": set and you are talking about moving between workspaces...

I only have one monitor, so I’m not sure if the monitor configuration is required. Either way, switching workspaces works as I would expect.

@LGUG2Z
Copy link
Owner

LGUG2Z commented Dec 20, 2024

Windows does not emit an event when an application goes into or leaves fullscreen mode (usually with F11) - if this is important to you, you should open a ticket with Microsoft if you are a paying customer of Windows.

The lack of events means that there is nothing for komorebi (or any other window manager) to respond to.

The same is true when maximizing and restoring a window, however in that case we manually track the state if the user triggers maximization via komorebic. I believe we could follow a similar approach and implement a toggle-full-screen command which will manually track this window state.

I don't think this is something that I'll personally work on but I'm happy to consider and provide guidance/feedback on PRs.

On a high level:

  • Do whatever gets done with maximized windows in the Workspace state:

    maximized_window: Option<Window>,

  • Figure out the win32 API calls to toggle this window mode in the same way that F11 does

  • Write safe wrappers for those calls in windows_api.rs and call them

  • Add a ToggleFullScreen SocketMessage, handle it in process_command.rs

  • Add a komorebic command to allow emitting the new message via the terminal and a keybind

@flipfloppy1
Copy link
Author

If Windows doesn’t provide any events for this it may be easier to have removing the title bar configurable via applications.json or komorebi.json as per #805, since removing the title bar and running komorebic toggle-maximize is graphically identical to F11 in most cases.

@LGUG2Z
Copy link
Owner

LGUG2Z commented Dec 20, 2024

For now there is an imperative way to add identifiers for this use case; I don't know off the top of my head if this allowlist can take the full range of matchers that would be required to add it to the JSON config, but we can probably get that in for the next release.

❯ komorebic remove-title-bar
Whitelist an application for title bar removal

Usage: komorebic.exe remove-title-bar <IDENTIFIER> <ID>

Arguments:
  <IDENTIFIER>  [possible values: exe, class, title, path]
  <ID>          Identifier as a string

@flipfloppy1
Copy link
Author

For now there is an imperative way to add identifiers for this use case; I don't know off the top of my head if this allowlist can take the full range of matchers that would be required to add it to the JSON config, but we can probably get that in for the next release.

That would be great! And thank you for the work that you do on this amazing WM. It's very nice to have a reliable tiling window manager in Windows.

IIRC, only the exe identifier works in komorebic remove-title-bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants