summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-04-26 16:21:58 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-04-28 15:38:51 +0200
commitef77e8b65149a29a541044239fccf5e14b95e94d (patch)
tree8182a140efbb517407f1039b6795c67819a31405 /src/plugins/platforms/xcb
parentfbef41167aa4aede67bc1ec904142e2e5e12c7fc (diff)
Added QWindowContext and got wiggly up and running with xcb.
(cherry picked from commit c980e4ef4ebc7699a6c3a7529d3f08ebafc21ffe)
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp13
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h8
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp11
-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/qxcbnativeinterface.cpp8
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp38
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h6
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.cpp4
9 files changed, 53 insertions, 48 deletions
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
index 190221c5f4..3af627c324 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);
@@ -148,7 +149,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..bae02fda2e 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -147,15 +147,16 @@ QXcbWindow *platformWindowFromId(xcb_window_t id)
{
QWidget *widget = QWidget::find(id);
if (widget)
- return static_cast<QXcbWindow *>(widget->platformWindow());
+ return static_cast<QXcbWindow *>(widget->windowHandle()->handle());
return 0;
}
-#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, window, handler) \
+#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 (QXcbWindow *platformWindow = platformWindowFromId(e->windowMember)) { \
+ QWindow *windowHandle = platformWindow->window(); \
+ QObjectPrivate *d = QObjectPrivate::get(windowHandle->widget()); \
if (!d->wasDeleted) \
platformWindow->handler(e); \
} \
@@ -166,7 +167,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()->widget(), e); \
} \
break;
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 9df5f14114..80f375c6b2 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->widget());
}
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/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index b2ca1beb6e..bef2d573d0 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -48,6 +48,8 @@
#include <QtCore/QDebug>
+#include <QtGui/qwindowcontext_qpa.h>
+
#if defined(XCB_USE_EGL)
#include "../eglconvenience/qeglplatformcontext.h"
#elif defined (XCB_USE_DRI2)
@@ -162,14 +164,14 @@ void *QXcbNativeInterface::graphicsDeviceForWidget(QWidget *widget)
void * QXcbNativeInterface::eglContextForWidget(QWidget *widget)
{
Q_ASSERT(widget);
- if (!widget->platformWindow()) {
+ if (!widget->windowHandle()) {
qDebug() << "QPlatformWindow does not exist for widget" << widget
<< "cannot return EGLContext";
return 0;
}
- QPlatformGLContext *platformContext = widget->platformWindow()->glContext();
+ QPlatformGLContext *platformContext = widget->windowHandle()->glContext()->handle();
if (!platformContext) {
- qDebug() << "QPlatformWindow" << widget->platformWindow() << "does not have a glContext"
+ qDebug() << "QWindow" << widget->windowHandle() << "does not have a glContext"
<< "cannot return EGLContext";
return 0;
}
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 0456638ab9..bc794446b2 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -85,10 +85,11 @@ static inline bool isTransient(const QWidget *w)
&& !w->testAttribute(Qt::WA_X11BypassTransientForHint));
}
-QXcbWindow::QXcbWindow(QWidget *tlw)
- : QPlatformWindow(tlw)
+QXcbWindow::QXcbWindow(QWindow *window)
+ : QPlatformWindow(window)
, m_context(0)
{
+ QWidget *tlw = window->widget();
m_screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(tlw));
setConnection(m_screen->connection());
@@ -112,14 +113,14 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
};
#if defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
- if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
+ if (window->surfaceType() == QWindow::OpenGLSurface
&& QApplicationPrivate::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;
@@ -243,7 +244,8 @@ void QXcbWindow::setVisible(bool visible)
{
xcb_wm_hints_t hints;
if (visible) {
- if (widget()->isMinimized())
+ // TODO: QWindow::isMinimized() or similar
+ if (window()->widget()->isMinimized())
xcb_wm_hints_set_iconic(&hints);
else
xcb_wm_hints_set_normal(&hints);
@@ -453,7 +455,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)
@@ -498,10 +500,10 @@ QPlatformGLContext *QXcbWindow::glContext() const
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 +522,11 @@ QPlatformGLContext *QXcbWindow::glContext() const
void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
{
- QWindowSurface *surface = widget()->windowSurface();
+ QWindowSurface *surface = window()->widget()->windowSurface();
if (surface) {
QRect rect(event->x, event->y, event->width, event->height);
- surface->flush(widget(), rect, QPoint());
+ surface->flush(window()->widget(), rect, QPoint());
}
}
@@ -532,7 +534,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()->widget());
} else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) {
xcb_client_message_event_t reply = *event;
@@ -568,7 +570,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
return;
QPlatformWindow::setGeometry(rect);
- QWindowSystemInterface::handleGeometryChange(widget(), rect);
+ QWindowSystemInterface::handleGeometryChange(window()->widget(), rect);
#if XCB_USE_DRI2
if (m_context)
@@ -616,7 +618,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()->widget(), event->time,
local, global, delta, hor ? Qt::Horizontal : Qt::Vertical);
return;
}
@@ -647,22 +649,22 @@ 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()->widget(), time, local, global, buttons);
}
void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *)
{
- QWindowSystemInterface::handleEnterEvent(widget());
+ QWindowSystemInterface::handleEnterEvent(window()->widget());
}
void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *)
{
- QWindowSystemInterface::handleLeaveEvent(widget());
+ QWindowSystemInterface::handleLeaveEvent(window()->widget());
}
void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *)
{
- QWindowSystemInterface::handleWindowActivated(widget());
+ QWindowSystemInterface::handleWindowActivated(window()->widget());
}
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..89e6bd7ed7 100644
--- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
@@ -204,14 +204,14 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoi
Q_XCB_NOOP(connection());
- QXcbWindow *window = static_cast<QXcbWindow *>(widget->window()->platformWindow());
+ QXcbWindow *window = static_cast<QXcbWindow *>(widget->windowHandle()->handle());
extern QWidgetData* qt_widget_data(QWidget *);
QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft();
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(window->xcb_window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset));
Q_XCB_NOOP(connection());