Recent

Author Topic: [SOLVED] Lazarus header too large on Linux  (Read 7481 times)

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
[SOLVED] Lazarus header too large on Linux
« on: October 13, 2016, 11:07:57 am »
Hi all!
I'm running Lazarus 1.6 32bit and 64bit at Debian Linux. At both cases I experience that Lazarus header window (menu and toolbar) is incorrectly scaled (see red arrow at attachment image). I always have to change it size manually, however it reverts to incorrect size at every launch.
Is there a way to fix this?
« Last Edit: November 16, 2016, 01:37:42 pm by Eugene Loza »
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

balazsszekely

  • Guest
Re: Lazarus header too large on Linux
« Reply #1 on: October 13, 2016, 11:11:49 am »
Hi Eugene,

Most likely a bug, you should file a bug report. Quick fix: uncheck "Automatically adjust IDE main window height".


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Lazarus header too large on Linux
« Reply #2 on: October 13, 2016, 11:19:31 am »
I'm running Lazarus 1.6 32bit and 64bit at Debian Linux. At both cases I experience that Lazarus header window (menu and toolbar) is incorrectly scaled (see red arrow at attachment image). I always have to change it size manually, however it reverts to incorrect size at every launch.

I remember similar complaints from other people but I could not reproduce it.
Does it happen if you start Lazarus with default configuration using --pcp param?
Does it happen also with QT bindings?
What about Lazarus trunk?
In any case we must find a way to reproduce before it can be fixed.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
Re: Lazarus header too large on Linux
« Reply #3 on: October 13, 2016, 11:25:40 am »
Quick fix: uncheck "Automatically adjust IDE main window height".
Thanks a lot it's working!!!
Quote
Most likely a bug, you should file a bug report.
I've made a few bug reports... but usual response I get is irritated "it's not a bug, it's a feature" and "ask at forum before filling bug reports and don't waste our time"...
Well, while I'm not a complete noob, I can't really call myself a FPC expert (most of my experience still comes from Turbo Pascal)... so I've decided to leave bug reports to users more experienced than me...
I really don't want to harm anybody by my inexperience, lack of knowledge, or just inadvertence...

Quote
Does it happen if you start Lazarus with default configuration using --pcp param?
I'll try it right away and will report in a few minutes.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
Re: Lazarus header too large on Linux
« Reply #4 on: October 13, 2016, 11:42:13 am »
No, lazarus-ide --pcp gives the same result.

I've played a little with window size/position options (see attachment). "Let the windowmanager decide..." shows wierd results :)
Default for "Main Menu" is "Restore Window Geometry" with value 83. Header bar (32 pixels) + Main Menu+toolbar (83 pixels) takes 105 pixels. I don't remember exactly, but it seems that Linux counts Header Bar in window.height, and Windows doesn't. So value 83 would be correct at Windows machine, but wrong at Linux (must be 105).
So, as being too small, the Window height is automatically enlarged to ~213 pixels.

If I disable "Automatically adjust IDE main window height" and set the height to 105 I get a correct IDE toolbar size.
If I enable "Automatically adjust IDE main window height" the MainMenu height resets to 83 and the IDE toolbar size becomes 213 pixels instead of 105.
« Last Edit: October 13, 2016, 11:58:44 am by Eugene Loza »
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

balazsszekely

  • Guest
Re: Lazarus header too large on Linux
« Reply #5 on: October 13, 2016, 11:59:56 am »
Quote
but usual response I get is irritated "it's not a bug, it's a feature" and "ask at forum before filling bug reports and don't waste our time"...
This feature was implemented by @Ondrej. He's definitely not irritated and grumpy. In fact he's very helpful.

