diff options
Diffstat (limited to 'src/plugins/platforms')
101 files changed, 1286 insertions, 540 deletions
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 705e60439e..5d751631a9 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -9,7 +9,10 @@ OBJECTIVE_SOURCES = main.mm \ qnsview.mm \ qcocoaeventloopintegration.mm \ qcocoaautoreleasepool.mm \ - qnswindowdelegate.mm + qnswindowdelegate.mm \ + qcocoaglcontext.mm \ + qcocoanativeinterface.mm + OBJECTIVE_HEADERS = qcocoaintegration.h \ qcocoawindowsurface.h \ @@ -17,13 +20,18 @@ OBJECTIVE_HEADERS = qcocoaintegration.h \ qnsview.h \ qcocoaeventloopintegration.h \ qcocoaautoreleasepool.h \ - qnswindowdelegate.h + qnswindowdelegate.h \ + qcocoaglcontext.h \ + qcocoanativeinterface.h + +DEFINES += QT_BUILD_COCOA_LIB #add libz for freetype. LIBS += -lz LIBS += -framework cocoa -include(../fontdatabases/coretext/coretext.pri) +QT += core-private gui-private + +include(../fontdatabases/basicunix/basicunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target - diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm index 885916ed74..d9858b0e9a 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm @@ -47,9 +47,6 @@ #include <QtCore/QElapsedTimer> -#include <QDebug> -#include <QApplication> - void wakeupCallback ( void * ) { QPlatformEventLoopIntegration::processEvents(); } diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h new file mode 100644 index 0000000000..4d330a4294 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -0,0 +1,28 @@ +#ifndef QCOCOAGLCONTEXT_H +#define QCOCOAGLCONTEXT_H + +#include <QtGui/QPlatformGLContext> +#include <QtGui/QWindowFormat> + +#include <Cocoa/Cocoa.h> + +QT_BEGIN_NAMESPACE + +class QCocoaGLContext : public QPlatformGLContext +{ +public: + QCocoaGLContext(NSOpenGLView *glView); + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + QWindowFormat windowFormat() const; + static NSOpenGLPixelFormat *createNSOpenGLPixelFormat(); + NSOpenGLContext *nsOpenGLContext() const; +private: + NSOpenGLView *m_glView; +}; + +QT_END_NAMESPACE + +#endif // QCOCOAGLCONTEXT_H diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm new file mode 100644 index 0000000000..3a87537e64 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -0,0 +1,83 @@ +#include "qcocoaglcontext.h" +#include <qdebug.h> +#include <QtCore/private/qcore_mac_p.h> + +#import <Cocoa/Cocoa.h> + +QCocoaGLContext::QCocoaGLContext(NSOpenGLView *glView) +:m_glView(glView) +{ + +} + +void QCocoaGLContext::makeCurrent() +{ + [[m_glView openGLContext] makeCurrentContext]; +} +void QCocoaGLContext::doneCurrent() +{ + [NSOpenGLContext clearCurrentContext]; +} + +void QCocoaGLContext::swapBuffers() +{ + [[m_glView openGLContext] flushBuffer]; +} + +void* QCocoaGLContext::getProcAddress(const QString& procName) +{ + CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, + CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, false); + CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, url); + CFStringRef procNameCF = QCFString::toCFStringRef(procName); + void *proc = CFBundleGetFunctionPointerForName(bundle, procNameCF); + CFRelease(url); + CFRelease(bundle); + CFRelease(procNameCF); + return proc; +} + +// Match up with createNSOpenGLPixelFormat below! +QWindowFormat QCocoaGLContext::windowFormat() const +{ + QWindowFormat format; + format.setRedBufferSize(8); + format.setGreenBufferSize(8); + format.setBlueBufferSize(8); + format.setAlphaBufferSize(8); + +/* + format.setDepthBufferSize(24); + format.setAccumBufferSize(0); + format.setStencilBufferSize(8); + format.setSampleBuffers(false); + format.setSamples(1); + format.setDepth(true); + format.setRgba(true); + format.setAlpha(true); + format.setAccum(false); + format.setStencil(true); + format.setStereo(false); + format.setDirectRendering(false); +*/ + return format; +} + +NSOpenGLPixelFormat *QCocoaGLContext::createNSOpenGLPixelFormat() +{ + NSOpenGLPixelFormatAttribute attrs[] = + { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFADepthSize, 32, + 0 + }; + + NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; + return pixelFormat; +} + +NSOpenGLContext *QCocoaGLContext::nsOpenGLContext() const +{ + return [m_glView openGLContext]; +} + diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 2a04e8c2ed..1d961ed1b0 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -77,15 +77,15 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + QPlatformWindow *createPlatformWindow(QWindow *window) const; + QWindowSurface *createWindowSurface(QWindow *widget, WId winId) const; QList<QPlatformScreen *> screens() const { return mScreens; } QPlatformFontDatabase *fontDatabase() const; QPlatformEventLoopIntegration *createEventLoopIntegration() const; - + QPlatformNativeInterface *nativeInterface() const; private: QList<QPlatformScreen *> mScreens; QPlatformFontDatabase *mFontDb; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 7c4319c5e7..31815d8a65 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -44,10 +44,9 @@ #include "qcocoawindow.h" #include "qcocoawindowsurface.h" #include "qcocoaeventloopintegration.h" +#include "qcocoanativeinterface.h" -#include "qcoretextfontdatabase.h" - -#include <QtGui/QApplication> +#include "qbasicunixfontdatabase.h" #include <private/qpixmap_raster_p.h> @@ -74,7 +73,7 @@ QCocoaScreen::~QCocoaScreen() } QCocoaIntegration::QCocoaIntegration() - : mFontDb(new QCoreTextFontDatabase()) + : mFontDb(new QBasicUnixFontDatabase()) { mPool = new QCocoaAutoReleasePool; @@ -98,6 +97,7 @@ bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) cons { switch (cap) { case ThreadedPixmaps: return true; + case OpenGL : return true; default: return QPlatformIntegration::hasCapability(cap); } } @@ -109,15 +109,14 @@ QPixmapData *QCocoaIntegration::createPixmapData(QPixmapData::PixelType type) co return new QRasterPixmapData(type); } -QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWidget *widget, WId winId) const +QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWindow *window) const { - Q_UNUSED(winId); - return new QCocoaWindow(widget); + return new QCocoaWindow(window); } -QWindowSurface *QCocoaIntegration::createWindowSurface(QWidget *widget, WId winId) const +QWindowSurface *QCocoaIntegration::createWindowSurface(QWindow *window, WId winId) const { - return new QCocoaWindowSurface(widget,winId); + return new QCocoaWindowSurface(window, winId); } QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const @@ -129,4 +128,10 @@ QPlatformEventLoopIntegration *QCocoaIntegration::createEventLoopIntegration() c { return new QCocoaEventLoopIntegration(); } + +QPlatformNativeInterface *QCocoaIntegration::nativeInterface() const +{ + return new QCocoaNativeInterface(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h new file mode 100644 index 0000000000..78f5ce0f94 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOCOANATIVEINTERFACE_H +#define QCOCOANATIVEINTERFACE_H + +#include <QtGui/QPlatformNativeInterface> + +class QWidget; + +class QCocoaNativeInterface : public QPlatformNativeInterface +{ +public: + void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window); +}; + +#endif // QCOCOANATIVEINTERFACE_H diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm new file mode 100644 index 0000000000..859e04ccc7 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoanativeinterface.h" +#include "qcocoaglcontext.h" +#include <qbytearray.h> +#include <qwindow.h> +#include "qplatformwindow_qpa.h" +#include "qwindowformat_qpa.h" +#include "qplatformglcontext_qpa.h" +#include "qwindowcontext_qpa.h" +#include <qdebug.h> + +void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) +{ + if (resourceString == "nsopenglcontext") { + QPlatformGLContext *platformContext = window->glContext()->handle(); + return static_cast<QCocoaGLContext *>(platformContext)->nsOpenGLContext(); + } + return 0; +} diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index b71879de41..98e3de29cb 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -46,27 +46,32 @@ #include <QPlatformWindow> +#include "qcocoaglcontext.h" +#include "qnsview.h" + QT_BEGIN_NAMESPACE class QCocoaWindow : public QPlatformWindow { public: - QCocoaWindow(QWidget *tlw); + QCocoaWindow(QWindow *tlw); ~QCocoaWindow(); void setGeometry(const QRect &rect); - void setVisible(bool visible); - WId winId() const; - NSView *contentView() const; - void setContentView(NSView *contentView); void windowDidResize(); + QPlatformGLContext *glContext() const; + private: + friend class QCocoaWindowSurface; NSWindow *m_nsWindow; + QNSView *m_contentView; + NSView *m_windowSurfaceView; + mutable QCocoaGLContext *m_glContext; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index aa54fe90ad..a0ac3a69a8 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -41,17 +41,16 @@ #include "qcocoawindow.h" #include "qnswindowdelegate.h" #include "qcocoaautoreleasepool.h" - -#include <QWidget> - -#include <QtGui/QApplication> +#include "qcocoaglcontext.h" +#include "qnsview.h" #include <QWindowSystemInterface> #include <QDebug> -QCocoaWindow::QCocoaWindow(QWidget *tlw) +QCocoaWindow::QCocoaWindow(QWindow *tlw) : QPlatformWindow(tlw) + , m_glContext(0) { QCocoaAutoReleasePool pool; const QRect geo = tlw->geometry(); @@ -67,6 +66,20 @@ QCocoaWindow::QCocoaWindow(QWidget *tlw) [m_nsWindow makeKeyAndOrderFront:nil]; [m_nsWindow setAcceptsMouseMovedEvents:YES]; + + m_contentView = [[QNSView alloc] initWithQWindow:tlw]; + + if (tlw->surfaceType() == QWindow::OpenGLSurface) { + NSRect glFrame = NSMakeRect(0, 0, geo.width(), geo.height()); + m_windowSurfaceView = [[NSOpenGLView alloc] initWithFrame : glFrame pixelFormat : QCocoaGLContext::createNSOpenGLPixelFormat() ]; + [m_contentView setAutoresizesSubviews : YES]; + [m_windowSurfaceView setAutoresizingMask : (NSViewWidthSizable | NSViewHeightSizable)]; + [m_contentView addSubview : m_windowSurfaceView]; + } else { + m_windowSurfaceView = m_contentView; + } + + [m_nsWindow setContentView:m_contentView]; } QCocoaWindow::~QCocoaWindow() @@ -88,7 +101,7 @@ void QCocoaWindow::setVisible(bool visible) WId QCocoaWindow::winId() const { - return WId([m_nsWindow windowNumber]); + return WId(m_nsWindow); } NSView *QCocoaWindow::contentView() const @@ -96,15 +109,18 @@ NSView *QCocoaWindow::contentView() const return [m_nsWindow contentView]; } -void QCocoaWindow::setContentView(NSView *contentView) -{ - [m_nsWindow setContentView:contentView]; -} - void QCocoaWindow::windowDidResize() { //jlind: XXX This isn't ideal. Eventdispatcher does not run when resizing... NSRect rect = [[m_nsWindow contentView]frame]; QRect geo(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); - QWindowSystemInterface::handleGeometryChange(widget(),geo); + QWindowSystemInterface::handleGeometryChange(window(),geo); +} + +QPlatformGLContext *QCocoaWindow::glContext() const +{ + if (!m_glContext) { + m_glContext = new QCocoaGLContext(m_windowSurfaceView); + } + return m_glContext; } diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.h b/src/plugins/platforms/cocoa/qcocoawindowsurface.h index 5ae7be197d..01e504e08d 100644 --- a/src/plugins/platforms/cocoa/qcocoawindowsurface.h +++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.h @@ -54,18 +54,16 @@ QT_BEGIN_NAMESPACE class QCocoaWindowSurface : public QWindowSurface { public: - QCocoaWindowSurface(QWidget *window, WId wid); + QCocoaWindowSurface(QWindow *window, WId wid); ~QCocoaWindowSurface(); QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void flush(QWindow *widget, const QRegion ®ion, const QPoint &offset); void resize (const QSize &size); private: - QCocoaWindow *m_cocoaWindow; QImage *m_image; - QNSView *m_contentView; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm index ecf6879c67..02d5617f96 100644 --- a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm +++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm @@ -42,7 +42,6 @@ #include "qcocoawindowsurface.h" #include <QtCore/qdebug.h> - #include <QtGui/QPainter> QT_BEGIN_NAMESPACE @@ -56,17 +55,16 @@ QRect flipedRect(const QRect &sourceRect,int height) return flippedRect; } -QCocoaWindowSurface::QCocoaWindowSurface(QWidget *window, WId wId) +QCocoaWindowSurface::QCocoaWindowSurface(QWindow *window, WId wId) : QWindowSurface(window) { - m_cocoaWindow = static_cast<QCocoaWindow *>(window->platformWindow()); + Q_UNUSED(wId); + m_cocoaWindow = static_cast<QCocoaWindow *>(window->handle()); const QRect geo = window->geometry(); NSRect rect = NSMakeRect(geo.x(),geo.y(),geo.width(),geo.height()); - m_contentView = [[QNSView alloc] initWithWidget:window]; - m_cocoaWindow->setContentView(m_contentView); - m_image = new QImage(window->size(),QImage::Format_ARGB32); + m_image = new QImage(window->geometry().size(),QImage::Format_ARGB32); } QCocoaWindowSurface::~QCocoaWindowSurface() @@ -79,7 +77,7 @@ QPaintDevice *QCocoaWindowSurface::paintDevice() return m_image; } -void QCocoaWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QCocoaWindowSurface::flush(QWindow *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); Q_UNUSED(offset); @@ -87,7 +85,7 @@ void QCocoaWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QP QRect geo = region.boundingRect(); NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height()); - [m_contentView displayRect:rect]; + [m_cocoaWindow->m_windowSurfaceView displayRect:rect]; } void QCocoaWindowSurface::resize(const QSize &size) @@ -96,8 +94,7 @@ void QCocoaWindowSurface::resize(const QSize &size) delete m_image; m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied); NSSize newSize = NSMakeSize(size.width(),size.height()); - [m_contentView setImage:m_image]; - + [m_cocoaWindow->m_windowSurfaceView setImage:m_image]; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index fc946e2f29..81bea27304 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -48,17 +48,18 @@ @interface QNSView : NSView { CGImageRef m_cgImage; - QWidget *m_widget; + QWindow *m_window; Qt::MouseButtons m_buttons; } - (id)init; -- (id)initWithWidget:(QWidget *)widget; +- (id)initWithQWindow:(QWindow *)window; - (void)setImage:(QImage *)image; - (void)drawRect:(NSRect)dirtyRect; - (BOOL)isFlipped; +- (BOOL)acceptsFirstResponder; - (void)handleMouseEvent:(NSEvent *)theEvent; - (void)mouseDown:(NSEvent *)theEvent; @@ -74,6 +75,12 @@ - (void)otherMouseDragged:(NSEvent *)theEvent; - (void)otherMouseUp:(NSEvent *)theEvent; +- (int) convertKeyCode : (QChar)keyCode; +- (Qt::KeyboardModifiers) convertKeyModifiers : (ulong)modifierFlags; +- (void)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType; +- (void)keyDown:(NSEvent *)theEvent; +- (void)keyUp:(NSEvent *)theEvent; + @end #endif //QNSVIEW_H diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 6fda27b352..ba9bb9e691 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -52,16 +52,16 @@ self = [super init]; if (self) { m_cgImage = 0; - m_widget = 0; + m_window = 0; m_buttons = Qt::NoButton; } return self; } -- (id)initWithWidget:(QWidget *)widget { +- (id)initWithQWindow:(QWindow *)widget { self = [self init]; if (self) { - m_widget = widget; + m_window = widget; } return self; } @@ -130,6 +130,11 @@ return YES; } +- (BOOL)acceptsFirstResponder +{ + return YES; +} + - (void)handleMouseEvent:(NSEvent *)theEvent; { NSPoint point = [self convertPoint: [theEvent locationInWindow] fromView: nil]; @@ -138,40 +143,42 @@ NSTimeInterval timestamp = [theEvent timestamp]; ulong qt_timestamp = timestamp * 1000; - QWindowSystemInterface::handleMouseEvent(m_widget,qt_timestamp,qt_localPoint,QPoint(),m_buttons); + QWindowSystemInterface::handleMouseEvent(m_window,qt_timestamp,qt_localPoint,QPoint(),m_buttons); } - - (void)mouseDown:(NSEvent *)theEvent - { - m_buttons |= Qt::LeftButton; - [self handleMouseEvent:theEvent]; - } - - (void)mouseDragged:(NSEvent *)theEvent - { - if (!(m_buttons & Qt::LeftButton)) - qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); - [self handleMouseEvent:theEvent]; - } - - (void)mouseUp:(NSEvent *)theEvent - { - m_buttons &= QFlag(~int(Qt::LeftButton)); - [self handleMouseEvent:theEvent]; - } + +- (void)mouseDown:(NSEvent *)theEvent +{ + m_buttons |= Qt::LeftButton; + [self handleMouseEvent:theEvent]; +} + +- (void)mouseDragged:(NSEvent *)theEvent +{ + if (!(m_buttons & Qt::LeftButton)) + qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + [self handleMouseEvent:theEvent]; +} + +- (void)mouseUp:(NSEvent *)theEvent +{ + m_buttons &= QFlag(~int(Qt::LeftButton)); + [self handleMouseEvent:theEvent]; +} - (void)mouseMoved:(NSEvent *)theEvent { - qDebug() << "mouseMove"; [self handleMouseEvent:theEvent]; } - (void)mouseEntered:(NSEvent *)theEvent { Q_UNUSED(theEvent); - QWindowSystemInterface::handleEnterEvent(m_widget); + QWindowSystemInterface::handleEnterEvent(m_window); } - (void)mouseExited:(NSEvent *)theEvent { Q_UNUSED(theEvent); - QWindowSystemInterface::handleLeaveEvent(m_widget); + QWindowSystemInterface::handleLeaveEvent(m_window); } - (void)rightMouseDown:(NSEvent *)theEvent { @@ -206,6 +213,84 @@ [self handleMouseEvent:theEvent]; } +- (int) convertKeyCode : (QChar)keyChar +{ + if (keyChar.isLower()) + keyChar = keyChar.toUpper(); + int keyCode = keyChar.unicode(); + + int qtKeyCode = Qt::Key(keyCode); // default case, overrides below + switch (keyCode) { + case NSEnterCharacter: qtKeyCode = Qt::Key_Enter; break; + case NSBackspaceCharacter: qtKeyCode = Qt::Key_Backspace; break; + case NSTabCharacter: qtKeyCode = Qt::Key_Tab; break; + case NSNewlineCharacter: qtKeyCode = Qt::Key_Return; break; + case NSCarriageReturnCharacter: qtKeyCode = Qt::Key_Return; break; + case NSBackTabCharacter: qtKeyCode = Qt::Key_Backtab; break; + case 27 : qtKeyCode = Qt::Key_Escape; break; + case NSDeleteCharacter : qtKeyCode = Qt::Key_Backspace; break; // Cocoa sends us delete when pressing backspace. + case NSUpArrowFunctionKey: qtKeyCode = Qt::Key_Up; break; + case NSDownArrowFunctionKey: qtKeyCode = Qt::Key_Down; break; + case NSLeftArrowFunctionKey: qtKeyCode = Qt::Key_Left; break; + case NSRightArrowFunctionKey: qtKeyCode = Qt::Key_Right; break; + case NSInsertFunctionKey: qtKeyCode = Qt::Key_Insert; break; + case NSDeleteFunctionKey: qtKeyCode = Qt::Key_Delete; break; + case NSHomeFunctionKey: qtKeyCode = Qt::Key_Home; break; + case NSEndFunctionKey: qtKeyCode = Qt::Key_End; break; + case NSPageUpFunctionKey: qtKeyCode = Qt::Key_PageUp; break; + case NSPageDownFunctionKey: qtKeyCode = Qt::Key_PageDown; break; + case NSPrintScreenFunctionKey: qtKeyCode = Qt::Key_Print; break; + case NSScrollLockFunctionKey: qtKeyCode = Qt::Key_ScrollLock; break; + case NSPauseFunctionKey: qtKeyCode = Qt::Key_Pause; break; + case NSSysReqFunctionKey: qtKeyCode = Qt::Key_SysReq; break; + case NSMenuFunctionKey: qtKeyCode = Qt::Key_Menu; break; + case NSHelpFunctionKey: qtKeyCode = Qt::Key_Help; break; + default : break; + } + + // handle all function keys (F1-F35) + if (keyCode >= NSF1FunctionKey && keyCode <= NSF35FunctionKey) + qtKeyCode = Qt::Key_F1 + (keyCode - NSF1FunctionKey); + + return qtKeyCode; +} + +- (Qt::KeyboardModifiers) convertKeyModifiers : (ulong)modifierFlags +{ + Qt::KeyboardModifiers qtMods =Qt::NoModifier; + if (modifierFlags & NSShiftKeyMask) + qtMods |= Qt::ShiftModifier; + if (modifierFlags & NSControlKeyMask) + qtMods |= Qt::MetaModifier; + if (modifierFlags & NSAlternateKeyMask) + qtMods |= Qt::AltModifier; + if (modifierFlags & NSCommandKeyMask) + qtMods |= Qt::ControlModifier; + if (modifierFlags & NSNumericPadKeyMask) + qtMods |= Qt::KeypadModifier; + return qtMods; +} + +- (void)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType +{ + NSTimeInterval timestamp = [theEvent timestamp]; + ulong qt_timestamp = timestamp * 1000; + QString characters = QString::fromUtf8([[theEvent characters] UTF8String]); + Qt::KeyboardModifiers modifiers = [self convertKeyModifiers : [theEvent modifierFlags]]; + QChar ch([[theEvent charactersIgnoringModifiers] characterAtIndex:0]); + int keyCode = [self convertKeyCode : ch]; + + QWindowSystemInterface::handleKeyEvent(m_window, qt_timestamp, QEvent::Type(eventType), keyCode, modifiers, characters); +} +- (void)keyDown:(NSEvent *)theEvent +{ + [self handleKeyEvent : theEvent eventType :int(QEvent::KeyPress)]; +} + +- (void)keyUp:(NSEvent *)theEvent +{ + [self handleKeyEvent : theEvent eventType :int(QEvent::KeyRelease)]; +} @end diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h index f4dcec73dd..d6dabf05cb 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.h +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -46,6 +46,26 @@ #include "qcocoawindow.h" +#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 +@protocol NSWindowDelegate <NSObject> +//- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize; +//- (void)windowDidMiniaturize:(NSNotification*)notification; +- (void)windowDidResize:(NSNotification *)notification; +- (void)windowWillClose:(NSNotification *)notification; +//- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame; +//- (void)windowDidMove:(NSNotification *)notification; +//- (BOOL)windowShouldClose:(id)window; +//- (void)windowDidDeminiaturize:(NSNotification *)notification; +//- (void)windowDidBecomeMain:(NSNotification*)notification; +//- (void)windowDidResignMain:(NSNotification*)notification; +//- (void)windowDidBecomeKey:(NSNotification*)notification; +//- (void)windowDidResignKey:(NSNotification*)notification; +//- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu; +//- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard; +//- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame; +@end +#endif + @interface QNSWindowDelegate : NSObject <NSWindowDelegate> { QCocoaWindow *m_cocoaWindow; diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index 58dffb7c09..80e9ba272b 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -67,7 +67,7 @@ - (void)windowWillClose:(NSNotification *)notification { Q_UNUSED(notification); - QWindowSystemInterface::handleCloseEvent(m_cocoaWindow->widget()); + QWindowSystemInterface::handleCloseEvent(m_cocoaWindow->window()); } @end diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp index df7abc1401..f3ce0fa809 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE -QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format) +QVector<EGLint> q_createConfigAttributesFromFormat(const QWindowFormat &format) { int redSize = format.redBufferSize(); int greenSize = format.greenBufferSize(); @@ -53,17 +53,6 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat & int stencilSize = format.stencilBufferSize(); int sampleCount = format.samples(); - // QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that - // type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1: - if (format.alpha() && alphaSize <= 0) - alphaSize = 1; - if (format.depth() && depthSize <= 0) - depthSize = 1; - if (format.stencil() && stencilSize <= 0) - stencilSize = 1; - if (format.sampleBuffers() && sampleCount <= 0) - sampleCount = 1; - // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide // the best performance. The EGL config selection algorithm is a bit stange in this regard: // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard @@ -82,14 +71,14 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat & // if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat, // they will probably get a 32-bit config, even when there's an RGB565 config available. - // Now normalize the values so -1 becomes 0 - redSize = redSize > 0 ? redSize : 0; - greenSize = greenSize > 0 ? greenSize : 0; - blueSize = blueSize > 0 ? blueSize : 0; - alphaSize = alphaSize > 0 ? alphaSize : 0; - depthSize = depthSize > 0 ? depthSize : 0; - stencilSize = stencilSize > 0 ? stencilSize : 0; - sampleCount = sampleCount > 0 ? sampleCount : 0; +// // Now normalize the values so -1 becomes 0 +// redSize = redSize > 0 ? redSize : 0; +// greenSize = greenSize > 0 ? greenSize : 0; +// blueSize = blueSize > 0 ? blueSize : 0; +// alphaSize = alphaSize > 0 ? alphaSize : 0; +// depthSize = depthSize > 0 ? depthSize : 0; +// stencilSize = stencilSize > 0 ? stencilSize : 0; +// sampleCount = sampleCount > 0 ? sampleCount : 0; QVector<EGLint> configAttributes; @@ -206,7 +195,7 @@ bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes) return false; } -EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType) +EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QWindowFormat &format, bool highestPixelFormat, int surfaceType) { EGLConfig cfg = 0; QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format); @@ -214,11 +203,7 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW configureAttributes.append(surfaceType); configureAttributes.append(EGL_RENDERABLE_TYPE); - if (format.windowApi() == QPlatformWindowFormat::OpenVG) { - configureAttributes.append(EGL_OPENVG_BIT); - } else { - configureAttributes.append(EGL_OPENGL_ES2_BIT); - } + configureAttributes.append(EGL_OPENGL_ES2_BIT); configureAttributes.append(EGL_NONE); do { @@ -272,9 +257,9 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW return 0; } -QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config) +QWindowFormat q_windowFormatFromConfig(EGLDisplay display, const EGLConfig config) { - QPlatformWindowFormat format; + QWindowFormat format; EGLint redSize = 0; EGLint greenSize = 0; EGLint blueSize = 0; @@ -282,7 +267,6 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con EGLint depthSize = 0; EGLint stencilSize = 0; EGLint sampleCount = 0; - EGLint level = 0; eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); @@ -291,7 +275,6 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); - eglGetConfigAttrib(display, config, EGL_LEVEL, &level); format.setRedBufferSize(redSize); format.setGreenBufferSize(greenSize); @@ -300,10 +283,7 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con format.setDepthBufferSize(depthSize); format.setStencilBufferSize(stencilSize); format.setSamples(sampleCount); - format.setDirectRendering(true); // All EGL contexts are direct-rendered - format.setRgba(true); // EGL doesn't support colour index rendering format.setStereo(false); // EGL doesn't support stereo buffers - format.setAccumBufferSize(0); // EGL doesn't support accululation buffers // Clear the EGL error state because some of the above may // have errored out because the attribute is not applicable diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h index c7d3d61ae5..d0863219ab 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.h +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h @@ -43,16 +43,16 @@ #define QEGLCONVENIENCE_H -#include <QtGui/QPlatformWindowFormat> +#include <QtGui/QWindowFormat> #include <QtCore/QVector> #include <EGL/egl.h> QT_BEGIN_NAMESPACE -QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format); +QVector<EGLint> q_createConfigAttributesFromFormat(const QWindowFormat &format); bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes); -EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT); -QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config); +EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QWindowFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT); +QWindowFormat q_windowFormatFromConfig(EGLDisplay display, const EGLConfig config); bool q_hasEglExtension(EGLDisplay display,const char* extensionName); QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index ae5215f320..30dd86215d 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -66,7 +66,7 @@ QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, E qFatal("EGL error"); } - m_windowFormat = qt_qPlatformWindowFormatFromConfig(display,config); + m_windowFormat = q_windowFormatFromConfig(display,config); } QEGLPlatformContext::~QEGLPlatformContext() @@ -88,7 +88,6 @@ QEGLPlatformContext::~QEGLPlatformContext() void QEGLPlatformContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); #ifdef QEGL_EXTRA_DEBUG qWarning("QEglContext::makeCurrent: %p\n",this); #endif @@ -118,7 +117,6 @@ void QEGLPlatformContext::makeCurrent() } void QEGLPlatformContext::doneCurrent() { - QPlatformGLContext::doneCurrent(); #ifdef QEGL_EXTRA_DEBUG qWarning("QEglContext::doneCurrent:%p\n",this); #endif @@ -146,7 +144,7 @@ void* QEGLPlatformContext::getProcAddress(const QString& procName) return (void *)eglGetProcAddress(qPrintable(procName)); } -QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const +QWindowFormat QEGLPlatformContext::windowFormat() const { return m_windowFormat; } diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h index 69835d7eb4..048fd72215 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h @@ -56,7 +56,7 @@ public: void swapBuffers(); void* getProcAddress(const QString& procName); - QPlatformWindowFormat platformWindowFormat() const; + QWindowFormat windowFormat() const; EGLContext eglContext() const; private: @@ -65,7 +65,7 @@ private: EGLSurface m_eglSurface; EGLenum m_eglApi; - QPlatformWindowFormat m_windowFormat; + QWindowFormat m_windowFormat; }; #endif //QOPENKODEGLINTEGRATION_H diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h index f125eab3c1..66079edacb 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.h +++ b/src/plugins/platforms/eglfs/qeglfswindow.h @@ -46,7 +46,7 @@ #include "qeglfsscreen.h" #include <QPlatformWindow> -#include <QtGui/QWidget> +#include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp index 895f8af58e..c87dc497b4 100644 --- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp +++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp @@ -41,7 +41,7 @@ #include "qbasicunixfontdatabase.h" -#include <QtGui/private/qapplication_p.h> +#include <QtGui/private/qguiapplication_p.h> #include <QtGui/QPlatformScreen> #include <QtCore/QFile> diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 2a3fd5a8b5..5655b6b7fd 100644 --- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -46,7 +46,6 @@ #include <QtCore/QElapsedTimer> -#include <QtGui/private/qapplication_p.h> #include <QtGui/QPlatformScreen> #include <QtGui/private/qfontengine_ft_p.h> diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp index eb0f6a6604..1d9c5090dd 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp @@ -70,7 +70,7 @@ enum { #undef FontChange #endif -QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit) +QVector<int> qglx_buildSpec(const QWindowFormat &format, int drawableBit) { QVector<int> spec(48); int i = 0; @@ -79,55 +79,43 @@ QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit spec[i++] = 0; spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = drawableBit; - if (format.rgba()) { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; - spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize(); - spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(); - spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(); - if (format.alpha()) { - spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); - } - - if (format.accum()) { - spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; - if (format.alpha()) { - spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - } - } - } else { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works.... - spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8; + spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize(); + spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(); + spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(); + if (format.hasAlpha()) { + spec[i++] = GLX_ALPHA_SIZE; spec[i++] = format.alphaBufferSize(); } - spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False; + spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QWindowFormat::SingleBuffer ? True : False; + spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False; - if (format.depth()) { - spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); + if (format.depthBufferSize() > 0) { + spec[i++] = GLX_DEPTH_SIZE; spec[i++] = format.depthBufferSize(); } - if (format.stencil()) { + if (format.stencilBufferSize() > 0) { spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); } - if (format.sampleBuffers()) { + + if (format.samples() > 1) { spec[i++] = GLX_SAMPLE_BUFFERS_ARB; spec[i++] = 1; spec[i++] = GLX_SAMPLES_ARB; - spec[i++] = format.samples() == -1 ? 4 : format.samples(); + spec[i++] = format.samples(); } spec[i++] = XNone; return spec; } -GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format, int drawableBit) +GLXFBConfig qglx_findConfig(Display *display, int screen , const QWindowFormat &format, int drawableBit) { bool reduced = true; GLXFBConfig chosenConfig = 0; - QPlatformWindowFormat reducedFormat = format; + QWindowFormat reducedFormat = format; while (!chosenConfig && reduced) { QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit); int confcount = 0; @@ -138,7 +126,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow for (int i = 0; i < confcount; i++) { chosenConfig = configs[i]; // Make sure we try to get an ARGB visual if the format asked for an alpha: - if (reducedFormat.alpha()) { + if (reducedFormat.hasAlpha()) { int alphaSize; glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize); if (alphaSize > 0) { @@ -159,7 +147,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow XFree(configs); } - reducedFormat = qglx_reducePlatformWindowFormat(reducedFormat,&reduced); + reducedFormat = qglx_reduceWindowFormat(reducedFormat,&reduced); } if (!chosenConfig) @@ -168,16 +156,16 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow return chosenConfig; } -XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format) +XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QWindowFormat &format) { GLXFBConfig config = qglx_findConfig(display,screen,format); XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display,config); return visualInfo; } -QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) +QWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext) { - QPlatformWindowFormat format; + QWindowFormat format; int redSize = 0; int greenSize = 0; int blueSize = 0; @@ -186,16 +174,9 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB int stencilSize = 0; int sampleBuffers = 0; int sampleCount = 0; - int level = 0; - int rgba = 0; int stereo = 0; - int accumSizeA = 0; - int accumSizeR = 0; - int accumSizeG = 0; - int accumSizeB = 0; XVisualInfo *vi = glXGetVisualFromFBConfig(display,config); - glXGetConfig(display,vi,GLX_RGBA,&rgba); XFree(vi); glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); @@ -204,12 +185,7 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers); - glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level); glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB); format.setRedBufferSize(redSize); format.setGreenBufferSize(greenSize); @@ -217,39 +193,31 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB format.setAlphaBufferSize(alphaSize); format.setDepthBufferSize(depthSize); format.setStencilBufferSize(stencilSize); - format.setSampleBuffers(sampleBuffers); - if (format.sampleBuffers()) { + if (sampleBuffers) { glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); format.setSamples(sampleCount); } - format.setDirectRendering(glXIsDirect(display, ctx)); - format.setRgba(rgba); format.setStereo(stereo); - format.setAccumBufferSize(accumSizeB); return format; } -QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) +QWindowFormat qglx_reduceWindowFormat(const QWindowFormat &format, bool *reduced) { - QPlatformWindowFormat retFormat = format; + QWindowFormat retFormat = format; *reduced = true; - if (retFormat.sampleBuffers()) { - retFormat.setSampleBuffers(false); + if (retFormat.samples() > 1) { + retFormat.setSamples(0); } else if (retFormat.stereo()) { retFormat.setStereo(false); - } else if (retFormat.accum()) { - retFormat.setAccum(false); - }else if (retFormat.stencil()) { - retFormat.setStencil(false); - }else if (retFormat.alpha()) { - retFormat.setAlpha(false); - }else if (retFormat.depth()) { - retFormat.setDepth(false); - }else if (retFormat.doubleBuffer()) { - retFormat.setDoubleBuffer(false); + }else if (retFormat.stencilBufferSize() > 0) { + retFormat.setStencilBufferSize(0); + }else if (retFormat.hasAlpha()) { + retFormat.setAlphaBufferSize(0); + }else if (retFormat.depthBufferSize() > 0) { + retFormat.setDepthBufferSize(0); }else{ *reduced = false; } diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.h b/src/plugins/platforms/glxconvenience/qglxconvenience.h index 2c59dbb324..765a08a39d 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.h +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.h @@ -42,15 +42,15 @@ #ifndef QGLXCONVENIENCE_H #define QGLXCONVENIENCE_H -#include <QPlatformWindowFormat> +#include <QWindowFormat> #include <X11/Xlib.h> #include <GL/glx.h> -XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format); -GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); -QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); -QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); -QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); +XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QWindowFormat &format); +GLXFBConfig qglx_findConfig(Display *display, int screen, const QWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); +QWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); +QVector<int> qglx_buildSpec(const QWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); +QWindowFormat qglx_reduceWindowFormat(const QWindowFormat &format, bool *reduced); #endif // QGLXCONVENIENCE_H diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index d1088e3233..5c8b55478a 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -1,5 +1,6 @@ TARGET = qminimal include(../../qpluginbase.pri) +QT += gui-private core-private QT = core-private gui-private DESTDIR = $$QT.gui.plugins/platforms diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index 44a4eb6adc..13dba86691 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -69,14 +69,14 @@ QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) return new QRasterPixmapData(type); } -QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWidget *widget, WId winId) const +QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWindow *window) const { - Q_UNUSED(winId); - return new QPlatformWindow(widget); + Q_UNUSED(window); + return new QPlatformWindow(window); } -QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget, WId winId) const +QWindowSurface *QMinimalIntegration::createWindowSurface(QWindow *window, WId winId) const { Q_UNUSED(winId); - return new QMinimalWindowSurface(widget); + return new QMinimalWindowSurface(window); } diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h index 993d364c1b..eecb4e51a7 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.h +++ b/src/plugins/platforms/minimal/qminimalintegration.h @@ -72,8 +72,8 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + QPlatformWindow *createPlatformWindow(QWindow *window) const; + QWindowSurface *createWindowSurface(QWindow *window, WId winId) const; QList<QPlatformScreen *> screens() const { return mScreens; } diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp index dd8c9b7045..b3f7532e37 100644 --- a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp +++ b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp @@ -42,11 +42,11 @@ #include "qminimalwindowsurface.h" #include <QtCore/qdebug.h> -#include <QtGui/private/qapplication_p.h> +#include <private/qguiapplication_p.h> QT_BEGIN_NAMESPACE -QMinimalWindowSurface::QMinimalWindowSurface(QWidget *window) +QMinimalWindowSurface::QMinimalWindowSurface(QWindow *window) : QWindowSurface(window) { //qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this; @@ -62,9 +62,9 @@ QPaintDevice *QMinimalWindowSurface::paintDevice() return &mImage; } -void QMinimalWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QMinimalWindowSurface::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { - Q_UNUSED(widget); + Q_UNUSED(window); Q_UNUSED(region); Q_UNUSED(offset); @@ -78,7 +78,7 @@ void QMinimalWindowSurface::resize(const QSize &size) { //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect; QWindowSurface::resize(size); - QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format(); + QImage::Format format = QGuiApplicationPrivate::platformIntegration()->screens().first()->format(); if (mImage.size() != size) mImage = QImage(size, format); } diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.h b/src/plugins/platforms/minimal/qminimalwindowsurface.h index bfeeacadc9..88ed279590 100644 --- a/src/plugins/platforms/minimal/qminimalwindowsurface.h +++ b/src/plugins/platforms/minimal/qminimalwindowsurface.h @@ -45,17 +45,18 @@ #include <QtGui/private/qwindowsurface_p.h> #include <QtGui/QPlatformWindow> +#include <QtGui/QImage> QT_BEGIN_NAMESPACE class QMinimalWindowSurface : public QWindowSurface { public: - QMinimalWindowSurface(QWidget *window); + QMinimalWindowSurface(QWindow *window); ~QMinimalWindowSurface(); QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); void resize(const QSize &size); private: diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index d34dff8a34..ef54ee63b9 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -53,7 +53,7 @@ #include <EGL/egl.h> -#include <QtGui/qwidget.h> +#include <QtWidgets/qwidget.h> #include <QtGui/private/qwidget_p.h> #include <QtGui/private/qapplication_p.h> diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index 492569796f..9d7ae296a9 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -9,3 +9,7 @@ contains(QT_CONFIG, wayland) { contains(QT_CONFIG, xcb) { SUBDIRS += xcb } + +mac { + SUBDIRS += cocoa +} diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp index be2de7c007..38dea35bff 100644 --- a/src/plugins/platforms/vnc/qvncserver.cpp +++ b/src/plugins/platforms/vnc/qvncserver.cpp @@ -43,7 +43,7 @@ #include <QtCore/qtimer.h> #include <QtCore/qregexp.h> -#include <QtGui/qwidget.h> +#include <QtWidgets/qwidget.h> #include <QtGui/qpolygon.h> #include <QtGui/qpainter.h> diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h index ac16039c9d..bb829a15fb 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h @@ -44,7 +44,7 @@ class QWaylandWindow; class QWaylandDisplay; -class QWidget; +class QWindow; class QWaylandGLIntegration { @@ -54,7 +54,7 @@ public: virtual void initialize() = 0; - virtual QWaylandWindow *createEglWindow(QWidget *widget) = 0; + virtual QWaylandWindow *createEglWindow(QWindow *window) = 0; static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay); }; diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp index ebe4c7bf86..3fc063aab7 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp @@ -47,6 +47,7 @@ #include <QtOpenGL/QGLFramebufferObject> #include <QtOpenGL/QGLContext> +#include <QPlatformGLContext> #include <QtOpenGL/private/qglengineshadermanager_p.h> @@ -133,9 +134,9 @@ static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, drawTexture(r, texture, texSize, sourceRect); } -QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWidget *window) +QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWindow *window) : QWindowSurface(window) - , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) + , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) , mPaintDevice(0) { @@ -153,30 +154,29 @@ QPaintDevice *QWaylandGLWindowSurface::paintDevice() void QWaylandGLWindowSurface::beginPaint(const QRegion &) { - window()->platformWindow()->glContext()->makeCurrent(); + window()->handle()->glContext()->makeCurrent(); glClearColor(0,0,0,0xff); glClear(GL_COLOR_BUFFER_BIT); } -void QWaylandGLWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QWaylandGLWindowSurface::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(offset); Q_UNUSED(region); - QWaylandWindow *ww = (QWaylandWindow *) widget->platformWindow(); - + if (mPaintDevice->isBound()) mPaintDevice->release(); QRect rect(0,0,size().width(),size().height()); - QGLContext *ctx = QGLContext::fromPlatformGLContext(ww->glContext()); + QGLContext *ctx = QGLContext::fromWindowContext(window->glContext()); blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect); - ww->glContext()->swapBuffers(); + window->glContext()->swapBuffers(); } void QWaylandGLWindowSurface::resize(const QSize &size) { QWindowSurface::resize(size); - window()->platformWindow()->glContext()->makeCurrent(); + window()->glContext()->makeCurrent(); delete mPaintDevice; mPaintDevice = new QGLFramebufferObject(size); } diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h index 8d53b42a56..1de449b4dc 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h @@ -51,13 +51,13 @@ class QGLFramebufferObject; class QWaylandGLWindowSurface : public QWindowSurface { public: - QWaylandGLWindowSurface(QWidget *window); + QWaylandGLWindowSurface(QWindow *window); ~QWaylandGLWindowSurface(); void beginPaint(const QRegion &); QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); void resize(const QSize &size); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp index d63087d934..6971459659 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp @@ -97,8 +97,6 @@ QWaylandReadbackEglContext::~QWaylandReadbackEglContext() void QWaylandReadbackEglContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); - mWindow->waitForFrameSync(); eglMakeCurrent(mEglIntegration->eglDisplay(),mPixmapSurface,mPixmapSurface,mContext); @@ -114,7 +112,7 @@ void QWaylandReadbackEglContext::swapBuffers() { eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface); - if (QPlatformGLContext::currentContext() != this) { + if (QWindowContext::currentContext().handle() != this) { makeCurrent(); } @@ -145,7 +143,7 @@ void * QWaylandReadbackEglContext::getProcAddress(const QString &procName) QPlatformWindowFormat QWaylandReadbackEglContext::platformWindowFormat() const { - return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); + return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); } void QWaylandReadbackEglContext::geometryChanged() diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h index ac682759e9..1540b92080 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h @@ -43,7 +43,6 @@ #define QWAYLANDREADBACKEGLGLCONTEXT_H #include <QPlatformGLContext> -#include <QtGui/QWidget> #include "qwaylandreadbackeglintegration.h" #include "qwaylandreadbackeglwindow.h" diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp index 20f7ffb609..8a3d769e65 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp @@ -81,7 +81,7 @@ void QWaylandReadbackEglIntegration::initialize() } } -QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWidget *widget) +QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWindow *window) { return new QWaylandReadbackEglWindow(widget,this); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h index 84fa64fd34..767634bbc2 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h @@ -48,7 +48,6 @@ #include <QtCore/QDataStream> #include <QtCore/QMetaType> #include <QtCore/QVariant> -#include <QtGui/QWidget> #include <X11/Xlib.h> @@ -61,7 +60,7 @@ public: ~QWaylandReadbackEglIntegration(); void initialize(); - QWaylandWindow *createEglWindow(QWidget *widget); + QWaylandWindow *createEglWindow(QWindow *window); QWaylandDisplay *waylandDisplay() const; Display *xDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp index 2ae212ba67..134f431c3d 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp @@ -43,7 +43,7 @@ #include "qwaylandreadbackeglcontext.h" -QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration) +QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWindow *window, QWaylandReadbackEglIntegration *eglIntegration) : QWaylandShmWindow(window) , mEglIntegration(eglIntegration) , mContext(0) diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h index 453ad27cd9..6fd09659dc 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h @@ -50,7 +50,7 @@ class QWaylandReadbackEglContext; class QWaylandReadbackEglWindow : public QWaylandShmWindow { public: - QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration); + QWaylandReadbackEglWindow(QWindow *window, QWaylandReadbackEglIntegration *eglIntegration); WindowType windowType() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp index 08c5cf6c51..5bafd418df 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp @@ -85,8 +85,6 @@ QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegr void QWaylandReadbackGlxContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); - glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext); } @@ -97,7 +95,7 @@ void QWaylandReadbackGlxContext::doneCurrent() void QWaylandReadbackGlxContext::swapBuffers() { - if (QPlatformGLContext::currentContext() != this) { + if (QWindowContext::currentContext().handle() != this) { makeCurrent(); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp index 4651f0c30e..25422d6c4f 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp @@ -66,9 +66,9 @@ void QWaylandReadbackGlxIntegration::initialize() { } -QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWidget *widget) +QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWindow *window) { - return new QWaylandReadbackGlxWindow(widget,this); + return new QWaylandReadbackGlxWindow(window,this); } QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h index 9056393905..c706da7f79 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h @@ -48,7 +48,7 @@ #include <QtCore/QDataStream> #include <QtCore/QMetaType> #include <QtCore/QVariant> -#include <QtGui/QWidget> +#include <QtGui/QWindow> #include <X11/Xlib.h> @@ -60,7 +60,7 @@ public: void initialize(); - QWaylandWindow *createEglWindow(QWidget *widget); + QWaylandWindow *createEglWindow(QWindow *window); QWaylandDisplay *waylandDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp index ca1603c649..f095862227 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp @@ -41,7 +41,7 @@ #include "qwaylandreadbackglxwindow.h" -QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration) +QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration) : QWaylandShmWindow(window) , mGlxIntegration(glxIntegration) , mContext(0) diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h index 4d7bb3ee74..47a1ce9ab4 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h @@ -49,7 +49,7 @@ class QWaylandReadbackGlxWindow : public QWaylandShmWindow { public: - QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration); + QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration); WindowType windowType() const; QPlatformGLContext *glContext() const; diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp index ddd17636c1..ac58312310 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -73,7 +73,7 @@ void QWaylandEglIntegration::initialize() } } -QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWidget *window) +QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWindow *window) { return new QWaylandEglWindow(window); } diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h index 3a26f97b32..66e272353a 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h @@ -47,7 +47,7 @@ #include "qwaylandeglinclude.h" class QWaylandWindow; -class QWidget; +class QWindow; class QWaylandEglIntegration : public QWaylandGLIntegration { @@ -57,7 +57,7 @@ public: void initialize(); - QWaylandWindow *createEglWindow(QWidget *window); + QWaylandWindow *createEglWindow(QWindow *window); EGLDisplay eglDisplay() const; struct wl_egl_display *nativeDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp index cf52f39d15..ad8786fd50 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp @@ -44,7 +44,7 @@ #include "qwaylandscreen.h" #include "qwaylandglcontext.h" -QWaylandEglWindow::QWaylandEglWindow(QWidget *window) +QWaylandEglWindow::QWaylandEglWindow(QWindow *window) : QWaylandWindow(window) , mGLContext(0) , mWaylandEglWindow(0) diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h index 856321dec8..ddc7a5af6e 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h @@ -51,7 +51,7 @@ class QWaylandGLContext; class QWaylandEglWindow : public QWaylandWindow { public: - QWaylandEglWindow(QWidget *window); + QWaylandEglWindow(QWindow *window); ~QWaylandEglWindow(); WindowType windowType() const; void setGeometry(const QRect &rect); diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp index d293019909..d8cff1f8c1 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -55,7 +55,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindo , mEglDisplay(eglDisplay) , mSurface(EGL_NO_SURFACE) , mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true)) - , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig)) + , mFormat(q_windowFormatFromConfig(mEglDisplay,mConfig)) { QPlatformGLContext *sharePlatformContext = 0; sharePlatformContext = format.sharedGLContext(); @@ -90,7 +90,6 @@ QWaylandGLContext::~QWaylandGLContext() void QWaylandGLContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); if (mSurface == EGL_NO_SURFACE) { qWarning("makeCurrent with EGL_NO_SURFACE"); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index 92acf752e4..21b369d0ae 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -75,8 +75,6 @@ QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(QWaylandXCompositeEGL void QWaylandXCompositeEGLContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); - eglMakeCurrent(mEglIntegration->eglDisplay(),mEglWindowSurface,mEglWindowSurface,mContext); } @@ -102,7 +100,7 @@ void * QWaylandXCompositeEGLContext::getProcAddress(const QString &procName) QPlatformWindowFormat QWaylandXCompositeEGLContext::platformWindowFormat() const { - return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); + return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); } void QWaylandXCompositeEGLContext::sync_function(void *data) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp index 7537b52d59..6f7428024a 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp @@ -70,9 +70,9 @@ void QWaylandXCompositeEGLIntegration::initialize() { } -QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWidget *widget) +QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWindow *window) { - return new QWaylandXCompositeEGLWindow(widget,this); + return new QWaylandXCompositeEGLWindow(window,this); } Display * QWaylandXCompositeEGLIntegration::xDisplay() const diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h index 590ae3754c..8edaa2becd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h @@ -49,7 +49,7 @@ #include <QtCore/QDataStream> #include <QtCore/QMetaType> #include <QtCore/QVariant> -#include <QtGui/QWidget> +#include <QtGui/QWindow> #include <QWaitCondition> @@ -66,7 +66,7 @@ public: void initialize(); - QWaylandWindow *createEglWindow(QWidget *widget); + QWaylandWindow *createEglWindow(QWindow *window); QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp index 1c9d36fe92..19cbbd2d49 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp @@ -43,7 +43,7 @@ #include <QtCore/QDebug> -QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration) +QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration) : QWaylandWindow(window) , mGlxIntegration(glxIntegration) , mContext(0) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h index fc33b32322..111e751815 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h @@ -49,7 +49,7 @@ class QWaylandXCompositeEGLWindow : public QWaylandWindow { public: - QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration); + QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration); WindowType windowType() const; QPlatformGLContext *glContext() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp index baf0fa3432..39bd99e5a0 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -46,6 +46,7 @@ #include "wayland-xcomposite-client-protocol.h" #include <QtCore/QDebug> +#include <QtGui/QRegion> #include <X11/extensions/Xcomposite.h> @@ -55,7 +56,7 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLX , mWindow(window) , mBuffer(0) , mXWindow(0) - , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat())) + , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->window()->format())) , mWaitingForSyncCallback(false) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); @@ -66,7 +67,6 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLX void QWaylandXCompositeGLXContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); glXMakeCurrent(mGlxIntegration->xDisplay(),mXWindow,mContext); } @@ -90,7 +90,7 @@ void * QWaylandXCompositeGLXContext::getProcAddress(const QString &procName) return (void *) glXGetProcAddress(reinterpret_cast<GLubyte *>(procName.toLatin1().data())); } -QPlatformWindowFormat QWaylandXCompositeGLXContext::platformWindowFormat() const +QWindowFormat QWaylandXCompositeGLXContext::windowFormat() const { return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h index eb2e5a518e..2a94bd1c00 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -64,7 +64,7 @@ public: void swapBuffers(); void* getProcAddress(const QString& procName); - QPlatformWindowFormat platformWindowFormat() const; + QWindowFormat windowFormat() const; void geometryChanged(); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp index 5cb6ef336b..03b00da910 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -70,9 +70,9 @@ void QWaylandXCompositeGLXIntegration::initialize() { } -QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWidget *widget) +QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *window) { - return new QWaylandXCompositeGLXWindow(widget,this); + return new QWaylandXCompositeGLXWindow(window,this); } Display * QWaylandXCompositeGLXIntegration::xDisplay() const diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h index 24a40167e2..4f53449915 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h @@ -49,7 +49,7 @@ #include <QtCore/QDataStream> #include <QtCore/QMetaType> #include <QtCore/QVariant> -#include <QtGui/QWidget> +#include <QtGui/QWindow> #include <X11/Xlib.h> @@ -63,7 +63,7 @@ public: void initialize(); - QWaylandWindow *createEglWindow(QWidget *widget); + QWaylandWindow *createEglWindow(QWindow *window); QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp index db0f254a20..40b72186f0 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp @@ -43,7 +43,7 @@ #include <QtCore/QDebug> -QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration) +QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration) : QWaylandWindow(window) , mGlxIntegration(glxIntegration) , mContext(0) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h index 536153dbcf..f1bab465d4 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h @@ -49,7 +49,7 @@ class QWaylandXCompositeGLXWindow : public QWaylandWindow { public: - QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration); + QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration); WindowType windowType() const; QPlatformGLContext *glContext() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp index 4b0d3a073f..81c18058dd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp @@ -42,6 +42,7 @@ #include "qwaylandxcompositebuffer.h" #include "wayland-client.h" +#include "wayland-xcomposite-client-protocol.h" QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(wl_xcomposite *xcomposite, uint32_t window, const QSize &size, wl_visual *visual) :mSize(size) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h index b346651957..c51f6bbf4c 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h @@ -43,8 +43,10 @@ #define QWAYLANDXCOMPOSITEBUFFER_H #include "qwaylandbuffer.h" +#include <stdint.h> -#include "wayland-xcomposite-client-protocol.h" +struct wl_xcomposite; +struct wl_visual; class QWaylandXCompositeBuffer : public QWaylandBuffer { diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp index cf9c5a7591..3c90112a91 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp +++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp @@ -43,7 +43,7 @@ #include "qwaylanddisplay.h" #include "qwaylandinputdevice.h" #include <QtGui/QPlatformNativeInterface> -#include <QtGui/QApplication> +#include <QtGui/QGuiApplication> #include <QtCore/QMimeData> #include <QtCore/QStringList> #include <QtCore/QFile> diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp index 614686f971..72274a28f9 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp @@ -108,11 +108,11 @@ QWaylandCursor::QWaylandCursor(QWaylandScreen *screen) { } -void QWaylandCursor::changeCursor(QCursor *cursor, QWidget *widget) +void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window) { const struct pointer_image *p; - if (widget == NULL) + if (window == NULL) return; p = NULL; diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h index 254cb9473a..9f7d871249 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.h +++ b/src/plugins/platforms/wayland/qwaylandcursor.h @@ -52,7 +52,7 @@ class QWaylandCursor : QPlatformCursor { public: QWaylandCursor(QWaylandScreen *screen); - void changeCursor(QCursor *cursor, QWidget *widget); + void changeCursor(QCursor *cursor, QWindow *window); QWaylandShmBuffer *mBuffer; QWaylandDisplay *mDisplay; }; diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 9011f5799a..310e266e64 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -56,8 +56,7 @@ #endif #include <QtCore/QAbstractEventDispatcher> -#include <QtGui/QApplication> -#include <QtGui/private/qapplication_p.h> +#include <QtGui/private/qguiapplication_p.h> #include <unistd.h> #include <fcntl.h> @@ -281,7 +280,7 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id, new QWaylandInputDevice(mDisplay, id); mInputDevices.append(inputDevice); } else if (interface == "wl_selection_offer") { - QPlatformIntegration *plat = QApplicationPrivate::platformIntegration(); + QPlatformIntegration *plat = QGuiApplicationPrivate::platformIntegration(); QWaylandClipboard *clipboard = static_cast<QWaylandClipboard *>(plat->clipboard()); clipboard->createSelectionOffer(id); } diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index f9e7c95861..de541f7d64 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -110,7 +110,7 @@ void QWaylandInputDevice::inputHandleMotion(void *data, inputDevice->mSurfacePos = QPoint(surface_x, surface_y); inputDevice->mGlobalPos = QPoint(x, y); inputDevice->mTime = time; - QWindowSystemInterface::handleMouseEvent(window->widget(), + QWindowSystemInterface::handleMouseEvent(window->window(), time, inputDevice->mSurfacePos, inputDevice->mGlobalPos, @@ -152,7 +152,7 @@ void QWaylandInputDevice::inputHandleButton(void *data, inputDevice->mButtons &= ~qt_button; inputDevice->mTime = time; - QWindowSystemInterface::handleMouseEvent(window->widget(), + QWindowSystemInterface::handleMouseEvent(window->window(), time, inputDevice->mSurfacePos, inputDevice->mGlobalPos, @@ -269,7 +269,7 @@ void QWaylandInputDevice::inputHandleKey(void *data, sym = translateKey(sym, s, sizeof s); if (window) { - QWindowSystemInterface::handleKeyEvent(window->widget(), + QWindowSystemInterface::handleKeyEvent(window->window(), time, type, sym, inputDevice->mModifiers, QString::fromLatin1(s)); @@ -292,13 +292,13 @@ void QWaylandInputDevice::inputHandlePointerFocus(void *data, if (inputDevice->mPointerFocus) { window = inputDevice->mPointerFocus; - QWindowSystemInterface::handleLeaveEvent(window->widget()); + QWindowSystemInterface::handleLeaveEvent(window->window()); inputDevice->mPointerFocus = NULL; } if (surface) { window = (QWaylandWindow *) wl_surface_get_user_data(surface); - QWindowSystemInterface::handleEnterEvent(window->widget()); + QWindowSystemInterface::handleEnterEvent(window->window()); inputDevice->mPointerFocus = window; } @@ -330,7 +330,7 @@ void QWaylandInputDevice::inputHandleKeyboardFocus(void *data, if (surface) { window = (QWaylandWindow *) wl_surface_get_user_data(surface); inputDevice->mKeyboardFocus = window; - QWindowSystemInterface::handleWindowActivated(window->widget()); + QWindowSystemInterface::handleWindowActivated(window->window()); } else { inputDevice->mKeyboardFocus = NULL; QWindowSystemInterface::handleWindowActivated(0); diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 6166c142eb..7df6c4a526 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -51,7 +51,7 @@ #include <QtGui/QWindowSystemInterface> #include <QtGui/QPlatformCursor> -#include <QtGui/QPlatformWindowFormat> +#include <QtGui/QWindowFormat> #include <QtGui/private/qpixmap_raster_p.h> #ifdef QT_WAYLAND_GL_SUPPORT @@ -98,27 +98,25 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) return new QRasterPixmapData(type); } -QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const +QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const { - Q_UNUSED(winId); #ifdef QT_WAYLAND_GL_SUPPORT - bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL); + bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface; if (useOpenGL) - return mDisplay->eglIntegration()->createEglWindow(widget); + return mDisplay->eglIntegration()->createEglWindow(window); #endif - return new QWaylandShmWindow(widget); + return new QWaylandShmWindow(window); } -QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId winId) const +QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const { Q_UNUSED(winId); - Q_UNUSED(winId); #ifdef QT_WAYLAND_GL_SUPPORT - bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL); + bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface; if (useOpenGL) - return new QWaylandGLWindowSurface(widget); + return new QWaylandGLWindowSurface(window); #endif - return new QWaylandShmWindowSurface(widget); + return new QWaylandShmWindowSurface(window); } QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index fc748b0f1d..f0bb27a4ed 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -56,8 +56,8 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + QPlatformWindow *createPlatformWindow(QWindow *window) const; + QWindowSurface *createWindowSurface(QWindow *window, WId winId) const; QList<QPlatformScreen *> screens() const; diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp index c3bfba03cc..8a7799e7a9 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp @@ -43,30 +43,30 @@ #include "qwaylanddisplay.h" #include "qwaylandwindow.h" -#include <QtGui/private/qapplication_p.h> +#include <QtGui/private/qguiapplication_p.h> -void *QWaylandNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget) +void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { QByteArray lowerCaseResource = resourceString.toLower(); if (lowerCaseResource == "display") - return qPlatformScreenForWidget(widget)->display()->wl_display(); + return qPlatformScreenForWindow(window)->display()->wl_display(); if (lowerCaseResource == "surface") { - return ((QWaylandWindow *) widget->platformWindow())->wl_surface(); + return ((QWaylandWindow *) window->handle())->wl_surface(); } return NULL; } -QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWidget(QWidget *widget) +QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWindow(QWindow *window) { QWaylandScreen *screen; - if (widget) { - screen = static_cast<QWaylandScreen *>(QPlatformScreen::platformScreenForWidget(widget)); + if (window) { + screen = static_cast<QWaylandScreen *>(QPlatformScreen::platformScreenForWindow(window)); } else { - screen = static_cast<QWaylandScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]); + screen = static_cast<QWaylandScreen *>(QGuiApplicationPrivate::platformIntegration()->screens()[0]); } return screen; } diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.h b/src/plugins/platforms/wayland/qwaylandnativeinterface.h index ac4cdb9a22..dbb17a63a9 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.h +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.h @@ -49,11 +49,11 @@ class QWaylandNativeInterface : public QPlatformNativeInterface { public: - void *nativeResourceForWidget(const QByteArray &resourceString, - QWidget *widget); + void *nativeResourceForWindow(const QByteArray &resourceString, + QWindow *window); private: - static QWaylandScreen *qPlatformScreenForWidget(QWidget *widget); + static QWaylandScreen *qPlatformScreenForWindow(QWindow *window); }; diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index 4f50cb61e6..8888f256ce 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -81,9 +81,9 @@ QImage::Format QWaylandScreen::format() const return mFormat; } -QWaylandScreen * QWaylandScreen::waylandScreenFromWidget(QWidget *widget) +QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window) { - QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWidget(widget); + QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(window); return static_cast<QWaylandScreen *>(platformScreen); } diff --git a/src/plugins/platforms/wayland/qwaylandscreen.h b/src/plugins/platforms/wayland/qwaylandscreen.h index 7784646da9..ec52e37166 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.h +++ b/src/plugins/platforms/wayland/qwaylandscreen.h @@ -62,7 +62,7 @@ public: wl_visual *visual() const; - static QWaylandScreen *waylandScreenFromWidget(QWidget *widget); + static QWaylandScreen *waylandScreenFromWindow(QWindow *window); private: QWaylandDisplay *mWaylandDisplay; diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp index 34f4436f25..4bc54399ee 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp @@ -41,7 +41,6 @@ #include "qwaylandshmsurface.h" #include <QtCore/qdebug.h> -#include <QtGui/private/qapplication_p.h> #include "qwaylanddisplay.h" #include "qwaylandshmwindow.h" @@ -91,10 +90,10 @@ QWaylandShmBuffer::~QWaylandShmBuffer(void) wl_buffer_destroy(mBuffer); } -QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window) +QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWindow *window) : QWindowSurface(window) , mBuffer(0) - , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) + , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) { } @@ -109,27 +108,27 @@ QPaintDevice *QWaylandShmWindowSurface::paintDevice() void QWaylandShmWindowSurface::beginPaint(const QRegion &) { - QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow()); + QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->handle()); Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); waylandWindow->waitForFrameSync(); } -void QWaylandShmWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QWaylandShmWindowSurface::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { - Q_UNUSED(widget); + Q_UNUSED(window); Q_UNUSED(offset); - QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow()); + QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window->handle()); Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); waylandWindow->damage(region); } void QWaylandShmWindowSurface::resize(const QSize &size) { - QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow()); + QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->handle()); Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); QWindowSurface::resize(size); - QImage::Format format = QPlatformScreen::platformScreenForWidget(window())->format(); + QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format(); if (mBuffer != NULL && mBuffer->size() == size) return; diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmsurface.h index b29ceaf1b8..ce3e5ff5b9 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.h +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.h @@ -44,7 +44,7 @@ #include "qwaylandbuffer.h" #include <QtGui/private/qwindowsurface_p.h> - +#include <QtGui/QImage> #include <QtGui/QPlatformWindow> QT_BEGIN_NAMESPACE @@ -65,11 +65,11 @@ private: class QWaylandShmWindowSurface : public QWindowSurface { public: - QWaylandShmWindowSurface(QWidget *window); + QWaylandShmWindowSurface(QWindow *window); ~QWaylandShmWindowSurface(); QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); void resize(const QSize &size); void beginPaint(const QRegion &); diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp index c083e58305..c298668dfe 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp @@ -47,8 +47,8 @@ #include <QtCore/QDebug> -QWaylandShmWindow::QWaylandShmWindow(QWidget *widget) - : QWaylandWindow(widget) +QWaylandShmWindow::QWaylandShmWindow(QWindow *window) + : QWaylandWindow(window) { newSurfaceCreated(); } diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h index 5dc6351c46..473c6df2ee 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.h +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h @@ -48,7 +48,7 @@ class QWaylandShmWindow : public QWaylandWindow { public: - QWaylandShmWindow(QWidget *widget); + QWaylandShmWindow(QWindow *window); ~QWaylandShmWindow(); WindowType windowType() const; diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index d2a7647fc0..1e13f30b64 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -46,19 +46,20 @@ #include "qwaylandinputdevice.h" #include "qwaylandscreen.h" +#include <QtGui/QWindow> + #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT #include "windowmanager_integration/qwaylandwindowmanagerintegration.h" #endif #include <QCoreApplication> -#include <QtGui/QWidget> #include <QtGui/QWindowSystemInterface> #include <QDebug> -QWaylandWindow::QWaylandWindow(QWidget *window) +QWaylandWindow::QWaylandWindow(QWindow *window) : QPlatformWindow(window) - , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) + , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) , mBuffer(0) , mWaitingForFrameSync(false) { @@ -118,7 +119,7 @@ void QWaylandWindow::configure(uint32_t time, uint32_t edges, setGeometry(geometry); - QWindowSystemInterface::handleGeometryChange(widget(), geometry); + QWindowSystemInterface::handleGeometryChange(window(), geometry); } void QWaylandWindow::attach(QWaylandBuffer *buffer) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h index 47d49a70d9..53bfcc7bd6 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.h +++ b/src/plugins/platforms/wayland/qwaylandwindow.h @@ -59,7 +59,7 @@ public: Egl }; - QWaylandWindow(QWidget *window); + QWaylandWindow(QWindow *window); ~QWaylandWindow(); virtual WindowType windowType() const = 0; diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 3f5a69cf75..e49c73bfae 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -39,6 +39,11 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND INCLUDEPATH += $$PWD +QT += gui-private +QT += opengl-private +QT += core-private +QT += widgets-private + include ($$PWD/gl_integration/gl_integration.pri) include ($$PWD/windowmanager_integration/windowmanager_integration.pri) diff --git a/src/plugins/platforms/xcb/qdri2context.cpp b/src/plugins/platforms/xcb/qdri2context.cpp index dbbfa67d8f..8d436f1735 100644 --- a/src/plugins/platforms/xcb/qdri2context.cpp +++ b/src/plugins/platforms/xcb/qdri2context.cpp @@ -45,7 +45,7 @@ #include "qxcbconnection.h" #include <QtCore/QDebug> -#include <QtGui/QWidget> +#include <QtWidgets/QWidget> #include <xcb/dri2.h> #include <xcb/xfixes.h> @@ -146,7 +146,6 @@ QDri2Context::~QDri2Context() void QDri2Context::makeCurrent() { - QPlatformGLContext::makeCurrent(); Q_D(QDri2Context); eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,d->eglContext); @@ -156,7 +155,6 @@ void QDri2Context::makeCurrent() void QDri2Context::doneCurrent() { - QPlatformGLContext::doneCurrent(); Q_D(QDri2Context); eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT); } diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index 1417157bdf..7c0751f896 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -50,6 +50,8 @@ #include <X11/Xutil.h> #include <GL/glx.h> +#include <QtGui/QWindowContext> + #include "qglxintegration.h" #include "qglxconvenience.h" @@ -57,18 +59,17 @@ #include <dlfcn.h> #endif -QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format) +QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QWindowFormat &format) : QPlatformGLContext() , m_screen(screen) , m_drawable((Drawable)window) , m_context(0) { Q_XCB_NOOP(m_screen->connection()); - const QPlatformGLContext *sharePlatformContext; - sharePlatformContext = format.sharedGLContext(); + const QWindowContext *shareContext = format.sharedContext(); GLXContext shareGlxContext = 0; - if (sharePlatformContext) - shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext(); + if (shareContext) + shareGlxContext = static_cast<const QGLXContext*>(shareContext->handle())->glxContext(); GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format); m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE); @@ -93,7 +94,6 @@ QGLXContext::~QGLXContext() void QGLXContext::makeCurrent() { Q_XCB_NOOP(m_screen->connection()); - QPlatformGLContext::makeCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context); Q_XCB_NOOP(m_screen->connection()); } @@ -101,7 +101,6 @@ void QGLXContext::makeCurrent() void QGLXContext::doneCurrent() { Q_XCB_NOOP(m_screen->connection()); - QPlatformGLContext::doneCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0); Q_XCB_NOOP(m_screen->connection()); } @@ -147,7 +146,7 @@ void* QGLXContext::getProcAddress(const QString& procName) return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data())); } -QPlatformWindowFormat QGLXContext::platformWindowFormat() const +QWindowFormat QGLXContext::windowFormat() const { return m_windowFormat; } diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h index 99b72a04b5..4450083959 100644 --- a/src/plugins/platforms/xcb/qglxintegration.h +++ b/src/plugins/platforms/xcb/qglxintegration.h @@ -45,7 +45,7 @@ #include "qxcbwindow.h" #include <QtGui/QPlatformGLContext> -#include <QtGui/QPlatformWindowFormat> +#include <QtGui/QWindowFormat> #include <QtCore/QMutex> @@ -54,7 +54,7 @@ class QGLXContext : public QPlatformGLContext { public: - QGLXContext(Window window, QXcbScreen *xd, const QPlatformWindowFormat &format); + QGLXContext(Window window, QXcbScreen *xd, const QWindowFormat &format); ~QGLXContext(); virtual void makeCurrent(); @@ -64,13 +64,13 @@ public: GLXContext glxContext() const { return m_context; } - QPlatformWindowFormat platformWindowFormat() const; + QWindowFormat windowFormat() const; private: QXcbScreen *m_screen; Drawable m_drawable; GLXContext m_context; - QPlatformWindowFormat m_windowFormat; + QWindowFormat m_windowFormat; QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context); }; diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 7ad12fe8b1..4035ba1bef 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -46,7 +46,7 @@ #include <QtAlgorithms> #include <QSocketNotifier> -#include <QtGui/private/qapplication_p.h> +#include <QtGui/private/qguiapplication_p.h> #include <QAbstractEventDispatcher> #include <QtCore/QDebug> @@ -143,22 +143,26 @@ QXcbConnection::~QXcbConnection() delete m_keyboard; } -QXcbWindow *platformWindowFromId(xcb_window_t id) +void QXcbConnection::addWindow(xcb_window_t id, QXcbWindow *window) { - QWidget *widget = QWidget::find(id); - if (widget) - return static_cast<QXcbWindow *>(widget->platformWindow()); - return 0; + m_mapper.insert(id, window); } -#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, window, handler) \ +void QXcbConnection::removeWindow(xcb_window_t id) +{ + m_mapper.remove(id); +} + +QXcbWindow *QXcbConnection::platformWindowFromId(xcb_window_t id) +{ + return m_mapper.value(id, 0); +} + +#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \ { \ event_t *e = (event_t *)event; \ - if (QXcbWindow *platformWindow = platformWindowFromId(e->window)) { \ - QObjectPrivate *d = QObjectPrivate::get(platformWindow->widget()); \ - if (!d->wasDeleted) \ - platformWindow->handler(e); \ - } \ + if (QXcbWindow *platformWindow = platformWindowFromId(e->windowMember)) \ + platformWindow->handler(e); \ } \ break; @@ -166,7 +170,7 @@ break; { \ event_t *e = (event_t *)event; \ if (QXcbWindow *platformWindow = platformWindowFromId(e->event)) \ - m_keyboard->handler(platformWindow->widget(), e); \ + m_keyboard->handler(platformWindow->window(), e); \ } \ break; diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 6b5f81047d..cbdfff7e15 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -44,6 +44,7 @@ #include <xcb/xcb.h> +#include <QHash> #include <QList> #include <QObject> #include <QVector> @@ -51,6 +52,9 @@ #define Q_XCB_DEBUG class QXcbScreen; +class QXcbWindow; + +typedef QHash<xcb_window_t, QXcbWindow *> WindowMapper; namespace QXcbAtom { enum Atom { @@ -255,6 +259,9 @@ public: void sync(); void handleXcbError(xcb_generic_error_t *error); + void addWindow(xcb_window_t id, QXcbWindow *window); + void removeWindow(xcb_window_t id); + private slots: void processXcbEvents(); @@ -264,6 +271,7 @@ private: #ifdef XCB_USE_DRI2 void initializeDri2(); #endif + QXcbWindow *platformWindowFromId(xcb_window_t id); xcb_connection_t *m_connection; const xcb_setup_t *m_setup; @@ -303,6 +311,8 @@ private: template <typename cookie_t> friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); #endif + + WindowMapper m_mapper; }; #define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display())) diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 9df5f14114..7aa3b3f1ba 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -87,16 +87,15 @@ QPixmapData *QXcbIntegration::createPixmapData(QPixmapData::PixelType type) cons return new QRasterPixmapData(type); } -QPlatformWindow *QXcbIntegration::createPlatformWindow(QWidget *widget, WId winId) const +QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const { - Q_UNUSED(winId); - return new QXcbWindow(widget); + return new QXcbWindow(window); } -QWindowSurface *QXcbIntegration::createWindowSurface(QWidget *widget, WId winId) const +QWindowSurface *QXcbIntegration::createWindowSurface(QWindow *window, WId winId) const { Q_UNUSED(winId); - return new QXcbWindowSurface(widget); + return new QXcbWindowSurface(window); } QList<QPlatformScreen *> QXcbIntegration::screens() const diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index d27fd716ab..0de6f15657 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -57,8 +57,8 @@ public: bool hasCapability(Capability cap) const; QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + QPlatformWindow *createPlatformWindow(QWindow *window) const; + QWindowSurface *createWindowSurface(QWindow *window, WId winId) const; QList<QPlatformScreen *> screens() const; void moveToScreen(QWidget *window, int screen); diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index f501c00e94..b6e95392a6 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -913,7 +913,7 @@ QXcbKeyboard::~QXcbKeyboard() // #define XCB_KEYBOARD_DEBUG -void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time) +void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time) { int col = state & XCB_MOD_MASK_SHIFT ? 1 : 0; @@ -954,17 +954,17 @@ void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycod QString string = translateKeySym(sym, state, qtcode, modifiers, chars, count); - QWindowSystemInterface::handleExtendedKeyEvent(widget, time, type, qtcode, modifiers, code, 0, state, string.left(count)); + QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers, code, 0, state, string.left(count)); } -void QXcbKeyboard::handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event) +void QXcbKeyboard::handleKeyPressEvent(QWindow *window, const xcb_key_press_event_t *event) { - handleKeyEvent(widget, QEvent::KeyPress, event->detail, event->state, event->time); + handleKeyEvent(window, QEvent::KeyPress, event->detail, event->state, event->time); } -void QXcbKeyboard::handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event) +void QXcbKeyboard::handleKeyReleaseEvent(QWindow *window, const xcb_key_release_event_t *event) { - handleKeyEvent(widget, QEvent::KeyRelease, event->detail, event->state, event->time); + handleKeyEvent(window, QEvent::KeyRelease, event->detail, event->state, event->time); } void QXcbKeyboard::handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h index ddade79d51..ee951bfd4b 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.h +++ b/src/plugins/platforms/xcb/qxcbkeyboard.h @@ -48,21 +48,23 @@ #include <QEvent> +class QWindow; + class QXcbKeyboard : public QXcbObject { public: QXcbKeyboard(QXcbConnection *connection); ~QXcbKeyboard(); - void handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event); - void handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event); + void handleKeyPressEvent(QWindow *window, const xcb_key_press_event_t *event); + void handleKeyReleaseEvent(QWindow *window, const xcb_key_release_event_t *event); void handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event); Qt::KeyboardModifiers translateModifiers(int s); private: - void handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time); + void handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time); int translateKeySym(uint key) const; QString translateKeySym(xcb_keysym_t keysym, uint xmodifiers, diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index b2ca1beb6e..9d0eb86480 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -43,11 +43,13 @@ #include "qxcbscreen.h" -#include <QtGui/private/qapplication_p.h> +#include <private/qguiapplication_p.h> #include <QtCore/QMap> #include <QtCore/QDebug> +#include <QtGui/qwindowcontext_qpa.h> + #if defined(XCB_USE_EGL) #include "../eglconvenience/qeglplatformcontext.h" #elif defined (XCB_USE_DRI2) @@ -71,29 +73,29 @@ public: Q_GLOBAL_STATIC(QXcbResourceMap, qXcbResourceMap) -void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget) +void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { QByteArray lowerCaseResource = resourceString.toLower(); ResourceType resource = qXcbResourceMap()->value(lowerCaseResource); void *result = 0; switch(resource) { case Display: - result = displayForWidget(widget); + result = displayForWindow(window); break; case EglDisplay: - result = eglDisplayForWidget(widget); + result = eglDisplayForWindow(window); break; case Connection: - result = connectionForWidget(widget); + result = connectionForWindow(window); break; case Screen: - result = qPlatformScreenForWidget(widget); + result = qPlatformScreenForWindow(window); break; case GraphicsDevice: - result = graphicsDeviceForWidget(widget); + result = graphicsDeviceForWindow(window); break; case EglContext: - result = eglContextForWidget(widget); + result = eglContextForWindow(window); break; default: result = 0; @@ -101,75 +103,70 @@ void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceStr return result; } -QXcbScreen *QXcbNativeInterface::qPlatformScreenForWidget(QWidget *widget) +QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window) { QXcbScreen *screen; - if (widget) { - screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget)); + if (window) { + screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window)); }else { - screen = static_cast<QXcbScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]); + screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens()[0]); } return screen; } -void *QXcbNativeInterface::displayForWidget(QWidget *widget) +void *QXcbNativeInterface::displayForWindow(QWindow *window) { #if defined(XCB_USE_XLIB) - QXcbScreen *screen = qPlatformScreenForWidget(widget); + QXcbScreen *screen = qPlatformScreenForWindow(window); return screen->connection()->xlib_display(); #else - Q_UNUSED(widget); + Q_UNUSED(window); return 0; #endif } -void *QXcbNativeInterface::eglDisplayForWidget(QWidget *widget) +void *QXcbNativeInterface::eglDisplayForWindow(QWindow *window) { #if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL) - QXcbScreen *screen = qPlatformScreenForWidget(widget); + QXcbScreen *screen = qPlatformScreenForWindow(window); return screen->connection()->egl_display(); #else - Q_UNUSED(widget) + Q_UNUSED(window) return 0; #endif } -void *QXcbNativeInterface::connectionForWidget(QWidget *widget) +void *QXcbNativeInterface::connectionForWindow(QWindow *window) { - QXcbScreen *screen = qPlatformScreenForWidget(widget); + QXcbScreen *screen = qPlatformScreenForWindow(window); return screen->xcb_connection(); } -void *QXcbNativeInterface::screenForWidget(QWidget *widget) +void *QXcbNativeInterface::screenForWindow(QWindow *window) { - QXcbScreen *screen = qPlatformScreenForWidget(widget); + QXcbScreen *screen = qPlatformScreenForWindow(window); return screen->screen(); } -void *QXcbNativeInterface::graphicsDeviceForWidget(QWidget *widget) +void *QXcbNativeInterface::graphicsDeviceForWindow(QWindow *window) { #if defined(XCB_USE_DRI2) - QXcbScreen *screen = qPlatformScreenForWidget(widget); + QXcbScreen *screen = qPlatformScreenForWindow(window); QByteArray deviceName = screen->connection()->dri2DeviceName(); return deviceName.data(); #else - Q_UNUSED(widget); + Q_UNUSED(window); return 0; #endif } -void * QXcbNativeInterface::eglContextForWidget(QWidget *widget) +void * QXcbNativeInterface::eglContextForWindow(QWindow *window) { - Q_ASSERT(widget); - if (!widget->platformWindow()) { - qDebug() << "QPlatformWindow does not exist for widget" << widget - << "cannot return EGLContext"; - return 0; - } - QPlatformGLContext *platformContext = widget->platformWindow()->glContext(); + Q_ASSERT(window); + QPlatformGLContext *platformContext = window->glContext()->handle(); if (!platformContext) { - qDebug() << "QPlatformWindow" << widget->platformWindow() << "does not have a glContext" + qDebug() << "QWindow" << window << "does not have a glContext" << "cannot return EGLContext"; return 0; } diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index f60905cc3d..5cf3d8c6a6 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -59,17 +59,17 @@ public: EglContext }; - void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget); + void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window); - void *displayForWidget(QWidget *widget); - void *eglDisplayForWidget(QWidget *widget); - void *connectionForWidget(QWidget *widget); - void *screenForWidget(QWidget *widget); - void *graphicsDeviceForWidget(QWidget *widget); - void *eglContextForWidget(QWidget *widget); + void *displayForWindow(QWindow *window); + void *eglDisplayForWindow(QWindow *window); + void *connectionForWindow(QWindow *window); + void *screenForWindow(QWindow *window); + void *graphicsDeviceForWindow(QWindow *window); + void *eglContextForWindow(QWindow *window); private: - static QXcbScreen *qPlatformScreenForWidget(QWidget *widget); + static QXcbScreen *qPlatformScreenForWindow(QWindow *window); }; #endif // QXCBNATIVEINTERFACE_H diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 1c12ee3059..851a781d6c 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -102,6 +102,26 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int num free(reply); m_syncRequestSupported = m_windowManagerName != QLatin1String("KWin"); + + m_clientLeader = xcb_generate_id(xcb_connection()); + Q_XCB_CALL2(xcb_create_window(xcb_connection(), + XCB_COPY_FROM_PARENT, + m_clientLeader, + m_screen->root, + 0, 0, 1, 1, + 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, + m_screen->root_visual, + 0, 0), connection); + + Q_XCB_CALL2(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_clientLeader, + atom(QXcbAtom::WM_CLIENT_LEADER), + XCB_ATOM_WINDOW, + 32, + 1, + &m_clientLeader), connection); } QXcbScreen::~QXcbScreen() diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 9547d016b7..8efafb35bc 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -67,6 +67,8 @@ public: xcb_screen_t *screen() const { return m_screen; } xcb_window_t root() const { return m_screen->root; } + xcb_window_t clientLeader() const { return m_clientLeader; } + QString windowManagerName() const { return m_windowManagerName; } bool syncRequestSupported() const { return m_syncRequestSupported; } @@ -75,6 +77,7 @@ private: int m_number; QString m_windowManagerName; bool m_syncRequestSupported; + xcb_window_t m_clientLeader; }; #endif diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 0dd29eb8b2..2a7594ee9b 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -51,7 +51,8 @@ #include <xcb/xcb_icccm.h> -#include <private/qapplication_p.h> +#include <private/qguiapplication_p.h> +#include <private/qwindow_p.h> #include <private/qwindowsurface_p.h> #include <QtGui/QWindowSystemInterface> @@ -72,31 +73,51 @@ #include "../eglconvenience/qxlibeglintegration.h" #endif +//#ifdef NET_WM_STATE_DEBUG + // Returns true if we should set WM_TRANSIENT_FOR on \a w -static inline bool isTransient(const QWidget *w) +static inline bool isTransient(const QWindow *w) { - return ((w->windowType() == Qt::Dialog - || w->windowType() == Qt::Sheet - || w->windowType() == Qt::Tool - || w->windowType() == Qt::SplashScreen - || w->windowType() == Qt::ToolTip - || w->windowType() == Qt::Drawer - || w->windowType() == Qt::Popup) - && !w->testAttribute(Qt::WA_X11BypassTransientForHint)); + return w->windowType() == Qt::Dialog + || w->windowType() == Qt::Sheet + || w->windowType() == Qt::Tool + || w->windowType() == Qt::SplashScreen + || w->windowType() == Qt::ToolTip + || w->windowType() == Qt::Drawer + || w->windowType() == Qt::Popup; } -QXcbWindow::QXcbWindow(QWidget *tlw) - : QPlatformWindow(tlw) +QXcbWindow::QXcbWindow(QWindow *window) + : QPlatformWindow(window) + , m_window(0) , m_context(0) + , m_syncCounter(0) { - m_screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(tlw)); + m_screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens().at(0)); setConnection(m_screen->connection()); - const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_EVENT_MASK; + create(); +} + +void QXcbWindow::create() +{ + bool wasCreated = (m_window != 0); + destroy(); + + m_windowState = Qt::WindowNoState; + m_hasReceivedSyncRequest = false; + + Qt::WindowType type = window()->windowType(); + + const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK; const quint32 values[] = { // XCB_CW_BACK_PIXMAP XCB_NONE, + // XCB_CW_OVERRIDE_REDIRECT + type == Qt::Popup, + // XCB_CW_SAVE_UNDER + type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, // XCB_CW_EVENT_MASK XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY @@ -107,20 +128,27 @@ QXcbWindow::QXcbWindow(QWidget *tlw) | XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW + | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_FOCUS_CHANGE }; + QRect rect = window()->geometry(); + + xcb_window_t xcb_parent_id = m_screen->root(); + if (parent() && !window()->isTopLevel()) + xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window(); + #if defined(XCB_USE_GLX) || defined(XCB_USE_EGL) - if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL - && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL) - || tlw->platformWindowFormat().alpha()) + if ((window()->surfaceType() == QWindow::OpenGLSurface + && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) + || window()->requestedWindowFormat().hasAlpha()) { #if defined(XCB_USE_GLX) - XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat()); + XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), window()->requestedWindowFormat()); #elif defined(XCB_USE_EGL) EGLDisplay eglDisplay = connection()->egl_display(); - EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true); + EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,window()->requestedWindowFormat(),true); VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig); XVisualInfo visualInfoTemplate; @@ -134,17 +162,17 @@ QXcbWindow::QXcbWindow(QWidget *tlw) if (visualInfo) { m_depth = visualInfo->depth; m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; - Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone); + Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), xcb_parent_id, visualInfo->visual, AllocNone); XSetWindowAttributes a; a.background_pixel = WhitePixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber()); a.border_pixel = BlackPixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber()); a.colormap = cmap; - m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(), + m_window = XCreateWindow(DISPLAY_FROM_XCB(this), xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(), 0, visualInfo->depth, InputOutput, visualInfo->visual, CWBackPixel|CWBorderPixel|CWColormap, &a); - printf("created GL window: %d\n", m_window); + printf("created GL window: %x\n", m_window); } else { qFatal("no window!"); } @@ -158,20 +186,22 @@ QXcbWindow::QXcbWindow(QWidget *tlw) Q_XCB_CALL(xcb_create_window(xcb_connection(), XCB_COPY_FROM_PARENT, // depth -- same as root m_window, // window id - m_screen->root(), // parent window id - tlw->x(), - tlw->y(), - tlw->width(), - tlw->height(), + xcb_parent_id, // parent window id + rect.x(), + rect.y(), + rect.width(), + rect.height(), 0, // border width XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class m_screen->screen()->root_visual, // visual 0, // value mask 0)); // value list - printf("created regular window: %d\n", m_window); + printf("created regular window: %x\n", m_window); } + connection()->addWindow(m_window, this); + Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values)); xcb_atom_t properties[4]; @@ -183,7 +213,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw) if (m_screen->syncRequestSupported()) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); - if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint) + if (window()->windowFlags() & Qt::WindowContextHelpButtonHint) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); Q_XCB_CALL(xcb_change_property(xcb_connection(), @@ -211,29 +241,41 @@ QXcbWindow::QXcbWindow(QWidget *tlw) &m_syncCounter)); } - if (isTransient(tlw) && tlw->parentWidget()) { - // ICCCM 4.1.2.6 - QWidget *p = tlw->parentWidget()->window(); - xcb_window_t parentWindow = p->winId(); - Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, - 1, &parentWindow)); - - } - // set the PID to let the WM kill the application if unresponsive long pid = getpid(); Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_PID), XCB_ATOM_CARDINAL, 32, 1, &pid)); + + xcb_wm_hints_t hints; + memset(&hints, 0, sizeof(hints)); + xcb_wm_hints_set_normal(&hints); + + xcb_set_wm_hints(xcb_connection(), m_window, &hints); + + xcb_window_t leader = m_screen->clientLeader(); + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + atom(QXcbAtom::WM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32, + 1, &leader)); + + if (wasCreated) + setWindowFlags(window()->windowFlags()); } QXcbWindow::~QXcbWindow() { + destroy(); +} + +void QXcbWindow::destroy() +{ delete m_context; - if (m_screen->syncRequestSupported()) + if (m_syncCounter && m_screen->syncRequestSupported()) Q_XCB_CALL(xcb_sync_destroy_counter(xcb_connection(), m_syncCounter)); - Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); + if (m_window) { + connection()->removeWindow(m_window); + Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); + } } void QXcbWindow::setGeometry(const QRect &rect) @@ -248,33 +290,78 @@ void QXcbWindow::setGeometry(const QRect &rect) void QXcbWindow::setVisible(bool visible) { - xcb_wm_hints_t hints; - if (visible) { - if (widget()->isMinimized()) + if (visible) + show(); + else + hide(); +} + +void QXcbWindow::show() +{ + if (window()->isTopLevel()) { + xcb_get_property_cookie_t cookie = xcb_get_wm_hints(xcb_connection(), m_window); + + xcb_generic_error_t *error; + + xcb_wm_hints_t hints; + xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, &error); + + if (error) { + connection()->handleXcbError(error); + free(error); + } + + if (window()->windowState() & Qt::WindowMinimized) xcb_wm_hints_set_iconic(&hints); else xcb_wm_hints_set_normal(&hints); + xcb_set_wm_hints(xcb_connection(), m_window, &hints); - Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); - connection()->sync(); - } else { - Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window)); - - // send synthetic UnmapNotify event according to icccm 4.1.4 - xcb_unmap_notify_event_t event; - event.response_type = XCB_UNMAP_NOTIFY; - event.sequence = 0; // does this matter? - event.event = m_screen->root(); - event.window = m_window; - event.from_configure = false; - Q_XCB_CALL(xcb_send_event(xcb_connection(), false, m_screen->root(), - XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); - xcb_flush(xcb_connection()); + // update WM_NORMAL_HINTS + propagateSizeHints(); + + // update WM_TRANSIENT_FOR + if (isTransient(window()) && parent()) { + // ICCCM 4.1.2.6 + xcb_window_t parentWindow = static_cast<QXcbWindow *>(parent())->xcb_window(); + + // todo: set transient for group (wm_client_leader) if no parent, a la qwidget_x11.cpp + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, + 1, &parentWindow)); + } + + // update _MOTIF_WM_HINTS + updateMotifWmHintsBeforeMap(); + + // update _NET_WM_STATE + updateNetWmStateBeforeMap(); } + + Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); + xcb_flush(xcb_connection()); + + connection()->sync(); +} + +void QXcbWindow::hide() +{ + Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window)); + + // send synthetic UnmapNotify event according to icccm 4.1.4 + xcb_unmap_notify_event_t event; + event.response_type = XCB_UNMAP_NOTIFY; + event.event = m_screen->root(); + event.window = m_window; + event.from_configure = false; + Q_XCB_CALL(xcb_send_event(xcb_connection(), false, m_screen->root(), + XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); + + xcb_flush(xcb_connection()); } -struct QtMWMHints { +struct QtMotifWmHints { quint32 flags, functions, decorations; qint32 input_mode; quint32 status; @@ -307,33 +394,142 @@ enum { MWM_INPUT_FULL_APPLICATION_MODAL = 3L }; +static QtMotifWmHints getMotifWmHints(QXcbConnection *c, xcb_window_t window) +{ + QtMotifWmHints hints; + + xcb_get_property_cookie_t get_cookie = + xcb_get_property(c->xcb_connection(), 0, window, c->atom(QXcbAtom::_MOTIF_WM_HINTS), + c->atom(QXcbAtom::_MOTIF_WM_HINTS), 0, 20); + + xcb_generic_error_t *error; + + xcb_get_property_reply_t *reply = + xcb_get_property_reply(c->xcb_connection(), get_cookie, &error); + + if (reply && reply->format == 32 && reply->type == c->atom(QXcbAtom::_MOTIF_WM_HINTS)) { + hints = *((QtMotifWmHints *)xcb_get_property_value(reply)); + } else if (error) { + c->handleXcbError(error); + free(error); + + hints.flags = 0L; + hints.functions = MWM_FUNC_ALL; + hints.decorations = MWM_DECOR_ALL; + hints.input_mode = 0L; + hints.status = 0L; + } + + free(reply); + + return hints; +} + +static void setMotifWmHints(QXcbConnection *c, xcb_window_t window, const QtMotifWmHints &hints) +{ + if (hints.flags != 0l) { + Q_XCB_CALL2(xcb_change_property(c->xcb_connection(), + XCB_PROP_MODE_REPLACE, + window, + c->atom(QXcbAtom::_MOTIF_WM_HINTS), + c->atom(QXcbAtom::_MOTIF_WM_HINTS), + 32, + 5, + &hints), c); + } else { + Q_XCB_CALL2(xcb_delete_property(c->xcb_connection(), window, c->atom(QXcbAtom::_MOTIF_WM_HINTS)), c); + } +} + +void QXcbWindow::printNetWmState(const QVector<xcb_atom_t> &state) +{ + printf("_NET_WM_STATE (%d): ", state.size()); + for (int i = 0; i < state.size(); ++i) { +#define CHECK_WM_STATE(state_atom) \ + if (state.at(i) == atom(QXcbAtom::state_atom))\ + printf(#state_atom " "); + CHECK_WM_STATE(_NET_WM_STATE_ABOVE) + CHECK_WM_STATE(_NET_WM_STATE_BELOW) + CHECK_WM_STATE(_NET_WM_STATE_FULLSCREEN) + CHECK_WM_STATE(_NET_WM_STATE_MAXIMIZED_HORZ) + CHECK_WM_STATE(_NET_WM_STATE_MAXIMIZED_VERT) + CHECK_WM_STATE(_NET_WM_STATE_MODAL) + CHECK_WM_STATE(_NET_WM_STATE_STAYS_ON_TOP) + CHECK_WM_STATE(_NET_WM_STATE_DEMANDS_ATTENTION) +#undef CHECK_WM_STATE + } + printf("\n"); +} + +QVector<xcb_atom_t> QXcbWindow::getNetWmState() +{ + QVector<xcb_atom_t> result; + + xcb_get_property_cookie_t get_cookie = + xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), + XCB_ATOM_ATOM, 0, 1024); + + xcb_generic_error_t *error; + + xcb_get_property_reply_t *reply = + xcb_get_property_reply(xcb_connection(), get_cookie, &error); + + if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) { + result.resize(reply->length); + + memcpy(result.data(), xcb_get_property_value(reply), reply->length * sizeof(xcb_atom_t)); + +#ifdef NET_WM_STATE_DEBUG + printf("getting net wm state (%x)\n", m_window); + printNetWmState(result); +#endif + + free(reply); + } else if (error) { + connection()->handleXcbError(error); + free(error); + } else { +#ifdef NET_WM_STATE_DEBUG + printf("getting net wm state (%x), empty\n", m_window); +#endif + } + + return result; +} + +void QXcbWindow::setNetWmState(const QVector<xcb_atom_t> &atoms) +{ + if (atoms.isEmpty()) { + Q_XCB_CALL(xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_STATE))); + } else { + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + atom(QXcbAtom::_NET_WM_STATE), XCB_ATOM_ATOM, 32, + atoms.count(), atoms.constData())); + } + xcb_flush(xcb_connection()); +} + + Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags) { Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); - setNetWmWindowTypes(flags); - if (type == Qt::ToolTip) flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint; if (type == Qt::Popup) flags |= Qt::X11BypassWindowManagerHint; - bool topLevel = (flags & Qt::Window); - bool popup = (type == Qt::Popup); - bool dialog = (type == Qt::Dialog - || type == Qt::Sheet); - bool desktop = (type == Qt::Desktop); - bool tool = (type == Qt::Tool || type == Qt::SplashScreen - || type == Qt::ToolTip || type == Qt::Drawer); + setNetWmWindowFlags(flags); + setMotifWindowFlags(flags); - Q_UNUSED(topLevel); - Q_UNUSED(dialog); - Q_UNUSED(desktop); - Q_UNUSED(tool); + return flags; +} - bool tooltip = (type == Qt::ToolTip); +void QXcbWindow::setMotifWindowFlags(Qt::WindowFlags flags) +{ + Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); - QtMWMHints mwmhints; + QtMotifWmHints mwmhints; mwmhints.flags = 0L; mwmhints.functions = 0L; mwmhints.decorations = 0; @@ -393,30 +589,88 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags) mwmhints.decorations = 0; } - if (mwmhints.flags != 0l) { - Q_XCB_CALL(xcb_change_property(xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_window, - atom(QXcbAtom::_MOTIF_WM_HINTS), - atom(QXcbAtom::_MOTIF_WM_HINTS), - 32, - 5, - &mwmhints)); - } else { - Q_XCB_CALL(xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_MOTIF_WM_HINTS))); - } + setMotifWmHints(connection(), m_window, mwmhints); +} - if (popup || tooltip) { - const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER; - const quint32 values[] = { true, true }; +void QXcbWindow::changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two) +{ + xcb_client_message_event_t event; + + event.response_type = XCB_CLIENT_MESSAGE; + event.format = 32; + event.window = m_window; + event.type = atom(QXcbAtom::_NET_WM_STATE); + event.data.data32[0] = set ? 1 : 0; + event.data.data32[1] = one; + event.data.data32[2] = two; + event.data.data32[3] = 0; + event.data.data32[4] = 0; + + Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); +} - Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values)); +Qt::WindowState QXcbWindow::setWindowState(Qt::WindowState state) +{ + if (state == m_windowState) + return state; + + // unset old state + switch (m_windowState) { + case Qt::WindowMinimized: + Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); + break; + case Qt::WindowMaximized: + changeNetWmState(false, + atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ), + atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); + break; + case Qt::WindowFullScreen: + changeNetWmState(false, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); + break; + default: + break; + } + + // set new state + switch (state) { + case Qt::WindowMinimized: + { + xcb_client_message_event_t event; + + event.response_type = XCB_CLIENT_MESSAGE; + event.format = 32; + event.window = m_window; + event.type = atom(QXcbAtom::WM_CHANGE_STATE); + event.data.data32[0] = XCB_WM_STATE_ICONIC; + event.data.data32[1] = 0; + event.data.data32[2] = 0; + event.data.data32[3] = 0; + event.data.data32[4] = 0; + + Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); + } + break; + case Qt::WindowMaximized: + changeNetWmState(true, + atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ), + atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); + break; + case Qt::WindowFullScreen: + changeNetWmState(true, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); + break; + case Qt::WindowNoState: + break; + default: + break; } - return QPlatformWindow::setWindowFlags(flags); + connection()->sync(); + + m_windowState = state; + return m_windowState; } -void QXcbWindow::setNetWmWindowTypes(Qt::WindowFlags flags) +void QXcbWindow::setNetWmWindowFlags(Qt::WindowFlags flags) { // in order of decreasing priority QVector<uint> windowTypes; @@ -452,6 +706,90 @@ void QXcbWindow::setNetWmWindowTypes(Qt::WindowFlags flags) windowTypes.count(), windowTypes.constData())); } +void QXcbWindow::updateMotifWmHintsBeforeMap() +{ + QtMotifWmHints mwmhints = getMotifWmHints(connection(), m_window); + + if (window()->windowModality() != Qt::NonModal) { + switch (window()->windowModality()) { + case Qt::WindowModal: + mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL; + break; + case Qt::ApplicationModal: + default: + mwmhints.input_mode = MWM_INPUT_FULL_APPLICATION_MODAL; + break; + } + mwmhints.flags |= MWM_HINTS_INPUT_MODE; + } else { + mwmhints.input_mode = MWM_INPUT_MODELESS; + mwmhints.flags &= ~MWM_HINTS_INPUT_MODE; + } + + if (window()->minimumSize() == window()->maximumSize()) { + // fixed size, remove the resize handle (since mwm/dtwm + // isn't smart enough to do it itself) + mwmhints.flags |= MWM_HINTS_FUNCTIONS; + if (mwmhints.functions == MWM_FUNC_ALL) { + mwmhints.functions = MWM_FUNC_MOVE; + } else { + mwmhints.functions &= ~MWM_FUNC_RESIZE; + } + + if (mwmhints.decorations == MWM_DECOR_ALL) { + mwmhints.flags |= MWM_HINTS_DECORATIONS; + mwmhints.decorations = (MWM_DECOR_BORDER + | MWM_DECOR_TITLE + | MWM_DECOR_MENU); + } else { + mwmhints.decorations &= ~MWM_DECOR_RESIZEH; + } + } + + if (window()->windowFlags() & Qt::WindowMinimizeButtonHint) { + mwmhints.flags |= MWM_HINTS_DECORATIONS; + mwmhints.decorations |= MWM_DECOR_MINIMIZE; + mwmhints.functions |= MWM_FUNC_MINIMIZE; + } + if (window()->windowFlags() & Qt::WindowMaximizeButtonHint) { + mwmhints.flags |= MWM_HINTS_DECORATIONS; + mwmhints.decorations |= MWM_DECOR_MAXIMIZE; + mwmhints.functions |= MWM_FUNC_MAXIMIZE; + } + if (window()->windowFlags() & Qt::WindowCloseButtonHint) + mwmhints.functions |= MWM_FUNC_CLOSE; + + setMotifWmHints(connection(), m_window, mwmhints); +} + +void QXcbWindow::updateNetWmStateBeforeMap() +{ + QVector<xcb_atom_t> netWmState; + + Qt::WindowFlags flags = window()->windowFlags(); + if (flags & Qt::WindowStaysOnTopHint) { + netWmState.append(atom(QXcbAtom::_NET_WM_STATE_ABOVE)); + netWmState.append(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); + } else if (flags & Qt::WindowStaysOnBottomHint) { + netWmState.append(atom(QXcbAtom::_NET_WM_STATE_BELOW)); + } + + if (window()->windowState() & Qt::WindowFullScreen) { + netWmState.append(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); + } + + if (window()->windowState() & Qt::WindowMaximized) { + netWmState.append(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ)); + netWmState.append(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); + } + + if (window()->windowModality() != Qt::NonModal) { + netWmState.append(atom(QXcbAtom::_NET_WM_STATE_MODAL)); + } + + setNetWmState(netWmState); +} + WId QXcbWindow::winId() const { return m_window; @@ -459,8 +797,13 @@ WId QXcbWindow::winId() const void QXcbWindow::setParent(const QPlatformWindow *parent) { + // re-create for compatibility + create(); + QPoint topLeft = geometry().topLeft(); - Q_XCB_CALL(xcb_reparent_window(xcb_connection(), window(), static_cast<const QXcbWindow *>(parent)->window(), topLeft.x(), topLeft.y())); + + xcb_window_t xcb_parent_id = parent ? static_cast<const QXcbWindow *>(parent)->xcb_window() : m_screen->root(); + Q_XCB_CALL(xcb_reparent_window(xcb_connection(), xcb_window(), xcb_parent_id, topLeft.x(), topLeft.y())); } void QXcbWindow::setWindowTitle(const QString &title) @@ -490,6 +833,37 @@ void QXcbWindow::lower() Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); } +void QXcbWindow::propagateSizeHints() +{ + // update WM_NORMAL_HINTS + xcb_size_hints_t hints; + + QRect rect = geometry(); + + xcb_size_hints_set_position(&hints, true, rect.x(), rect.y()); + xcb_size_hints_set_size(&hints, true, rect.width(), rect.height()); + + QWindow *win = window(); + + QSize minimumSize = win->minimumSize(); + QSize maximumSize = win->maximumSize(); + QSize baseSize = win->baseSize(); + QSize sizeIncrement = win->sizeIncrement(); + + if (minimumSize.width() > 0 || minimumSize.height() > 0) + xcb_size_hints_set_min_size(&hints, minimumSize.width(), minimumSize.height()); + + if (maximumSize.width() < QWINDOWSIZE_MAX || maximumSize.height() < QWINDOWSIZE_MAX) + xcb_size_hints_set_max_size(&hints, maximumSize.width(), maximumSize.height()); + + if (sizeIncrement.width() > 0 || sizeIncrement.height() > 0) { + xcb_size_hints_set_base_size(&hints, baseSize.width(), baseSize.height()); + xcb_size_hints_set_resize_inc(&hints, sizeIncrement.width(), sizeIncrement.height()); + } + + xcb_set_wm_normal_hints(xcb_connection(), m_window, &hints); +} + void QXcbWindow::requestActivateWindow() { Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, XCB_TIME_CURRENT_TIME)); @@ -498,17 +872,17 @@ void QXcbWindow::requestActivateWindow() QPlatformGLContext *QXcbWindow::glContext() const { - if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { printf("no opengl\n"); return 0; } if (!m_context) { #if defined(XCB_USE_GLX) QXcbWindow *that = const_cast<QXcbWindow *>(this); - that->m_context = new QGLXContext(m_window, m_screen, widget()->platformWindowFormat()); + that->m_context = new QGLXContext(m_window, m_screen, window()->requestedWindowFormat()); #elif defined(XCB_USE_EGL) EGLDisplay display = connection()->egl_display(); - EGLConfig config = q_configFromQPlatformWindowFormat(display,widget()->platformWindowFormat(),true); + EGLConfig config = q_configFromQPlatformWindowFormat(display,window()->requestedWindowFormat(),true); QVector<EGLint> eglContextAttrs; eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); eglContextAttrs.append(2); @@ -527,11 +901,11 @@ QPlatformGLContext *QXcbWindow::glContext() const void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event) { - QWindowSurface *surface = widget()->windowSurface(); + QWindowSurface *surface = window()->surface(); if (surface) { QRect rect(event->x, event->y, event->width, event->height); - surface->flush(widget(), rect, QPoint()); + surface->flush(window(), rect, QPoint()); } } @@ -539,7 +913,7 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even { if (event->format == 32 && event->type == atom(QXcbAtom::WM_PROTOCOLS)) { if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) { - QWindowSystemInterface::handleCloseEvent(widget()); + QWindowSystemInterface::handleCloseEvent(window()); } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) { xcb_client_message_event_t reply = *event; @@ -575,7 +949,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * return; QPlatformWindow::setGeometry(rect); - QWindowSystemInterface::handleGeometryChange(widget(), rect); + QWindowSystemInterface::handleGeometryChange(window(), rect); #if XCB_USE_DRI2 if (m_context) @@ -623,7 +997,7 @@ void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event) && (modifiers & Qt::AltModifier)) || (event->detail == 6 || event->detail == 7)); - QWindowSystemInterface::handleWheelEvent(widget(), event->time, + QWindowSystemInterface::handleWheelEvent(window(), event->time, local, global, delta, hor ? Qt::Horizontal : Qt::Vertical); return; } @@ -654,22 +1028,35 @@ void QXcbWindow::handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_times buttons ^= button; // X event uses state *before*, Qt uses state *after* - QWindowSystemInterface::handleMouseEvent(widget(), time, local, global, buttons); + QWindowSystemInterface::handleMouseEvent(window(), time, local, global, buttons); } -void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *) +void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) { - QWindowSystemInterface::handleEnterEvent(widget()); + if ((event->mode != XCB_NOTIFY_MODE_NORMAL && event->mode != XCB_NOTIFY_MODE_UNGRAB) + || event->detail == XCB_NOTIFY_DETAIL_VIRTUAL + || event->detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL) + { + return; + } + + QWindowSystemInterface::handleEnterEvent(window()); } -void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *) +void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) { - QWindowSystemInterface::handleLeaveEvent(widget()); + if ((event->mode != XCB_NOTIFY_MODE_NORMAL && event->mode != XCB_NOTIFY_MODE_UNGRAB) + || event->detail == XCB_NOTIFY_DETAIL_INFERIOR) + { + return; + } + + QWindowSystemInterface::handleLeaveEvent(window()); } void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *) { - QWindowSystemInterface::handleWindowActivated(widget()); + QWindowSystemInterface::handleWindowActivated(window()); } void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 20b464061a..ec6fe95dd8 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -43,7 +43,7 @@ #define QXCBWINDOW_H #include <QtGui/QPlatformWindow> -#include <QtGui/QPlatformWindowFormat> +#include <QtGui/QWindowFormat> #include <QtGui/QImage> #include <xcb/xcb.h> @@ -56,25 +56,27 @@ class QXcbScreen; class QXcbWindow : public QXcbObject, public QPlatformWindow { public: - QXcbWindow(QWidget *tlw); + QXcbWindow(QWindow *window); ~QXcbWindow(); void setGeometry(const QRect &rect); void setVisible(bool visible); Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); + Qt::WindowState setWindowState(Qt::WindowState state); WId winId() const; void setParent(const QPlatformWindow *window); void setWindowTitle(const QString &title); void raise(); void lower(); + void propagateSizeHints(); void requestActivateWindow(); QPlatformGLContext *glContext() const; - xcb_window_t window() const { return m_window; } + xcb_window_t xcb_window() const { return m_window; } uint depth() const { return m_depth; } QImage::Format format() const { return m_format; } @@ -95,7 +97,22 @@ public: void updateSyncRequestCounter(); private: - void setNetWmWindowTypes(Qt::WindowFlags flags); + void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0); + QVector<xcb_atom_t> getNetWmState(); + void setNetWmState(const QVector<xcb_atom_t> &atoms); + void printNetWmState(const QVector<xcb_atom_t> &state); + + void setNetWmWindowFlags(Qt::WindowFlags flags); + void setMotifWindowFlags(Qt::WindowFlags flags); + + void updateMotifWmHintsBeforeMap(); + void updateNetWmStateBeforeMap(); + + void create(); + void destroy(); + + void show(); + void hide(); QXcbScreen *m_screen; @@ -109,6 +126,7 @@ private: xcb_sync_counter_t m_syncCounter; bool m_hasReceivedSyncRequest; + Qt::WindowState m_windowState; }; #endif diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 88a54dc316..07b3763ff0 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -168,12 +168,12 @@ void QXcbShmImage::preparePaint(const QRegion ®ion) } } -QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface) - : QWindowSurface(widget, setDefaultSurface) +QXcbWindowSurface::QXcbWindowSurface(QWindow *window, bool setDefaultSurface) + : QWindowSurface(window, setDefaultSurface) , m_image(0) , m_syncingResize(false) { - QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget)); + QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window)); setConnection(screen->connection()); } @@ -206,7 +206,7 @@ void QXcbWindowSurface::endPaint(const QRegion &) { } -void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QXcbWindowSurface::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { QRect bounds = region.boundingRect(); @@ -215,14 +215,11 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi Q_XCB_NOOP(connection()); - QXcbWindow *window = static_cast<QXcbWindow *>(widget->window()->platformWindow()); - - extern QWidgetData* qt_widget_data(QWidget *); - QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft(); + QXcbWindow *platformWindow = static_cast<QXcbWindow *>(window->handle()); QVector<QRect> rects = region.rects(); for (int i = 0; i < rects.size(); ++i) - m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset)); + m_image->put(platformWindow->xcb_window(), rects.at(i).topLeft(), rects.at(i).translated(offset)); Q_XCB_NOOP(connection()); @@ -230,7 +227,7 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi xcb_flush(xcb_connection()); connection()->sync(); m_syncingResize = false; - window->updateSyncRequestCounter(); + platformWindow->updateSyncRequestCounter(); } } @@ -242,8 +239,8 @@ void QXcbWindowSurface::resize(const QSize &size) Q_XCB_NOOP(connection()); QWindowSurface::resize(size); - QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(window())); - QXcbWindow* win = static_cast<QXcbWindow *>(window()->platformWindow()); + QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window())); + QXcbWindow* win = static_cast<QXcbWindow *>(window()->handle()); delete m_image; m_image = new QXcbShmImage(screen, size, win->depth(), win->format()); diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbwindowsurface.h index 23d32ef445..60ed7497db 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.h +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.h @@ -53,11 +53,11 @@ class QXcbShmImage; class QXcbWindowSurface : public QXcbObject, public QWindowSurface { public: - QXcbWindowSurface(QWidget *widget, bool setDefaultSurface = true); + QXcbWindowSurface(QWindow *widget, bool setDefaultSurface = true); ~QXcbWindowSurface(); QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); void resize(const QSize &size); bool scroll(const QRegion &area, int dx, int dy); diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 139f5c9591..93a226bd06 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -25,6 +25,8 @@ HEADERS = \ qxcbwindowsurface.h \ qxcbnativeinterface.h +QT += gui-private core-private + contains(QT_CONFIG, opengl) { QT += opengl |