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

Feature: Remember Windows Position #1158

Open
SyntaxDreamer opened this issue Dec 11, 2024 · 7 comments
Open

Feature: Remember Windows Position #1158

SyntaxDreamer opened this issue Dec 11, 2024 · 7 comments
Assignees
Labels

Comments

@SyntaxDreamer
Copy link

I have 5 displays, with a DisplayLink Dock.

When I open the MarkdownMonster, it always opens it by default on the monitor that is set as the main (default) one on Windows 11.

It would be nice if it would remember the windows position and monitor like other applications. For example, if I moved it to monitor 3 and close it, it should then always open on monitor 3.

The same should be true for the window used by the external preview option.

Most Windows applications do this by default for years. They remember where it was last opened, that means monitor, and even position, if in case it was resized.

@RickStrahl
Copy link
Owner

RickStrahl commented Dec 11, 2024

Whoa 5 monitors? Yikes.

Well, MM does this for my setup with 2 monitors. I open MM on a secondary monitor shut down and it comes back up on the secondary monitor. I suspect there's an edge case here with 5 monitors where the virtual space is too far out where the monitor gets moved. The default is 10,000 pixels so I suspect it lies outside of it.

How are your monitors laid out and how big are they? Can you try using a monitor that is most 'adjacent' to your main monitor - and thus more likely to be within a more limited pixel range - and see if that works?

MM basically uses a virtualized desktop space - all monitors are mapped into that pixel space and the shutdown location is remembered. If the location is outside of dimensions when MM starts back up it will pull the monitor back onto the main screen
and size it to fit. I suspect that the latter is somehow getting triggered in your scenario.

Another related issue is if the Window is maximized on another screen - it looks like there's a bug that when that's the case the position is not correctly remembered as it restores maximized onto the main screen.

I'll take a look and review the algo for this - I bet there's some outer limit that is triggering the move back to the main desktop.

@RickStrahl RickStrahl self-assigned this Dec 11, 2024
@RickStrahl RickStrahl added the bug label Dec 11, 2024
@RickStrahl
Copy link
Owner

I've added a fix for the Maximized window positioning. Maximized windows should now remember their position and come back on the monitor they were last run on (assuming the screen layouts stay the same).

v3.5.6.2

@RickStrahl
Copy link
Owner

Incidentally this patch also fixes a related issue where the window in some cases double positions and appears to bounce around - specifically in Maximized modes but also when relocating to other screens.

This update should snap windows into the right place exactly once (as it should be) in all situations.

@SyntaxDreamer
Copy link
Author

Seems related to presentation mode. See #1155

@RickStrahl
Copy link
Owner

Reporsted from #1155 to keep the thread focused

Sorry, was busy. Downloaded latest version 3.5.6.2.

Good news. The copy error is gone. Fixed.

The bad news. The windows/monitor position is now worse than before.

Before:
It was always launching the application on my main monitor.

After:
Now it's launching it split between 2 monitors, offset, only a little part of the bottom is visible, the other parts are offset from the view port. I just move them and maximize, hitting windows shortcut keys, but for someone who does not know the shortcuts on Windows they will be stuck without being able to select the application and drag it back with their cursor. This can be very frustrating for some people if an application goes offset, and it's not visible.

The way I open it:

I just open a markdown file, I set .md files to use Markdown Monster as default. In the settings I have the checkbox option enabled 'Open in Presentation Mode' because I mostly want to open files to read them first, as documentation by default.

I decided to test this with the setting off. And then it seems to work. It seems to remember the monitor, and it opens the applications correctly. I then check the setting again, and it goes off-screen once more, between 2 monitors (none of which are the one I actually set before).

It seems to be isolated to when Presentation Mode is turned on.

The JSON after closing the app (with Presentation Mode checked)

  "WindowPosition": {
    "Top": 1080,
    "Left": 516,
    "Width": 1050,
    "Height": 690,
    "InternalPreviewWidth": 883,

I think you just need to look into Presentation Mode, I will turn it off for now, not a big deal, but at least we know where the bug is 😊

@RickStrahl
Copy link
Owner

Confirmed. I see different behavior than you, but it's definitely not right.

On my machine with Open in Presentation Mode checked, if I close the monitor on my second monitor, it'll reopen in what seems like a random position on my main monitor which is very odd.

I'll have to take a look and see.

Presentation mode on startup is tricky due to timing of the document loading and I think the hacks around waiting for the document to be available are causing this weird behavior.

Taking a look...

@RickStrahl
Copy link
Owner

RickStrahl commented Dec 16, 2024

Give 3.6.7.2+ a try - it should have the presentation mode issue fixed.

As suspected this was a timing issue with the notification bit getting fired before the window had properly positioned itself and then wrote out the wrong values to the configuration, which threw off the resizing.

The solution is to do the presentation mode activation after the window has completed loading. This will make the startup a little janky as the window adjusts after it becomes visible, but it ensures that mode behaves correct and it only occurs on startup when presentation mode is explicitly requested on startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants