Bug 360466 - When a PyQt5 application uses move() to set the position of the main window KDE offsets the window position
Summary: When a PyQt5 application uses move() to set the position of the main window K...
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 5.5.5
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-13 11:59 UTC by Barry Scott
Modified: 2016-03-15 22:06 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Barry Scott 2016-03-13 11:59:49 UTC
When a PyQt5 application uses move() to set the position of the main window KDE offsets the position.

In all my PyQt5 application  the QMainWindow pistiion and size are remembered
by recording the last values seen in the resizeEvent and moveEvent callbacks.

When the application starts up in QMainWindow position and size are restored.
self.resize( width, height )
self.move( x, y )

Under KDE I see that the first moveEvent reported is the expected X and Y coordinate
but then a second moveEvent pushes the window down by 29 pixles and right by 6 pixels.

The QT documentation sugegsts that this is a bug in X11 window manager behaviour, see:

http://doc.qt.io/qt-5/application-windows.html#window-geometry

Do you agree and can this be fixed.

Reproducible: Always


Actual Results:  
Window not placed in the X and Y position of the QMainWindow.move(). It is pushed down and to the right.

Expected Results:  
Allow a new window to placed exactly where the QMainWindow.move( X, Y ) have requested.
Comment 1 Thomas Lübking 2016-03-14 16:25:49 UTC
"Depends" - you can expect "x,y" to be the final position of *your* window, not the framed window.
However, I've no idea what PyQt is doing behind the scenes, can you attach a simple testcase (to inspect what's going on)?
Comment 2 Barry Scott 2016-03-15 14:46:47 UTC
kwin is doing the right thing if I use the right Qt API.

For record the right thing to do is use saveGeometry()/restoreGeometry() to have an
applications window restored to the position and size the user left it in.

The wrong thing to do is use moveEvent() to find position and resizeEvent() to find the size
to save. Then use resize() and move() to restrore them.

Qt does some "magic" under the covers to have restoreGeometry() do the right thing.

Apologies for the false bug report.