1 From 0edba039247ce888dbb7ff0a93c7b9ec01bac46e Mon Sep 17 00:00:00 2001
2 From: Philippe Coval <philippe.coval@open.eurogiciel.org>
3 Date: Wed, 26 Mar 2014 10:16:01 +0100
4 Subject: [PATCH 17/21] xdg-shell: Add minimize feature to QWindow using
7 The feature is disabled by default,
8 and can be enabled at runtime
9 by exporting QT_WAYLAND_USE_XDG_SHELL env variable.
11 This patch relies on presence of protocol file
12 which has been imported from weston-1.4.0 sources,
13 until the xdg-shell is merge into wayland itself.
15 Because xdg-shell is experimental,
16 code fallback to WaylandShell if no XdgShell
17 but keep in mind those shells are exclusive.
19 Since xdg-shell and wayland-shell share most of the API,
20 some factorization is done by an (empty) abstraction class
21 to keep the code more readable.
23 Despite xdg-shell introduces new popups concept,
24 they're not used on this change for maitainance purpose.
28 * This change depends on presence of xdg-shell protocol file.
30 * You can check a demo video
31 (qt-tizen-cinematic-experience-20140430-rzr)
33 https://www.youtube.com/watch?v=pY_XXvKc_0E#
35 * Use Super+Tab to show window again if hidden
37 Task-number: QTBUG-38633/part/2of2
38 Change-Id: I2d7ed85bea1847d82439fdfc893a3dbb2581ffff
39 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
40 Origin: https://www.qt.gitorious.org/qt/qtwayland/commit/768484daaa64bea965bef981a16f59be8db0c190
41 Bug-Tizen: TIVI-3113/part
42 Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
44 src/client/client.pro | 5 +
45 src/client/qwaylanddisplay.cpp | 5 +
46 src/client/qwaylanddisplay_p.h | 4 +
47 src/client/qwaylandshellsurface.cpp | 134 ------------------------
48 src/client/qwaylandshellsurface_p.h | 40 +++-----
49 src/client/qwaylandwindow.cpp | 40 ++++++--
50 src/client/qwaylandwlshellsurface.cpp | 186 ++++++++++++++++++++++++++++++++++
51 src/client/qwaylandwlshellsurface_p.h | 101 ++++++++++++++++++
52 src/client/qwaylandxdgsurface.cpp | 173 +++++++++++++++++++++++++++++++
53 src/client/qwaylandxdgsurface_p.h | 105 +++++++++++++++++++
54 10 files changed, 625 insertions(+), 168 deletions(-)
55 create mode 100644 src/client/qwaylandwlshellsurface.cpp
56 create mode 100644 src/client/qwaylandwlshellsurface_p.h
57 create mode 100644 src/client/qwaylandxdgsurface.cpp
58 create mode 100644 src/client/qwaylandxdgsurface_p.h
60 diff --git a/src/client/client.pro b/src/client/client.pro
61 index 10cbd31..9ecf82f 100644
62 --- a/src/client/client.pro
63 +++ b/src/client/client.pro
64 @@ -41,6 +41,7 @@ WAYLANDCLIENTSOURCES += \
65 ../extensions/qtkey-extension.xml \
66 ../extensions/windowmanager.xml \
67 ../3rdparty/protocol/text.xml \
68 + ../3rdparty/protocol/xdg-shell.xml \
70 SOURCES += qwaylandintegration.cpp \
71 qwaylandnativeinterface.cpp \
72 @@ -57,6 +58,8 @@ SOURCES += qwaylandintegration.cpp \
73 qwaylanddatadevicemanager.cpp \
74 qwaylanddatasource.cpp \
75 qwaylandshellsurface.cpp \
76 + qwaylandwlshellsurface.cpp \
77 + qwaylandxdgsurface.cpp \
78 qwaylandextendedoutput.cpp \
79 qwaylandextendedsurface.cpp \
80 qwaylandsubsurface.cpp \
81 @@ -85,6 +88,8 @@ HEADERS += qwaylandintegration_p.h \
82 qwaylanddatadevicemanager_p.h \
83 qwaylanddatasource_p.h \
84 qwaylandshellsurface_p.h \
85 + qwaylandwlshellsurface_p.h \
86 + qwaylandxdgsurface_p.h \
87 qwaylandextendedoutput_p.h \
88 qwaylandextendedsurface_p.h \
89 qwaylandsubsurface_p.h \
90 diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
91 index 0b715c0..7f953ad 100644
92 --- a/src/client/qwaylanddisplay.cpp
93 +++ b/src/client/qwaylanddisplay.cpp
95 #include "qwaylandqtkey_p.h"
97 #include <QtWaylandClient/private/qwayland-text.h>
98 +#include <QtWaylandClient/private/qwayland-xdg-shell.h>
100 #include <QtCore/QAbstractEventDispatcher>
101 #include <QtGui/private/qguiapplication_p.h>
102 @@ -206,6 +207,10 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
103 mCompositor.init(registry, id);
104 } else if (interface == QStringLiteral("wl_shm")) {
105 mShm = static_cast<struct wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface,1));
106 + } else if (interface == QStringLiteral("xdg_shell")
107 + && qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) {
108 + mShellXdg.reset(new QtWayland::xdg_shell(registry, id));
109 + mShellXdg->use_unstable_version(QtWayland::xdg_shell::version_current);
110 } else if (interface == QStringLiteral("wl_shell")){
111 mShell.reset(new QtWayland::wl_shell(registry, id));
112 } else if (interface == QStringLiteral("wl_seat")) {
113 diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
114 index 40cb2b2..cf5dfc2 100644
115 --- a/src/client/qwaylanddisplay_p.h
116 +++ b/src/client/qwaylanddisplay_p.h
119 #include <QtWaylandClient/private/qwayland-wayland.h>
120 #include <QtWaylandClient/private/qwaylandclientexport_p.h>
121 +#include <QtWaylandClient/private/qwayland-xdg-shell.h>
123 struct wl_cursor_image;
125 @@ -78,6 +79,7 @@ namespace QtWayland {
126 class qt_sub_surface_extension;
127 class qt_surface_extension;
128 class wl_text_input_manager;
132 typedef void (*RegistryListener)(void *data,
133 @@ -113,6 +115,7 @@ public:
134 QtWayland::wl_compositor *compositor() { return &mCompositor; }
136 QtWayland::wl_shell *shell() { return mShell.data(); }
137 + QtWayland::xdg_shell *shellXdg() { return mShellXdg.data(); }
139 QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
140 QWaylandInputDevice *defaultInputDevice() const;
141 @@ -168,6 +171,7 @@ private:
142 QThread *mEventThread;
143 QWaylandEventThread *mEventThreadObject;
144 QScopedPointer<QtWayland::wl_shell> mShell;
145 + QScopedPointer<QtWayland::xdg_shell> mShellXdg;
146 QList<QPlatformScreen *> mScreens;
147 QList<QWaylandInputDevice *> mInputDevices;
148 QList<Listener> mRegistryListeners;
149 diff --git a/src/client/qwaylandshellsurface.cpp b/src/client/qwaylandshellsurface.cpp
150 index b7a819f..80e509b 100644
151 --- a/src/client/qwaylandshellsurface.cpp
152 +++ b/src/client/qwaylandshellsurface.cpp
154 ****************************************************************************/
156 #include "qwaylandshellsurface_p.h"
158 -#include "qwaylanddisplay_p.h"
159 -#include "qwaylandwindow_p.h"
160 -#include "qwaylandinputdevice_p.h"
161 -#include "qwaylanddecoration_p.h"
162 -#include "qwaylandscreen_p.h"
164 -#include <QtCore/QDebug>
168 -QWaylandShellSurface::QWaylandShellSurface(struct ::wl_shell_surface *shell_surface, QWaylandWindow *window)
169 - : QtWayland::wl_shell_surface(shell_surface)
171 - , m_maximized(false)
172 - , m_fullscreen(false)
176 -QWaylandShellSurface::~QWaylandShellSurface()
178 - wl_shell_surface_destroy(object());
181 -void QWaylandShellSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
183 - resize(inputDevice->wl_seat(),
184 - inputDevice->serial(),
188 -void QWaylandShellSurface::move(QWaylandInputDevice *inputDevice)
190 - move(inputDevice->wl_seat(),
191 - inputDevice->serial());
194 -void QWaylandShellSurface::setMaximized()
196 - m_maximized = true;
197 - m_size = m_window->window()->geometry().size();
201 -void QWaylandShellSurface::setFullscreen()
203 - m_fullscreen = true;
204 - m_size = m_window->window()->geometry().size();
205 - set_fullscreen(WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, 0);
208 -void QWaylandShellSurface::setNormal()
210 - if (m_fullscreen || m_maximized) {
211 - m_fullscreen = m_maximized = false;
213 - QMargins m = m_window->frameMargins();
214 - m_window->configure(0, m_size.width() + m.left() + m.right(), m_size.height() + m.top() + m.bottom());
218 -void QWaylandShellSurface::setMinimized()
220 - // TODO: There's no wl_shell_surface API for this
223 -void QWaylandShellSurface::setTopLevel()
228 -void QWaylandShellSurface::updateTransientParent(QWindow *parent)
230 - QWaylandWindow *parent_wayland_window = static_cast<QWaylandWindow *>(parent->handle());
231 - if (!parent_wayland_window)
234 - // set_transient expects a position relative to the parent
235 - QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
236 - QWindow *parentWin = m_window->window()->transientParent();
237 - transientPos -= parentWin->geometry().topLeft();
238 - if (parent_wayland_window->decoration()) {
239 - transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
240 - transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
243 - uint32_t flags = 0;
244 - Qt::WindowFlags wf = m_window->window()->flags();
245 - if (wf.testFlag(Qt::ToolTip)
246 - || wf.testFlag(Qt::WindowTransparentForInput))
247 - flags |= WL_SHELL_SURFACE_TRANSIENT_INACTIVE;
249 - set_transient(parent_wayland_window->object(),
255 -void QWaylandShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial)
257 - QWaylandWindow *parent_wayland_window = parent;
258 - if (!parent_wayland_window)
261 - // set_popup expects a position relative to the parent
262 - QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
263 - transientPos -= parent_wayland_window->geometry().topLeft();
264 - if (parent_wayland_window->decoration()) {
265 - transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
266 - transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
269 - set_popup(device->wl_seat(), serial, parent_wayland_window->object(),
270 - transientPos.x(), transientPos.y(), 0);
273 -void QWaylandShellSurface::shell_surface_ping(uint32_t serial)
278 -void QWaylandShellSurface::shell_surface_configure(uint32_t edges,
282 - m_window->configure(edges, width, height);
285 -void QWaylandShellSurface::shell_surface_popup_done()
287 - QCoreApplication::postEvent(m_window->window(), new QCloseEvent());
291 diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
292 index 2477c3f..2f59f60 100644
293 --- a/src/client/qwaylandshellsurface_p.h
294 +++ b/src/client/qwaylandshellsurface_p.h
295 @@ -55,39 +55,25 @@ class QWaylandWindow;
296 class QWaylandInputDevice;
299 -class Q_WAYLAND_CLIENT_EXPORT QWaylandShellSurface : public QtWayland::wl_shell_surface
300 +class Q_WAYLAND_CLIENT_EXPORT QWaylandShellSurface
303 - QWaylandShellSurface(struct ::wl_shell_surface *shell_surface, QWaylandWindow *window);
304 - ~QWaylandShellSurface();
305 + virtual ~QWaylandShellSurface() {}
306 + virtual void resize(QWaylandInputDevice * /*inputDevice*/, enum wl_shell_surface_resize /*edges*/)
309 - using QtWayland::wl_shell_surface::resize;
310 - void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges);
312 - using QtWayland::wl_shell_surface::move;
313 - void move(QWaylandInputDevice *inputDevice);
314 + virtual void move(QWaylandInputDevice * /*inputDevice*/) {}
315 + virtual void setTitle(const QString & /*title*/) {}
316 + virtual void setAppId(const QString & /*appId*/) {}
319 - void setMaximized();
320 - void setFullscreen();
322 - void setMinimized();
324 - void setTopLevel();
325 - void updateTransientParent(QWindow *parent);
326 - void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial);
328 - QWaylandWindow *m_window;
333 - void shell_surface_ping(uint32_t serial) Q_DECL_OVERRIDE;
334 - void shell_surface_configure(uint32_t edges,
336 - int32_t height) Q_DECL_OVERRIDE;
337 - void shell_surface_popup_done() Q_DECL_OVERRIDE;
338 + virtual void setMaximized() {}
339 + virtual void setFullscreen() {}
340 + virtual void setNormal() {}
341 + virtual void setMinimized() {}
343 + virtual void setTopLevel() {}
344 + virtual void updateTransientParent(QWindow * /*parent*/) {}
345 friend class QWaylandWindow;
348 diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
349 index 920c977..3fb3a49 100644
350 --- a/src/client/qwaylandwindow.cpp
351 +++ b/src/client/qwaylandwindow.cpp
353 #include "qwaylandinputdevice_p.h"
354 #include "qwaylandscreen_p.h"
355 #include "qwaylandshellsurface_p.h"
356 +#include "qwaylandwlshellsurface_p.h"
357 +#include "qwaylandxdgsurface_p.h"
358 #include "qwaylandextendedsurface_p.h"
359 #include "qwaylandsubsurface_p.h"
360 #include "qwaylanddecoration_p.h"
361 @@ -92,8 +94,16 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
365 - if (mDisplay->shell() && window->type() & Qt::Window && !(window->flags() & Qt::BypassWindowManagerHint))
366 - mShellSurface = new QWaylandShellSurface(mDisplay->shell()->get_shell_surface(object()), this);
367 + if (!(window->flags() & Qt::BypassWindowManagerHint)) {
368 + if (mDisplay->shellXdg()) {
369 + if (window->type() & Qt::Window) {
370 + mShellSurface = new QWaylandXdgSurface(mDisplay->shellXdg()->get_xdg_surface(object()), this);
372 + } else if (mDisplay->shell() && window->type() & Qt::Window) {
373 + mShellSurface = new QWaylandWlShellSurface(mDisplay->shell()->get_shell_surface(object()), this);
377 if (mDisplay->windowExtension())
378 mExtendedWindow = new QWaylandExtendedSurface(this, mDisplay->windowExtension()->get_extended_surface(object()));
379 if (mDisplay->subSurfaceExtension())
380 @@ -101,12 +111,12 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
383 // Set initial surface title
384 - mShellSurface->set_title(window->title());
385 + mShellSurface->setTitle(window->title());
387 // Set surface class to the .desktop file name (obtained from executable name)
388 QFileInfo exeFileInfo(qApp->applicationFilePath());
389 QString className = exeFileInfo.baseName() + QLatin1String(".desktop");
390 - mShellSurface->set_class(className);
391 + mShellSurface->setAppId(className);
394 if (QPlatformWindow::parent() && mSubSurfaceWindow) {
395 @@ -170,7 +180,7 @@ void QWaylandWindow::setParent(const QPlatformWindow *parent)
396 void QWaylandWindow::setWindowTitle(const QString &title)
399 - mShellSurface->set_title(title);
400 + mShellSurface->setTitle(title);
403 if (mWindowDecoration && window()->isVisible())
404 @@ -212,8 +222,10 @@ void QWaylandWindow::setVisible(bool visible)
405 mMouseDevice = parent->mMouseDevice;
406 mMouseSerial = parent->mMouseSerial;
409 - mShellSurface->setPopup(transientParent(), mMouseDevice, mMouseSerial);
410 + QWaylandWlShellSurface *wlshellSurface = dynamic_cast<QWaylandWlShellSurface*>(mShellSurface);
411 + if (mMouseDevice && wlshellSurface) {
412 + wlshellSurface->setPopup(transientParent(), mMouseDevice, mMouseSerial);
416 if (!mSentInitialResize) {
417 @@ -428,6 +440,20 @@ void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags)
419 bool QWaylandWindow::createDecoration()
421 + // so far only xdg-shell support this "unminimize" trick, may be moved elsewhere
422 + if (mState == Qt::WindowMinimized) {
423 + QWaylandXdgSurface *xdgSurface = dynamic_cast<QWaylandXdgSurface *>(mShellSurface);
424 + if ( xdgSurface ) {
425 + if (xdgSurface->isFullscreen()) {
426 + setWindowStateInternal(Qt::WindowFullScreen);
427 + } else if (xdgSurface->isMaximized()) {
428 + setWindowStateInternal(Qt::WindowMaximized);
430 + setWindowStateInternal(Qt::WindowNoState);
435 static bool disableWaylandDecorations = !qgetenv("QT_WAYLAND_DISABLE_WINDOWDECORATION").isEmpty();
436 if (disableWaylandDecorations)
438 diff --git a/src/client/qwaylandwlshellsurface.cpp b/src/client/qwaylandwlshellsurface.cpp
440 index 0000000..4b73ec2
442 +++ b/src/client/qwaylandwlshellsurface.cpp
444 +/****************************************************************************
446 +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
447 +** Contact: http://www.qt-project.org/legal
449 +** This file is part of the config.tests of the Qt Toolkit.
451 +** $QT_BEGIN_LICENSE:LGPL$
452 +** Commercial License Usage
453 +** Licensees holding valid commercial Qt licenses may use this file in
454 +** accordance with the commercial license agreement provided with the
455 +** Software or, alternatively, in accordance with the terms contained in
456 +** a written agreement between you and Digia. For licensing terms and
457 +** conditions see http://qt.digia.com/licensing. For further information
458 +** use the contact form at http://qt.digia.com/contact-us.
460 +** GNU Lesser General Public License Usage
461 +** Alternatively, this file may be used under the terms of the GNU Lesser
462 +** General Public License version 2.1 as published by the Free Software
463 +** Foundation and appearing in the file LICENSE.LGPL included in the
464 +** packaging of this file. Please review the following information to
465 +** ensure the GNU Lesser General Public License version 2.1 requirements
466 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
468 +** In addition, as a special exception, Digia gives you certain additional
469 +** rights. These rights are described in the Digia Qt LGPL Exception
470 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
472 +** GNU General Public License Usage
473 +** Alternatively, this file may be used under the terms of the GNU
474 +** General Public License version 3.0 as published by the Free Software
475 +** Foundation and appearing in the file LICENSE.GPL included in the
476 +** packaging of this file. Please review the following information to
477 +** ensure the GNU General Public License version 3.0 requirements will be
478 +** met: http://www.gnu.org/copyleft/gpl.html.
483 +****************************************************************************/
485 +#include "qwaylandwlshellsurface_p.h"
487 +#include "qwaylanddisplay_p.h"
488 +#include "qwaylandwindow_p.h"
489 +#include "qwaylandinputdevice_p.h"
490 +#include "qwaylanddecoration_p.h"
491 +#include "qwaylandscreen_p.h"
493 +#include <QtCore/QDebug>
497 +QWaylandWlShellSurface::QWaylandWlShellSurface(struct ::wl_shell_surface *shell_surface, QWaylandWindow *window)
498 + : QtWayland::wl_shell_surface(shell_surface)
500 + , m_maximized(false)
501 + , m_fullscreen(false)
505 +QWaylandWlShellSurface::~QWaylandWlShellSurface()
507 + wl_shell_surface_destroy(object());
510 +void QWaylandWlShellSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
512 + resize(inputDevice->wl_seat(),
513 + inputDevice->serial(),
517 +void QWaylandWlShellSurface::move(QWaylandInputDevice *inputDevice)
519 + move(inputDevice->wl_seat(),
520 + inputDevice->serial());
523 +void QWaylandWlShellSurface::setTitle(const QString & title)
525 + return QtWayland::wl_shell_surface::set_title(title);
528 +void QWaylandWlShellSurface::setAppId(const QString & appId)
530 + return QtWayland::wl_shell_surface::set_class(appId);
533 +void QWaylandWlShellSurface::setMaximized()
535 + m_maximized = true;
536 + m_size = m_window->window()->geometry().size();
540 +void QWaylandWlShellSurface::setFullscreen()
542 + m_fullscreen = true;
543 + m_size = m_window->window()->geometry().size();
544 + set_fullscreen(WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, 0);
547 +void QWaylandWlShellSurface::setNormal()
549 + if (m_fullscreen || m_maximized) {
550 + m_fullscreen = m_maximized = false;
552 + QMargins m = m_window->frameMargins();
553 + m_window->configure(0, m_size.width() + m.left() + m.right(), m_size.height() + m.top() + m.bottom());
557 +void QWaylandWlShellSurface::setMinimized()
559 + // TODO: There's no wl_shell_surface API for this
562 +void QWaylandWlShellSurface::setTopLevel()
567 +void QWaylandWlShellSurface::updateTransientParent(QWindow *parent)
569 + QWaylandWindow *parent_wayland_window = static_cast<QWaylandWindow *>(parent->handle());
570 + if (!parent_wayland_window)
573 + // set_transient expects a position relative to the parent
574 + QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
575 + QWindow *parentWin = m_window->window()->transientParent();
576 + transientPos -= parentWin->geometry().topLeft();
577 + if (parent_wayland_window->decoration()) {
578 + transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
579 + transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
582 + uint32_t flags = 0;
583 + Qt::WindowFlags wf = m_window->window()->flags();
584 + if (wf.testFlag(Qt::ToolTip)
585 + || wf.testFlag(Qt::WindowTransparentForInput))
586 + flags |= WL_SHELL_SURFACE_TRANSIENT_INACTIVE;
588 + set_transient(parent_wayland_window->object(),
594 +void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial)
596 + QWaylandWindow *parent_wayland_window = parent;
597 + if (!parent_wayland_window)
600 + // set_popup expects a position relative to the parent
601 + QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
602 + transientPos -= parent_wayland_window->geometry().topLeft();
603 + if (parent_wayland_window->decoration()) {
604 + transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
605 + transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
608 + set_popup(device->wl_seat(), serial, parent_wayland_window->object(),
609 + transientPos.x(), transientPos.y(), 0);
612 +void QWaylandWlShellSurface::shell_surface_ping(uint32_t serial)
617 +void QWaylandWlShellSurface::shell_surface_configure(uint32_t edges,
621 + m_window->configure(edges, width, height);
624 +void QWaylandWlShellSurface::shell_surface_popup_done()
626 + QCoreApplication::postEvent(m_window->window(), new QCloseEvent());
630 diff --git a/src/client/qwaylandwlshellsurface_p.h b/src/client/qwaylandwlshellsurface_p.h
632 index 0000000..d02bb7b
634 +++ b/src/client/qwaylandwlshellsurface_p.h
636 +/****************************************************************************
638 +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
639 +** Contact: http://www.qt-project.org/legal
641 +** This file is part of the config.tests of the Qt Toolkit.
643 +** $QT_BEGIN_LICENSE:LGPL$
644 +** Commercial License Usage
645 +** Licensees holding valid commercial Qt licenses may use this file in
646 +** accordance with the commercial license agreement provided with the
647 +** Software or, alternatively, in accordance with the terms contained in
648 +** a written agreement between you and Digia. For licensing terms and
649 +** conditions see http://qt.digia.com/licensing. For further information
650 +** use the contact form at http://qt.digia.com/contact-us.
652 +** GNU Lesser General Public License Usage
653 +** Alternatively, this file may be used under the terms of the GNU Lesser
654 +** General Public License version 2.1 as published by the Free Software
655 +** Foundation and appearing in the file LICENSE.LGPL included in the
656 +** packaging of this file. Please review the following information to
657 +** ensure the GNU Lesser General Public License version 2.1 requirements
658 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
660 +** In addition, as a special exception, Digia gives you certain additional
661 +** rights. These rights are described in the Digia Qt LGPL Exception
662 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
664 +** GNU General Public License Usage
665 +** Alternatively, this file may be used under the terms of the GNU
666 +** General Public License version 3.0 as published by the Free Software
667 +** Foundation and appearing in the file LICENSE.GPL included in the
668 +** packaging of this file. Please review the following information to
669 +** ensure the GNU General Public License version 3.0 requirements will be
670 +** met: http://www.gnu.org/copyleft/gpl.html.
675 +****************************************************************************/
677 +#ifndef QWAYLANDWLSHELLSURFACE_H
678 +#define QWAYLANDWLSHELLSURFACE_H
680 +#include <QtCore/QSize>
682 +#include <wayland-client.h>
684 +#include <QtWaylandClient/private/qwayland-wayland.h>
685 +#include <QtWaylandClient/private/qwaylandclientexport_p.h>
686 +#include "qwaylandshellsurface_p.h"
690 +class QWaylandWindow;
691 +class QWaylandInputDevice;
694 +class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellSurface : public QtWayland::wl_shell_surface
695 + , public QWaylandShellSurface
698 + QWaylandWlShellSurface(struct ::wl_shell_surface *shell_surface, QWaylandWindow *window);
699 + virtual ~QWaylandWlShellSurface();
701 + using QtWayland::wl_shell_surface::resize;
702 + void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges) Q_DECL_OVERRIDE;
704 + using QtWayland::wl_shell_surface::move;
705 + void move(QWaylandInputDevice *inputDevice) Q_DECL_OVERRIDE;
707 + void setTitle(const QString & title) Q_DECL_OVERRIDE;
708 + void setAppId(const QString &appId) Q_DECL_OVERRIDE;
711 + void setMaximized() Q_DECL_OVERRIDE;
712 + void setFullscreen() Q_DECL_OVERRIDE;
713 + void setNormal() Q_DECL_OVERRIDE;
714 + void setMinimized() Q_DECL_OVERRIDE;
716 + void setTopLevel() Q_DECL_OVERRIDE;
717 + void updateTransientParent(QWindow *parent) Q_DECL_OVERRIDE;
718 + void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial);
720 + QWaylandWindow *m_window;
725 + void shell_surface_ping(uint32_t serial) Q_DECL_OVERRIDE;
726 + void shell_surface_configure(uint32_t edges,
728 + int32_t height) Q_DECL_OVERRIDE;
729 + void shell_surface_popup_done() Q_DECL_OVERRIDE;
731 + friend class QWaylandWindow;
736 +#endif // QWAYLANDSHELLSURFACE_H
737 diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp
739 index 0000000..1b8affa
741 +++ b/src/client/qwaylandxdgsurface.cpp
743 +/****************************************************************************
745 +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
746 +** Contact: http://www.qt-project.org/legal
748 +** This file is part of the config.tests of the Qt Toolkit.
750 +** $QT_BEGIN_LICENSE:LGPL$
751 +** Commercial License Usage
752 +** Licensees holding valid commercial Qt licenses may use this file in
753 +** accordance with the commercial license agreement provided with the
754 +** Software or, alternatively, in accordance with the terms contained in
755 +** a written agreement between you and Digia. For licensing terms and
756 +** conditions see http://qt.digia.com/licensing. For further information
757 +** use the contact form at http://qt.digia.com/contact-us.
759 +** GNU Lesser General Public License Usage
760 +** Alternatively, this file may be used under the terms of the GNU Lesser
761 +** General Public License version 2.1 as published by the Free Software
762 +** Foundation and appearing in the file LICENSE.LGPL included in the
763 +** packaging of this file. Please review the following information to
764 +** ensure the GNU Lesser General Public License version 2.1 requirements
765 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
767 +** In addition, as a special exception, Digia gives you certain additional
768 +** rights. These rights are described in the Digia Qt LGPL Exception
769 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
771 +** GNU General Public License Usage
772 +** Alternatively, this file may be used under the terms of the GNU
773 +** General Public License version 3.0 as published by the Free Software
774 +** Foundation and appearing in the file LICENSE.GPL included in the
775 +** packaging of this file. Please review the following information to
776 +** ensure the GNU General Public License version 3.0 requirements will be
777 +** met: http://www.gnu.org/copyleft/gpl.html.
782 +****************************************************************************/
784 +#include "qwaylandxdgsurface_p.h"
786 +#include "qwaylanddisplay_p.h"
787 +#include "qwaylandwindow_p.h"
788 +#include "qwaylandinputdevice_p.h"
789 +#include "qwaylanddecoration_p.h"
790 +#include "qwaylandscreen_p.h"
792 +#include <QtCore/QDebug>
796 +QWaylandXdgSurface::QWaylandXdgSurface(struct ::xdg_surface *xdg_surface, QWaylandWindow *window)
797 + : QtWayland::xdg_surface(xdg_surface)
799 + , m_maximized(false)
800 + , m_minimized(false)
801 + , m_fullscreen(false)
805 +QWaylandXdgSurface::~QWaylandXdgSurface()
807 + xdg_surface_destroy(object());
810 +void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
812 + // May need some conversion if types get incompatibles, ATM they're identical
813 + enum resize_edge const * const arg = reinterpret_cast<enum resize_edge const * const>(&edges);
814 + resize(inputDevice, *arg);
817 +void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum resize_edge edges)
819 + resize(inputDevice->wl_seat(),
820 + inputDevice->serial(),
824 +void QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice)
826 + move(inputDevice->wl_seat(),
827 + inputDevice->serial());
830 +void QWaylandXdgSurface::setMaximized()
832 + m_maximized = true;
833 + m_size = m_window->window()->geometry().size();
837 +void QWaylandXdgSurface::setFullscreen()
839 + m_fullscreen = true;
840 + m_size = m_window->window()->geometry().size();
844 +void QWaylandXdgSurface::setNormal()
846 + if (m_fullscreen || m_maximized || m_minimized) {
847 + if (m_maximized) { unset_maximized(); }
848 + if (m_fullscreen) { unset_fullscreen(); }
850 + m_fullscreen = m_maximized = m_minimized = false;
852 + QMargins m = m_window->frameMargins();
853 + m_window->configure(0, m_size.width() + m.left() + m.right(), m_size.height() + m.top() + m.bottom());
857 +void QWaylandXdgSurface::setMinimized()
859 + m_minimized = true;
860 + m_size = m_window->window()->geometry().size();
864 +void QWaylandXdgSurface::setTopLevel()
866 + // There's no xdg_shell_surface API for this, ignoring
869 +void QWaylandXdgSurface::updateTransientParent(QWindow *parent)
871 + QWaylandWindow *parent_wayland_window = static_cast<QWaylandWindow *>(parent->handle());
872 + if (!parent_wayland_window)
875 + // set_transient expects a position relative to the parent
876 + QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
877 + QWindow *parentWin = m_window->window()->transientParent();
878 + transientPos -= parentWin->geometry().topLeft();
879 + if (parent_wayland_window->decoration()) {
880 + transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
881 + transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
884 + uint32_t flags = 0;
885 + Qt::WindowFlags wf = m_window->window()->flags();
886 + if (wf.testFlag(Qt::ToolTip)
887 + || wf.testFlag(Qt::WindowTransparentForInput))
888 + flags |= XDG_SURFACE_SET_TRANSIENT_FOR;
890 + set_transient_for(parent_wayland_window->object());
893 +void QWaylandXdgSurface::setTitle(const QString & title)
895 + return QtWayland::xdg_surface::set_title(title);
898 +void QWaylandXdgSurface::setAppId(const QString & appId)
900 + return QtWayland::xdg_surface::set_app_id(appId);
903 +void QWaylandXdgSurface::xdg_surface_ping(uint32_t serial)
908 +void QWaylandXdgSurface::xdg_surface_configure(uint32_t edges, int32_t width,
911 + m_window->configure(edges, width, height);
916 diff --git a/src/client/qwaylandxdgsurface_p.h b/src/client/qwaylandxdgsurface_p.h
918 index 0000000..744d3f3
920 +++ b/src/client/qwaylandxdgsurface_p.h
922 +/****************************************************************************
924 +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
925 +** Contact: http://www.qt-project.org/legal
927 +** This file is part of the config.tests of the Qt Toolkit.
929 +** $QT_BEGIN_LICENSE:LGPL$
930 +** Commercial License Usage
931 +** Licensees holding valid commercial Qt licenses may use this file in
932 +** accordance with the commercial license agreement provided with the
933 +** Software or, alternatively, in accordance with the terms contained in
934 +** a written agreement between you and Digia. For licensing terms and
935 +** conditions see http://qt.digia.com/licensing. For further information
936 +** use the contact form at http://qt.digia.com/contact-us.
938 +** GNU Lesser General Public License Usage
939 +** Alternatively, this file may be used under the terms of the GNU Lesser
940 +** General Public License version 2.1 as published by the Free Software
941 +** Foundation and appearing in the file LICENSE.LGPL included in the
942 +** packaging of this file. Please review the following information to
943 +** ensure the GNU Lesser General Public License version 2.1 requirements
944 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
946 +** In addition, as a special exception, Digia gives you certain additional
947 +** rights. These rights are described in the Digia Qt LGPL Exception
948 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
950 +** GNU General Public License Usage
951 +** Alternatively, this file may be used under the terms of the GNU
952 +** General Public License version 3.0 as published by the Free Software
953 +** Foundation and appearing in the file LICENSE.GPL included in the
954 +** packaging of this file. Please review the following information to
955 +** ensure the GNU General Public License version 3.0 requirements will be
956 +** met: http://www.gnu.org/copyleft/gpl.html.
961 +****************************************************************************/
963 +#ifndef QWAYLANDXDGSURFACE_H
964 +#define QWAYLANDXDGSURFACE_H
966 +#include <QtCore/QSize>
968 +#include <wayland-client.h>
970 +#include <QtWaylandClient/private/qwayland-xdg-shell.h>
971 +#include <QtWaylandClient/private/qwaylandclientexport_p.h>
972 +#include "qwaylandshellsurface_p.h"
976 +class QWaylandWindow;
977 +class QWaylandInputDevice;
980 +class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurface : public QtWayland::xdg_surface
981 + , public QWaylandShellSurface
984 + QWaylandXdgSurface(struct ::xdg_surface *shell_surface, QWaylandWindow *window);
985 + virtual ~QWaylandXdgSurface();
987 + using QtWayland::xdg_surface::resize;
988 + void resize(QWaylandInputDevice *inputDevice, enum resize_edge edges);
990 + void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges) Q_DECL_OVERRIDE;
992 + using QtWayland::xdg_surface::move;
993 + void move(QWaylandInputDevice *inputDevice) Q_DECL_OVERRIDE;
995 + void setTitle(const QString &title) Q_DECL_OVERRIDE;
996 + void setAppId(const QString &appId) Q_DECL_OVERRIDE;
998 + bool isFullscreen() const { return m_fullscreen; }
999 + bool isMaximized() const { return m_maximized; }
1002 + void setMaximized() Q_DECL_OVERRIDE;
1003 + void setFullscreen() Q_DECL_OVERRIDE;
1004 + void setNormal() Q_DECL_OVERRIDE;
1005 + void setMinimized() Q_DECL_OVERRIDE;
1007 + void setTopLevel() Q_DECL_OVERRIDE;
1008 + void updateTransientParent(QWindow *parent) Q_DECL_OVERRIDE;
1011 + QWaylandWindow *m_window;
1014 + bool m_fullscreen;
1017 + void xdg_surface_ping(uint32_t serial) Q_DECL_OVERRIDE;
1018 + void xdg_surface_configure(uint32_t edges,
1020 + int32_t height) Q_DECL_OVERRIDE;
1021 + friend class QWaylandWindow;
1026 +#endif // QWAYLANDXDGSURFACE_H