Closed efojug closed 10 months ago
Hello, thank you for the contribution!
That was the call I was planning to add yeah, though as it is right now this would actually override the window position the user has configured via their configuration file. I think it's probably fine to only set the window position if a position isn't set via the config file though. However, it probably wouldn't be a bad idea to double check that considering how some of the config loading logic is still a bit of a mess. A bit more tricky to solve though is that placing the call here places the top left corner of the window in the center of the screen instead of the center of the window. Probably changing the visibility and location after the window was reconfigured should work for that, but I'm not entirely sure that would always work.
I've updated the code so that the window is created so that the center of the window is centered to the screen, which shouldn't affect the application of the existing configuration file
Hey, this strategy looks like it should work fine.
Some comments:
PositionSettings#hasPosition
is true.setLocationRelativeTo(null)
like in your initial version, the only reason that did not work before was because there was nothing in the frame (since reconfigure adds the content). That method also properly handles the case where (0, 0) is not the top left of the display (as is the root cause of #94).CloseListener
), so we can probably just add the logic there (and probably rename the class to MainWindowListener
or something).It should be available now. :3
Hi, thanks for the quick update!
Sorry, but here are some more comments 😅
buildGUI
function runs the user passed position is already set, so there's no need to set it again.hasPosition
method to check if a position is present or not.buildGUI
function. If you changed that because of the 3rd point from my previous message, that was referring to not adding a second window listener and instead reusing the currently existing CloseListener (and possibly renaming it).Sorry, I misunderstood your previous reply. It should be working now.
Yep, that was the approach I was thinking of.
I made some minor changes and fixed a bug I introduced yesterday that caused the position to be set incorrectly... Note that the regular config handling already sets the position if one is present, so the window handler only needed to handle the case where the is no position. Also note that setLocationRelativeTo
is a more robust method so it's preferable over computing the location manually, and if you do compute it manually you need to add in the coordinates of the window because the primary display is not always at (0,0).
Anyway, thanks again for the contribution!
I'll merge this if you're fine with the changes I made.
Okay, thanks for the guidance.
Hmm. your tweaked code doesn't seem to set the default configuration window position correctly
The default position is set by the (moved to ConfigLoader
classMain#applyConfig
now), which is called from either the main dialog or the right click menu (the latter being why a window listener cannot set it correctly). There is a separate bug when it comes to loading CLI/default configurations though, which is the root cause behind #92, but I'll fix that one in a bit.
I'm going to merge this to prevent another merge conflict, but let me know if you can reproduce a case where a default position isn't applied correctly.
Set the kps window position to the center of the screen #94