Support ShowIsFullScreen in plugin and compositor.
authorSamuel Rødal <samuel.rodal@nokia.com>
Wed, 22 Feb 2012 09:52:54 +0000 (10:52 +0100)
committerSamuel Rødal <samuel.rodal@nokia.com>
Thu, 23 Feb 2012 08:19:43 +0000 (09:19 +0100)
Added way of controlling client side style hint ShowIsFullScreen from
compositor, and added support in plugin for the WindowFullScreen state.

Change-Id: I60efa5692b26e9a4079c3c2fb66eb72b67badd02
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
14 files changed:
extensions/windowmanager.xml
src/compositor/compositor_api/waylandcompositor.cpp
src/compositor/compositor_api/waylandcompositor.h
src/compositor/wayland_wrapper/wlcompositor.cpp
src/compositor/wayland_wrapper/wlcompositor.h
src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
src/plugins/platforms/wayland/qwaylanddisplay.cpp
src/plugins/platforms/wayland/qwaylandintegration.cpp
src/plugins/platforms/wayland/qwaylandintegration.h
src/plugins/platforms/wayland/qwaylandwindow.cpp
src/plugins/platforms/wayland/qwaylandwindow.h
src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp
src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h

index a725e8d..b2226c4 100644 (file)
@@ -45,6 +45,8 @@
         <request name="authenticate_with_token">
             <arg name="processid" type="string" />
         </request>
-
+        <event name="hints">
+            <arg name="show_is_fullscreen" type="int"/>
+        </event>
     </interface>
 </protocol>
index 4e1097c..301d422 100644 (file)
@@ -142,6 +142,11 @@ void WaylandCompositor::overrideSelection(QMimeData *data)
     m_compositor->overrideSelection(data);
 }
 
+void WaylandCompositor::setClientFullScreenHint(bool value)
+{
+    m_compositor->setClientFullScreenHint(value);
+}
+
 const char *WaylandCompositor::socketName() const
 {
     if (m_socket_name.isEmpty())
index 8406298..c68cd6c 100644 (file)
@@ -80,6 +80,8 @@ public:
     virtual void retainedSelectionReceived(QMimeData *mimeData);
     void overrideSelection(QMimeData *data);
 
+    void setClientFullScreenHint(bool value);
+
     const char *socketName() const;
 
     void setScreenOrientation(Qt::ScreenOrientation orientation);
index bd02b67..41445b6 100644 (file)
@@ -376,6 +376,11 @@ QRect Compositor::outputGeometry() const
     return m_output_global.geometry();
 }
 
