summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qdri2context.cpp4
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp15
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h8
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp30
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h10
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp9
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h8
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp65
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h16
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp96
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h6
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.cpp19
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.h4
-rw-r--r--src/plugins/platforms/xcb/xcb.pro2
16 files changed, 172 insertions, 136 deletions
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/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 0456638ab9..f6d9c2f762 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -51,7 +51,7 @@
#include <xcb/xcb_icccm.h>
-#include <private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
#include <private/qwindowsurface_p.h>
#include <QtGui/QWindowSystemInterface>
@@ -72,6 +72,7 @@
#include "../eglconvenience/qxlibeglintegration.h"
#endif
+#if 0
// Returns true if we should set WM_TRANSIENT_FOR on \a w
static inline bool isTransient(const QWidget *w)
{
@@ -84,12 +85,13 @@ static inline bool isTransient(const QWidget *w)
|| w->windowType() == Qt::Popup)
&& !w->testAttribute(Qt::WA_X11BypassTransientForHint));
}
+#endif
-QXcbWindow::QXcbWindow(QWidget *tlw)
- : QPlatformWindow(tlw)
+QXcbWindow::QXcbWindow(QWindow *window)
+ : QPlatformWindow(window)
, m_context(0)
{
- m_screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(tlw));
+ m_screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens().at(0));
setConnection(m_screen->connection());
@@ -107,19 +109,26 @@ 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 (window->parent() && window->parent()->handle())
+ xcb_parent_id = static_cast<QXcbWindow *>(window->parent()->handle())->xcb_window();
+
#if defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
- if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
- && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ if (window->surfaceType() == QWindow::OpenGLSurface
+ && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
{
#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;
@@ -131,11 +140,11 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount);
#endif //XCB_USE_GLX
if (visualInfo) {
- 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.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,
CWColormap, &a);
@@ -151,11 +160,11 @@ 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
@@ -165,6 +174,8 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
printf("created regular window: %d\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];
@@ -176,7 +187,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(),
@@ -204,7 +215,8 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
&m_syncCounter));
}
- if (isTransient(tlw) && tlw->parentWidget()) {
+#if 0
+ if (tlw && isTransient(tlw) && tlw->parentWidget()) {
// ICCCM 4.1.2.6
QWidget *p = tlw->parentWidget()->window();
xcb_window_t parentWindow = p->winId();
@@ -213,6 +225,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
1, &parentWindow));
}
+#endif
// set the PID to let the WM kill the application if unresponsive
long pid = getpid();
@@ -226,6 +239,7 @@ QXcbWindow::~QXcbWindow()
delete m_context;
if (m_screen->syncRequestSupported())
Q_XCB_CALL(xcb_sync_destroy_counter(xcb_connection(), m_syncCounter));
+ connection()->removeWindow(m_window);
Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window));
}
@@ -243,7 +257,8 @@ void QXcbWindow::setVisible(bool visible)
{
xcb_wm_hints_t hints;
if (visible) {
- if (widget()->isMinimized())
+ // TODO: QWindow::isMinimized() or similar
+ if (window()->windowState() & Qt::WindowMinimized)
xcb_wm_hints_set_iconic(&hints);
else
xcb_wm_hints_set_normal(&hints);
@@ -406,7 +421,7 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values));
}
- return QPlatformWindow::setWindowFlags(flags);
+ return flags;
}
void QXcbWindow::setNetWmWindowTypes(Qt::WindowFlags flags)
@@ -453,7 +468,7 @@ WId QXcbWindow::winId() const
void QXcbWindow::setParent(const QPlatformWindow *parent)
{
QPoint topLeft = geometry().topLeft();
- Q_XCB_CALL(xcb_reparent_window(xcb_connection(), window(), static_cast<const QXcbWindow *>(parent)->window(), topLeft.x(), topLeft.y()));
+ Q_XCB_CALL(xcb_reparent_window(xcb_connection(), xcb_window(), static_cast<const QXcbWindow *>(parent)->xcb_window(), topLeft.x(), topLeft.y()));
}
void QXcbWindow::setWindowTitle(const QString &title)
@@ -491,17 +506,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);
@@ -520,11 +535,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());
}
}
@@ -532,7 +547,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;
@@ -568,7 +583,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)
@@ -616,7 +631,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;
}
@@ -647,22 +662,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 e049837253..3ed58b33d3 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 <xcb/xcb.h>
#include <xcb/sync.h>
@@ -55,7 +55,7 @@ class QXcbScreen;
class QXcbWindow : public QXcbObject, public QPlatformWindow
{
public:
- QXcbWindow(QWidget *tlw);
+ QXcbWindow(QWindow *window);
~QXcbWindow();
void setGeometry(const QRect &rect);
@@ -73,7 +73,7 @@ public:
QPlatformGLContext *glContext() const;
- xcb_window_t window() const { return m_window; }
+ xcb_window_t xcb_window() const { return m_window; }
void handleExposeEvent(const xcb_expose_event_t *event);
void handleClientMessageEvent(const xcb_client_message_event_t *event);
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
index 718f09383c..a371d2dd06 100644
--- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
@@ -167,12 +167,12 @@ void QXcbShmImage::preparePaint(const QRegion &region)
}
}
-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());
}
@@ -195,7 +195,7 @@ void QXcbWindowSurface::endPaint(const QRegion &)
{
}
-void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QXcbWindowSurface::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
QRect bounds = region.boundingRect();
@@ -204,14 +204,11 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, 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());
@@ -219,7 +216,7 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoi
xcb_flush(xcb_connection());
connection()->sync();
m_syncingResize = false;
- window->updateSyncRequestCounter();
+ platformWindow->updateSyncRequestCounter();
}
}
@@ -231,7 +228,7 @@ void QXcbWindowSurface::resize(const QSize &size)
Q_XCB_NOOP(connection());
QWindowSurface::resize(size);
- QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(window()));
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window()));
delete m_image;
m_image = new QXcbShmImage(screen, size);
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 &region, const QPoint &offset);
+ void flush(QWindow *window, const QRegion &region, 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 83d7eb4d1f..175bdd8451 100644
--- a/src/plugins/platforms/xcb/xcb.pro
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -27,6 +27,8 @@ HEADERS = \
qxcbwindowsurface.h \
qxcbnativeinterface.h
+QT += gui-private core-private
+
contains(QT_CONFIG, opengl) {
QT += opengl