summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandwindow.cpp
diff options
context:
space:
mode:
authorPhilippe Coval <philippe.coval@open.eurogiciel.org>2014-03-26 10:16:01 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-09 11:44:30 +0200
commit768484daaa64bea965bef981a16f59be8db0c190 (patch)
tree0e65a8d37f340a4dcdd1f3eb10f4245afba9e35a /src/client/qwaylandwindow.cpp
parentc2a22eea6716e073875474adf624d8463eba836c (diff)
Add minimize feature to QWindow using wayland's xdg-shell
The feature is disabled by default, and can be enabled at runtime by exporting QT_WAYLAND_USE_XDG_SHELL env variable. This patch relies on presence of protocol file which has been imported from weston-1.4.0 sources, until the xdg-shell is merge into wayland itself. Because xdg-shell is experimental, code fallback to WaylandShell if no XdgShell but keep in mind those shells are exclusive. Since xdg-shell and wayland-shell share most of the API, some factorization is done by an (empty) abstraction class to keep the code more readable. Despite xdg-shell introduces new popups concept, they're not used on this change for maitainance purpose. Notes: * This change depends on presence of xdg-shell protocol file. * You can check a demo video (qt-tizen-cinematic-experience-20140430-rzr) of the test case at : https://www.youtube.com/watch?v=pY_XXvKc_0E# * Use Super+Tab to show window again if hidden Task-number: QTBUG-38633/part/2of2 Change-Id: I2d7ed85bea1847d82439fdfc893a3dbb2581c14a Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r--src/client/qwaylandwindow.cpp40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 216c2551d..9a7b7f09e 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -46,6 +46,8 @@
#include "qwaylandinputdevice_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandshellsurface_p.h"
+#include "qwaylandwlshellsurface_p.h"
+#include "qwaylandxdgsurface_p.h"
#include "qwaylandextendedsurface_p.h"
#include "qwaylandsubsurface_p.h"
#include "qwaylanddecoration_p.h"
@@ -92,8 +94,16 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
static WId id = 1;
mWindowId = id++;
- if (mDisplay->shell() && window->type() & Qt::Window && !(window->flags() & Qt::BypassWindowManagerHint))
- mShellSurface = new QWaylandShellSurface(mDisplay->shell()->get_shell_surface(object()), this);
+ if (!(window->flags() & Qt::BypassWindowManagerHint)) {
+ if (mDisplay->shellXdg()) {
+ if (window->type() & Qt::Window) {
+ mShellSurface = new QWaylandXdgSurface(mDisplay->shellXdg()->get_xdg_surface(object()), this);
+ }
+ } else if (mDisplay->shell() && window->type() & Qt::Window) {
+ mShellSurface = new QWaylandWlShellSurface(mDisplay->shell()->get_shell_surface(object()), this);
+ }
+ }
+
if (mDisplay->windowExtension())
mExtendedWindow = new QWaylandExtendedSurface(this, mDisplay->windowExtension()->get_extended_surface(object()));
if (mDisplay->subSurfaceExtension())
@@ -101,12 +111,12 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
if (mShellSurface) {
// Set initial surface title
- mShellSurface->set_title(window->title());
+ mShellSurface->setTitle(window->title());
// Set surface class to the .desktop file name (obtained from executable name)
QFileInfo exeFileInfo(qApp->applicationFilePath());
QString className = exeFileInfo.baseName() + QLatin1String(".desktop");
- mShellSurface->set_class(className);
+ mShellSurface->setAppId(className);
}
if (QPlatformWindow::parent() && mSubSurfaceWindow) {
@@ -171,7 +181,7 @@ void QWaylandWindow::setParent(const QPlatformWindow *parent)
void QWaylandWindow::setWindowTitle(const QString &title)
{
if (mShellSurface) {
- mShellSurface->set_title(title);
+ mShellSurface->setTitle(title);
}
if (mWindowDecoration && window()->isVisible())
@@ -223,8 +233,10 @@ void QWaylandWindow::setVisible(bool visible)
mMouseDevice = parent->mMouseDevice;
mMouseSerial = parent->mMouseSerial;
- if (mMouseDevice)
- mShellSurface->setPopup(transientParent(), mMouseDevice, mMouseSerial);
+ QWaylandWlShellSurface *wlshellSurface = dynamic_cast<QWaylandWlShellSurface*>(mShellSurface);
+ if (mMouseDevice && wlshellSurface) {
+ wlshellSurface->setPopup(transientParent(), mMouseDevice, mMouseSerial);
+ }
}
setGeometry(window()->geometry());
@@ -434,6 +446,20 @@ void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags)
bool QWaylandWindow::createDecoration()
{
+ // so far only xdg-shell support this "unminimize" trick, may be moved elsewhere
+ if (mState == Qt::WindowMinimized) {
+ QWaylandXdgSurface *xdgSurface = dynamic_cast<QWaylandXdgSurface *>(mShellSurface);
+ if ( xdgSurface ) {
+ if (xdgSurface->isFullscreen()) {
+ setWindowStateInternal(Qt::WindowFullScreen);
+ } else if (xdgSurface->isMaximized()) {
+ setWindowStateInternal(Qt::WindowMaximized);
+ } else {
+ setWindowStateInternal(Qt::WindowNoState);
+ }
+ }
+ }
+
static bool disableWaylandDecorations = !qgetenv("QT_WAYLAND_DISABLE_WINDOWDECORATION").isEmpty();
if (disableWaylandDecorations)
return false;