Wayland: clamp window resizes to screen size
authorJesse Barnes <jbarnes@virtuousgeek.org>
Mon, 8 Nov 2010 21:05:19 +0000 (13:05 -0800)
committerJørgen Lind <jorgen.lind@nokia.com>
Tue, 25 Jan 2011 18:04:15 +0000 (19:04 +0100)
src/plugins/platforms/wayland/qwaylanddrmsurface.cpp

index c9fb187..7756e85 100644 (file)
@@ -196,11 +196,13 @@ void QWaylandDrmWindowSurface::flush(QWidget *widget, const QRegion &region, con
     }
 }
 
-void QWaylandDrmWindowSurface::resize(const QSize &size)
+void QWaylandDrmWindowSurface::resize(const QSize &requestedSize)
 {
     QWaylandWindow *ww = (QWaylandWindow *) window()->platformWindow();
-    QWindowSurface::resize(size);
-    QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format();
+    QWaylandScreen *screen = (QWaylandScreen *)QApplicationPrivate::platformIntegration()->screens().first();
+    QImage::Format format = screen->format();
+    QSize screenSize = screen->geometry().size();
+    QSize size = requestedSize;
 
     if (mBuffer != NULL && mBuffer->mSize == size)
        return;
@@ -208,6 +210,14 @@ void QWaylandDrmWindowSurface::resize(const QSize &size)
     if (mBuffer != NULL)
        delete mBuffer;
 
+    /* Clamp to screen size */
+    if (size.width() > screenSize.width())
+       size.setWidth(screenSize.width());
+    if (size.height() > screenSize.height())
+       size.setHeight(screenSize.height());
+
+    QWindowSurface::resize(size);
+
     mBuffer = new QWaylandDrmBuffer(mDisplay, size, format);
 
     ww->attach(mBuffer);