View Issue Details

IDProjectCategoryView StatusLast Update
0028034LazarusLCLpublic2020-04-16 20:41
ReporterOndrej Pokorny Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
OSLinux 
Product Version1.5 (SVN) 
Summary0028034: GetSystemMetrics(SM_CYMENU) delivers wrong result
DescriptionTMainMenu.Height / LCLIntf.GetSystemMetrics(SM_CYMENU) returns different result on Gtk2 and Win32.

Under Win32, it returns the height of a single-lined main menu, under Gtk2 it returns (lgsMenu+lgsMenuBar+FCachedBorderSize) which is too much (the actual menu height is smaller than the result).
Steps To ReproduceCheck the result of Menu.Height on various OS/WidgetSets. You will see a huge difference between Win32 and Gtk2.

Or see the attached project.
TagsNo tags attached.
Fixed in Revision51806,62997
LazTarget-
WidgetsetGTK 2, QT
Attached Files

Relationships

related to 0027940 closedJuha Manninen Patches Lazarus IDE has an unnecessary MaxHeight-constraint 
related to 0028036 confirmed Lazarus Form ClientHeight ignores main menu height 

Activities

Ondrej Pokorny

2015-05-06 09:09

developer  

MenuHeight.lpi.zip (3,738 bytes)

Zeljan Rikalo

2016-03-02 09:27

developer   ~0090542

