Implemented graceful quitting of clients.
authorSamuel Rødal <samuel.rodal@nokia.com>
Fri, 18 May 2012 21:32:36 +0000 (23:32 +0200)
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>
Sat, 19 May 2012 05:58:30 +0000 (07:58 +0200)
Send a quit message to let the client shut down cleanly.

Change-Id: I5f99c9b92341fdb5f1b171f6fe36f26bf8a47026
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
extensions/windowmanager.xml
src/compositor/wayland_wrapper/wlcompositor.cpp
src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
src/plugins/platforms/wayland/qwaylandintegration.cpp
src/plugins/platforms/wayland/qwaylandintegration.h
src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp
src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h

index 352f3b3..d418e9e 100644 (file)
@@ -58,5 +58,7 @@
         <event name="hints">
             <arg name="show_is_fullscreen" type="int"/>
         </event>
+        <event name="quit">
+        </event>
     </interface>
 </protocol>
index 9f00045..5a1bf6d 100644 (file)
@@ -294,8 +294,13 @@ void Compositor::markSurfaceAsDirty(Wayland::Surface *surface)
 void Compositor::destroyClient(WaylandClient *c)
 {
     wl_client *client = static_cast<wl_client *>(c);
-    if (client) {
+    if (!client)
+        return;
+
+    if (m_windowManagerIntegration->managedClient(client)) {
+        m_windowManagerIntegration->sendQuitMessage(client);
         m_windowManagerIntegration->removeClient(client);
+    } else {
         wl_client_destroy(client);
     }
 }
index 2d760cf..6d85905 100644 (file)
@@ -109,6 +109,17 @@ void WindowManagerServerIntegration::setShowIsFullScreen(bool value)
     }
 }
 
+void WindowManagerServerIntegration::sendQuitMessage(wl_client *client)
+{
+    struct wl_resource *resource;
+    wl_list_for_each(resource, &client_resources, link) {
+        if (resource->client == client) {
+            wl_windowmanager_send_quit(resource);
+            return;
+        }
+    }
+}
+
 struct WindowManagerServerIntegrationClientData
 {
     QByteArray url;
index aec877e..9c2fa19 100644 (file)
@@ -75,6 +75,7 @@ public:
     WaylandManagedClient *managedClient(wl_client *client) const;
 
     void setShowIsFullScreen(bool value);
+    void sendQuitMessage(wl_client *client);
 
 signals:
     void clientAuthenticated(wl_client *client);
index 33883b9..0469f3f 100644 (file)
@@ -87,6 +87,15 @@ QWaylandIntegration::QWaylandIntegration()
     mInputContext = QPlatformInputContextFactory::create();
 }
 
+QWaylandIntegration::~QWaylandIntegration()
+{
+    delete mDrag;
+    delete mClipboard;
+    delete mAccessibility;
+    delete mNativeInterface;
+    delete mDisplay;
+}
+
 QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const
 {
     return mNativeInterface;
index 093a25b..9bb6130 100644 (file)
@@ -54,6 +54,7 @@ class QWaylandIntegration : public QPlatformIntegration
 {
 public:
     QWaylandIntegration();
+    ~QWaylandIntegration();
 
     bool hasCapability(QPlatformIntegration::Capability cap) const;
     QPlatformWindow *createPlatformWindow(QWindow *window) const;
index 347da61..25565ad 100644 (file)
@@ -125,7 +125,8 @@ void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *displa
 }
 
 const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::windowmanager_listener = {
-    QWaylandWindowManagerIntegration::handle_hints
+    QWaylandWindowManagerIntegration::handle_hints,
+    QWaylandWindowManagerIntegration::handle_quit
 };
 
 void QWaylandWindowManagerIntegration::handle_hints(void *data, wl_windowmanager *ext, int32_t showIsFullScreen)
@@ -135,6 +136,13 @@ void QWaylandWindowManagerIntegration::handle_hints(void *data, wl_windowmanager
     self->d_func()->m_showIsFullScreen = showIsFullScreen;
 }
 
+void QWaylandWindowManagerIntegration::handle_quit(void *data, wl_windowmanager *ext)
+{
+    Q_UNUSED(data);
+    Q_UNUSED(ext);
+    QGuiApplication::quit();
+}
+
 void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId)
 {
     Q_D(QWaylandWindowManagerIntegration);
index 3d61295..c2a2329 100644 (file)
@@ -86,6 +86,7 @@ private:
     static void handle_hints(void *data,
                              struct wl_windowmanager *ext,
                              int32_t showIsFullScreen);
+    static void handle_quit(void *data, struct wl_windowmanager *ext);
 
     static const struct wl_windowmanager_listener m_windowManagerListener;