[Lazarus] Qt/Qt5 under X11 new feature - accurate frame size

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Qt/Qt5 under X11 new feature - accurate frame size

Free Pascal - Lazarus mailing list
Hi all,

Why this feature ?
1.Assume form with position poWorkAreaRect - you expect that your form
   will be shown in the middle of the screen, taking systray into account.
2.Inside FormCreate() you change your form width and height eg:
   Width := Screen.Width - (Screen.Width div 10);
   Height := Screen.Height - (Screen.Height div 10);

3.Now show your form. It's not centered but offsetted right-down by left
border and title bar - so not in center (gtk2 has this problem too).
Problem comes from fact that x11 does not provide window frame until
window is mapped , so we calculate eg form position with wrong values
because we are missing complete window frame info.

Problem is visible by using GetWindowRect() anywhere in code where
handle is allocated but window isn't mapped by window manager (x11).

There's no way to know decorations size (borders, title bar) under X11
when window is not mapped (but eg handle exists) - so it is much
different from eg win32 which have full frame correct even when window
is not visible.

I've decided to fix it (thanks to more spare time those days) and
finally I've managed GetWindowRect() (and maybe other later) to get
accurate frame size under X11.

I set it up by using dummy widget in the background when app starts and
creates it's Application.MainForm handle, so after Application.MainForm
handle is created we have WM frame size.
If you don't want to use this trick then pass -disableaccurateframe to
your app.

I've tested both qt and qt5 on Mint 19.2 64bit on KDE, cinnamon, xfce,
openbox, lxde and xfce, and same WMs under Fedora 30 64bit and it work
like a charm.
Note that creation of dummy widget is pretty fast on my machines (20-30
msec) so it's not big deal in comparision to this feature. I would like
to get some feedback about timings from older hardware and older distros
if possible (qt or qt5).
If someone want to debug dummy widget timings add -dDEBUGQTFRAMESIZE.

Please test and report if there's any problem under x11 with qt/qt5
(minimum is lazarus svn r62975 :)

Later, maybe gtk2 can be fixed in same way, so probably no more
segfaults with size messages because of invalid GetWindowRect().

zeljko
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Qt/Qt5 under X11 new feature - accurate frame size

Free Pascal - Lazarus mailing list
On 4/14/20 3:41 PM, zeljko via lazarus wrote:

> Please test and report if there's any problem under x11 with qt/qt5
> (minimum is lazarus svn r62975 :)

Just to correct my self (fix in the meantime), minimum for testing
should be trunk lazarus r62977

zeljko
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus