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

Notepad++ opes on non existing screen #15150

Open
1 task done
stefanino-ch opened this issue May 17, 2024 · 10 comments
Open
1 task done

Notepad++ opes on non existing screen #15150

stefanino-ch opened this issue May 17, 2024 · 10 comments

Comments

@stefanino-ch
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Description of the Issue

OS: Windows, current version.

Notepad++ installed on laptop.
Laptop is used in two different setups (not all of my workplaces are equipped with the same HW)

  1. with Laptop screen plus ONE external monitor
  2. with Laptop screen and TWO external monitors

If Notepad++ is used in setup 2 on monitor 2 it remembers this position.
After switching (even after a reboot) to setup 1, notepad++ still opens on the not existing screen 2 which is not available. Therefore Notepad++ is not utilizable until switching back to setup 2, and moving it back to the Laptop screen or screen 1.

Steps To Reproduce

  1. Laptop and two external screens. Open Notepad++ on 2nd external screen. Close Notepad++.
  2. Shutdown Laptop
  3. Disconnect external screen 2.
  4. Start Laptop, open Notepad++-> Icon in the taskbar is displayed, but the window itself is not accessible

Current Behavior

Window is somethimes not available, depending on setup changes (number of external monitors) and on what monitor Notepad++ was last used.

Expected Behavior

At start check if intitial coordinates of the window are within the viewable range.
If this is not the case, change inital coordinates to make sure window is displayed.

Debug Information

na

Anything else?

No response

@molsonkiko
Copy link
Contributor

molsonkiko commented May 25, 2024

Going forward, please paste in your Debug Information, using ?->Debug Info... from the Notepad++ main menu. It helps us help you.

I think you should be able to fix this issue by doing the following steps:

  1. Close Notepad++. This procedure can't be done while it is open.

  2. Using a text editor other than Notepad++ (like Notepad), open your config.xml file. If you have a normal "Program Files" installation, the path to this file is %AppData%/Roaming/Notepad++/config.xml. If you have a portable installation, this is in the same directory as the notepad++.exe executable.

  3. If you scroll down in this file, you will find an XML subtree that looks like this:

    <GUIConfigs>
            <GUIConfig name="ToolBar" visible="yes">standard</GUIConfig>
            <GUIConfig name="StatusBar">show</GUIConfig>
    ... there may be more elements here
            <GUIConfig name="AppPosition" x="601" y="252" width="942" height="718" isMaximized="no" />
    
  4. The element that starts with <GUIConfig name="AppPosition" is the one you want to edit, because this controls the position and size of the Notepad++ main window. Probably the best thing to do is to change the x and y attributes both to 0, so that the window will start at the top right corner of your main monitor. This element should look like <GUIConfig name="AppPosition" x="0" y="0" width="942" height="718" isMaximized="no" />

  5. Save the changes to the document in your other text editor.

  6. Reopen Notepad++. The window should be in the top right corner of your main monitor.

  7. If it is still not in the right position, repeat steps 1-6, changing the x and y attributes until it works.

There is probably an easier way to do this, using something like PowerShell instead of another text editor, but I'm not aware of it.

@alankilborn
Copy link
Contributor

I think you should be able to fix this issue by doing the following steps:
...7 steps...

The steps seem like they would work.
But...is it reasonable for the user to do these 7 steps the next time he gets into the situation, and the time after that, etc.?

@molsonkiko
Copy link
Contributor

molsonkiko commented May 25, 2024

@alankilborn

But...is it reasonable for the user to do these 7 steps the next time he gets into the situation, and the time after that, etc.?

No it's not, so something probably ought to be fixed.

I looks to me like the relevant code is here, so maybe this is some kind of weird bug with SetWindowPlacement. Unfortunately, my setup doesn't have any external monitors so I don't know how I could even replicate this bug, let alone fix it.

@alankilborn
Copy link
Contributor

It is indeed a strange situation. I used to have a laptop and a sometimes-connected-sometimes-not external screen situation, and Notepad++ never failed to appear on the laptop's screen at the right time.

Currently, although this doesn't involve Notepad++, I have a 4th monitor that I keep turned off via its switch but it is connected electronically. This monitor, though, seems to "be there", because when I move the mouse off to the right of monitor number 3, the mouse will move "into" this dark monitor. I'd think it shouldn't. I haven't investigated any further. Anyway, just an interesting thing...nothing to do with Notepad++.

@stefanino-ch
Copy link
Author

@alankilborn
First of all thank you for the replay.
Yes the 7 steps do help to get Notepad++ back on the screen, just hat to do them before.

From my days as SW developer I remember somehow a discussion about such an issue. What we did there was to ask the operating system about the "viewport size" and checked that at least some part of the window would be displayed within that size.
Not sure if this could be done with windows and c++....

@alankilborn
Copy link
Contributor

@stefanino-ch

Notepad++ already calls SetWindowPlacement which is supposed to handle such a situation, from the MS docs: "If the information specified in WINDOWPLACEMENT would result in a window that is completely off the screen, the system will automatically adjust the coordinates so that the window is visible, taking into account changes in screen resolution and multiple monitor configuration."

The bottom line is that it needs to be replicated (your problem) and then looked into.

@stefanino-ch
Copy link
Author

@alankilborn
Can I assist somehow in bug hunting?
I would not be able to setup a whole development environment on the laptop it happens, and additionally i was never a c++ developer. But executing test code should be doable....

@alankilborn
Copy link
Contributor

@stefanino-ch I will try replicating based on what I said HERE which may be similar to your setup.

@stefanino-ch
Copy link
Author

@alankilborn
My monitors are left from the laptop. Yesterday I had name="AppPosition" x="-1745".
Just an idea: does the check algorithm take into account also negative values correctly?

@alankilborn
Copy link
Contributor

@stefanino-ch

There really isn't a "check algorithm" in Notepad++. As I'm sure you can see from the code link @molsonkiko provided earlier, Notepad++ isn't doing much with the values, other than passing them on to a Windows function to do the placement of the main window.

Windows handles monitor coordinate systems in a "big rectangle" representing all of the "desktop". The upper left of your primary monitor (in your case your laptop screen) is coordinate (0,0) -- in an (x,y) sense -- and thus, if you have extra monitor(s) "placed" to the left of the laptop screen, a negative X value is reasonable and expected.

When it is convenient for me to be swapping hardware around, I'll try to replicate your reported problem.

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

No branches or pull requests

3 participants