In my opinion the windows option feature conflicts with the desktop feature. Please try this:
1. Make sure  "Automatically adjust IDE main window height" is checked
2. Adjust the main window height as you like
3. Go to Lazmenu-->Tools-->Desktops--> Press the save button
4. Restart lazarus and see what happens

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
Re: Lazarus header too large on Linux
« Reply #6 on: October 13, 2016, 12:19:50 pm »
In fact he's very helpful.
Don't get me wrong. It's my problem, not developer's... I'm really not a pro... And I really lack experience in FreePascal.
While programming in pascal for over 20 years by now, I still haven't learned all the basics...
That's why I mostly look and learn :)
[offtop]E.g. I see a strange code that might be a bug in
https://github.com/graemeg/freepascal/blob/master/rtl/inc/system.inc#L641
In my opinion it should be:
function random(l:longint): longint;
begin
{ otherwise we can return values = l (JM) }
  if (l <= 1) then
    random := 0
  else
    random := longint((int64(mtwist_u32rand)*l) shr 32);
end;
to support relatively probable case l<0.
But I'm just afraid to post anything like that because I can be badly wrong here :) E.g. the mtwist_u32rand function won't be called and the seed won't cycle which might be important in some cases.
[/offtop]
Quote
1. Make sure  "Automatically adjust IDE main window height" is checked
2. Adjust the main window height as you like
3. Go to Lazmenu-->Tools-->Desktops--> Press the save button
4. Restart lazarus and see what happens
No, it resets height to 213 pixels just as without saving "desktop".
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Lazarus header too large on Linux
« Reply #7 on: October 13, 2016, 12:26:06 pm »
This feature was implemented by @Ondrej. He's definitely not irritated and grumpy. In fact he's very helpful.

Yes, this one should be reported, it has happened with other people, too.
However Ondrej has not been able to reproduce it either.
It means the people who can reproduce must do some research and debugging about where it goes wrong.
There is:
 function TMainIDEBar.CalcMainIDEHeight: Integer;
Add DebugLn() lines and start Lazarus from a console. The debug output goes to the same console. Defining a log file is possible, too.

Quote
In my opinion the windows option feature conflicts with the desktop feature. Please try this:
1. Make sure  "Automatically adjust IDE main window height" is checked
2. Adjust the main window height as you like
...

GetMem, the main window height cannot be adjusted manually when the option is checked.

Yes, the windows option feature conflicts with the desktop feature. It is a mess.
I remember Ondrej has plans to revamp it. Now he is busy with personal affairs. I don't know how long it takes.

« Last Edit: October 13, 2016, 12:29:12 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
Re: Lazarus header too large on Linux
« Reply #8 on: October 13, 2016, 12:47:41 pm »
Default for "Main Menu" is "Restore Window Geometry" with value 83. Header bar (32 pixels) + Main Menu+toolbar (83 pixels) takes 105 pixels. I don't remember exactly, but it seems that Linux counts Header Bar in window.height, and Windows doesn't. So value 83 would be correct at Windows machine, but wrong at Linux (must be 105).
So, as being too small, the Window height is automatically enlarged to ~213 pixels.
Well, yes. That was a good example of my ignorance :)
If I uncheck "Automatically adjust IDE main window height" and type height "105" for MainWindow it resets to 83 upon restart, but still works fine.
Moreover, the "Automatically adjust IDE main window height" works perfectly if checked, but "Show complete components palette" is unchecked.
The IDE height fails only if both are checked.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
Re: Lazarus header too large on Linux
« Reply #9 on: October 13, 2016, 12:55:19 pm »
While playing with "Show complete components palette" option I've fount out that it works perfectly fine IF I change the current tab - it automatically resizes the main window correctly as soon as amount of lines in the component palette changes and later from that on it works perfecly adjusting window height to fit 1 or 2 lines of component palette items...
It looks like the TMainIDEBar.CalcMainIDEHeight tries to determine the IDEHeight before the components palette is populated. And triggers another re-calculation only if amount of component palette lines has changed.
« Last Edit: October 13, 2016, 12:59:57 pm by Eugene Loza »
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Lazarus header too large on Linux
« Reply #10 on: October 13, 2016, 12:59:39 pm »
I've played a little with window size/position options (see attachment). "Let the windowmanager decide..." shows wierd results :)
Default for "Main Menu" is "Restore Window Geometry" with value 83.
For me "Let the windowmanager decide" works. It increases the height slichtly to 92 which is better, it has a small nice margin now.
Can the problem be caused by a window manager. Which one you have with Debian?

