From e35d1a00541f3f2a1ed692a910b86f9344d12085 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B8rgen=20Lind?= Date: Mon, 9 Jan 2012 18:53:22 +0100 Subject: [PATCH] Create a ShellSurface class MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit so that we can actually do something usefull in the callbacks Change-Id: Ie8e85757bf5c90caa40db34df1b8bc642ba09962 Sanity-Review: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/compositor/wayland_wrapper/wayland_wrapper.pri | 4 +- src/compositor/wayland_wrapper/wlcompositor.cpp | 3 +- src/compositor/wayland_wrapper/wlcompositor.h | 7 ++- .../{wlshell.cpp => wlshellsurface.cpp} | 60 ++++++++++++---------- .../{wlshell.h => wlshellsurface.h} | 32 ++++++++---- src/compositor/wayland_wrapper/wlsurface.cpp | 14 +++++ src/compositor/wayland_wrapper/wlsurface.h | 4 ++ 7 files changed, 80 insertions(+), 44 deletions(-) rename src/compositor/wayland_wrapper/{wlshell.cpp => wlshellsurface.cpp} (67%) rename src/compositor/wayland_wrapper/{wlshell.h => wlshellsurface.h} (83%) diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri index 6340f5c..8bb7b17 100644 --- a/src/compositor/wayland_wrapper/wayland_wrapper.pri +++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri @@ -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 \ diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp index 067263c..d777921 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/compositor/wayland_wrapper/wlcompositor.cpp @@ -50,6 +50,7 @@ #include "wlextendedoutput.h" #include "wlextendedsurface.h" #include "wlsubsurface.h" +#include "wlshellsurface.h" #include #include @@ -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); diff --git a/src/compositor/wayland_wrapper/wlcompositor.h b/src/compositor/wayland_wrapper/wlcompositor.h index 828df09..60b0f02 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.h +++ b/src/compositor/wayland_wrapper/wlcompositor.h @@ -48,7 +48,6 @@ #include "wloutput.h" #include "wldisplay.h" #include "wlshmbuffer.h" -#include "wlshell.h" #include @@ -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; diff --git a/src/compositor/wayland_wrapper/wlshell.cpp b/src/compositor/wayland_wrapper/wlshellsurface.cpp similarity index 67% rename from src/compositor/wayland_wrapper/wlshell.cpp rename to src/compositor/wayland_wrapper/wlshellsurface.cpp index c395ae9..3b7e29e 100644 --- a/src/compositor/wayland_wrapper/wlshell.cpp +++ b/src/compositor/wayland_wrapper/wlshellsurface.cpp @@ -38,11 +38,11 @@ ** ****************************************************************************/ -#include "wlshell.h" - -#include "wlcompositor.h" +#include "wlshellsurface.h" #include "wlcompositor.h" +#include "wlsurface.h" +#include "wlinputdevice.h" #include #include @@ -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_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(shell_surface_resource->data); + InputDevice *input_device = static_cast(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(shell_surface_resource->data); + ShellSurface *parent_shell_surface = static_cast(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 }; } diff --git a/src/compositor/wayland_wrapper/wlshell.h b/src/compositor/wayland_wrapper/wlshellsurface.h similarity index 83% rename from src/compositor/wayland_wrapper/wlshell.h rename to src/compositor/wayland_wrapper/wlshellsurface.h index 981c31f..a97d079 100644 --- a/src/compositor/wayland_wrapper/wlshell.h +++ b/src/compositor/wayland_wrapper/wlshellsurface.h @@ -38,14 +38,15 @@ ** ****************************************************************************/ -#ifndef WLSHELL_H -#define WLSHELL_H +#ifndef WLSHELLSURFACE_H +#define WLSHELLSURFACE_H -#include "waylandresourcecollection.h" +#include 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 diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index fdfd14b..591619d 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -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); diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h index e784c6c..c7f1393 100644 --- a/src/compositor/wayland_wrapper/wlsurface.h +++ b/src/compositor/wayland_wrapper/wlsurface.h @@ -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 d_ptr; -- 2.7.4