Recent

Author Topic: Qt5 on Gnome wrong top and left  (Read 2038 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2995
    • tomboy-ng, a rewrite of the classic Tomboy
Qt5 on Gnome wrong top and left
« on: January 07, 2024, 12:53:15 am »
OK, seeing something quite strange here.

On Debian Gnome Bookworm, using qt5 widget set, a non modal form reports its Left and Top coordinates incorrectly.  It tells me keft is -30 when the form is clearly in the middle of the screen.

Am I missing something here ?

Further investigation as time permits ....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 2995
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt5 on Gnome wrong top and left
« Reply #1 on: January 07, 2024, 09:09:06 am »
Just to be specific about the above :

Code: Pascal  [Select][+][-]
  1. procedure TForm1.SpeedButton2Click(Sender: TObject);
  2. begin
  3.     LabelLeft.Caption := inttostr(Left);
  4.     LabelTop.Caption  := inttostr(Top);
  5. end;
   

Tells me the window is at -3, -30 where ever I locate it on the screen.
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 2995
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt5 on Gnome wrong top and left
« Reply #2 on: January 14, 2024, 12:40:14 am »
I have reported this issue here.
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40695

Attached is a very simple demo.

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 2995
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt5 on Gnome wrong top and left
« Reply #3 on: January 14, 2024, 12:43:53 am »

I have established the problem definitely relates to use of Wayland, turn Wayland off and things work normally.

This behavior is a particular problem when one form pops up another, user will expect the new form to position itself near the first one, its either up near top left of screen (gnome) or towards bottom right (KDE).

As the adoption of wayland seems unstoppable, this is a major issue.

Attached is a very simple demo.
« Last Edit: January 15, 2024, 12:04:17 am by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

zeljko

  • Hero Member
  • *****
  • Posts: 1632
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Qt5 on Gnome wrong top and left
« Reply #4 on: January 14, 2024, 04:31:24 pm »
I've already answered on issue, but I was wrong. ATM, wayland does not support window positioning at all. Even window activating is in standard protocols from 12/2023
https://wayland.app/protocols/xdg-activation-v1 . As I can find over google, xdg_toplevel_move() and it's read x,y sibling will be something that can guarantee correct x,y of toplevel window. Now, it does not work with Qt5 and Qt6 because of poor wayland implementations.

dbannon

  • Hero Member
  • *****
  • Posts: 2995
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt5 on Gnome wrong top and left
« Reply #5 on: January 15, 2024, 03:02:33 am »
Yes, thanks Zelijko. I was coming to the same conclusion, that it 'should' work but does not. We are being experimented on. And it applies to positioning a new window too.

Forcing an app to use an X11 session instead of Wayland solves all of these problems and stops heaps of warning messages on the command line. But, as far as I can see, no way, programmatically, to force that X11 session, it has to be an env var. Pity.
Code: [Select]
XDG_SESSION_TYPE=x11 ./myapp <enter>
Would it be possible to call this somewhere in your QT initialization code ?
Code: [Select]
qputenv("XDG_SESSION_TYPE", "x11");
As I understand it, actually using Wayland is only beneficial if you want some unproven inter-process security. Let other people be experimented on until it all works....

EDIT: I note suggestions that "x11" won't work with Qt6 but "xcb" does. And xcb is a more modern approach, written to prove that the x11 architecture is viable even if the code is not. But my tests here indicate that neither [xcb, x11] make Qt6 work. And, I guess, Qt6 should be our long term focus ?

Davo
« Last Edit: January 15, 2024, 03:24:14 am by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

zeljko

  • Hero Member
  • *****
  • Posts: 1632
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Qt5 on Gnome wrong top and left
« Reply #6 on: January 15, 2024, 09:58:10 am »
Actually you should not touch XDG_SESSION_TYPE, but set QT_QPA_PLATFORM=xcb.

dbannon

  • Hero Member
  • *****
  • Posts: 2995
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt5 on Gnome wrong top and left
« Reply #7 on: January 15, 2024, 12:25:04 pm »
I think I will set eg QT_QPA_PLATFORM=xcb in the desktop file for my packaging -
Code: Pascal  [Select][+][-]
  1. ...
  2. Exec=env QT_QPA_PLATFORM=xcb tomboy-ng
  3. ...

There does not seem to be a downside and it does seem to solve some problems. Especially with Fedora where I have just tested four desktops for Fedora 39, Gnome, KDE, Cinnanon and Xfce. Only Xfce was usable over Wayland.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

zeljko

  • Hero Member
  • *****
  • Posts: 1632
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Qt5 on Gnome wrong top and left
« Reply #8 on: January 15, 2024, 01:21:00 pm »
I don't expect wayland be good for lcl.in next minimum 2-3 years.

 

TinyPortal © 2005-2018