Forum > Suggestions
Form Positioning (Run & Design Time)
Tony Stone:
I wanted to share some thoughts on form positioning in Lazarus and see what others think about potential improvements.
My Development Setup and The Issue:
I develop on a Linux Mint Cinnamon desktop with a multi-monitor setup. My primary development display is positioned far to the left and below a much larger monitor. Because of this, my form positions often get saved with high Top values (e.g., 3200), due to the layout:
Layout:
--- Code: Bash [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---xrandr --output HDMI-0 --mode 3840x2160 --pos 0x2160 --primaryxrandr --output DP-0 --mode 1920x2160 --pos 3840x2160xrandr --output DP-2 --mode 1920x2160 --pos 5760x2160xrandr --output DP-4 --mode 3840x2160 --pos 1920x0
This isn't an issue during development for me, but when I publish or share my project, the forms often appear off-screen for others. Lazarus has the "Publish Project" feature, and I wonder if it would be useful to include an option that resets all form Top and Left values to 0, ensuring visibility on most configurations.
I've experimented with different TPosition settings, such as:
poDesigned, poDefault, poScreenCenter, poDesktopCenter, poWorkAreaCenter
However, in my GTK2 projects, these settings are not always respected. I’ve also had unpredictable behavior with some of them in the past (I’ll bring that up in another post later). Even if these settings worked perfectly, they wouldn't help if someone opens my project in Lazarus and can't see the form because it’s off-screen. And because of the weird issues i often leave it in poDesigned but because of this I often end up sharing executables with friends and they quickly let me know "HEY WE CAN'T SEE A WINDOW!"
As fore design time, experienced users know to check Top and Left or use the "Center Lost Window" feature, I’ve had issues with that in the past (especially on a Windows laptop). I believe those were addressed, but overall, form positioning still feels clunky at times.
I’d love to hear others' thoughts, but here are a couple of ideas:
When opening a project, if Lazarus detects that a form is positioned outside the visible screen area, it could prompt the user with an option to center it on their active display.
An additional option in "Publish Project" to reset form positions (Top=0, Left=0) so shared projects always start in a visible location.
This has been frustrating enough times that I felt it was worth discussing. I’d love to hear how others handle this issue or if there’s a better approach. Maybe I just need to adjust my workflow or habits, but if a simple fix could improve Lazarus itself, I’d be happy to try implementing it myself to avoid taking up developers’ time.
I’ve attached a screenshot of my display layout, which shows how my primary display is positioned well below where most people’s displays bottoms are. I don’t know if my setup is very unusual, but I doubt I’m the only one with an arrangement like this.
One other thing I keep considering should be an option is for the form to open in the center of the display where the mouse positions currently is positioned. Thunderbird works like this, it will open on whatever display has your mouse. I also implemented this myself in a couple of my programs because I had a couple friends I made programs for who kept yelling at me for not having a form in their viewable display.
Looking forward to any suggestions or thoughts!
AmatCoder:
1) Do not distribute binaries with poDesigned as position.
2) If poDefault, poScreenCenter or poDesktopCenter has unpredictable behavior with the same window manager is just a bug in Lazarus.
3) On Linux, you can't guarantee the position due to the different window managers. From GTK2 documentation:
--- Quote ---gtk_window_move ()
Asks the window manager to move window to the given position. Window managers are free to ignore this;
--- End quote ---
Tony Stone:
Yeah like I said there is unpredictable window behavior such as a continuously growing form if you set a form postion off screen which has something to do with window snapping that is in Cinnamon now. I didn't really want to make this a discussion about those issues though. I am just thinking that window positioning seems a bit clunky at times and I think some of it can probably be improved by the IDE itself. Maybe even a notice that the window you just focused is off screen and a yes/no dialog that asks to center it on the current screen would be a huge improvement for just the IDE side of things. On first though. But I imagine maybe there is a possibility where we may want a window to be off screen?
And as far as Window positioning for my distributed binaries I think I am gonna come up with my own reusable code for all of my projects so my forms my programs will never open off screen and I think I am gonna stick with the aproach used by Thunderbird where it will open on the display that has the mouse.
Am I wrong though, is there no way to improve the IDE and it is NOT clunky and just my opinion? Or does anyone else get the feeling of clunkiness with window positions ever?
n7800:
--- Quote from: Tony Stone on February 06, 2025, 03:53:23 am ---Lazarus has the "Publish Project" feature, and I wonder if it would be useful to include an option that resets all form Top and Left values to 0, ensuring visibility on most configurations.
--- End quote ---
Then when you open the project, the form will cover the menu and the IDE toolbar. Or, on the contrary, it will hide behind it, and you will still have to drag it with the mouse.
In addition, this will change the Left/Top properties of the form, and when launched application, it will open in the very corner.
It will then be more logical for the publishing functions to simply change the Position:=poWorkAreaCenter property or another...
--- Quote from: Tony Stone on February 06, 2025, 03:53:23 am ---When opening a project, if Lazarus detects that a form is positioned outside the visible screen area, it could prompt the user with an option to center it on their active display.
--- End quote ---
A project can have a lot of forms (open units). When opening a project, a lot of confirmations may appear for each window at once. Even if they appear only when opening a form, this will not allow you to simply press [Ctrl+Tab] to scroll through the tabs.
What's worse is that if the user wants to save Left/Top, then these questions will be displayed every time the project is opened...
Extra questions should be avoided, perhaps the user did not want to edit forms at all. Or even launched the IDE to open another project (and when launched, the last one opened).
n7800:
I think it's easier to "silently" move the form within the screen when opening it. But the problem is that this will change its coordinates. And even simply opening and closing the project (with saving) will change it. But usually they don't matter unless they are too small (0;0) or too large (off-screen). So as a disableable option, this might be a reasonable option.
I don't know what to do if there are several monitors... But it's obvious that the form should move so that it is visible on at least one of them.
Navigation
[0] Message Index
[#] Next page