Open stefanino-ch opened 1 month ago
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:
Close Notepad++. This procedure can't be done while it is open.
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.
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" />
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" />
Save the changes to the document in your other text editor.
Reopen Notepad++. The window should be in the top right corner of your main monitor.
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.
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.?
@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.
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++.
@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++....
@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.
@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....
@stefanino-ch I will try replicating based on what I said HERE which may be similar to your setup.
@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?
@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.
I tried this test:
N++ main window appears on the laptop (primary) monitor.
So, while I can't replicate the problem, I certainly believe a problem exists. But I'm not sure what to suggest as a fix, because I'm guessing that in certain situations it is Windows that is itself not doing the right thing when monitors are removed from a setup.
Perhaps someone else will have some insight on this issue.
Could you please also check where the search window is opening. I find this quite annoying that it does not follow the main window to another screen. If this odd behavior could be fixed along with this bug, I would not have to open another issue.
I found another related bug report by @DannyN358, though it is yet to be confirmed:
Note that there is a feature request by @stanpetit related to this bug report:
Shamelessly stealing the example:
<GUIConfig name="AppPosition" x="0" y="0" width="1366" height="768" isMaximized="yes" />
<GUIConfig name="FindWindowPosition" left="751" top="17" right="1340" bottom="381" isLessModeOn="no" />
Windows allows the use of multiple task bars and moves the app window to the respective monitor. I noticed that the window flashes up in the previous location for the fraction of a second.
EDIT: See https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15357#issuecomment-2191014637 about a proposed fix, though I could not confirm it:
Could you please also check where the search window is opening.
Totally separate and unrelated issue. Please don't pollute existing issues with unrelated stuff.
editing the config.xml fixed my issue. Thank you!
Is there an existing issue for this?
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)
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
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
Anything else?
No response