Skip to content

Commit

Permalink
doc: Add note about platform support for window positions
Browse files Browse the repository at this point in the history
On some platforms, such as Wayland (and also eglfs), manual window
positioning is not supported. Since this has caused confusion in the
past, we add a note to the documentation.

Pick-to: 6.2 6.5
Fixes: QTBUG-86780
Change-Id: Idf8dcdfad8ccfb9eb0f704fce05216562e433e20
Reviewed-by: Tor Arne Vestbø <[email protected]>
  • Loading branch information
eskilblomfeldt committed Mar 17, 2023
1 parent f50b853 commit 5c7a3ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/gui/kernel/qwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,10 @@ void QWindow::setFramePosition(const QPoint &point)
For interactively moving windows, see startSystemMove(). For interactively
resizing windows, see startSystemResize().
\note Not all windowing systems support setting or querying top level window positions.
On such a system, programmatically moving windows may not have any effect, and artificial
values may be returned for the current positions, such as \c QPoint(0, 0).
\sa position(), startSystemMove()
*/
void QWindow::setPosition(const QPoint &pt)
Expand All @@ -1905,6 +1909,10 @@ void QWindow::setPosition(int posx, int posy)
\fn QPoint QWindow::position() const
\brief Returns the position of the window on the desktop excluding any window frame
\note Not all windowing systems support setting or querying top level window positions.
On such a system, programmatically moving windows may not have any effect, and artificial
values may be returned for the current positions, such as \c QPoint(0, 0).
\sa setPosition()
*/

Expand Down
9 changes: 9 additions & 0 deletions src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@
depends on the result of QWidget::frameGeometry() and the
capability of the window manager to do proper window placement,
neither of which can be guaranteed.

\section2 Wayland Peculiarities

On Wayland, programmatically setting or getting the position of a top-level window from the
client-side is typically not supported. Technically speaking, it depends on the shell
interface. For typical desktop compositors, however, the default shell interface will be
\c{XDG Shell}, which does not support manual positioning of windows. In such cases, Qt will
ignore calls to set the top-level position of a window, and, when queried, the window position
will always be returned as QPoint(0, 0).
*/

/*!
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/kernel/qwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3547,6 +3547,10 @@ int QWidget::y() const
See the \l{Window Geometry} documentation for an overview of geometry
issues with windows.
\note Not all windowing systems support setting or querying top level window positions.
On such a system, programmatically moving windows may not have any effect, and artificial
values may be returned for the current positions, such as \c QPoint(0, 0).
\sa frameGeometry, size, x(), y()
*/
QPoint QWidget::pos() const
Expand Down

0 comments on commit 5c7a3ea

Please sign in to comment.