Recent

Author Topic: Setting the IDE's default launch location/display  (Read 1978 times)

Nel_Fie

  • Jr. Member
  • **
  • Posts: 53
Setting the IDE's default launch location/display
« on: September 26, 2024, 06:50:01 pm »
I'm not sure if this is the right place to ask, but anyway:

Is there a known way to set the default launch location and/or display for Lazarus as installed via FPCUpDeluxe, either through options, or by modifying some kind of config file, or some other way available on Ubuntu?

For context: I have a computer setup with three monitors, the primary of which is on DVI rather than HDMI. After recently reinstalling my NVIDIA graphics driver on Ubuntu 22.04 LTS, all my instances of Lazarus (installed via FPCUpDeluxe) up to 3.99 insist on launching on my secondary display (which is on HDMI) instead of the primary display as it used to.
Now this wouldn't be too much of a problem per se, except that a lot of sub-windows that launch intermittently during work also launch to the wrong display - including the all-important auto-completion form! So I'm currently in a situation where I basically can't use auto-complete as intended because the darn thing pops up on an entirely separate screen from the source editor.

A look through the installation files suggests to me that there's maybe a way to fix this by modifying files found in the "config_lazarus" folder, or maybe by modifying the .desktop file through which Lazarus is launched, but I wanted to ask if anyone already knows a solution before I waste my time poking around and modifying random parameters that I don't fully understand.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8135
Re: Setting the IDE's default launch location/display
« Reply #1 on: September 26, 2024, 07:26:52 pm »
I'm not sure you'll find that sort of thing in the .desktop file, and my own experience is that desktop environments tend to be a bit patchy as to how well they hew to what's specified in there. I also don't think that there'll be anything in the ~/.lazarus directory since that's really for the location of files (but I'd happily be corrected).

You might possibly find that it's in your project's .lps file: this can be safely deleted but I'd suggest starting with a clean project and seeing what happened.

Apart from that you might find that your desktop environment- whatever Ubuntu provides these days (I'm a Debian user, inclined towards KDE) has some sort of per-program override setting.

Are you using Wayland or X11? Can you swap to check the other's behaviour?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10692
  • Debugger - SynEdit - and more
    • wiki
Re: Setting the IDE's default launch location/display
« Reply #2 on: September 26, 2024, 08:55:33 pm »
Normally the IDE should remember the last location of each window. It has for me on multi monitor setups under Win and Fedora.

And the code-completion drop-down should follow the source editor...

Depending on OS handling (though I only know that for Win), if your screens have different DPI settings then there can be some weirdness. (I have only seen that for hints).

I would suggest to backup your config ~/.lazarus  and start with an empty one. Just to see if that helps.
if it does copy files back, until you know which one causes the issue.
- non-xml file can probably remain in the folder, but back them up anyway
- if you have packages installed your lazarus executable is in that folder too, and you want to keep it in there.

Nel_Fie

  • Jr. Member
  • **
  • Posts: 53
Re: Setting the IDE's default launch location/display
« Reply #3 on: September 27, 2024, 02:42:20 pm »
Thank you both for the replies.

I'm not sure you'll find that sort of thing in the .desktop file, and my own experience is that desktop environments tend to be a bit patchy as to how well they hew to what's specified in there. I also don't think that there'll be anything in the ~/.lazarus directory since that's really for the location of files (but I'd happily be corrected).

You might possibly find that it's in your project's .lps file: this can be safely deleted but I'd suggest starting with a clean project and seeing what happened.

Apart from that you might find that your desktop environment- whatever Ubuntu provides these days (I'm a Debian user, inclined towards KDE) has some sort of per-program override setting.

Are you using Wayland or X11? Can you swap to check the other's behaviour?

MarkMLl


Okay, good to know I can (hopefully) exclude the .desktop and Lazarus's home directory.

I'm pretty sure the .lps file is not at fault. For a start, even the splash screen pops up on the wrong screen, as well as the error handling form which showed up after following Martin_fr's suggestion of trying out with an empty config folder.
But more importantly, there seems to be something fundamentally "borked" with my installation of 3.99 because since the graphics driver update, it always starts with a new project, even though "open last project at launch" is toggled. This error does not occur with my instances of Lazarus 3.4 and 2.2.6, yet they also launch onto the wrong monitor. Regardless of version, they all do this when loading a project that I know for sure I had saved on the right monitor, so the storage in the .lps shouldn't be the issue, unless Lazarus performs some operation on the parameters in there when loading the file.

I've looked into per-program overrides for launch location for Ubuntu, but couldn't find anything yet - and I'm not sure if it would apply to the FPCUpDeluxe installation of Lazarus? I'm a dilettante, but from what I can tell, it seems to be portable and self-contained, unlike a version installed through a .deb file or something like that...

I'm on X11, but I've given Wayland a quick test. The same error occurs.
However, something else happened: it did not apply my display settings from X11, and re-set the HDMI monitor as the primary display - exactly that one to which Lazarus now obsessively launches. Maybe there's an issue with my monitors and/or how Ubuntu stores my display configuration? Is there a way to basically wipe or reset that to zero, and re-register all display devices from scratch?

Normally the IDE should remember the last location of each window. It has for me on multi monitor setups under Win and Fedora.

And the code-completion drop-down should follow the source editor...

Depending on OS handling (though I only know that for Win), if your screens have different DPI settings then there can be some weirdness. (I have only seen that for hints).

I would suggest to backup your config ~/.lazarus  and start with an empty one. Just to see if that helps.
if it does copy files back, until you know which one causes the issue.
- non-xml file can probably remain in the folder, but back them up anyway
- if you have packages installed your lazarus executable is in that folder too, and you want to keep it in there.

It does remember the relative positions of the windows, but the whole layout is moved to the wrong monitor. As said in my reply to MarkMLI above, even the splash screen pops up there.

I've tried starting with an empty config folder as you describe, but no luck. I just get an error handling form complaining about missing configuration files - which pops up on the wrong monitor as well.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10692
  • Debugger - SynEdit - and more
    • wiki
Re: Setting the IDE's default launch location/display
« Reply #4 on: September 27, 2024, 03:13:26 pm »
So if you have a form in the designer (NOT the embedded designer), and you move it from one monitor to the other => what are the top/left coordinates?

Each Monitor should normally report its own range.

E.g. the left monitor could have x from 0 to 1919 and the right could start at 1920.
Or the left monitor could have x from -1920 to -1 and the right starts at 0.

If you then set a top/left value in the Object inspector (for your design form) does it move to the correct monitor?

I am not sure which config file those coordinates will be in. But one file must have them. So if the IDE is closed the positions of all windows should be in one of the files.

Nel_Fie

  • Jr. Member
  • **
  • Posts: 53
Re: Setting the IDE's default launch location/display
« Reply #5 on: September 29, 2024, 12:40:00 pm »
So if you have a form in the designer (NOT the embedded designer), and you move it from one monitor to the other => what are the top/left coordinates?

Each Monitor should normally report its own range.

E.g. the left monitor could have x from 0 to 1919 and the right could start at 1920.
Or the left monitor could have x from -1920 to -1 and the right starts at 0.

If you then set a top/left value in the Object inspector (for your design form) does it move to the correct monitor?

I am not sure which config file those coordinates will be in. But one file must have them. So if the IDE is closed the positions of all windows should be in one of the files.

It seems you were onto the cause of the problem here! I looked at the top/left values of the form as you instructed, and while "left" was at 0 for the left-most edge of the primary monitor, "top" was at 0 for the top edge of the problematic secondary monitor - which was perhaps expected since my layout was such that said secondary monitor is higher up than the primary one.

So, I modified my display layout to put the secondary monitor at level with the primary one - and now Lazarus launches on the primary monitor as it's supposed to, along with the auto-complete text box.

From that I would infer that Lazarus somehow prioritises the "top" value over the "left" value, and over any information as to which display is primary, in order to decide its placement at launch? Is that intended behaviour, or something to report?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10692
  • Debugger - SynEdit - and more
    • wiki
Re: Setting the IDE's default launch location/display
« Reply #6 on: September 29, 2024, 02:10:47 pm »
and while "left" was at 0 for the left-most edge of the primary monitor, "top" was at 0 for the top edge of the problematic secondary monitor - which was perhaps expected since my layout was such that said secondary monitor is higher up than the primary one.

That should be ok, as long as your 2ndary monitors top then is something like 1200 or 1440 or .... depending on the height of the upper monitor.

I don't know how gaps would be handled (though I wouldn't expect issues, if the coordinates are otherwise correct.
I have several monitors (but on Windows) including positive and negative top and left. And it works fine.

One more thing... IIRC, if a form is partly (or maybe to much) off the screen, then the IDE tries to move it into the screen.
Or possible the same for the desktop.



Create a new application, and create a FormCreate event.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.   m: TMonitor;
  4.   i: Integer;
  5. begin
  6.   for i := 0 to Screen.MonitorCount -1 do begin
  7.     m := Screen.Monitors[i];
  8.     WriteLn(format('%d:  %d, %d / %d, %d', [i, m.Top, m.Left, m.Height, m.Width]));
  9.   end;
  10.   WriteLn(format('Desk:  %d, %d / %d, %d', [Screen.DesktopTop, Screen.DesktopLeft, Screen.DesktopHeight, Screen.DesktopWidth]));
  11.   WriteLn(format('Work:  %d, %d / %d, %d', [Screen.WorkAreaTop, Screen.WorkAreaLeft, Screen.WorkAreaHeight, Screen.WorkAreaWidth]));
  12.   writeln(Screen.Height, ' ', screen.Width);
  13. end;
  14.  

Then run it from a console (so you can see the output / or check the debug > output window).
You should then get to monitors. And the desktop should comprise all of those monitors.

Workarea/height/width for me is just the primary monitor. But it doesn't stop my IDE from other screens. I may have to check the startup code which values it uses to constrain where the IDE places its windows.

Like the code completion dropdown uses "Screen.MonitorFromPoint();" and then must be within that monitor.
As well as ClientToScreen which would need to be tested from a form (or a panel in a form) placed on each monitor (one at a time) and checked that the returned monitor has the correct bounds.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10692
  • Debugger - SynEdit - and more
    • wiki
Re: Setting the IDE's default launch location/display
« Reply #7 on: September 29, 2024, 02:20:14 pm »
Also: Find your EnvironmentOptions.xml

It is in the "primary config path" => menu: view > IDE Internals > About IDE
(usually ~/.lazarus)

In that file should be a section (count may differ):
Code: Text  [Select][+][-]
  1.   <Desktops Count="2" ActiveDesktop="default">

For each entry (according to count) you find one (big) section (name varies / xml-name has increasing numbrers)
Code: Text  [Select][+][-]
  1.     <Desktop1 Name="default">

And in each section an entry for each window:
Code: Text  [Select][+][-]
  1.       <MainIDE>
  2.         <Caption Value="MainIDE"/>
  3.         <CustomPosition Left="-1401" Top="-605" Width="1081" Height="58"/>
  4.         <Visible Value="True"/>
  5.       </MainIDE>
  6.  

So this example shows my "MainIDE" (the main window, with the menu, the toolbar, and the component palette) to be on a screen above and left to my main screen (actually the screen is just to the left, but it has a bigger height, so it start above and ends below).

If you open your IDE, move the main-ide window to one of your screens and close the IDE => then that is what should be stored (after closing the IDE).

You can check if those value get updated.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10692
  • Debugger - SynEdit - and more
    • wiki
Re: Setting the IDE's default launch location/display
« Reply #8 on: September 29, 2024, 02:23:17 pm »
And: Do you use Anchordocking? (if yes, does it work without?)

Nel_Fie

  • Jr. Member
  • **
  • Posts: 53
Re: Setting the IDE's default launch location/display
« Reply #9 on: September 30, 2024, 11:36:11 am »
Ok, so that's a lot of stuff at once, I'll try to address everything but forgive me in case I miss something.

Anchordocking: yes, I've tested both with and without, it makes not difference.

For a start, there's an additional detail I've noticed while messing around with my display layout: the issue only occurs if the secondary display's bottom edge is at least at the same height as the primary one's bottom edge. If the secondary display's bottom is below that of the primary, everything works fine. So it seems that either Lazarus takes this into account for placement, or Ubuntu itself constructs a different set of values in accordance with some built-in bias about relative placement of displays?

That aside, I've tested your sample project, and the values returned are different depending on whether I use a display layout that causes the issue. For a layout where it does happen, the values are as follows:

Code: Pascal  [Select][+][-]
  1. 0:  720, 0 / 1200, 1600
  2. 1:  0, 1600 / 1920, 1080
  3. 2:  840, 2680 / 1080, 1920
  4. Desk:  0, 0 / 1920, 4600
  5. Work:  0, 1600 / 1920, 3000
  6. 1200 1600
 

For a non-problematic layout, the values look like this:

Code: Pascal  [Select][+][-]
  1. 0:  473, 0 / 1200, 1600
  2. 1:  0, 1600 / 1920, 1080
  3. 2:  593, 2680 / 1080, 1920
  4. Desk:  0, 0 / 1920, 4600
  5. Work:  500, 54 / 1420, 4546
  6. 1200 1600

So the "Work" values are definitely affected.

As for EnvironmentOptions.xml, the values look the same regardless of layout. For Desktop1:

Code: Pascal  [Select][+][-]
  1.       <MainIDE>
  2.         <Caption Value="MainIDE"/>
  3.         <CustomPosition Left="1663" Top="296" Width="1026" Height="58"/>
  4.         <Visible Value="True"/>
  5.       </MainIDE>

A small hitch here is probably that based on the numbering of my monitors, my primary display should be Desktop2, but I've checked, and the values don't change there either, regardless of display layout.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10692
  • Debugger - SynEdit - and more
    • wiki
Re: Setting the IDE's default launch location/display
« Reply #10 on: September 30, 2024, 02:40:15 pm »
Quote
Code: Text  [Select][+][-]
  1.  <CustomPosition Left="1663" Top="296" Width="1026" Height="58"/>

So 1663 is 63 pixels from the left of  "1:"

Add 1026, then the right end of the MainIDE bar is at x= 1099
But the screen only has a width of 1080.

I have to double check, but I believe at start up the IDE checks that the window is in the screen (not sure: completely or partly...). That helps, if you disconnected a screen, and the IDE used to be on that disconnected screen.

In your case, and if indeed it thinks it needs to take action, then it needs to decide:
- move a bit to the left, and shrink the width.
- move a bit down, a lot to the left and keep the width (on screen "0:").

Have you tried reducing the window width yourself?
If you do, start with keeping maybe 20 extra pixel distance to the monitors border. There may be additional issues getting the correct size of the window decoration (window bar and frame) as those are handled by the OS, not the LCL.

That said, if it turns out to be something like the above, I don't say that the current reaction is correct. Just trying to find some clues first.

Nel_Fie

  • Jr. Member
  • **
  • Posts: 53
Re: Setting the IDE's default launch location/display
« Reply #11 on: October 01, 2024, 02:05:25 pm »
I've tested what you suggest, but first two notes that might affect the conclusion:

- I've re-installed Lazarus 3.99+fpc to fix the "load last project" bug, among others.
- I'm using Anchor Docking.

So, right now, the IDE places itself on the secondary monitor regardless of previous position ONLY immediately after switching to the problematic display layout. If I move it to the primary, the values are stored correctly, and it launches onto the primary for every subsequent launch at the correct position, as long as the display configuration remains the same, and for what I've tested, regardless of the size of the IDE, or the "fullscreen"-status of the IDE.

HOWEVER. Some weird stuff does happen. As previously stated, other forms are consistently transposed to the secondary monitor nonetheless, e.g. splash screen or auto-completion pop-up.
Also, when trying to move the IDE, it has a tendency to jump and snap around the screen a lot - suggesting that Lazarus is struggling to figure out how it's supposed to position and scale itself.

A secondary detail I've noticed but which is probably unrelated and more of an Anchor Docking bug : changing display layouts, or scaling the IDE beyond the screen has a tendency to mess up the docking of different forms, the Messages form in particular (which I usually dock below the source editor) tends to get pushed up underneath the source editor, basically hiding it. I have to undock the source editor to reveal and access the Messages form, in order to dock it properly again.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10692
  • Debugger - SynEdit - and more
    • wiki
Re: Setting the IDE's default launch location/display
« Reply #12 on: October 02, 2024, 12:15:54 pm »
So it will probably be needed to search where the LCL/IDE compares the stored/loaded Window bounds with the monitor bounds.
That will take some time... I'll have to see when I can have a look at that. (basically search for all access to those methods, and add logging...)

Of course it might still be something else... But need to start somewhere.

Nel_Fie

  • Jr. Member
  • **
  • Posts: 53
Re: Setting the IDE's default launch location/display
« Reply #13 on: October 02, 2024, 06:52:46 pm »
No doubt a significant task, yes. Good luck, I hope the cause and solution turn up easily.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10692
  • Debugger - SynEdit - and more
    • wiki
Re: Setting the IDE's default launch location/display
« Reply #14 on: October 22, 2024, 01:38:57 pm »
Sorry been a while.

I can confirm that an anchordocked IDE on very first start choses an "unconventional" monitor to show up on... But I had no time to dive into it.

As for
Quote
HOWEVER. Some weird stuff does happen. As previously stated, other forms are consistently transposed to the secondary monitor nonetheless, e.g. splash screen or auto-completion pop-up.
Splash screen probably uses display center or something like that. But it may also be affected by being a borderless form.
Completion pop up, no idea.

It could be some interaction between LCL and your Windowmanager.

As I am currently to busy, I suggest to please report this on our bug tracker.


Quote
Also, when trying to move the IDE, it has a tendency to jump and snap around the screen a lot - suggesting that Lazarus is struggling to figure out how it's supposed to position and scale itself.

I have seen the main-ide-bar (undocked) responding "jumpy" to any attempt of the user to move it. That only happens on some GTK Window managers....

But I don't work on the code that deals with GTK. So this is outside the scope that I can help with.

Quote
A secondary detail I've noticed but which is probably unrelated and more of an Anchor Docking bug : changing display layouts, or scaling the IDE beyond the screen has a tendency to mess up the docking of different forms, the Messages form in particular (which I usually dock below the source editor) tends to get pushed up underneath the source editor, basically hiding it. I have to undock the source editor to reveal and access the Messages form, in order to dock it properly again.

This is a known issue => so I haven't figured out all cases that trigger it.

It also relates that if you try to dock to the outside of the IDE window (preview is shown on the outside), but the window then can not grow as much as desired, there are weird things happening. https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41184 (anchordocking wont completely lock the form, but something still sometimes goes wrong).

And yes, then there is a case were the some dock panels, are bigger than the containing window, and therefore cut off. I had an attempt to fix some of it, but it made the above effect worse.



 

TinyPortal © 2005-2018