Moreover, the "Automatically adjust IDE main window height" works perfectly if checked, but "Show complete components palette" is unchecked.
The IDE height fails only if both are checked.
Ok, that is interesting.
If you look at the code, it iterates the component icons and finds the biggest value.
For all relevant code please look for AutoAdjustIDEHeight and AutoAdjustIDEHeightFullCompPal in mainbar.pas.

Quote
It looks like the TMainIDEBar.CalcMainIDEHeight tries to determine the IDEHeight before the components palette is populated. And triggers another re-calculation only if amount of component palette lines has changed.
No, the component palette has no icons before it is populated.
« Last Edit: October 13, 2016, 01:08:33 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
Re: Lazarus header too large on Linux
« Reply #11 on: October 13, 2016, 01:18:03 pm »
Yes, that's the code (I'll post it here for convenience):
https://github.com/alrieckert/lazarus/blob/master/ide/mainbar.pas#L738
(I hope I look at the correct variant)
So, basically if this line fails
https://github.com/alrieckert/lazarus/blob/master/ide/mainbar.pas#L778
and the cycle continues then the result becomes incorrect.

Hmm... maybe that's the case when WIDTH is not determined correctly at startup which causes HEIGHT to get 3 to 4 additional lines of components palette.
e.g. when I ask "Get Windowmanager to decide" for Main Window height&width the width is 566 instead of 1200 if "Restore window geometry" with "auto adjust"...
Might the sequence be:
1. WindowManager tries to set Width of the Main Window
2. Component palette arranges elements into 4 or 5 lines.
3. Automatically determine window height (based on incorrect number of lines)
4. Automatically determine window width
5. Rearrange component palette into one line (but the height remains the same).
That explains why breaking after encountering EnvironmentOptions.Desktop.AutoAdjustIDEHeightFullCompPal provides a correct result (as number of lines is 1 regardless of WIDTH)

Window manager is XFCE 4.10 @ Debian Jessie (both 32 and 64 bit).
« Last Edit: October 13, 2016, 01:23:48 pm by Eugene Loza »
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

balazsszekely

  • Guest
Re: Lazarus header too large on Linux
« Reply #12 on: October 13, 2016, 01:26:56 pm »
Quote
@Eugene
Hmm... maybe that's the case when WIDTH is not determined correctly at startup which causes HEIGHT to get 3 to 4 additional lines of components palette.
e.g. when I ask "Get Windowmanager to decide" for Main Window height&width the width is 566 instead of 1200 if "Restore window geometry" with "auto adjust"..
Why don't you try to debug the IDE? Create a Debug IDE profile first, then run lazarus from inside lazarus. This would be a good opportunity to find the elusive bug.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
Re: Lazarus header too large on Linux
« Reply #13 on: October 13, 2016, 01:45:40 pm »
Why don't you try to debug the IDE?
I don't see anywhere TMainIDEBar.width or TMainIDEBar.clientWidth is set. I'm currently looking at https://github.com/alrieckert/lazarus/blob/master/ide/main.pp#L1497 but still I don't understand it that well to debug anything here.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Lazarus header too large on Linux
« Reply #14 on: October 13, 2016, 04:21:01 pm »
I don't see anywhere TMainIDEBar.width or TMainIDEBar.clientWidth is set. I'm currently looking at https://github.com/alrieckert/lazarus/blob/master/ide/main.pp#L1497 but still I don't understand it that well to debug anything here.

Debugging is the best way to understand code! I would not understand most of Lazarus code either if I didn't debug it.
You see the call history, variable values, how the code jumps etc.
Now we know the reason for your slow progress in 20 years. :)
I made small changes in r53106. Now the IDE height calculation is called from Resizing handler only after IDE has started.
Added a DebugLn(), too.
I don't believe it solves the problem though. Please test if the order of function calls in procedure TMainIDE.StartIDE affects things. There is MainIDEBar.InitPaletteAndCoolBar.
Add more DebugLn()s or use the real debugger ...

BTW, I also got a narrow main window when "Let the windowmanager decide" was set and I closed + restarted Lazarus.
It clearly does not work. I hope the conflicting settings will be solved later, but it is not relevant for the current problem in your system. It should work with "Restore Window Geometry" at least.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018