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: unplugging a monitor #90

Open
TimUntersberger opened this issue Jul 28, 2020 · 6 comments · May be fixed by #293
Open

bug: unplugging a monitor #90

TimUntersberger opened this issue Jul 28, 2020 · 6 comments · May be fixed by #293
Assignees
Labels
bug Something isn't working difficulty: hard priority: medium medium priority
Milestone

Comments

@TimUntersberger
Copy link
Owner

TimUntersberger commented Jul 28, 2020

Description

@ramirezmike

So, my setup is a laptop plugged into a monitor and I keep the laptop screen on but use the monitor as my primary display. I also keep multi_monitor set to false as I like to keep my laptop screen essentially "pinned" with a chat program. When I unplug the monitor with a couple workspaces set up wwm keeps running and the workspaces just move over to the laptop screen, but they keep the same size as they were while on the monitor. There's also some weirdness with the taskbar/appbar but I can resolve that by just using those keybindings I added hah. I haven't tried to see what happens with multi_monitor set to true.

Detecting when a device gets removed is possible via the WM_DEVICECHANGE event. I am thinking about just listening to this event and then comparing the list of displays returned by the EnumDisplayMonitors and the ones currently saved.

Things to consider:

  • What happens when the primary display gets removed?
  • What happens when a display gets added (How does this influence the indices?)
  • What happens when a display gets added and it is the new primary display?
  • What happens when a display gets removed?

Ideas on how to solve this

What happens when the primary display gets removed

Add the workspaces to the new primary display.

What happens when a display gets removed

Move all of the workspaces on the removed display to the primary display.

What happens when a display gets added

This shouldn't really affect the existing displays. It will just be added to the current list.

What happens when a display gets added and it is the new primary display

All of the current displays should stay the same, but the current primary display and the new display swap places.

@ramirezmike
Copy link
Collaborator

This one can definitely use a bit of planning, I think.

Things to consider:

  • What happens when the primary display gets removed?

I think the program should find the new primary and move (combine?) all the workspaces there and maybe leave any additional workspaces on other monitors unaffected.

I think an additional wrinkle to think about on this one is what happens when a display gets added and it is the new primary display. That's how I have my laptop setup, for instance. Any monitor plugged into it turns into the primary display.

@TimUntersberger TimUntersberger self-assigned this Jul 30, 2020
@ramirezmike

This comment has been minimized.

@TimUntersberger

This comment has been minimized.

@TimUntersberger
Copy link
Owner Author

TimUntersberger commented Aug 24, 2020

I tried to implement a fix for this and already know when a monitor gets disconnected/connected. The problem is that it seems like the hmonitor ids change when you plug in a new monitor or remove one. I don't know whether this is possible. I'll push everything to multi-monitor-fix.

@fredizzimo
Copy link
Contributor

Hi,

I have been working on fixing this in this branch https://github.com/fredizzimo/nog/commits/dpi_scaling

It's almost ready, but I still have to fix a few issues and I also need to go through everything again and perhaps clean up some code, since this is the first time I'm writing rust and I have learned quite a bit during the process.

The logic I have chosen is quite simple, if the old monitor still exist, move the workspace there, otherwise move it to the default monitor, but this can of course be extended in the future. I currently don't handle the case when no monitor is connected, for that we would need either a virtual monitor, or exit the workmode. For me the hmonitor ids have been stable, even when I move monitors around from side to side, or when I change the resolution. But there are quite a few different functions for getting acutal device ids, which should be stable, so I will change it to that before sending the pull request. I did notice though that the taskbar position and size queries sometimes fails after monitor changes, but that does not matter, since a taskbar position even it sent afterwards, which corrects the situation.

Note that I originally did not plan to fix this, my original plan was to just fix #92, which I still had. But it turned out that in order to do that I had to properly enable per monitor DPI scaling. And that lead adding support for changing of dpi scaling and resolutions. Which lead me to handle changes to the task bar size and positions. And by that time multi-monitor handling was basically there, so I had to add that too.

It also automaticaly fixes the frame calculation for #207, without the need for any special cases.

Another thing that I noticed that it fixes, is the title bar texts of some programs, which previously permanently got really small when the window was moved to another monitor.

@TimUntersberger
Copy link
Owner Author

It's almost ready, but I still have to fix a few issues and I also need to go through everything again and perhaps clean up some code, since this is the first time I'm writing rust and I have learned quite a bit during the process.

Could you please open a draft PR?

Note that I originally did not plan to fix this, my original plan was to just fix #92, which I still had. But it turned out that in order to do that I had to properly enable per monitor DPI scaling. And that lead adding support for changing of dpi scaling and resolutions. Which lead me to handle changes to the task bar size and positions. And by that time multi-monitor handling was basically there, so I had to add that too.

😆

It also automaticaly fixes the frame calculation for #207, without the need for any special cases.

So special rules for chromium and firefox can be removed after your PR is merged?

Thank you for your hard work 🙏

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

Successfully merging a pull request may close this issue.

3 participants