+void Compositor::setClientFullScreenHint(bool value)
+{
+    m_windowManagerIntegration->setShowIsFullScreen(value);
+}
+
 InputDevice* Compositor::defaultInputDevice()
 {
     return m_default_input_device;
index d8acad2..be9b109 100644 (file)
@@ -120,6 +120,8 @@ public:
     void setOutputGeometry(const QRect &geometry);
     QRect outputGeometry() const;
 
+    void setClientFullScreenHint(bool value);
+
     void enableTouchExtension();
     TouchExtensionGlobal *touchExtension() { return m_touchExtension; }
     void configureTouchExtension(int flags);
index f7e08c8..75c6332 100644 (file)
@@ -48,6 +48,7 @@
 
 WindowManagerServerIntegration::WindowManagerServerIntegration(QObject *parent)
     : QObject(parent)
+    , m_showIsFullScreen(false)
 {
 }
 
@@ -94,13 +95,23 @@ void WindowManagerServerIntegration::authenticateWithToken(wl_client *client, co
     emit clientAuthenticated(client);
 }
 
+void WindowManagerServerIntegration::setShowIsFullScreen(bool value)
+{
+    m_showIsFullScreen = value;
+    struct wl_resource *resource;
+    wl_list_for_each(resource,&client_resources, link) {
+        wl_resource_post_event(resource, WL_WINDOWMANAGER_HINTS, int32_t(m_showIsFullScreen));
+    }
+}
+
 void WindowManagerServerIntegration::bind_func(struct wl_client *client, void *data,
                                       uint32_t version, uint32_t id)
 {
     Q_UNUSED(version);
     WindowManagerServerIntegration *win_mgr = static_cast<WindowManagerServerIntegration *>(data);
-    struct wl_resource *resource = wl_client_add_object(client,&wl_windowmanager_interface,&windowmanager_interface,id,data);
+    wl_resource *resource = wl_client_add_object(client,&wl_windowmanager_interface,&windowmanager_interface,id,data);
     win_mgr->registerResource(resource);
+    wl_resource_post_event(resource, WL_WINDOWMANAGER_HINTS, int32_t(win_mgr->m_showIsFullScreen));
 }
 
 
index 2077a73..d2e01b1 100644 (file)
@@ -73,7 +73,7 @@ public:
 
     WaylandManagedClient *managedClient(wl_client *client) const;
 
-    void setScreenOrientation(wl_client *client, struct wl_resource *output_resource, Qt::ScreenOrientation orientationInDegrees);
+    void setShowIsFullScreen(bool value);
 
 signals:
     void clientAuthenticated(wl_client *client);
@@ -83,6 +83,7 @@ private:
     void authenticateWithToken(wl_client *client, const char *token);
 
 private:
+    bool m_showIsFullScreen;
     QMap<wl_client*, WaylandManagedClient*> m_managedClients;
 
     static void bind_func(struct wl_client *client, void *data,
index 3b76abe..159c0cc 100644 (file)
 #include "gl_integration/qwaylandglintegration.h"
 #endif
 
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
+#endif
+
 QWaylandIntegration::QWaylandIntegration()
     : mFontDb(new QGenericUnixFontDatabase())
     , mEventDispatcher(createUnixEventDispatcher())
@@ -151,3 +155,12 @@ QPlatformInputContext *QWaylandIntegration::inputContext() const
 {
     return mInputContext;
 }
+
+QVariant QWaylandIntegration::styleHint(StyleHint hint) const
+{
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+    if (hint == ShowIsFullScreen && mDisplay->windowManagerIntegration())
+        return mDisplay->windowManagerIntegration()->showIsFullScreen();
+#endif
+    return QPlatformIntegration::styleHint(hint);
+}
index 757510b..8d0c093 100644 (file)
@@ -72,6 +72,8 @@ public:
 
     QPlatformInputContext *inputContext() const;
 
+    QVariant styleHint(StyleHint hint) const;
+
 private:
     QPlatformFontDatabase *mFontDb;
     QAbstractEventDispatcher *mEventDispatcher;
index 1142c31..b70860d 100644 (file)
@@ -147,7 +147,7 @@ void QWaylandWindow::attach(QWaylandBuffer *buffer)
 {
     mBuffer = buffer;
 
-    if (window()->visible()) {
+    if (window()->isVisible()) {
         wl_surface_attach(mSurface, mBuffer->buffer(),0,0);
         if (buffer)
             QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size()));
@@ -222,6 +222,22 @@ Qt::ScreenOrientation QWaylandWindow::requestWindowOrientation(Qt::ScreenOrienta
     return Qt::PrimaryOrientation;
 }
 
+Qt::WindowState QWaylandWindow::setWindowState(Qt::WindowState state)
+{
+    if (state == Qt::WindowFullScreen || state == Qt::WindowMaximized) {
+        QScreen *screen = window()->screen();
+
+        QRect geometry = screen->mapBetween(window()->windowOrientation(), screen->primaryOrientation(), screen->geometry());
+        setGeometry(geometry);
+
+        QWindowSystemInterface::handleGeometryChange(window(), geometry);
+
+        return state;
+    }
+
+    return Qt::WindowNoState;
+}
+
 Qt::WindowFlags QWaylandWindow::setWindowFlags(Qt::WindowFlags flags)
 {
     return mExtendedWindow->setWindowFlags(flags);
index b67e11d..ad36181 100644 (file)
@@ -88,6 +88,7 @@ public:
     void handleContentOrientationChange(Qt::ScreenOrientation orientation);
     Qt::ScreenOrientation requestWindowOrientation(Qt::ScreenOrientation orientation);
 
+    Qt::WindowState setWindowState(Qt::WindowState state);
     Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
 
 protected:
index a98ffdf..3e2507e 100644 (file)
@@ -61,20 +61,20 @@ public:
     QWaylandDisplay *m_waylandDisplay;
     struct wl_windowmanager *m_waylandWindowManager;
     QHash<QWindow*, QVariantMap> m_queuedProperties;
-
+    bool m_showIsFullScreen;
 };
 
 QWaylandWindowManagerIntegrationPrivate::QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay)
     : m_blockPropertyUpdates(false)
     , m_waylandDisplay(waylandDisplay)
     , m_waylandWindowManager(0)
+    , m_showIsFullScreen(false)
 {
 
 }
 
 QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::m_instance = 0;
 
-
 QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay)
 {
     return new QWaylandWindowManagerIntegration(waylandDisplay);
@@ -106,6 +106,12 @@ struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const
     return d->m_waylandWindowManager;
 }
 
+bool QWaylandWindowManagerIntegration::showIsFullScreen() const
+{
+    Q_D(const QWaylandWindowManagerIntegration);
+    return d->m_showIsFullScreen;
+}
+
 void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
 {
     Q_UNUSED(version);
@@ -113,9 +119,21 @@ void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *displa
         QWaylandWindowManagerIntegration *integration = static_cast<QWaylandWindowManagerIntegration *>(data);
         integration->d_ptr->m_waylandWindowManager =
                 static_cast<struct wl_windowmanager *>(wl_display_bind(display, id, &wl_windowmanager_interface));
+        wl_windowmanager_add_listener(integration->d_ptr->m_waylandWindowManager, &windowmanager_listener, integration);
     }
 }
 
+const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::windowmanager_listener = {
+    QWaylandWindowManagerIntegration::handle_hints
+};
+
+void QWaylandWindowManagerIntegration::handle_hints(void *data, wl_windowmanager *ext, int32_t showIsFullScreen)
+{
+    Q_UNUSED(ext);
+    QWaylandWindowManagerIntegration *self = static_cast<QWaylandWindowManagerIntegration *>(data);
+    self->d_func()->m_showIsFullScreen = showIsFullScreen;
+}
+
 void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId)
 {
     Q_D(QWaylandWindowManagerIntegration);
index af93eac..cfb4df7 100644 (file)
@@ -68,6 +68,8 @@ public:
     void mapClientToProcess(long long processId);
     void authenticateWithToken(const QByteArray &token = QByteArray());
 
+    bool showIsFullScreen() const;
+
 private:
     static void wlHandleListenerGlobal(wl_display *display, uint32_t id,
                                        const char *interface, uint32_t version, void *data);
@@ -76,6 +78,12 @@ private:
     QScopedPointer<QWaylandWindowManagerIntegrationPrivate> d_ptr;
     static QWaylandWindowManagerIntegration *m_instance;
 
+    static const struct wl_windowmanager_listener windowmanager_listener;
+
+    static void handle_hints(void *data,
+                             struct wl_windowmanager *ext,
+                             int32_t showIsFullScreen);
+
     static const struct wl_windowmanager_listener m_windowManagerListener;
 };