1From e7ed869dd126463b927f931e2649e7f57c342cf9 Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Wed, 27 Feb 2019 16:52:15 +0800 4Subject: [PATCH 05/17] qwaylandxdgshell: Support setting window position 5 6Support setting window position. 7Note: 81/ (0,0) initial position(default position) would be ignored. 92/ The decoration would be ignored when the space not enough. 103/ QT would not aware of the wayland position. 11 12Change-Id: Ifb1433b3902d44c1b2e43036bc1805a6e00128fb 13Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 14--- 15 .../xdg-shell/qwaylandxdgshell.cpp | 14 ++++++++++++++ 16 .../xdg-shell/qwaylandxdgshell_p.h | 2 ++ 17 2 files changed, 16 insertions(+) 18 19diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp 20index d7d0ddf..61f7e8c 100644 21--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp 22+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp 23@@ -355,6 +355,20 @@ void QWaylandXdgSurface::propagateSizeHints() 24 void QWaylandXdgSurface::setWindowGeometry(const QRect &rect) 25 { 26 set_window_geometry(rect.x(), rect.y(), rect.width(), rect.height()); 27+ 28+ if (m_window) { 29+ QPoint position = m_window->geometry().topLeft(); 30+ 31+ // Also avoid initial position (0,0). 32+ // What if we do want to be at (0,0)? 33+ if (m_position == position) 34+ return; 35+ m_position = position; 36+ 37+ // HACK: Set window position through .set_window_geometry(x, y, 0, 0) 38+ set_window_geometry(position.x() > 0 ? position.x() : 0, 39+ position.y() > 0 ? position.y() : 0, 0, 0); 40+ } 41 } 42 43 void QWaylandXdgSurface::setSizeHints() 44diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h 45index 0c98be3..27d4a2e 100644 46--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h 47+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h 48@@ -154,6 +154,8 @@ private: 49 QRegion m_exposeRegion; 50 uint m_pendingConfigureSerial = 0; 51 52+ QPoint m_position; 53+ 54 friend class QWaylandXdgShell; 55 }; 56 57-- 582.20.1 59 60