-
Notifications
You must be signed in to change notification settings - Fork 6
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
Hotkey to force restore #5
Comments
Hi, lets think this through first. Can you list the steps how you would like to restore windows? Currently all window positions are saved whenever a monitor is plugged in/out. After that, restore the windows from a previous session with less/more monitors. I am not sure if it would help to manually trigger a restore-windows-function. 'Cause at this point either the wrong positions are already saved, or the restore did actually restore the windows. Do you want a “save” as well as “restore” hotkey? – or to put it differently: how do you think a manual restore will help you? vs. automatically triggering the same action as soon as the monitor count changes? |
DisplayMaid works the next way: you save your windows position (for every space) and then you can restore the state using hotkey combination on every space. That was the main idea. I'm still not able to understand how memmon works with spaces. I'm on space 2, disconnect ex. display, switch to space 3, then connect display, it restores nothing. As soon as I switch to space 1 it restores windows properly. Switch to space 2 or 3 again - nothing happens. Should it restore windows automatically for every space as soon as I switch to them? |
Yes, it should work exactly that way. Memmon should save the stat of all windows of all spaces as soon as you unplug or attach a new monitor. But it will only restore the windows of a space as soon as you navigate to that space (limitations of AXUIElement). This is also what DisplayMaid says: "Display Maid can’t save or restore positions for windows that are not in the currently active space. This is because there isn't currently a way provided to interact with windows that are in hidden spaces. " But, Memmon should indeed restore the windows once you visit a space. Can you check whether all windows are "forgotten" or if it happens only to specific apps? I noticed that Firefox / Chrome may have issues with restoring the windows. But Finder windows should work fine. |
This is about all windows. Btw, do you use separate spaces per display? |
As of now I have no access to an external monitor. So I can't really debug what is going on. What do you mean with seperate spaces per display? If you use spaces, each display will have the same number of spaces. Or in other words, each space has as many display as are connected. During my testing a few months ago I had a setup with one external display and my internal Macbook display. I would place my windows, with the display attached, in two spaces. Then I detach the external display and all the windows get moved to the internal display. I also tested what happens if I switch between spaces at this stage and after the next stage. Next, I reattach the display and the windows of the current space get re-set again to their original position. If I switch to another space, the windows do get re-set there too. However it took one or two seconds before macOS got the notification that a space-change was performed (always a little shock fearing it wouldnt fix it). |
You can try this snippet out to see if a manual restore will help: self.statusItem.menu!.addItem(withTitle: "Restore Now", action: #selector(self.testme), keyEquivalent: "r")
@objc func testme() {
let spaceWinNums = self.getWinIds()
for (pid, bounds) in self.state[self.numScreens] ?? [:] {
self.setWindowSizes(pid, bounds.filter{ spaceWinNums.contains($0.0) })
}
} Put the first line e.g., after line 41 in You can run the script with The hotkey will only work when the status menu is open but for testing purposes it suffices. If that helps, we can talk about adding a global hotkey ... that is too much trouble for now. |
Ah, oh! Yeah, I can imagine that my space enumeration hack may not work with this option enabled, though I am not sure. I will have to test it once I get my hands on an external display again. If the manual restore works, then it is only a notification issue. If not, I'll have to dig into the space detection algorithm. Keep me posted on your result 👍 |
I've tried to run modified app but it stopped work at all. |
ah, yeah, you'll need to add Terminal (or whatever app you are using to run the script) to "System Preference" > "Security & Privacy" > "Accessibility". |
I've already done it. Still no luck. |
Hello! Thank you for the great app!
It would be very helpful if I was able to use some keys combination to trigger restoring. That would partially resolve issue related to spaces.
The text was updated successfully, but these errors were encountered: