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/qglxintegration.cpp61
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp27
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h6
-rw-r--r--src/plugins/platforms/xcb/xcb-plugin.pro1
-rw-r--r--src/plugins/platforms/xcb/xcb-static/xcb-static.pro3
8 files changed, 67 insertions, 42 deletions
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
index 3b13df863e..bcb35f6cf0 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -165,7 +165,7 @@ static void updateFormatFromContext(QSurfaceFormat &format)
QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlatformOpenGLContext *share,
const QVariant &nativeHandle)
: QPlatformOpenGLContext()
- , m_screen(screen)
+ , m_display(DISPLAY_FROM_XCB(screen))
, m_config(0)
, m_context(0)
, m_shareContext(0)
@@ -200,7 +200,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
- QList<QByteArray> glxExt = QByteArray(glXQueryExtensionsString(DISPLAY_FROM_XCB(m_screen), m_screen->screenNumber())).split(' ');
+ QList<QByteArray> glxExt = QByteArray(glXQueryExtensionsString(m_display, screen->screenNumber())).split(' ');
bool supportsProfiles = glxExt.contains("GLX_ARB_create_context_profile");
// Use glXCreateContextAttribsARB if available
@@ -269,10 +269,10 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
contextAttributes << None;
- m_context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, m_shareContext, true, contextAttributes.data());
+ m_context = glXCreateContextAttribsARB(m_display, config, m_shareContext, true, contextAttributes.data());
if (!m_context && m_shareContext) {
// re-try without a shared glx context
- m_context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, 0, true, contextAttributes.data());
+ m_context = glXCreateContextAttribsARB(m_display, config, 0, true, contextAttributes.data());
if (m_context)
m_shareContext = 0;
}
@@ -285,10 +285,10 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
if (m_format.renderableType() == QSurfaceFormat::OpenGLES)
return;
- m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, m_shareContext, true);
+ m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, m_shareContext, true);
if (!m_context && m_shareContext) {
// re-try without a shared glx context
- m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, 0, true);
+ m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, 0, true);
if (m_context)
m_shareContext = 0;
}
@@ -306,14 +306,14 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
return;
// Note that m_format gets updated with the used surface format
- visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(screen), screen->screenNumber(), &m_format);
+ visualInfo = qglx_findVisualInfo(m_display, screen->screenNumber(), &m_format);
if (!visualInfo)
qFatal("Could not initialize GLX");
- m_context = glXCreateContext(DISPLAY_FROM_XCB(screen), visualInfo, m_shareContext, true);
+ m_context = glXCreateContext(m_display, visualInfo, m_shareContext, true);
if (!m_context && m_shareContext) {
// re-try without a shared glx context
m_shareContext = 0;
- m_context = glXCreateContext(DISPLAY_FROM_XCB(screen), visualInfo, 0, true);
+ m_context = glXCreateContext(m_display, visualInfo, Q_NULLPTR, true);
}
// Create a temporary window so that we can make the new context current
@@ -325,13 +325,15 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
if (m_context && window) {
GLXContext prevContext = glXGetCurrentContext();
GLXDrawable prevDrawable = glXGetCurrentDrawable();
- glXMakeCurrent(DISPLAY_FROM_XCB(screen), window, m_context);
+ glXMakeCurrent(m_display, window, m_context);
updateFormatFromContext(m_format);
- glXMakeCurrent(DISPLAY_FROM_XCB(screen), prevDrawable, prevContext);
+
+ // Make our context non-current
+ glXMakeCurrent(m_display, prevDrawable, prevContext);
}
// Destroy our temporary window
- XDestroyWindow(DISPLAY_FROM_XCB(screen), window);
+ XDestroyWindow(m_display, window);
}
void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const QVariant &nativeHandle)
@@ -449,7 +451,18 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const
QGLXContext::~QGLXContext()
{
if (m_ownsContext)
- glXDestroyContext(DISPLAY_FROM_XCB(m_screen), m_context);
+ glXDestroyContext(m_display, m_context);
+}
+
+static QXcbScreen *screenForPlatformSurface(QPlatformSurface *surface)
+{
+ QSurface::SurfaceClass surfaceClass = surface->surface()->surfaceClass();
+ if (surfaceClass == QSurface::Window) {
+ return static_cast<QXcbScreen *>(static_cast<QXcbWindow *>(surface)->screen());
+ } else if (surfaceClass == QSurface::Offscreen) {
+ return static_cast<QXcbScreen *>(static_cast<QGLXPbuffer *>(surface)->screen());
+ }
+ return Q_NULLPTR;
}
QVariant QGLXContext::nativeHandle() const
@@ -462,24 +475,24 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface)
bool success = false;
Q_ASSERT(surface->surface()->supportsOpenGL());
- Display *dpy = DISPLAY_FROM_XCB(m_screen);
GLXDrawable glxDrawable = 0;
QSurface::SurfaceClass surfaceClass = surface->surface()->surfaceClass();
if (surfaceClass == QSurface::Window) {
m_isPBufferCurrent = false;
QXcbWindow *window = static_cast<QXcbWindow *>(surface);
glxDrawable = window->xcb_window();
- success = glXMakeCurrent(dpy, glxDrawable, m_context);
+ success = glXMakeCurrent(m_display, glxDrawable, m_context);
} else if (surfaceClass == QSurface::Offscreen) {
m_isPBufferCurrent = true;
QGLXPbuffer *pbuffer = static_cast<QGLXPbuffer *>(surface);
glxDrawable = pbuffer->pbuffer();
- success = glXMakeContextCurrent(dpy, glxDrawable, glxDrawable, m_context);
+ success = glXMakeContextCurrent(m_display, glxDrawable, glxDrawable, m_context);
}
if (success) {
int interval = surface->format().swapInterval();
- if (interval >= 0 && m_swapInterval != interval) {
+ QXcbScreen *screen = screenForPlatformSurface(surface);
+ if (interval >= 0 && m_swapInterval != interval && screen) {
m_swapInterval = interval;
typedef void (*qt_glXSwapIntervalEXT)(Display *, GLXDrawable, int);
typedef void (*qt_glXSwapIntervalMESA)(unsigned int);
@@ -488,15 +501,15 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface)
static bool resolved = false;
if (!resolved) {
resolved = true;
- QList<QByteArray> glxExt = QByteArray(glXQueryExtensionsString(dpy,
- m_screen->screenNumber())).split(' ');
+ QList<QByteArray> glxExt = QByteArray(glXQueryExtensionsString(m_display,
+ screen->screenNumber())).split(' ');
if (glxExt.contains("GLX_EXT_swap_control"))
glXSwapIntervalEXT = (qt_glXSwapIntervalEXT) getProcAddress("glXSwapIntervalEXT");
if (glxExt.contains("GLX_MESA_swap_control"))
glXSwapIntervalMESA = (qt_glXSwapIntervalMESA) getProcAddress("glXSwapIntervalMESA");
}
if (glXSwapIntervalEXT)
- glXSwapIntervalEXT(dpy, glxDrawable, interval);
+ glXSwapIntervalEXT(m_display, glxDrawable, interval);
else if (glXSwapIntervalMESA)
glXSwapIntervalMESA(interval);
}
@@ -508,9 +521,9 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface)
void QGLXContext::doneCurrent()
{
if (m_isPBufferCurrent)
- glXMakeContextCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0, 0);
+ glXMakeContextCurrent(m_display, 0, 0, 0);
else
- glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0);
+ glXMakeCurrent(m_display, 0, 0);
m_isPBufferCurrent = false;
}
@@ -521,7 +534,7 @@ void QGLXContext::swapBuffers(QPlatformSurface *surface)
glxDrawable = static_cast<QGLXPbuffer *>(surface)->pbuffer();
else
glxDrawable = static_cast<QXcbWindow *>(surface)->xcb_window();
- glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), glxDrawable);
+ glXSwapBuffers(m_display, glxDrawable);
if (surface->surface()->surfaceClass() == QSurface::Window) {
QXcbWindow *platformWindow = static_cast<QXcbWindow *>(surface);
@@ -542,7 +555,7 @@ void (*QGLXContext::getProcAddress(const QByteArray &procName)) ()
if (resolved && !glXGetProcAddressARB)
return 0;
if (!glXGetProcAddressARB) {
- QList<QByteArray> glxExt = QByteArray(glXGetClientString(DISPLAY_FROM_XCB(m_screen), GLX_EXTENSIONS)).split(' ');
+ QList<QByteArray> glxExt = QByteArray(glXGetClientString(m_display, GLX_EXTENSIONS)).split(' ');
if (glxExt.contains("GLX_ARB_get_proc_address")) {
#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
void *handle = dlopen(NULL, RTLD_LAZY);
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h
index abe3216ad7..2acf262bd0 100644
--- a/src/plugins/platforms/xcb/qglxintegration.h
+++ b/src/plugins/platforms/xcb/qglxintegration.h
@@ -84,6 +84,7 @@ private:
void init(QXcbScreen *screen, QPlatformOpenGLContext *share, const QVariant &nativeHandle);
QXcbScreen *m_screen;
+ Display *m_display;
GLXFBConfig m_config;
GLXContext m_context;
GLXContext m_shareContext;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index ed5fe6d7c0..636914fd07 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -414,6 +414,9 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
qunsetenv("DESKTOP_STARTUP_ID");
sync();
+
+ if (qEnvironmentVariableIsEmpty("QT_IM_MODULE"))
+ qputenv("QT_IM_MODULE", QByteArray("compose"));
}
QXcbConnection::~QXcbConnection()
@@ -494,7 +497,7 @@ break;
if (QXcbWindowEventListener *eventListener = windowEventListenerFromId(e->event)) { \
handled = eventListener->handleGenericEvent(event, &result); \
if (!handled) \
- m_keyboard->handler(m_focusWindow ? m_focusWindow : eventListener, e); \
+ m_keyboard->handler(e); \
} \
} \
break;
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 60a36a8da1..bd62b07a09 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -164,7 +164,10 @@ void QXcbConnection::xi2SetupDevices()
if (bci->num_buttons >= 5) {
Atom label4 = bci->labels[3];
Atom label5 = bci->labels[4];
- if ((!label4 || qatom(label4) == QXcbAtom::ButtonWheelUp) && (!label5 || qatom(label5) == QXcbAtom::ButtonWheelDown))
+ // Some drivers have no labels on the wheel buttons, some have no label on just one and some have no label on
+ // button 4 and the wrong one on button 5. So we just check that they are not labelled with unrelated buttons.
+ if ((!label4 || qatom(label4) == QXcbAtom::ButtonWheelUp || qatom(label4) == QXcbAtom::ButtonWheelDown) &&
+ (!label5 || qatom(label5) == QXcbAtom::ButtonWheelUp || qatom(label5) == QXcbAtom::ButtonWheelDown))
scrollingDevice.legacyOrientations |= Qt::Vertical;
}
if (bci->num_buttons >= 7) {
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index c52714b456..dd2a9fcaed 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -1299,7 +1299,7 @@ private:
bool m_release;
};
-void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code,
+void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, xcb_keycode_t code,
quint16 state, xcb_timestamp_t time)
{
Q_XCB_NOOP(connection());
@@ -1307,6 +1307,13 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod
if (!m_config)
return;
+ QXcbWindow *source = connection()->platformWindowFromId(sourceWindow);
+ QXcbWindow *targetWindow = connection()->focusWindow() ? connection()->focusWindow() : source;
+ if (!targetWindow || !source)
+ return;
+ if (type == QEvent::KeyPress)
+ targetWindow->updateNetWmUserTime(time);
+
// It is crucial the order of xkb_state_key_get_one_sym & xkb_state_update_key operations is not reversed!
xcb_keysym_t sym = xkb_state_key_get_one_sym(xkb_state, code);
@@ -1347,7 +1354,7 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod
}
} else {
// look ahead for auto-repeat
- KeyChecker checker(((QXcbWindow *)window->handle())->xcb_window(), code, time);
+ KeyChecker checker(source->xcb_window(), code, time);
xcb_generic_event_t *event = connection()->checkEvent(checker);
if (event) {
isAutoRepeat = true;
@@ -1363,6 +1370,7 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod
filtered = inputContext->filterEvent(&event);
}
+ QWindow *window = targetWindow->window();
if (!filtered) {
if (type == QEvent::KeyPress && qtcode == Qt::Key_Menu) {
const QPoint globalPos = window->screen()->handle()->cursor()->pos();
@@ -1405,21 +1413,14 @@ QString QXcbKeyboard::lookupString(struct xkb_state *state, xcb_keycode_t code)
return QString::fromUtf8(chars);
}
-void QXcbKeyboard::handleKeyPressEvent(QXcbWindowEventListener *eventListener, const xcb_key_press_event_t *event)
+void QXcbKeyboard::handleKeyPressEvent(const xcb_key_press_event_t *event)
{
- QXcbWindow *window = eventListener->toWindow();
- if (!window)
- return;
- window->updateNetWmUserTime(event->time);
- handleKeyEvent(window->window(), QEvent::KeyPress, event->detail, event->state, event->time);
+ handleKeyEvent(event->event, QEvent::KeyPress, event->detail, event->state, event->time);
}
-void QXcbKeyboard::handleKeyReleaseEvent(QXcbWindowEventListener *eventListener, const xcb_key_release_event_t *event)
+void QXcbKeyboard::handleKeyReleaseEvent(const xcb_key_release_event_t *event)
{
- QXcbWindow *window = eventListener->toWindow();
- if (!window)
- return;
- handleKeyEvent(window->window(), QEvent::KeyRelease, event->detail, event->state, event->time);
+ handleKeyEvent(event->event, QEvent::KeyRelease, event->detail, event->state, event->time);
}
void QXcbKeyboard::handleMappingNotifyEvent(const void *event)
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index 11b7429aca..e816d3c003 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -64,8 +64,8 @@ public:
~QXcbKeyboard();
- void handleKeyPressEvent(QXcbWindowEventListener *eventListener, const xcb_key_press_event_t *event);
- void handleKeyReleaseEvent(QXcbWindowEventListener *eventListener, const xcb_key_release_event_t *event);
+ void handleKeyPressEvent(const xcb_key_press_event_t *event);
+ void handleKeyReleaseEvent(const xcb_key_release_event_t *event);
void handleMappingNotifyEvent(const void *event);
Qt::KeyboardModifiers translateModifiers(int s) const;
@@ -83,7 +83,7 @@ public:
#endif
protected:
- void handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
+ void handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
void resolveMaskConflicts();
QString lookupString(struct xkb_state *state, xcb_keycode_t code) const;
diff --git a/src/plugins/platforms/xcb/xcb-plugin.pro b/src/plugins/platforms/xcb/xcb-plugin.pro
index f227076b3b..9aaafadcad 100644
--- a/src/plugins/platforms/xcb/xcb-plugin.pro
+++ b/src/plugins/platforms/xcb/xcb-plugin.pro
@@ -95,6 +95,7 @@ contains(QT_CONFIG, opengl) {
DEFINES += $$QMAKE_DEFINES_XCB
LIBS += $$QMAKE_LIBS_XCB
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
+QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB
CONFIG += qpa/genericunixfontdatabase
diff --git a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
index dfdcb2e83a..d0fe282b14 100644
--- a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
+++ b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
@@ -10,6 +10,9 @@ XCB_DIR = ../../../../3rdparty/xcb
INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/include/xcb $$XCB_DIR/sysinclude
+QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
+QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB
+
# ignore compiler warnings in 3rdparty code
QMAKE_CFLAGS_STATIC_LIB+=-w