Recent

Author Topic: Form Positioning (Run & Design Time)  (Read 761 times)

Tony Stone

  • Sr. Member
  • ****
  • Posts: 267
Form Positioning (Run & Design Time)
« on: February 06, 2025, 03:53:23 am »
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  [Select][+][-]
  1. xrandr --output HDMI-0 --mode 3840x2160 --pos 0x2160 --primary
  2. xrandr --output DP-0 --mode 1920x2160 --pos 3840x2160
  3. xrandr --output DP-2 --mode 1920x2160 --pos 5760x2160
  4. xrandr --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

  • Jr. Member
  • **
  • Posts: 60
    • My site
Re: Form Positioning (Run & Design Time)
« Reply #1 on: February 06, 2025, 07:49:57 am »
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;

Tony Stone

  • Sr. Member
  • ****
  • Posts: 267
Re: Form Positioning (Run & Design Time)
« Reply #2 on: February 06, 2025, 02:42:14 pm »
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

  • Full Member
  • ***
  • Posts: 235
Re: Form Positioning (Run & Design Time)
« Reply #3 on: February 07, 2025, 01:58:16 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.

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...

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.

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

  • Full Member
  • ***
  • Posts: 235
Re: Form Positioning (Run & Design Time)
« Reply #4 on: February 07, 2025, 02:04:03 am »
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.

n7800

  • Full Member
  • ***
  • Posts: 235
Re: Form Positioning (Run & Design Time)
« Reply #5 on: February 07, 2025, 02:08:00 am »
I think that the most possible and correct solution (doesn't interfere with the previous one) is to set the Position property of the form to something defined (center) by default in new projects. That is, when the user clicks Project > New Project.

Then it won't affect old projects and will improve new ones. For me, a centered form has always been the expected option. The poDefault option also seems correct (WinAPI even allows to pass the desired coordinates to the process when creating it). Perhaps window managers can use it too.

Probably, I will even create a issue on the bug tracker.

n7800

  • Full Member
  • ***
  • Posts: 235
Re: Form Positioning (Run & Design Time)
« Reply #6 on: February 07, 2025, 02:09:42 am »
By the way, there are no problems at all during development if you use the "DockedFormEditor" package. The form editor is always pinned to the Source Editor. And it even allows you to scroll a very large form. I think you will find it useful.

Tony Stone

  • Sr. Member
  • ****
  • Posts: 267
Re: Form Positioning (Run & Design Time)
« Reply #7 on: February 07, 2025, 03:28:03 am »
I have tried the Docked Form Editor.  For some reason I just don't like it all that much(personal preference, no complaint with the feature itself).  But you are correct, during design and sharing my projects with my friends this would not be an issue ever.  Or even sharing my own projects to my self where I only have one monitor at work.

Like I said I really am not hoping to make a big issue out of something that only bothers me.  I am reading through your posts one mroe time though as you made some good points.

By the way, there are no problems at all during development if you use the "DockedFormEditor" package. The form editor is always pinned to the Source Editor. And it even allows you to scroll a very large form. I think you will find it useful.

 

TinyPortal © 2005-2018