Create a ShellSurface class
authorJørgen Lind <jorgen.lind@nokia.com>
Mon, 9 Jan 2012 17:53:22 +0000 (18:53 +0100)
committerSamuel Rødal <samuel.rodal@nokia.com>
Tue, 10 Jan 2012 14:49:25 +0000 (15:49 +0100)
so that we can actually do something usefull in the callbacks

Change-Id: Ie8e85757bf5c90caa40db34df1b8bc642ba09962
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/compositor/wayland_wrapper/wayland_wrapper.pri
src/compositor/wayland_wrapper/wlcompositor.cpp
src/compositor/wayland_wrapper/wlcompositor.h
src/compositor/wayland_wrapper/wlshellsurface.cpp [moved from src/compositor/wayland_wrapper/wlshell.cpp with 67% similarity]
src/compositor/wayland_wrapper/wlshellsurface.h [moved from src/compositor/wayland_wrapper/wlshell.h with 83% similarity]
src/compositor/wayland_wrapper/wlsurface.cpp
src/compositor/wayland_wrapper/wlsurface.h

index 6340f5c..8bb7b17 100644 (file)
@@ -10,7 +10,7 @@ HEADERS += \
     $$PWD/wloutput.h \
     $$PWD/wlshmbuffer.h \
     $$PWD/wlsurface.h \
-    $$PWD/wlshell.h \
+    $$PWD/wlshellsurface.h \
     $$PWD/wlinputdevice.h \
     $$PWD/wldatadevicemanager.h \
     $$PWD/wldatadevice.h \
@@ -26,7 +26,7 @@ SOURCES += \
     $$PWD/wloutput.cpp \
     $$PWD/wlshmbuffer.cpp \
     $$PWD/wlsurface.cpp \
-    $$PWD/wlshell.cpp \
+    $$PWD/wlshellsurface.cpp \
     $$PWD/wlinputdevice.cpp \
     $$PWD/wldatadevicemanager.cpp \
     $$PWD/wldatadevice.cpp \
index 067263c..d777921 100644 (file)
@@ -50,6 +50,7 @@
 #include "wlextendedoutput.h"
 #include "wlextendedsurface.h"
 #include "wlsubsurface.h"
+#include "wlshellsurface.h"
 
 #include <QWindow>
 #include <QSocketNotifier>
@@ -106,7 +107,6 @@ Compositor *Compositor::instance()
 
 Compositor::Compositor(WaylandCompositor *qt_compositor)
     : m_display(new Display)
-    , m_shell(this)
     , m_shm(m_display)
     , m_current_frame(0)
     , m_last_queued_buf(-1)
@@ -141,6 +141,7 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
 
     wl_display_add_global(m_display->handle(), &wl_shell_interface, &m_shell, Shell::bind_func);
 
+    m_shell = new Shell(this);
     m_outputExtension = new OutputExtensionGlobal(this);
     m_surfaceExtension = new SurfaceExtensionGlobal(this);
 
index 828df09..60b0f02 100644 (file)
@@ -48,7 +48,6 @@
 #include "wloutput.h"
 #include "wldisplay.h"
 #include "wlshmbuffer.h"
-#include "wlshell.h"
 
 #include <wayland-server.h>
 
@@ -65,6 +64,7 @@ class DataDeviceManager;
 class OutputExtensionGlobal;
 class SurfaceExtensionGlobal;
 class SubSurfaceExtensionGlobal;
