-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
fix: switching workspaces on secondary monitor #1128
base: master
Are you sure you want to change the base?
Conversation
I was just thinking about doing this last night! 😅 Will build this tonight when I'm back home, but I think it looks good 🤞 |
But this will break the fix that it is supposed to be doing! No matter if you have mff enabled or not when you have an empty workspace on one monitor, you are not able to focus it, since there is no container to focus, so you will never be able to change workspaces on that monitor. This code is made so that you can move your mouse there and be able to change workspaces. I thought about this before and I think we could add a new setting like This "mfm" should not be as annoying or intruding as the "mff" and could be set to true by default... |
Also this will create a new issue. Imagine two monitors with a bar on each monitor (komorebi-bar or YASB). Let's say there are multiple workspaces on both monitors, but currently both monitors have workspace with index 0 focused. You have a container focused on monitor 1, but now you want to change the workspace on monitor 2. You use the mouse to go to the bar on monitor 2 and press the button for a workspace (let's say it is workspace index 2), nothing happens on monitor 2 like you wanted, instead the change will happen on monitor 1 because it was the focused one. This is not the expected behavior at all, you don't want users to have to use a key bind to focus to another monitor to be able to use the mouse on the bar... |
unless i have been doing something wrong in my testing, this is false. i was able to focus an empty monitor by using alt+l/k and then use alt+0-9 to switch to a different workspace. regarding your second comment. this is indeed an issue. however i personally don't think just just having your mouse on a monitor warrants that monitor being the selected one. one idea i had was catching if the user clicks on the empty desktop and then setting the focus to that monitor. also is there a reason the bars don't specify a monitor when using those widgets? (considering focus-monitor-workspace exists) i will come back to this tomorrow |
This is a good call out, we have the monitor index in the bar config file and we should use this when interacting with the workspaces widget. |
I think it's worth focusing on reproducing this, tracking down any system settings that may be resulting in different behaviour for different users |
This commit follows up on a point made by @notTamion in #1128 - since we have the monitor index, we can use it in the bar's workspace widget to more accurately target workspaces via SocketMessage::FocusMonitorWorkspaceNumber.
is this not an intended feature? in my opinion it should be |
Here is how empty monitors should be treated like in my opinion: you should be able to select them by using hotkeys (the cli commands) or by clicking on the desktop so you can switch between workspaces, spawn new applications or do other operations on them. bar applications should be responsible for telling komorebi what monitor they want their operation to be done on instead of relying on komorebi focusing whatever the mouse is on right now (considering the cli commands state that they will apply the operation to the "focused window/container/workspace/window" and say nothing about them changing the focus) |
At this point I just want to understand what the factors are which lead to different behaviours for different people Komorebi has a long standing history of not changing system settings on behalf of the user, and this isn't going to change. However if there are some settings which can be set to provide a consistent experience with regards to this issue, we can document them and add the to the quickstart guide for users to opt in to. |
RE: Bar changes, they were implemented last night: 041ef57 |
just so i am understanding this correctly: you are not able to alt + l/k to focus an empty monitor? (it is a little "bugged" for me aswell as there isn't a border or anything to signal that its selected however then for example opening a new application puts it on that screen) |
Correct - I am not able to reliably spawn new application windows on a monitor with an empty workspace or change workspaces with |
fyi this is my config https://gist.github.com/notTamion/943f8568e03d1dc13bdd08dd6e2116c6 EDIT: more context: i believe this happens at window_manager:1630. here it focuses the monitor even if no container is on it |
Not all commands have variations that allow specifying monitor and workspace. Maybe one could argue that they should all have but that is not the point. The thing is there are some commands that work on the focused container/window and don't have an alternative to tell what monitor/workspace to act on. As an example you have the Again maybe the solution is to add alternative commands for the ones that need it which lets you specify the monitor and workspace. EDIT: Ok, now that I've taken a closer look I see that you didn't change the implementation for the command I mentioned above. Also that command seems to be the only one along with the ones you've changed that use that "hack". However
So basically only one of those commands actually has an alternative for bars or others to use... |
so for some applications it will spawn the application on the correct screen and for some it won't for example terminal will always spawn on the same monitor regardless of what you have focused, brave will always spawn on the monitor you have focused. this also happens when both your monitors aren't empty |
@alex-ds13
Obviously 1. is the easier option however that way we don't only screw people that use that setup, we also have commands which state that they affect the focused monitor/workspace etc. when in reality they use the mouse position (and in my opinion the correct way to use a tiling wm is with hotkeys and not the mouse) |
I agree with you. I too find it annoying sometimes when I used my mouse to do something on another monitor, then change focus with the keyboard and my commands after that act on the other monitor. I think option 2 would be the best, but there is still the issue that some users can't focus an empty workspace. That is why I was proposing a 3rd option where we would add a new config named |
@LGUG2Z From what I can see the issue where some users can't focus an empty workspace is cause by the lines that this PR is trying to fix. Because if you have monitor 1 focused and monitor 2 workspace is empty, when you try to move in the direction of monitor 2 to focus the monitor, komorebi is actually focusing that monitor, but since the mouse doesn't move there, then if you try to use a command to focus another workspace thinking you'll change workspace on monitor 2, since it detects that the mouse is on monitor 1 it refocus monitor 1 first and then applies the command. With this PR, if you have If we remove those lines entirely then you will be able to change focus to another monitor even when its workspace is empty! And any command you call next is handled on that monitor you just focused. Also with this approach there is no way of knowing that you just focused another monitor (when it's workspace is empty) so some users might be changing focus between windows, accidentally move to the other monitor without noticing it and then the next focus commands don't do anything unless they are in the direction of the previous monitor. Although this the same behavior that happens now anyway. In summary to me these are the best options:
|
the problem with solution 3 is that it doesn't actually fix the problem but instead just hides it behind a config option: i like 1. and 2. the most This is how i would do it:
@LGUG2Z opinion? |
What exactly do you mean with "adding a border when its selected"? A border to the monitor?
I wouldn't change the default to off, but instead I would change the quickstart config example to have this config there with the value off. This way there would never be a breaking change for anyone ever. And new users would get this working as expected from the get go when they run But yeah this now is a matter of what does @LGUG2Z prefer... BTW @LGUG2Z, why is this code here: WindowsApi::center_cursor_in_rect(&WindowsApi::window_rect(
window.hwnd,
)?)?; Why are we centering the cursor on the target monitor when we move focus across monitors and the target monitor has a monocled window? Shouldn't this be done only if the user had mff? |
Yeah like a Border around the work area, well more like inside the work area but the exact design can be tinkered on later |
There is a lot for me to catch up on here and realistically I'm not going to be able to get back to this in any meaningful capacity until next week. Some high level thoughts:
|
this is something i have been meaning to ask about. why aren't you just adding flags instead of adding a new subcommand for everything? i have only used clap once before but iirc this is something it supports |
If this is the case, then why were these lines added in the first place? I'm talking about these: // This is to ensure that even on an empty workspace on a secondary monitor, the
// secondary monitor where the cursor is focused will be used as the target for
// the workspace switch op
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
self.focus_monitor(monitor_idx)?;
} Because it seems to me, from what I've tested, that if these lines were removed then you would be able to focus an empty workspace on a secondary monitor by using something like When you have the time, try removing those lines completely and check the resulting behavior. I think you'll see it is the same behavior you have now as expected with the only difference that if you want to act on another monitor you first need to move focus there with the keyboard instead of with the mouse... |
i am not sure whether this is possible but: if we are able to catch moues clicks before the bar applications then we might be able to focus the clicked monitor and then the operations will be done on the correct monitor |
3e61a79
to
d3fdf2c
Compare
ed96b54
to
e6ddccc
Compare
If i understood the reason for this "re-focus" correctly this should be the proper fix for the problem. When having mouse follows focus disabled and trying to switch the workspace on another monitor by first switching focus to that monitor and then changing workspace it doesn't matter which monitor you have focused as it will automatically focus the monitor your cursor is on