Restoring positions after redocking does not work
- After redocking window positions and sizes are restored to one monitor
- All other monitors are empty
- Reading the config again does not fix it
Reading the config will not solve anything now. The app is now different. But I have tested it and it is very strange that it doesn't works for you. Could you be so gentle to run a special logging version to see your screen sizes and what the app is receiving in terms of internal Windows messages?
I don't have any Windows machine at home (I'm a Linux guy) and have to do this at work, but obviously I'm limited to my laptop and screens, and it works on mine so... I can't do more without help.
Thank you for your time and help!
Sure, just give me the link to the logging version.
I've created a branch to solve this issue: I0010-restoring-positions-doesnt-work You can find the logging binary there: bin
Sorry, I forgot to give instructions.
Just stop you current app, start this one in maximum screen size (two or more monitors), wait a second, undock, wait until you see the windows appear, dock and wait until windows are moved to their (theoretical) position (it should take a few seconds until Windows sends screen resolution change messages) and stop it. There should be a wm.log file: attach it here.
Again thank you for your help.
Well... I understand why it doesn't works for you. When you undock the screen size doesn't changes. I don't know why.
This is before undocking, 1920x1080
[../../src/window.hh:261] Receive WM_TIMER event.
[../../src/poshandler.cc:92] Getting current desktop windows.
[../../src/dev.hh:51] [dev] Screen: 1920, 1080
After undocking:
[../../src/window.hh:273] WM_DEVICECHAGE received!!!!
[../../src/window.hh:286] Message: DBT_DEVNODES_CHANGED
[../../src/window.hh:288] Screen size...
[../../src/dev.hh:51] [dev] Screen: 1920, 1080
[../../src/window.hh:290] New screen...
[../../src/dev.hh:51] [dev] Screen: 1920, 1080
[../../src/window.hh:292] Last screen...
[../../src/dev.hh:51] [dev] Screen: 1920, 1080
As you may see there is no resolution change: always 1920x1080. I'm going to investigate this on Google to see if there is someone who has find this very problem before and why is it caused.
Oh, this might me connected:
The screens are connected via a docking station. The screen settings in Windows show all three screens as connected but when I open Intels graphics settings I only see one screen. If I connect the screens directly with the laptop, without a docking station, I can see all screens in the windows settings and in the intel settings.
So you might need another way to access information about the screens.
Ok. I've found related windows info:
GetSystemMetrics(SM_CMONITORS) counts only visible display monitors. This is different from EnumDisplayMonitors, which enumerates both visible display monitors and invisible pseudo-monitors that are associated with mirroring drivers. An invisible pseudo-monitor is associated with a pseudo-device used to mirror application drawing for remoting or other purposes.
So I have to EnumDisplayMonitors and act upon that information. Let me some time (hopefully not much) to generate a new version.
Meanwhile, could you try the new version connecting the screens without the docking station? (Just to confirm the problem, not to take as a solution.)
Edit: sorry, will reupload in a second Sadly, did not work either...
wm.log Had to edit log due to containing sensitive information...
Ok, I've managed to reproduce the failure. I'm going to work on this. It may take some time as I can't work on this just now.
I've updated the loggin zip. Now it works in my laptop when:
- undocking, re-docking
- disabling one monitor through Windows "display settings"
Hope it works for you now. Tell me if it is OK or not.
Nope, sorry...
After undocking and redocking 2 monitors, still same behavior:
Also I now cannot open desktop overview anymore (WIN+TAB)... Restarting Explorer helped
I'm going to take the laptop at home and work on thins over the weekend.
Well... I am not going to hold you off :)
But I'll be able to test again on monday.
Another logging version uploaded. There should be no behavior changes, just more log. I've seen there are two ways to obtain the screen/s resolution. Let's check the second one.
This time most windows were restored (it took more time than in previous versions). Some windows were moved to other desktops and were not maximized. But they did not all stay on the same screen this time after redocking.
Could you please anonymize window names and app names in the next version? It takes quite some time to go through the logs and fix this.
Yes. Sorry for the anonymization. I should have thought about that before asking for help. Sorry.
Looking into the logs, it seems the resolution is: width: 5760, height: 1080. So the same resolution for every monitor: 1920x1080, but negative axis to position in different monitors:
[../../src/poshandler.cc:74] Adding window with class 'rctrl_renwnd32': , top 0, left -1548, right -74, bottom 862
Plus, there is a moment when there is only 3 monitors attached, and it reports 4:
[../../src/window.hh:262] Receive WM_TIMER event.
[../../src/dev.cc:7] get_ennum_windows called
[../../src/dev.cc:7] get_ennum_windows called
[../../src/dev.cc:7] get_ennum_windows called
[../../src/dev.hh:64] Metrics: width: 5760, height: 1080, right: 1920, bottom: 1080, monitors: 4
[../../src/dev.hh:70] [dev] Screen: 1920, 1080 (mon 4)
When screen size increments (3mon. => 4) I get the new positions. This fourth monitor must be a virtual one to draw or prepare to draw windows on it. Then, when I get the positions they are already for one monitor:
[../../src/poshandler.cc:74] Adding window with class 'rctrl_renwnd32': , top 0, left 434, right 1908, bottom 862
As you can see, the position isn't negative anymore. It was left -1548, right -74. So either Windows or the device driver is drawing window contents in a hidden memory buffer and after the draw, its bits are overwritten in the graphical card memory (or something in those lines.)
So I have to ignore the positions when... the system resolution is the same as the max resolution detected until now (5760x1080) and there are more monitors than there were when that resolution was first detected. Clearer: if I have 5760 with two monitors, I have to ignore positions when I have 5760 with three or more monitors.
Unfortunately I don't have a system doing those things with screen resolution and positioning, so I'm going to try several algorithms that may be activated by an app parameter to see if I can fix it.
I've uploaded a new version. It now takes in account not only the monitor count but also the virtual screen size (with all monitors.) I think this should work, so no parameters and one algorithm only. Cross your fingers! (Anonymized!)
Nope, sorry: wm.log
All windows are restored to one screen
[../../src/poshandler.cc:154] Can't set window placement for last window. [../../src/common.hh:176] Error: Ungültiges Fensterhandle
Means invalid window handle
Also, to make sure that we are on the same page: I talk about Desktops and Screens.
- By Screens I mean the actual monitor
- By Desktops I mean the Windows 10 feature that they stole from Linux where you can have several desktops and switch between them via shortcuts so you effectively have for example
3 monitors x 5 desktops = same space like having 15 monitors.
And there are two issues:
- Windows are restored to one screen
- Some windows change the desktop while being restored
We are currently trying to fix issue 1. https://github.com/manutalcual/winredock/issues/9 is issue 2.
Hi, I didn't have much time last week to develop this. Now I've changed the paradigm and taken another approach: I store in memory all windows in each desktop configuration. Before there was one desktop and I was trying to move around windows when the desktop resolution changed, but I was keeping one desktop configuration. Now I keep every desktop configuration and store all window positions for each desktop configuration. Its easier and in my computer it works like a charm. It has the advantage that it will keep window positions even when only using the laptop. Great!
Now the difference with your machine: your machine gives the resolution changes before the dock or undock messages (which they aren't, BTW, I will receive that message when there is a network change (e.g. wired to wifi)) so I have to do everything in three steps. I've tested those steps and they work, again, in my computer. Lets see if it works in yours!
Thank you.
Some windows were restored, some were not. Some windows changed desktops.
I'll be on vacation for a month so you can take your time :D
Another try to solve the issue. It works like a charm for me.
Hey, welcome back! I'm going to investigate.
Just fell over this handy utility after I for god-knows-what time redocked my Win10-Thinkpad-Onelink+ and had to re-sort all my windows. Unfortunately it doesn't seem to work for me. I downloaded the bin, extracted and ran. Tried clicking around with the get/save/read buttons both before and after redocking (several times) but nothing seems to happen. Don't know if I am missing a crucial step? Pity though, it's a good idea!!
Hi,
Try branch restoring-positions-doesnt-works or something like that. In that branch you don't need to use the menu, all is done automatically (when it works.) Unfortunately, Microsoft apps are more or less redundant to be handled by others, so they usually don't work. And as a shame, I don't have enough time to investigate or develop further this tool. It works for me but it doesn't give anything else to me and I have to pay the bills. Sorry.
Fair enough, I can understand that. No worries, I'll keep looking.