+class Shell;
 
 class Q_COMPOSITOR_EXPORT Compositor : public QObject
 {
@@ -147,9 +147,6 @@ private:
     /* Output */
     //make this a list of the available screens
     OutputGlobal m_output_global;
-
-    Shell m_shell;
-
     /* shm/*/
     ShmHandler m_shm;
 
@@ -176,6 +173,8 @@ private:
     //extensions
     WindowManagerServerIntegration *m_windowManagerIntegration;
 
+
+    Shell *m_shell;
     OutputExtensionGlobal *m_outputExtension;
     SurfaceExtensionGlobal *m_surfaceExtension;
     SubSurfaceExtensionGlobal *m_subSurfaceExtension;
 **
 ****************************************************************************/
 
-#include "wlshell.h"
-
-#include "wlcompositor.h"
+#include "wlshellsurface.h"
 
 #include "wlcompositor.h"
+#include "wlsurface.h"
+#include "wlinputdevice.h"
 
 #include <QtCore/qglobal.h>
 #include <QtCore/QDebug>
@@ -63,17 +63,25 @@ void Shell::bind_func(struct wl_client *client, void *data,
 void Shell::get_shell_surface(struct wl_client *client,
               struct wl_resource *shell_resource,
               uint32_t id,
-              struct wl_resource *surface)
+              struct wl_resource *surface_super)
 {
-    Q_UNUSED(surface);
-    wl_client_add_object(client,&wl_shell_surface_interface,&shell_surface_interface,id,shell_resource->data);
+    Q_UNUSED(shell_resource);
+    Surface *surface = reinterpret_cast<Surface *>(surface_super);
+    new ShellSurface(client,id,surface);
 }
 
 const struct wl_shell_interface Shell::shell_interface = {
     Shell::get_shell_surface
 };
 
-void Shell::shell_surface_move(struct wl_client *client,
+ShellSurface::ShellSurface(wl_client *client, uint32_t id, Surface *surface)
+{
+    m_shellSurface = wl_client_add_object(client,&wl_shell_surface_interface,&shell_surface_interface,id,this);
+    surface->setShellSurface(this);
+
+}
+
+void ShellSurface::move(struct wl_client *client,
                 struct wl_resource *shell_surface_resource,
                 struct wl_resource *input_device,
                 uint32_t time)
@@ -84,55 +92,53 @@ void Shell::shell_surface_move(struct wl_client *client,
     Q_UNUSED(time);
 }
 
-void Shell::shell_surface_resize(struct wl_client *client,
+void ShellSurface::resize(struct wl_client *client,
                   struct wl_resource *shell_surface_resource,
-                  struct wl_resource *input_device,
+                  struct wl_resource *input_device_super,
                   uint32_t time,
                   uint32_t edges)
 {
-    Q_UNUSED(client);
     Q_UNUSED(shell_surface_resource);
-    Q_UNUSED(input_device);
-    Q_UNUSED(time);
-    Q_UNUSED(edges);
+    ShellSurface *shell_surface = static_cast<ShellSurface *>(shell_surface_resource->data);
+    InputDevice *input_device = static_cast<InputDevice *>(input_device_super->data);
 }
 
-void Shell::shell_surface_set_toplevel(struct wl_client *client,
+void ShellSurface::set_toplevel(struct wl_client *client,
                      struct wl_resource *shell_surface_resource)
 {
     Q_UNUSED(client);
     Q_UNUSED(shell_surface_resource);
 }
 
-void Shell::shell_surface_set_transient(struct wl_client *client,
+void ShellSurface::set_transient(struct wl_client *client,
                       struct wl_resource *shell_surface_resource,
-                      struct wl_resource *parent,
+                      struct wl_resource *parent_shell_surface_resource,
                       int x,
                       int y,
                       uint32_t flags)
 {
 
     Q_UNUSED(client);
-    Q_UNUSED(shell_surface_resource);
-    Q_UNUSED(parent);
-    Q_UNUSED(x);
-    Q_UNUSED(y);
     Q_UNUSED(flags);
+    ShellSurface *shell_surface = static_cast<ShellSurface *>(shell_surface_resource->data);
+    ShellSurface *parent_shell_surface = static_cast<ShellSurface *>(parent_shell_surface_resource->data);
+    QPointF point = parent_shell_surface->m_surface->pos() + QPoint(x,y);
+    shell_surface->m_surface->setPos(point);
 }
 
-void Shell::shell_surface_set_fullscreen(struct wl_client *client,
+void ShellSurface::set_fullscreen(struct wl_client *client,
                        struct wl_resource *shell_surface_resource)
 {
     Q_UNUSED(client);
     Q_UNUSED(shell_surface_resource);
 }
 
-const struct wl_shell_surface_interface Shell::shell_surface_interface = {
-    Shell::shell_surface_move,
-    Shell::shell_surface_resize,
-    Shell::shell_surface_set_toplevel,
-    Shell::shell_surface_set_transient,
-    Shell::shell_surface_set_fullscreen
+const struct wl_shell_surface_interface ShellSurface::shell_surface_interface = {
+    ShellSurface::move,
+    ShellSurface::resize,
+    ShellSurface::set_toplevel,
+    ShellSurface::set_transient,
+    ShellSurface::set_fullscreen
 };
 
 }
similarity index 83%
rename from src/compositor/wayland_wrapper/wlshell.h
rename to src/compositor/wayland_wrapper/wlshellsurface.h
index 981c31f..a97d079 100644 (file)
 **
 ****************************************************************************/
 
-#ifndef WLSHELL_H
-#define WLSHELL_H
+#ifndef WLSHELLSURFACE_H
+#define WLSHELLSURFACE_H
 
-#include "waylandresourcecollection.h"
+#include <wayland-server.h>
 
 namespace Wayland {
 
 class Compositor;
+class Surface;
 
 class Shell
 {
@@ -61,24 +62,35 @@ private:
                   struct wl_resource *surface);
     static const struct wl_shell_interface shell_interface;
 
-    static void shell_surface_move(struct wl_client *client,
+};
+
+class ShellSurface
+{
+public:
+    ShellSurface(struct wl_client *client, uint32_t id, Surface *surface);
+
+private:
+    struct wl_resource *m_shellSurface;
+    Surface *m_surface;
+
+    static void move(struct wl_client *client,
                     struct wl_resource *shell_surface_resource,
-                    struct wl_resource *input_device,
+                    struct wl_resource *input_device_super,
                     uint32_t time);
-    static void shell_surface_resize(struct wl_client *client,
+    static void resize(struct wl_client *client,
                       struct wl_resource *shell_surface_resource,
                       struct wl_resource *input_device,
                       uint32_t time,
                       uint32_t edges);
-    static void shell_surface_set_toplevel(struct wl_client *client,
+    static void set_toplevel(struct wl_client *client,
                          struct wl_resource *shell_surface_resource);
-    static void shell_surface_set_transient(struct wl_client *client,
+    static void set_transient(struct wl_client *client,
                           struct wl_resource *shell_surface_resource,
                           struct wl_resource *parent,
                           int x,
                           int y,
                           uint32_t flags);
-    static void shell_surface_set_fullscreen(struct wl_client *client,
+    static void set_fullscreen(struct wl_client *client,
                            struct wl_resource *shell_surface_resource);
 
     static const struct wl_shell_surface_interface shell_surface_interface;
@@ -87,4 +99,4 @@ private:
 
 }
 
-#endif // WLSHELL_H
+#endif // WLSHELLSURFACE_H
index fdfd14b..591619d 100644 (file)
@@ -235,6 +235,7 @@ public:
         , processId(0)
         , extendedSurface(0)
         , subSurface(0)
+        , shellSurface(0)
         , q_ptr(surface)
 
     {
@@ -352,6 +353,7 @@ public:
 
     ExtendedSurface *extendedSurface;
     SubSurface *subSurface;
+    ShellSurface *shellSurface;
 
     SurfaceBuffer bufferPool[buffer_pool_size];
 
@@ -653,6 +655,18 @@ SubSurface *Surface::subSurface() const
     return d->subSurface;
 }
 
+void Surface::setShellSurface(ShellSurface *shellSurface)
+{
+    Q_D(Surface);
+    d->shellSurface = shellSurface;
+}
+
+ShellSurface *Surface::shellSurface() const
+{
+    Q_D(const Surface);
+    return d->shellSurface;
+}
+
 void Surface::sendMousePressEvent(int x, int y, Qt::MouseButton button)
 {
     Q_D(Surface);
index e784c6c..c7f1393 100644 (file)
@@ -67,6 +67,7 @@ class Compositor;
 class Buffer;
 class ExtendedSurface;
 class SubSurface;
+class ShellSurface;
 
 class SurfacePrivate;
 
@@ -135,6 +136,9 @@ public:
     void setSubSurface(SubSurface *subSurface);
     SubSurface *subSurface() const;
 
+    void setShellSurface(ShellSurface *shellSurface);
+    ShellSurface *shellSurface() const;
+
     static const struct wl_surface_interface surface_interface;
 protected:
     QScopedPointer<SurfacePrivate> d_ptr;