summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-02-25 12:22:50 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-02-25 12:23:22 +0100
commit709e40093e6081b18e0d3003e0a088e1a9b6f211 (patch)
tree0f7c729c13b5a17f11ce176906f62ef43ea895a2 /src/plugins/platforms/xcb
parent62cd369594dc39e06e8c7ec2c761cfedf5d9c9ba (diff)
parent34b14a8472f44f8517577756e033b92ebd4c5912 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp14
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp76
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp12
5 files changed, 92 insertions, 15 deletions
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
index 15e11e7d0c..7725855327 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
@@ -57,7 +57,7 @@ public:
bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE;
void doneCurrent() Q_DECL_OVERRIDE;
void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
- void (*getProcAddress(const QByteArray &procName)) () Q_DECL_OVERRIDE;
+ QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE;
QSurfaceFormat format() const Q_DECL_OVERRIDE;
bool isSharing() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 250527e3ae..e1584999db 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -789,6 +789,15 @@ void QXcbConnection::handleButtonRelease(xcb_generic_event_t *ev)
qCDebug(lcQpaXInput, "xcb: released mouse button %d, button state %X", event->detail, static_cast<unsigned int>(m_buttons));
}
+void QXcbConnection::handleMotionNotify(xcb_generic_event_t *ev)
+{
+ xcb_motion_notify_event_t *event = (xcb_motion_notify_event_t *)ev;
+
+ m_buttons = (m_buttons & ~0x7) | translateMouseButtons(event->state);
+ if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
+ qDebug("xcb: moved mouse to %4d, %4d; button state %X", event->event_x, event->event_y, static_cast<unsigned int>(m_buttons));
+}
+
#ifndef QT_NO_XKB
namespace {
typedef union {
@@ -839,11 +848,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
handleButtonRelease(event);
HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent);
case XCB_MOTION_NOTIFY:
- if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled())) {
- xcb_motion_notify_event_t *mev = (xcb_motion_notify_event_t *)event;
- qDebug("xcb: moved mouse to %4d, %4d; button state %X", mev->event_x, mev->event_y, static_cast<unsigned int>(m_buttons));
- }
m_keyboard->updateXKBStateFromCore(((xcb_motion_notify_event_t *)event)->state);
+ handleMotionNotify(event);
HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent);
case XCB_CONFIGURE_NOTIFY:
HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent);
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index e3d9766a4b..90b859e612 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -497,6 +497,7 @@ private:
void updateScreens();
void handleButtonPress(xcb_generic_event_t *event);
void handleButtonRelease(xcb_generic_event_t *event);
+ void handleMotionNotify(xcb_generic_event_t *event);
bool m_xi2Enabled;
int m_xi2Minor;
@@ -507,6 +508,7 @@ private:
XInput2TouchDeviceData *touchDeviceForId(int id);
void xi2HandleEvent(xcb_ge_event_t *event);
void xi2HandleHierachyEvent(void *event);
+ void xi2HandleDeviceChangedEvent(void *event);
int m_xiOpCode, m_xiEventBase, m_xiErrorBase;
#ifndef QT_NO_TABLETEVENT
struct TabletData {
@@ -540,6 +542,7 @@ private:
Qt::Orientations legacyOrientations;
QPointF lastScrollPosition;
};
+ void updateScrollingDevice(ScrollingDevice& scrollingDevice, int num_classes, void *classes);
void xi2HandleScrollEvent(void *event, ScrollingDevice &scrollingDevice);
QHash<int, ScrollingDevice> m_scrollingDevices;
#endif // XCB_USE_XINPUT2
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index f225518cb9..e9fb47dabd 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -348,6 +348,7 @@ void QXcbConnection::xi2Select(xcb_window_t window)
// Listen for hotplug events
XIEventMask xiEventMask;
bitMask = XI_HierarchyChangedMask;
+ bitMask |= XI_DeviceChangedMask;
xiEventMask.deviceid = XIAllDevices;
xiEventMask.mask_len = sizeof(bitMask);
xiEventMask.mask = xiBitMask;
@@ -468,6 +469,11 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event)
xi2HandleHierachyEvent(xiEvent);
return;
}
+ if (xiEvent->evtype == XI_DeviceChanged) {
+ xi2HandleDeviceChangedEvent(xiEvent);
+ return;
+ }
+
#ifndef QT_NO_TABLETEVENT
for (int i = 0; i < m_tabletData.count(); ++i) {
if (m_tabletData.at(i).deviceId == xiEvent->deviceid) {
@@ -628,6 +634,64 @@ void QXcbConnection::xi2HandleHierachyEvent(void *event)
}
}
+void QXcbConnection::xi2HandleDeviceChangedEvent(void *event)
+{
+ xXIDeviceChangedEvent *xiEvent = reinterpret_cast<xXIDeviceChangedEvent *>(event);
+
+ // ### If a slave device changes (XIDeviceChange), we should probably run setup on it again.
+ if (xiEvent->reason != XISlaveSwitch)
+ return;
+
+#ifdef XCB_USE_XINPUT21
+ // This code handles broken scrolling device drivers that reset absolute positions
+ // when they are made active. Whenever a new slave device is made active the
+ // primary pointer sends a DeviceChanged event with XISlaveSwitch, and the new
+ // active slave in sourceid.
+
+ QHash<int, ScrollingDevice>::iterator device = m_scrollingDevices.find(xiEvent->sourceid);
+ if (device == m_scrollingDevices.end())
+ return;
+
+ int nrDevices = 0;
+ XIDeviceInfo* xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), xiEvent->sourceid, &nrDevices);
+ if (nrDevices <= 0) {
+ qCDebug(lcQpaXInputDevices, "scrolling device %d no longer present", xiEvent->sourceid);
+ return;
+ }
+ updateScrollingDevice(*device, xiDeviceInfo->num_classes, xiDeviceInfo->classes);
+ XIFreeDeviceInfo(xiDeviceInfo);
+#endif
+}
+
+void QXcbConnection::updateScrollingDevice(ScrollingDevice &scrollingDevice, int num_classes, void *classInfo)
+{
+#ifdef XCB_USE_XINPUT21
+ XIAnyClassInfo **classes = reinterpret_cast<XIAnyClassInfo**>(classInfo);
+ QPointF lastScrollPosition;
+ if (lcQpaXInput().isDebugEnabled())
+ lastScrollPosition = scrollingDevice.lastScrollPosition;
+ for (int c = 0; c < num_classes; ++c) {
+ if (classes[c]->type == XIValuatorClass) {
+ XIValuatorClassInfo *vci = reinterpret_cast<XIValuatorClassInfo *>(classes[c]);
+ const int valuatorAtom = qatom(vci->label);
+ if (valuatorAtom == QXcbAtom::RelHorizScroll || valuatorAtom == QXcbAtom::RelHorizWheel)
+ scrollingDevice.lastScrollPosition.setX(vci->value);
+ else if (valuatorAtom == QXcbAtom::RelVertScroll || valuatorAtom == QXcbAtom::RelVertWheel)
+ scrollingDevice.lastScrollPosition.setY(vci->value);
+ }
+ }
+ if (lcQpaXInput().isDebugEnabled() && lastScrollPosition != scrollingDevice.lastScrollPosition)
+ qCDebug(lcQpaXInput, "scrolling device %d moved from (%f, %f) to (%f, %f)", scrollingDevice.deviceId,
+ lastScrollPosition.x(), lastScrollPosition.y(),
+ scrollingDevice.lastScrollPosition.x(),
+ scrollingDevice.lastScrollPosition.y());
+#else
+ Q_UNUSED(scrollingDevice);
+ Q_UNUSED(num_classes);
+ Q_UNUSED(classInfo);
+#endif
+}
+
void QXcbConnection::handleEnterEvent(const xcb_enter_notify_event_t *)
{
#ifdef XCB_USE_XINPUT21
@@ -638,19 +702,11 @@ void QXcbConnection::handleEnterEvent(const xcb_enter_notify_event_t *)
int nrDevices = 0;
XIDeviceInfo* xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), scrollingDevice.deviceId, &nrDevices);
if (nrDevices <= 0) {
+ qCDebug(lcQpaXInputDevices, "scrolling device %d no longer present", scrollingDevice.deviceId);
it = m_scrollingDevices.erase(it);
continue;
}
- for (int c = 0; c < xiDeviceInfo->num_classes; ++c) {
- if (xiDeviceInfo->classes[c]->type == XIValuatorClass) {
- XIValuatorClassInfo *vci = reinterpret_cast<XIValuatorClassInfo *>(xiDeviceInfo->classes[c]);
- const int valuatorAtom = qatom(vci->label);
- if (valuatorAtom == QXcbAtom::RelHorizScroll || valuatorAtom == QXcbAtom::RelHorizWheel)
- scrollingDevice.lastScrollPosition.setX(vci->value);
- else if (valuatorAtom == QXcbAtom::RelVertScroll || valuatorAtom == QXcbAtom::RelVertWheel)
- scrollingDevice.lastScrollPosition.setY(vci->value);
- }
- }
+ updateScrollingDevice(scrollingDevice, xiDeviceInfo->num_classes, xiDeviceInfo->classes);
XIFreeDeviceInfo(xiDeviceInfo);
++it;
}
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 1d8ba69e55..2253dfecef 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -207,6 +207,18 @@ static inline QImage::Format imageFormatForVisual(int depth, quint32 red_mask, q
break;
}
qWarning("Unsupported screen format: depth: %d, red_mask: %x, blue_mask: %x", depth, red_mask, blue_mask);
+
+ switch (depth) {
+ case 24:
+ qWarning("Using RGB32 fallback, if this works your X11 server is reporting a bad screen format.");
+ return QImage::Format_RGB32;
+ case 16:
+ qWarning("Using RGB16 fallback, if this works your X11 server is reporting a bad screen format.");
+ return QImage::Format_RGB16;
+ default:
+ break;
+ }
+
return QImage::Format_Invalid;
}