View Issue Details

IDProjectCategoryView StatusLast Update
0036897LazarusWidgetsetpublic2020-04-16 13:26
ReporterZeljan Rikalo Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionreopened 
Product Version2.1 (SVN) 
Summary0036897: Qt/Qt5/Gtk2: bad result of QWidget::frameGeometry() when widget is not mapped
DescriptionOnly top windows:
eg. GetWindowRect() returns bad result if widget isn't mapped yet (not visible and not mapped to the windows system). Affects Qt,Qt5,Gtk2 on X11, and Qt/Qt5 on Windows and probably on Mac.
Steps To Reproduce1. Create form, add some menu, set size to W=640, H=480 in designer.
2. Set form position to poScreenCenter/poWorkAreaCenter
2.OnFormCreate() -> change width and height eg.
  Width := Screen.WorkAreaWidth - (Screen.WorkAreaWidth div 10);
  Height := Screen.WorkAreaHeight - (Screen.WorkAreaHeight div 10);

Form will not be centered properly on desktop.
TagsNo tags attached.
Fixed in Revision62970,62971,62977,62996
LazTarget-
WidgetsetGTK 2, QT, QT5
Attached Files

Relationships

related to 0036919 closedZeljan Rikalo Gtk2: Screen.WorkAreaRect returns wrong result 

Activities

Zeljan Rikalo

2020-04-11 16:02

developer   ~0122074

Added gtk2 widgetset too. Applies to all X11 widgetsets.

Zeljan Rikalo

2020-04-12 21:21

developer   ~0122098

Just notes for me: Testing on x11 must include various wm's and with compositing enabled/disabled since various combinations give different result.
There's patch for kwin (compositing on or off) which works ok for gtk2,qt and qt5, but under xfwm4, cinnamon, openbox it does not work as expected.

Zeljan Rikalo

2020-04-13 15:31

developer   ~0122127

Ok, seem that this problem is mostly visible with Form.Position := poScreenCenter, poWorkAreaCenter and poDesktopCenter.
GetWindowRect() should return 0 on all non win32 platforms if eg on X11 window isn't mapped yet.
Known misusage of GetWindowRect() is MainIDEBar. For x11 - TCustomForm.MoveToPosition checks result but get invalid rect from gtk2/qt/qt5 if it isn't mapped yet,
so proposal is to create intf procedure which will move form to the desired position at the moment when window is mapped.

Zeljan Rikalo

2020-04-14 14:55

developer   ~0122142

It's resolved for Qt and Qt5 under X11, and works perfect. To disable usage of accurate frames on x11 add application parameter -disableaccurateframe, so it will use old behaviour.
Now, GetWindowRect() is accurate 100% under x11 for mentioned widgetsets.

Zeljan Rikalo

2020-04-14 14:55

developer   ~0122143

Still to fix: Qt/Qt5 on win32 (maybe just check) and gtk2 on x11 using same approach of dummy widget for accurate frame.

Zeljan Rikalo

2020-04-14 17:16

developer   ~0122146

Qt/Qt5: Fixed misusage of IsRectEmpty() in GetWindowRect().

Zeljan Rikalo

2020-04-16 11:09

developer   ~0122169

Changed header - included Gtk2

Zeljan Rikalo

2020-04-16 11:24

developer   ~0122170

Completely resolved :)

Issue History

Date Modified Username Field Change
2020-04-10 16:28 Zeljan Rikalo New Issue
2020-04-10 16:28 Zeljan Rikalo Status new => assigned
2020-04-10 16:28 Zeljan Rikalo Assigned To => Zeljan Rikalo
2020-04-11 16:02 Zeljan Rikalo LazTarget => -
2020-04-11 16:02 Zeljan Rikalo Widgetset QT, QT5 => GTK 2, QT, QT5
2020-04-11 16:02 Zeljan Rikalo Note Added: 0122074
2020-04-12 21:21 Zeljan Rikalo Note Added: 0122098
2020-04-13 15:31 Zeljan Rikalo Note Added: 0122127
2020-04-14 11:19 Zeljan Rikalo Relationship added related to 0036913
2020-04-14 14:55 Zeljan Rikalo Status assigned => resolved
2020-04-14 14:55 Zeljan Rikalo Resolution open => fixed
2020-04-14 14:55 Zeljan Rikalo Fixed in Revision => 62970,62971
2020-04-14 14:55 Zeljan Rikalo Widgetset GTK 2, QT, QT5 => GTK 2, QT, QT5
2020-04-14 14:55 Zeljan Rikalo Note Added: 0122142
2020-04-14 14:55 Zeljan Rikalo Status resolved => feedback
2020-04-14 14:55 Zeljan Rikalo Resolution fixed => reopened
2020-04-14 14:55 Zeljan Rikalo Note Added: 0122143
2020-04-14 17:16 Zeljan Rikalo Status feedback => resolved
2020-04-14 17:16 Zeljan Rikalo Fixed in Revision 62970,62971 => 62970,62971,62977
2020-04-14 17:16 Zeljan Rikalo Widgetset GTK 2, QT, QT5 => GTK 2, QT, QT5
2020-04-14 17:16 Zeljan Rikalo Note Added: 0122146
2020-04-14 17:17 Zeljan Rikalo Status resolved => feedback
2020-04-14 18:35 Zeljan Rikalo Relationship deleted related to 0036913
2020-04-16 11:08 Zeljan Rikalo Relationship added related to 0036919
2020-04-16 11:09 Zeljan Rikalo Summary Qt/Qt5: bad result of QWidget::frameGeometry() when widget is not mapped => Qt/Qt5/Gtk2: bad result of QWidget::frameGeometry() when widget is not mapped
2020-04-16 11:09 Zeljan Rikalo Description Updated View Revisions
2020-04-16 11:09 Zeljan Rikalo Widgetset GTK 2, QT, QT5 => GTK 2, QT, QT5
2020-04-16 11:09 Zeljan Rikalo Note Added: 0122169
2020-04-16 11:24 Zeljan Rikalo Status feedback => resolved
2020-04-16 11:24 Zeljan Rikalo Fixed in Revision 62970,62971,62977 => 62970,62971,62977,62996
2020-04-16 11:24 Zeljan Rikalo Widgetset GTK 2, QT, QT5 => GTK 2, QT, QT5
2020-04-16 11:24 Zeljan Rikalo Note Added: 0122170
2020-04-16 13:26 Zeljan Rikalo Status resolved => closed