@Ondrej, Fedora 14 32bit, lazarus trunk, fpc-2.6.4, plastique theme is default for qt:
1.Qt returns 27
2.Gtk2 returns 28 (uses it's default gtk2 theme)

I don't see any problem with this values here. Menu height heavily depends on themes of those widgetsets. eg some values for Qt themes:

1.Windows - 25 px
2.Oxygen - 27 px
3.Plastique - 27 px
4.Motif - 31 px
5.Gtk2 - 28 px (NOTE THAT Qt returns same value as gtk2 with this theme).

Ondrej Pokorny

2016-03-02 10:29

developer  

menuheight-gtk2.png (6,880 bytes)   
menuheight-gtk2.png (6,880 bytes)   

Ondrej Pokorny

2016-03-02 10:35

developer   ~0090545

Last edited: 2016-03-02 10:42

View 3 revisions

Kubuntu+Gtk2 - 43px, see screenshot from demo app (I only reduced the number of menu items to 1, it has no effect).

When debugging into it, TGtk2WidgetSet.GetSystemMetrics at SM_CYMENU the result is:
39px after Result := GTK_Widget(P)^.requisition.Height;
43px after inc(Result, FCachedBorderSize);

Guess: maybe your system returns nil in "P := GetStyleWidget(lgsMenu);" and so the default hard-coded value of 24px +4px(from FCachedBorderSize) is used (?)

EDIT:
the actual value on my system (see screenshot) is 19px.

Ondrej Pokorny

2016-03-02 10:49

developer  

menuheight-qt.png (7,128 bytes)   
menuheight-qt.png (7,128 bytes)   

Ondrej Pokorny

2016-03-02 10:51

developer   ~0090546

Last edited: 2016-03-02 11:01

View 3 revisions

Btw Qt result is also wrong (tested on Linux and Windows).
Linux:
Actual = 21px
SM_CYMENU result = 25px

Windows:
Actual = 20px
SM_CYMENU result = 24px

The result differs from the actual value in 4px that may be here:
function TQtWidgetSet.GetMenuHeight: Integer;
  ...
    if QStyle_styleHint(QApplication_style(),
      QStyleSH_MainWindow_SpaceBelowMenuBar) > 0 then
      inc(FCachedMenuBarHeight, 4);


Zeljan Rikalo

2016-03-02 11:02

developer   ~0090547

How do you measure that with qt ?

Ondrej Pokorny

2016-03-02 11:06

developer   ~0090548

I take a screenshot and measure the pixels in my favorite graphics program.

Zeljan Rikalo

2016-03-02 12:43

developer   ~0090551

That QStyleSH_MainWindow_SpaceBelowMenuBar is there for reason, I cannot remember now, but I didn't put it there because of nothing.

Ondrej Pokorny

2016-03-02 13:54

developer   ~0090552

Last edited: 2016-03-02 14:07

View 2 revisions

>> That QStyleSH_MainWindow_SpaceBelowMenuBar is there for reason, I cannot remember now, but I didn't put it there because of nothing.

I believe you. But it makes the result wrong. Furthermore it is suspicious that you use a hard coded constant (4) and don't get it from themes/OS.

See the attached result for win+win32 and win+qt.

Ondrej Pokorny

2016-03-02 14:02

developer   ~0090553

Furthermore, for darwin it should return 0 because the menu bar is not part of the application window. It returns 1 now.

Ondrej Pokorny

2016-03-02 14:07

developer  

menuheight-win.png (5,002 bytes)   
menuheight-win.png (5,002 bytes)   

Zeljan Rikalo

2016-03-02 14:51

developer   ~0090557

Last edited: 2016-03-02 14:52

View 2 revisions

Feel free to change it according to your observations. I really don't have enough spare time to check why it is so atm. Could be because of X11 only ...don't know.

Ondrej Pokorny

2016-03-02 15:06

developer   ~0090558

>> Feel free to change it according to your observations. I really don't have enough spare time to check why it is so atm.

Is ok, I though you were interested because you assigned the issue to yourself.

Ondrej Pokorny

2016-03-02 16:10

developer   ~0090563

Qt fixed in 51806

Zeljan Rikalo

2020-04-16 14:25

developer   ~0122173

Please test and close if ok.

Issue History

Date Modified Username Field Change
2015-05-06 09:09 Ondrej Pokorny New Issue
2015-05-06 09:09 Ondrej Pokorny File Added: MenuHeight.lpi.zip
2015-05-06 11:21 Juha Manninen Relationship added related to 0027940
2016-03-01 17:39 Zeljan Rikalo Assigned To => Zeljan Rikalo
2016-03-01 17:39 Zeljan Rikalo Status new => assigned
2016-03-02 09:27 Zeljan Rikalo LazTarget => -
2016-03-02 09:27 Zeljan Rikalo Note Added: 0090542
2016-03-02 09:27 Zeljan Rikalo Status assigned => feedback
2016-03-02 10:29 Ondrej Pokorny File Added: menuheight-gtk2.png
2016-03-02 10:35 Ondrej Pokorny Note Added: 0090545
2016-03-02 10:35 Ondrej Pokorny Status feedback => assigned
2016-03-02 10:36 Ondrej Pokorny Note Edited: 0090545 View Revisions
2016-03-02 10:42 Ondrej Pokorny Note Edited: 0090545 View Revisions
2016-03-02 10:49 Ondrej Pokorny File Added: menuheight-qt.png
2016-03-02 10:51 Ondrej Pokorny Note Added: 0090546
2016-03-02 10:52 Ondrej Pokorny Widgetset GTK 2 => GTK 2, QT
2016-03-02 10:52 Ondrej Pokorny Platform Gtk2 =>
2016-03-02 10:58 Ondrej Pokorny Note Edited: 0090546 View Revisions
2016-03-02 11:01 Ondrej Pokorny Note Edited: 0090546 View Revisions
2016-03-02 11:02 Zeljan Rikalo Note Added: 0090547
2016-03-02 11:06 Ondrej Pokorny Note Added: 0090548
2016-03-02 12:43 Zeljan Rikalo Note Added: 0090551
2016-03-02 13:54 Ondrej Pokorny Note Added: 0090552
2016-03-02 14:02 Ondrej Pokorny Note Added: 0090553
2016-03-02 14:07 Ondrej Pokorny File Added: menuheight-win.png
2016-03-02 14:07 Ondrej Pokorny Note Edited: 0090552 View Revisions
2016-03-02 14:51 Zeljan Rikalo Note Added: 0090557
2016-03-02 14:52 Zeljan Rikalo Note Edited: 0090557 View Revisions
2016-03-02 15:06 Ondrej Pokorny Note Added: 0090558
2016-03-02 16:10 Ondrej Pokorny Fixed in Revision => 51806
2016-03-02 16:10 Ondrej Pokorny Note Added: 0090563
2020-04-05 11:27 Zeljan Rikalo Relationship added related to 0028036
2020-04-16 14:25 Zeljan Rikalo Status assigned => resolved
2020-04-16 14:25 Zeljan Rikalo Resolution open => fixed
2020-04-16 14:25 Zeljan Rikalo Fixed in Revision 51806 => 51806,62997
2020-04-16 14:25 Zeljan Rikalo Widgetset GTK 2, QT => GTK 2, QT
2020-04-16 14:25 Zeljan Rikalo Note Added: 0122173