diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2011-01-25 16:01:21 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-01-26 13:16:10 (GMT) |
commit | d36a3a6ebc17935371cfca2a9f22dcd683205b5b (patch) | |
tree | ca5cf1c79d99bab9594b8c6607469adcaa485854 /src/plugins | |
parent | 2d65cd502fb5508426748d9ef7af4697051f1c45 (diff) | |
download | Qt-d36a3a6ebc17935371cfca2a9f22dcd683205b5b.zip Qt-d36a3a6ebc17935371cfca2a9f22dcd683205b5b.tar.gz Qt-d36a3a6ebc17935371cfca2a9f22dcd683205b5b.tar.bz2 |
Lighthouse: Wayland. Make the wayland integration closer to Lighthosue
Today there is a connection between QWidget and QPlatformScreen. So I
added a accessor in QWaylandScreen to get the corresponding
QWaylandDisplay. So now it should be possible to have different
QWaylandDisplays. But also its possible to use the internal Lighthouse
api closer in the wayland plugin if that should be of interest ;)
Diffstat (limited to 'src/plugins')
13 files changed, 99 insertions, 39 deletions
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp index f4bae88..29c6abd 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp @@ -44,6 +44,7 @@ #include "qwaylanddisplay.h" #include "qwaylandinputdevice.h" #include "qwaylandshmsurface.h" +#include "qwaylandscreen.h" #include <QtGui/QImageReader> @@ -100,6 +101,13 @@ static const struct pointer_image { { DATADIR "/wayland/dnd-link.png", 13, 13 }, }; +QWaylandCursor::QWaylandCursor(QWaylandScreen *screen) + : QPlatformCursor(screen) + , mBuffer(0) + , mDisplay(screen->display()) +{ +} + void QWaylandCursor::changeCursor(QCursor *cursor, QWidget *widget) { const struct pointer_image *p; diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h index 8c9d263..19e6047 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.h +++ b/src/plugins/platforms/wayland/qwaylandcursor.h @@ -46,13 +46,11 @@ class QWaylandShmBuffer; class QWaylandDisplay; +class QWaylandScreen; class QWaylandCursor : QPlatformCursor { public: - QWaylandCursor(QWaylandDisplay *display, - QPlatformScreen *screen) - : QPlatformCursor(screen) - , mBuffer(0), mDisplay(display) { } + QWaylandCursor(QWaylandScreen *screen); void changeCursor(QCursor *cursor, QWidget *widget); QWaylandShmBuffer *mBuffer; diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index e5adb499..70713ec 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -169,19 +169,10 @@ void QWaylandDisplay::outputHandleGeometry(void *data, int32_t x, int32_t y, int32_t width, int32_t height) { - Q_UNUSED(output); - QWaylandDisplay *qwd = (QWaylandDisplay *) data; - QWaylandScreen *screen; - - screen = new QWaylandScreen(); - screen->mGeometry = QRect(x, y, width, height); - screen->mDepth = 32; - screen->mFormat = QImage::Format_ARGB32_Premultiplied; - screen->mOutput = output; - - new QWaylandCursor(qwd, screen); + QWaylandDisplay *waylandDisplay = (QWaylandDisplay *) data; - qwd->mScreens.append(screen); + QRect outputRect = QRect(x, y, width, height); + waylandDisplay->createNewScreen(output, outputRect); } const struct wl_output_listener QWaylandDisplay::outputListener = { @@ -305,6 +296,12 @@ QWaylandDisplay::~QWaylandDisplay(void) wl_display_destroy(mDisplay); } +void QWaylandDisplay::createNewScreen(struct wl_output *output, QRect geometry) +{ + QWaylandScreen *waylandScreen = new QWaylandScreen(this,output,geometry); + mScreens.append(waylandScreen); +} + void QWaylandDisplay::syncCallback(wl_display_sync_func_t func, void *data) { wl_display_sync_callback(mDisplay, func, data); diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index a95e9c0..f179713 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -43,6 +43,7 @@ #define QWAYLANDDISPLAY_H #include <QtCore/QObject> +#include <QtCore/QRect> #include <wayland-client.h> @@ -55,14 +56,16 @@ class QWaylandInputDevice; class QSocketNotifier; class QWaylandBuffer; class QPlatformScreen; +class QWaylandScreen; class QWaylandDisplay : public QObject { - Q_OBJECT; + Q_OBJECT public: QWaylandDisplay(void); ~QWaylandDisplay(void); + void createNewScreen(struct wl_output *output, QRect geometry); QList<QPlatformScreen *> screens() const { return mScreens; } struct wl_surface *createSurface(); struct wl_buffer *createShmBuffer(int fd, int width, int height, diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp b/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp index 0725919..76c8c33 100644 --- a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp @@ -219,10 +219,9 @@ QWaylandDrmBuffer *QWaylandPaintDevice::currentDrmBufferAndSwap() return currentDrmBuffer; } -QWaylandDrmWindowSurface::QWaylandDrmWindowSurface(QWidget *window, - QWaylandDisplay *display) +QWaylandDrmWindowSurface::QWaylandDrmWindowSurface(QWidget *window) : QWindowSurface(window) - , mDisplay(display) + , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) , mPaintDevice(new QWaylandPaintDevice(mDisplay, this,window->platformWindow()->glContext())) { diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.h b/src/plugins/platforms/wayland/qwaylanddrmsurface.h index aa3dbe7..eafea13 100644 --- a/src/plugins/platforms/wayland/qwaylanddrmsurface.h +++ b/src/plugins/platforms/wayland/qwaylanddrmsurface.h @@ -116,7 +116,7 @@ private: class QWaylandDrmWindowSurface : public QWindowSurface { public: - QWaylandDrmWindowSurface(QWidget *window, QWaylandDisplay *display); + QWaylandDrmWindowSurface(QWidget *window); ~QWaylandDrmWindowSurface(); void beginPaint(const QRegion &); diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index e647880..02bc680 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -80,7 +80,7 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const { Q_UNUSED(winId); - return new QWaylandWindow(widget, mDisplay); + return new QWaylandWindow(widget); } QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId winId) const @@ -89,8 +89,8 @@ QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId wi Q_UNUSED(winId); if (mUseOpenGL) - return new QWaylandDrmWindowSurface(widget, mDisplay); - return new QWaylandShmWindowSurface(widget, mDisplay); + return new QWaylandDrmWindowSurface(widget); + return new QWaylandShmWindowSurface(widget); } QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index 4a7e727..aa1083f 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -41,3 +41,47 @@ #include "qwaylandscreen.h" +#include "qwaylanddisplay.h" +#include "qwaylandcursor.h" + +QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output, QRect geometry) + : QPlatformScreen() + , mWaylandDisplay(waylandDisplay) + , mOutput(output) + , mGeometry(geometry) + , mDepth(32) + , mFormat(QImage::Format_ARGB32_Premultiplied) + , mWaylandCursor(new QWaylandCursor(this)) +{ +} + +QWaylandScreen::~QWaylandScreen() +{ + delete mWaylandCursor; +} + +QWaylandDisplay * QWaylandScreen::display() const +{ + return mWaylandDisplay; +} + +QRect QWaylandScreen::geometry() const +{ + return mGeometry; +} + +int QWaylandScreen::depth() const +{ + return mDepth; +} + +QImage::Format QWaylandScreen::format() const +{ + return mFormat; +} + +QWaylandScreen * QWaylandScreen::waylandScreenFromWidget(QWidget *widget) +{ + QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWidget(widget); + return static_cast<QWaylandScreen *>(platformScreen); +} diff --git a/src/plugins/platforms/wayland/qwaylandscreen.h b/src/plugins/platforms/wayland/qwaylandscreen.h index 808266e..368859f 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.h +++ b/src/plugins/platforms/wayland/qwaylandscreen.h @@ -44,21 +44,31 @@ #include <QtGui/QPlatformScreen> +class QWaylandDisplay; +class QWaylandCursor; + class QWaylandScreen : public QPlatformScreen { public: - QWaylandScreen() {} + QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output, QRect geometry); + ~QWaylandScreen(); - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } + QWaylandDisplay *display() const; -public: + QRect geometry() const; + int depth() const; + QImage::Format format() const; + + static QWaylandScreen *waylandScreenFromWidget(QWidget *widget); + +private: + QWaylandDisplay *mWaylandDisplay; + struct wl_output *mOutput; QRect mGeometry; int mDepth; QImage::Format mFormat; QSize mPhysicalSize; - struct wl_output *mOutput; + QWaylandCursor *mWaylandCursor; }; #endif // QWAYLANDSCREEN_H diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp index 7112424..83bb993 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp @@ -45,6 +45,7 @@ #include "qwaylanddisplay.h" #include "qwaylandwindow.h" +#include "qwaylandscreen.h" #include <wayland-client.h> #include <unistd.h> @@ -90,11 +91,10 @@ QWaylandShmBuffer::~QWaylandShmBuffer(void) wl_buffer_destroy(mBuffer); } -QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window, - QWaylandDisplay *display) +QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window) : QWindowSurface(window) , mBuffer(0) - , mDisplay(display) + , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) { } diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmsurface.h index 8c24e9f..266b290 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.h +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.h @@ -65,7 +65,7 @@ private: class QWaylandShmWindowSurface : public QWindowSurface { public: - QWaylandShmWindowSurface(QWidget *window, QWaylandDisplay *display); + QWaylandShmWindowSurface(QWidget *window); ~QWaylandShmWindowSurface(); QPaintDevice *paintDevice(); diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index fa62330..a28bdfe 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -42,6 +42,7 @@ #include "qwaylandwindow.h" #include "qwaylanddisplay.h" +#include "qwaylandscreen.h" #include "qwaylandglcontext.h" #include "qwaylandbuffer.h" @@ -52,16 +53,16 @@ #include <QDebug> -QWaylandWindow::QWaylandWindow(QWidget *window, QWaylandDisplay *display) +QWaylandWindow::QWaylandWindow(QWidget *window) : QPlatformWindow(window) - , mSurface(display->createSurface()) - , mDisplay(display) + , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) , mGLContext(0) , mBuffer(0) { static WId id = 1; - mWindowId = id++; + + mSurface = mDisplay->createSurface(); } QWaylandWindow::~QWaylandWindow() diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h index d5cc923..8b047d7 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.h +++ b/src/plugins/platforms/wayland/qwaylandwindow.h @@ -52,7 +52,7 @@ class QWaylandBuffer; class QWaylandWindow : public QPlatformWindow { public: - QWaylandWindow(QWidget *window, QWaylandDisplay *display); + QWaylandWindow(QWidget *window); ~QWaylandWindow(); struct wl_surface *surface() { return mSurface; } |