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/gl_integrations/xcb_glx/qglxintegration.cpp16
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.h10
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp75
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h101
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp57
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp26
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h14
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp3
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp11
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h30
-rw-r--r--src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbsystemtraytracker.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp45
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h44
19 files changed, 213 insertions, 238 deletions
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index 4e0c73450e..7640a711a9 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
@@ -56,6 +56,8 @@
#include <QtGlxSupport/private/qglxconvenience_p.h>
#include <QtPlatformHeaders/QGLXNativeContext>
+#include "qxcbglintegration.h"
+
#if !defined(QT_STATIC) && QT_CONFIG(dlopen)
#include <dlfcn.h>
#endif
@@ -691,6 +693,10 @@ void QGLXContext::queryDummyContext()
if (const char *renderer = (const char *) glGetString(GL_RENDERER)) {
for (int i = 0; qglx_threadedgl_blacklist_renderer[i]; ++i) {
if (strstr(renderer, qglx_threadedgl_blacklist_renderer[i]) != 0) {
+ qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: "
+ "blacklisted renderer \""
+ << qglx_threadedgl_blacklist_renderer[i]
+ << "\"";
m_supportsThreading = false;
break;
}
@@ -700,6 +706,11 @@ void QGLXContext::queryDummyContext()
if (glxvendor) {
for (int i = 0; qglx_threadedgl_blacklist_vendor[i]; ++i) {
if (strstr(glxvendor, qglx_threadedgl_blacklist_vendor[i]) != 0) {
+ qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: "
+ "blacklisted vendor \""
+ << qglx_threadedgl_blacklist_vendor[i]
+ << "\"";
+
m_supportsThreading = false;
break;
}
@@ -709,6 +720,11 @@ void QGLXContext::queryDummyContext()
context.doneCurrent();
if (oldContext && oldSurface)
oldContext->makeCurrent(oldSurface);
+
+ if (!m_supportsThreading) {
+ qCDebug(lcQpaGl) << "Force-enable multithreaded OpenGL by setting "
+ "environment variable QT_OPENGL_NO_SANITY_CHECK";
+ }
}
bool QGLXContext::supportsThreading()
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index a293066b93..01b3bca0d2 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -267,11 +267,6 @@ const int QXcbClipboard::clipboard_timeout = 5000;
QXcbClipboard::QXcbClipboard(QXcbConnection *c)
: QXcbObject(c), QPlatformClipboard()
- , m_requestor(XCB_NONE)
- , m_owner(XCB_NONE)
- , m_incr_active(false)
- , m_clipboard_closing(false)
- , m_incr_receive_time(0)
{
Q_ASSERT(QClipboard::Clipboard == 0);
Q_ASSERT(QClipboard::Selection == 1);
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h
index a0a4f4e5a1..bfeae13e10 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.h
+++ b/src/plugins/platforms/xcb/qxcbclipboard.h
@@ -102,14 +102,14 @@ private:
QMimeData *m_clientClipboard[2];
xcb_timestamp_t m_timestamp[2];
- xcb_window_t m_requestor;
- xcb_window_t m_owner;
+ xcb_window_t m_requestor = XCB_NONE;
+ xcb_window_t m_owner = XCB_NONE;
static const int clipboard_timeout;
- bool m_incr_active;
- bool m_clipboard_closing;
- xcb_timestamp_t m_incr_receive_time;
+ bool m_incr_active = false;
+ bool m_clipboard_closing = false;
+ xcb_timestamp_t m_incr_receive_time = 0;
};
#endif // QT_NO_CLIPBOARD
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 5e52d4d80f..5c15a9cbcb 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -131,7 +131,7 @@ typedef struct qt_xcb_ge_event_t {
static inline bool isXIEvent(xcb_generic_event_t *event, int opCode)
{
- qt_xcb_ge_event_t *e = (qt_xcb_ge_event_t *)event;
+ qt_xcb_ge_event_t *e = reinterpret_cast<qt_xcb_ge_event_t *>(event);
return e->extension == opCode;
}
#endif // XCB_USE_XINPUT2
@@ -251,7 +251,7 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event)
// Find a fake screen
const auto scrs = virtualDesktop->screens();
for (QPlatformScreen *scr : scrs) {
- QXcbScreen *xcbScreen = (QXcbScreen *)scr;
+ QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(scr);
if (xcbScreen->output() == XCB_NONE) {
screen = xcbScreen;
break;
@@ -377,7 +377,7 @@ void QXcbConnection::destroyScreen(QXcbScreen *screen)
// When primary screen is removed, set the new primary screen
// which belongs to the primary virtual desktop.
if (screen->isPrimary()) {
- QXcbScreen *newPrimary = (QXcbScreen *)virtualDesktop->screens().at(0);
+ QXcbScreen *newPrimary = static_cast<QXcbScreen *>(virtualDesktop->screens().at(0));
newPrimary->setPrimary(true);
const int idx = m_screens.indexOf(newPrimary);
if (idx > 0)
@@ -552,32 +552,10 @@ void QXcbConnection::initializeScreens()
}
QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName)
- : m_connection(0)
- , m_canGrabServer(canGrabServer)
+ : m_canGrabServer(canGrabServer)
, m_defaultVisualId(defaultVisualId)
- , m_primaryScreenNumber(0)
, m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
, m_nativeInterface(nativeInterface)
-#ifdef XCB_USE_XLIB
- , m_xlib_display(0)
-#endif
- , xfixes_first_event(0)
- , xrandr_first_event(0)
- , xkb_first_event(0)
- , has_xinerama_extension(false)
- , has_shape_extension(false)
- , has_randr_extension(false)
- , has_input_shape(false)
- , has_xkb(false)
- , m_buttons(0)
- , m_focusWindow(0)
- , m_mouseGrabber(0)
- , m_mousePressWindow(0)
- , m_clientLeader(0)
- , m_systemTrayTracker(0)
- , m_glIntegration(Q_NULLPTR)
- , m_xiGrab(false)
- , m_qtSelectionOwner(0)
{
#ifdef XCB_USE_XLIB
Display *dpy = XOpenDisplay(m_displayName.constData());
@@ -618,9 +596,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
initializeAllAtoms();
- m_time = XCB_CURRENT_TIME;
- m_netWmUserTime = XCB_CURRENT_TIME;
-
if (!qEnvironmentVariableIsSet("QT_XCB_NO_XRANDR"))
initializeXRandr();
if (!has_randr_extension)
@@ -630,7 +605,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
initializeXRender();
#if defined(XCB_USE_XINPUT2)
- m_xi2Enabled = false;
if (!qEnvironmentVariableIsSet("QT_XCB_NO_XI2"))
initializeXInput2();
#endif
@@ -712,7 +686,7 @@ QXcbConnection::~QXcbConnection()
delete m_glIntegration;
#ifdef XCB_USE_XLIB
- XCloseDisplay((Display *)m_xlib_display);
+ XCloseDisplay(static_cast<Display *>(m_xlib_display));
#else
xcb_disconnect(xcb_connection());
#endif
@@ -755,7 +729,7 @@ QXcbWindow *QXcbConnection::platformWindowFromId(xcb_window_t id)
#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \
{ \
- event_t *e = (event_t *)event; \
+ event_t *e = reinterpret_cast<event_t *>(event); \
if (QXcbWindowEventListener *eventListener = windowEventListenerFromId(e->windowMember)) { \
handled = eventListener->handleGenericEvent(event, &result); \
if (!handled) \
@@ -766,7 +740,7 @@ break;
#define HANDLE_KEYBOARD_EVENT(event_t, handler) \
{ \
- event_t *e = (event_t *)event; \
+ event_t *e = reinterpret_cast<event_t *>(event); \
if (QXcbWindowEventListener *eventListener = windowEventListenerFromId(e->event)) { \
handled = eventListener->handleGenericEvent(event, &result); \
if (!handled) \
@@ -1185,11 +1159,13 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
m_keyboard->updateXKBStateFromCore(((xcb_key_release_event_t *)event)->state);
HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent);
case XCB_MAPPING_NOTIFY:
- m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event);
+ m_keyboard->handleMappingNotifyEvent(reinterpret_cast<xcb_mapping_notify_event_t *>(event));
break;
case XCB_SELECTION_REQUEST:
{
- xcb_selection_request_event_t *sr = (xcb_selection_request_event_t *)event;
+#if QT_CONFIG(draganddrop) || QT_CONFIG(clipboard)
+ xcb_selection_request_event_t *sr = reinterpret_cast<xcb_selection_request_event_t *>(event);
+#endif
#ifndef QT_NO_DRAGANDDROP
if (sr->selection == atom(QXcbAtom::XdndSelection))
m_drag->handleSelectionRequest(sr);
@@ -1203,19 +1179,19 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
break;
}
case XCB_SELECTION_CLEAR:
- setTime(((xcb_selection_clear_event_t *)event)->time);
+ setTime((reinterpret_cast<xcb_selection_clear_event_t *>(event))->time);
#ifndef QT_NO_CLIPBOARD
- m_clipboard->handleSelectionClearRequest((xcb_selection_clear_event_t *)event);
+ m_clipboard->handleSelectionClearRequest(reinterpret_cast<xcb_selection_clear_event_t *>(event));
#endif
handled = true;
break;
case XCB_SELECTION_NOTIFY:
- setTime(((xcb_selection_notify_event_t *)event)->time);
+ setTime((reinterpret_cast<xcb_selection_notify_event_t *>(event))->time);
handled = false;
break;
case XCB_PROPERTY_NOTIFY:
{
- xcb_property_notify_event_t *pn = (xcb_property_notify_event_t *)event;
+ xcb_property_notify_event_t *pn = reinterpret_cast<xcb_property_notify_event_t *>(event);
if (pn->atom == atom(QXcbAtom::_NET_WORKAREA)) {
QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(pn->window);
if (virtualDesktop)
@@ -1240,7 +1216,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
if (!handled) {
if (response_type == xfixes_first_event + XCB_XFIXES_SELECTION_NOTIFY) {
- xcb_xfixes_selection_notify_event_t *notify_event = (xcb_xfixes_selection_notify_event_t *)event;
+ xcb_xfixes_selection_notify_event_t *notify_event = reinterpret_cast<xcb_xfixes_selection_notify_event_t *>(event);
setTime(notify_event->timestamp);
#ifndef QT_NO_CLIPBOARD
m_clipboard->handleXFixesSelectionRequest(notify_event);
@@ -1250,10 +1226,10 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
handled = true;
} else if (has_randr_extension && response_type == xrandr_first_event + XCB_RANDR_NOTIFY) {
- updateScreens((xcb_randr_notify_event_t *)event);
+ updateScreens(reinterpret_cast<xcb_randr_notify_event_t *>(event));
handled = true;
} else if (has_randr_extension && response_type == xrandr_first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
- xcb_randr_screen_change_notify_event_t *change_event = (xcb_randr_screen_change_notify_event_t *)event;
+ xcb_randr_screen_change_notify_event_t *change_event = reinterpret_cast<xcb_randr_screen_change_notify_event_t *>(event);
for (QXcbScreen *s : qAsConst(m_screens)) {
if (s->root() == change_event->root )
s->handleScreenChange(change_event);
@@ -1362,7 +1338,7 @@ void QXcbEventReader::run()
void QXcbEventReader::addEvent(xcb_generic_event_t *event)
{
if ((event->response_type & ~0x80) == XCB_CLIENT_MESSAGE
- && ((xcb_client_message_event_t *)event)->type == m_connection->atom(QXcbAtom::_QT_CLOSE_CONNECTION))
+ && (reinterpret_cast<xcb_client_message_event_t *>(event))->type == m_connection->atom(QXcbAtom::_QT_CLOSE_CONNECTION))
m_connection = 0;
m_events << event;
}
@@ -1428,7 +1404,7 @@ void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom a, uint id)
event.type = atom(a);
event.data.data32[0] = id;
- Q_XCB_CALL(xcb_send_event(xcb_connection(), false, eventListener, XCB_EVENT_MASK_NO_EVENT, (const char *)&event));
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), false, eventListener, XCB_EVENT_MASK_NO_EVENT, reinterpret_cast<const char *>(&event)));
Q_XCB_CALL(xcb_destroy_window(m_connection, eventListener));
xcb_flush(xcb_connection());
}
@@ -1448,7 +1424,7 @@ namespace
if ((event->response_type & ~0x80) != type) {
return false;
} else {
- xcb_property_notify_event_t *pn = (xcb_property_notify_event_t *)event;
+ xcb_property_notify_event_t *pn = reinterpret_cast<xcb_property_notify_event_t *>(event);
if ((pn->window == window) && (pn->atom == atom))
return true;
}
@@ -1476,7 +1452,7 @@ xcb_timestamp_t QXcbConnection::getTimestamp()
event = checkEvent(checker);
}
- xcb_property_notify_event_t *pn = (xcb_property_notify_event_t *)event;
+ xcb_property_notify_event_t *pn = reinterpret_cast<xcb_property_notify_event_t *>(event);
xcb_timestamp_t timestamp = pn->time;
free(event);
@@ -1500,7 +1476,8 @@ xcb_window_t QXcbConnection::getQtSelectionOwner()
{
if (!m_qtSelectionOwner) {
xcb_screen_t *xcbScreen = primaryVirtualDesktop()->screen();
- int x = 0, y = 0, w = 3, h = 3;
+ int16_t x = 0, y = 0;
+ uint16_t w = 3, h = 3;
m_qtSelectionOwner = xcb_generate_id(xcb_connection());
Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
@@ -1689,7 +1666,7 @@ bool QXcbConnection::compressEvent(xcb_generic_event_t *event, int currentIndex,
for (int j = nextIndex; j < eventqueue->size(); ++j) {
xcb_generic_event_t *next = eventqueue->at(j);
if (isValid(next) && next->response_type == XCB_CONFIGURE_NOTIFY
- && ((xcb_configure_notify_event_t *)next)->event == ((xcb_configure_notify_event_t*)event)->event)
+ && reinterpret_cast<xcb_configure_notify_event_t *>(next)->event == reinterpret_cast<xcb_configure_notify_event_t *>(event)->event)
{
return true;
}
@@ -1718,7 +1695,7 @@ void QXcbConnection::processXcbEvents()
(*eventqueue)[i] = 0;
if (!(event->response_type & ~0x80)) {
- handleXcbError((xcb_generic_error_t *)event);
+ handleXcbError(reinterpret_cast<xcb_generic_error_t *>(event));
continue;
}
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 22c7d1aa8e..6089265304 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -551,10 +551,9 @@ private:
void destroyScreen(QXcbScreen *screen);
void initializeScreens();
bool compressEvent(xcb_generic_event_t *event, int currentIndex, QXcbEventArray *eventqueue) const;
-
#ifdef XCB_USE_XINPUT2
- bool m_xi2Enabled;
- int m_xi2Minor;
+ bool m_xi2Enabled = false;
+ int m_xi2Minor = 2;
void initializeXInput2();
void finalizeXInput2();
void xi2SetupDevices();
@@ -568,20 +567,17 @@ private:
#endif // XCB_USE_XINPUT22
#ifndef QT_NO_TABLETEVENT
struct TabletData {
- TabletData() : deviceId(0), pointerType(QTabletEvent::UnknownPointer),
- tool(QTabletEvent::Stylus), buttons(0), serialId(0), inProximity(false) { }
- int deviceId;
- QTabletEvent::PointerType pointerType;
- QTabletEvent::TabletDevice tool;
- Qt::MouseButtons buttons;
- qint64 serialId;
- bool inProximity;
+ int deviceId = 0;
+ QTabletEvent::PointerType pointerType = QTabletEvent::UnknownPointer;
+ QTabletEvent::TabletDevice tool = QTabletEvent::Stylus;
+ Qt::MouseButtons buttons = 0;
+ qint64 serialId = 0;
+ bool inProximity = false;
struct ValuatorClassInfo {
- ValuatorClassInfo() : minVal(0.), maxVal(0.), curVal(0.) { }
- double minVal;
- double maxVal;
- double curVal;
- int number;
+ double minVal = 0;
+ double maxVal = 0;
+ double curVal = 0;
+ int number = -1;
};
QHash<int, ValuatorClassInfo> valuatorInfo;
};
@@ -593,12 +589,13 @@ private:
TabletData *tabletDataForDevice(int id);
#endif // !QT_NO_TABLETEVENT
struct ScrollingDevice {
- ScrollingDevice() : deviceId(0), verticalIndex(0), horizontalIndex(0), orientations(0), legacyOrientations(0) { }
- int deviceId;
- int verticalIndex, horizontalIndex;
- double verticalIncrement, horizontalIncrement;
- Qt::Orientations orientations;
- Qt::Orientations legacyOrientations;
+ int deviceId = 0;
+ int verticalIndex = 0;
+ int horizontalIndex = 0;
+ double verticalIncrement = 0;
+ double horizontalIncrement = 0;
+ Qt::Orientations orientations = 0;
+ Qt::Orientations legacyOrientations = 0;
QPointF lastScrollPosition;
};
void updateScrollingDevice(ScrollingDevice& scrollingDevice, int num_classes, void *classes);
@@ -609,36 +606,36 @@ private:
static void xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *event);
#endif
- xcb_connection_t *m_connection;
- const xcb_setup_t *m_setup;
- bool m_canGrabServer;
- xcb_visualid_t m_defaultVisualId;
+ xcb_connection_t *m_connection = nullptr;
+ const xcb_setup_t *m_setup = nullptr;
+ const bool m_canGrabServer;
+ const xcb_visualid_t m_defaultVisualId;
QList<QXcbVirtualDesktop *> m_virtualDesktops;
QList<QXcbScreen *> m_screens;
- int m_primaryScreenNumber;
+ int m_primaryScreenNumber = 0;
xcb_atom_t m_allAtoms[QXcbAtom::NAtoms];
- xcb_timestamp_t m_time;
- xcb_timestamp_t m_netWmUserTime;
+ xcb_timestamp_t m_time = XCB_CURRENT_TIME;
+ xcb_timestamp_t m_netWmUserTime = XCB_CURRENT_TIME;
QByteArray m_displayName;
- QXcbKeyboard *m_keyboard;
+ QXcbKeyboard *m_keyboard = nullptr;
#ifndef QT_NO_CLIPBOARD
- QXcbClipboard *m_clipboard;
+ QXcbClipboard *m_clipboard = nullptr;
#endif
#ifndef QT_NO_DRAGANDDROP
- QXcbDrag *m_drag;
+ QXcbDrag *m_drag = nullptr;
#endif
QScopedPointer<QXcbWMSupport> m_wmSupport;
- QXcbNativeInterface *m_nativeInterface;
+ QXcbNativeInterface *m_nativeInterface = nullptr;
#if defined(XCB_USE_XLIB)
- void *m_xlib_display;
+ void *m_xlib_display = nullptr;
#endif
- QXcbEventReader *m_reader;
+ QXcbEventReader *m_reader = nullptr;
#if defined(XCB_USE_XINPUT2)
QHash<int, XInput2TouchDeviceData*> m_touchDevices;
#ifdef XCB_USE_XINPUT22
@@ -671,29 +668,29 @@ private:
QVector<PeekFunc> m_peekFuncs;
- uint32_t xfixes_first_event;
- uint32_t xrandr_first_event;
- uint32_t xkb_first_event;
+ uint32_t xfixes_first_event = 0;
+ uint32_t xrandr_first_event = 0;
+ uint32_t xkb_first_event = 0;
- bool has_xinerama_extension;
- bool has_shape_extension;
- bool has_randr_extension;
+ bool has_xinerama_extension = false;
+ bool has_shape_extension = false;
+ bool has_randr_extension = false;
bool has_input_shape;
- bool has_xkb;
+ bool has_xkb = false;
- Qt::MouseButtons m_buttons;
+ Qt::MouseButtons m_buttons = 0;
- QXcbWindow *m_focusWindow;
- QXcbWindow *m_mouseGrabber;
- QXcbWindow *m_mousePressWindow;
+ QXcbWindow *m_focusWindow = nullptr;
+ QXcbWindow *m_mouseGrabber = nullptr;
+ QXcbWindow *m_mousePressWindow = nullptr;
- xcb_window_t m_clientLeader;
+ xcb_window_t m_clientLeader = 0;
QByteArray m_startupId;
- QXcbSystemTrayTracker *m_systemTrayTracker;
- QXcbGlIntegration *m_glIntegration;
- bool m_xiGrab;
+ QXcbSystemTrayTracker *m_systemTrayTracker = nullptr;
+ QXcbGlIntegration *m_glIntegration = nullptr;
+ bool m_xiGrab = false;
- xcb_window_t m_qtSelectionOwner;
+ xcb_window_t m_qtSelectionOwner = 0;
friend class QXcbEventReader;
};
@@ -704,7 +701,7 @@ Q_DECLARE_TYPEINFO(QXcbConnection::TabletData, Q_MOVABLE_TYPE);
#endif
#endif
-#define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display()))
+#define DISPLAY_FROM_XCB(object) (reinterpret_cast<Display *>(object->connection()->xlib_display()))
#define CREATE_VISUALINFO_FROM_DEFAULT_VISUALID(object) ((XVisualInfo *)(object->connection()->createVisualInfoForDefaultVisualId()))
template<typename T>
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index d91cbfe82d..14c138a911 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -42,6 +42,7 @@
#include "qxcbscreen.h"
#include "qxcbwindow.h"
#include "qtouchdevice.h"
+#include "QtCore/qmetaobject.h"
#include <qpa/qwindowsysteminterface_p.h>
#include <QDebug>
#include <cmath>
@@ -52,14 +53,8 @@
#include <X11/extensions/XI2proto.h>
struct XInput2TouchDeviceData {
- XInput2TouchDeviceData()
- : xiDeviceInfo(0)
- , qtTouchDevice(0)
- , providesTouchOrientation(false)
- {
- }
- XIDeviceInfo *xiDeviceInfo;
- QTouchDevice *qtTouchDevice;
+ XIDeviceInfo *xiDeviceInfo = nullptr;
+ QTouchDevice *qtTouchDevice = nullptr;
QHash<int, QWindowSystemInterface::TouchPoint> touchPoints;
QHash<int, QPointF> pointPressedPosition; // in screen coordinates where each point was pressed
@@ -67,7 +62,7 @@ struct XInput2TouchDeviceData {
QPointF firstPressedPosition; // in screen coordinates where the first point was pressed
QPointF firstPressedNormalPosition; // device coordinates (0 to 1, 0 to 1) where the first point was pressed
QSizeF size; // device size in mm
- bool providesTouchOrientation;
+ bool providesTouchOrientation = false;
};
void QXcbConnection::initializeXInput2()
@@ -80,7 +75,7 @@ void QXcbConnection::initializeXInput2()
Display *xDisplay = static_cast<Display *>(m_xlib_display);
if (XQueryExtension(xDisplay, "XInputExtension", &m_xiOpCode, &m_xiEventBase, &m_xiErrorBase)) {
int xiMajor = 2;
- m_xi2Minor = 2; // try 2.2 first, needed for TouchBegin/Update/End
+ // try 2.2 first, needed for TouchBegin/Update/End
if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) {
m_xi2Minor = 1; // for smooth scrolling 2.1 is enough
if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) {
@@ -214,6 +209,8 @@ void QXcbConnection::xi2SetupDevices()
isTablet = true;
tabletData.pointerType = QTabletEvent::Cursor;
dbgType = QLatin1String("cursor");
+ } else if (name.contains("wacom") && name.contains("finger touch")) {
+ isTablet = false;
} else if ((name.contains("pen") || name.contains("stylus")) && isTablet) {
tabletData.pointerType = QTabletEvent::Pen;
dbgType = QLatin1String("pen");
@@ -232,6 +229,9 @@ void QXcbConnection::xi2SetupDevices()
isTablet = true;
tabletData.pointerType = QTabletEvent::Pen;
dbgType = QLatin1String("pen");
+ } else if (name.contains("uc-logic") && isTablet) {
+ tabletData.pointerType = QTabletEvent::Pen;
+ dbgType = QLatin1String("pen");
} else {
isTablet = false;
}
@@ -444,10 +444,10 @@ XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
dev->size.setHeight((vci->max - vci->min) * 1000.0 / vciResolution);
} else if (vci->label == atom(QXcbAtom::AbsX)) {
caps |= QTouchDevice::Position;
- dev->size.setHeight((vci->max - vci->min) * 1000.0 / vciResolution);
+ dev->size.setWidth((vci->max - vci->min) * 1000.0 / vciResolution);
} else if (vci->label == atom(QXcbAtom::AbsY)) {
caps |= QTouchDevice::Position;
- dev->size.setWidth((vci->max - vci->min) * 1000.0 / vciResolution);
+ dev->size.setHeight((vci->max - vci->min) * 1000.0 / vciResolution);
}
break;
}
@@ -1066,6 +1066,18 @@ static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) {
return QTabletEvent::Stylus; // Safe default assumption if nonzero
}
+static const char *toolName(QTabletEvent::TabletDevice tool) {
+ static const QMetaObject *metaObject = qt_getEnumMetaObject(tool);
+ static const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(tool)));
+ return me.valueToKey(tool);
+}
+
+static const char *pointerTypeName(QTabletEvent::PointerType ptype) {
+ static const QMetaObject *metaObject = qt_getEnumMetaObject(ptype);
+ static const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(ptype)));
+ return me.valueToKey(ptype);
+}
+
bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletData)
{
bool handled = true;
@@ -1087,10 +1099,7 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD
break;
}
case XI_Motion:
- // Report TabletMove only when the stylus is touching the tablet or any button is pressed.
- // TODO: report proximity (hover) motion (no suitable Qt event exists yet).
- if (tabletData->buttons != Qt::NoButton)
- xi2ReportTabletEvent(xiEvent, tabletData);
+ xi2ReportTabletEvent(xiEvent, tabletData);
break;
case XI_PropertyEvent: {
// This is the wacom driver's way of reporting tool proximity.
@@ -1142,9 +1151,9 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD
// TODO maybe have a hash of tabletData->deviceId to device data so we can
// look up the tablet name here, and distinguish multiple tablets
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
- qCDebug(lcQpaXInputEvents, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d",
+ qCDebug(lcQpaXInputEvents, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x %s",
tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID],
- ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool);
+ ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], toolName(tabletData->tool));
}
XFree(data);
}
@@ -1167,6 +1176,7 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
if (!xcbWindow)
return;
QWindow *window = xcbWindow->window();
+ const Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(ev->mods.effective_mods);
const double scale = 65536.0;
QPointF local(ev->event_x / scale, ev->event_y / scale);
QPointF global(ev->root_x / scale, ev->root_y / scale);
@@ -1207,18 +1217,19 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
}
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
- qCDebug(lcQpaXInputEvents, "XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d "
- "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf",
- tabletData->deviceId, tabletData->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time,
+ qCDebug(lcQpaXInputEvents, "XI2 event on tablet %d with tool %s type %s seq %d detail %d time %d "
+ "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf modifiers 0x%x",
+ tabletData->deviceId, toolName(tabletData->tool), pointerTypeName(tabletData->pointerType),
+ ev->sequenceNumber, ev->detail, ev->time,
fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y),
fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y),
- (int)tabletData->buttons, pressure, xTilt, yTilt, rotation);
+ (int)tabletData->buttons, pressure, xTilt, yTilt, rotation, (int)modifiers);
QWindowSystemInterface::handleTabletEvent(window, ev->time, local, global,
tabletData->tool, tabletData->pointerType,
tabletData->buttons, pressure,
xTilt, yTilt, tangentialPressure,
- rotation, 0, tabletData->serialId);
+ rotation, 0, tabletData->serialId, modifiers);
}
QXcbConnection::TabletData *QXcbConnection::tabletDataForDevice(int id)
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index af9ffab8ae..b414bee204 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -214,6 +214,27 @@ QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
return xcbWindow;
}
+class QXcbForeignWindow : public QXcbWindow
+{
+public:
+ QXcbForeignWindow(QWindow *window, WId nativeHandle)
+ : QXcbWindow(window) { m_window = nativeHandle; }
+ ~QXcbForeignWindow() {}
+ bool isForeignWindow() const override { return true; }
+
+protected:
+ // No-ops
+ void create() override {}
+ void destroy() override {}
+};
+
+QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativeHandle) const
+{
+ QXcbWindow *xcbWindow = new QXcbForeignWindow(window, nativeHandle);
+ xcbWindow->create();
+ return xcbWindow;
+}
+
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
@@ -384,9 +405,6 @@ QVariant QXcbIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
case QPlatformIntegration::PasswordMaskCharacter:
// TODO using various xcb, gnome or KDE settings
break; // Not implemented, use defaults
- case QPlatformIntegration::FontSmoothingGamma:
- // Match Qt 4.8 text rendering, and rendering of other X11 toolkits.
- return qreal(1.0);
case QPlatformIntegration::StartDragDistance: {
// The default (in QPlatformTheme::defaultThemeHint) is 10 pixels, but
// on a high-resolution screen it makes sense to increase it.
@@ -448,7 +466,7 @@ QByteArray QXcbIntegration::wmClass() const
}
if (!name.isEmpty() && !className.isEmpty())
- m_wmClass = name.toLocal8Bit() + '\0' + className.toLocal8Bit() + '\0';
+ m_wmClass = std::move(name).toLocal8Bit() + '\0' + std::move(className).toLocal8Bit() + '\0';
}
return m_wmClass;
}
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index f8034f436f..baa5c9d835 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -61,6 +61,7 @@ public:
~QXcbIntegration();
QPlatformWindow *createPlatformWindow(QWindow *window) const override;
+ QPlatformWindow *createForeignWindow(QWindow *window, WId nativeHandle) const override;
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
#endif
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index a5aff7f11f..2e29c208c7 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -1136,12 +1136,6 @@ int QXcbKeyboard::keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modi
QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
: QXcbObject(connection)
- , m_autorepeat_code(0)
- , xkb_context(0)
- , xkb_keymap(0)
- , xkb_state(0)
- , latin_keymap(0)
- , m_hasLatinLayout(false)
{
memset(&xkb_names, 0, sizeof(xkb_names));
#if QT_CONFIG(xkb)
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index dfd2926435..74f9da0353 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -106,14 +106,14 @@ protected:
private:
void updateXKBStateFromState(struct xkb_state *kb_state, quint16 state);
- bool m_config;
- xcb_keycode_t m_autorepeat_code;
+ bool m_config = false;
+ xcb_keycode_t m_autorepeat_code = 0;
- struct xkb_context *xkb_context;
- struct xkb_keymap *xkb_keymap;
- struct xkb_state *xkb_state;
+ struct xkb_context *xkb_context = nullptr;
+ struct xkb_keymap *xkb_keymap = nullptr;
+ struct xkb_state *xkb_state = nullptr;
struct xkb_rule_names xkb_names;
- mutable struct xkb_keymap *latin_keymap;
+ mutable struct xkb_keymap *latin_keymap = nullptr;
struct _mod_masks {
uint alt;
@@ -143,7 +143,7 @@ private:
_mod_masks vmod_masks;
int core_device_id;
#endif
- bool m_hasLatinLayout;
+ bool m_hasLatinLayout = false;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp
index 3ec8fa491f..2848446098 100644
--- a/src/plugins/platforms/xcb/qxcbmime.cpp
+++ b/src/plugins/platforms/xcb/qxcbmime.cpp
@@ -299,7 +299,7 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString
QString formatWithCharset = format;
formatWithCharset.append(QLatin1String(";charset=utf-8"));
- xcb_atom_t a = connection->internAtom(formatWithCharset.toLatin1());
+ xcb_atom_t a = connection->internAtom(std::move(formatWithCharset).toLatin1());
if (a && atoms.contains(a)) {
*requestedEncoding = "utf-8";
return a;
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index b1575cbee4..725288633a 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -90,8 +90,7 @@ static int resourceType(const QByteArray &key)
}
QXcbNativeInterface::QXcbNativeInterface() :
- m_genericEventFilterType(QByteArrayLiteral("xcb_generic_event_t")),
- m_sysTraySelectionAtom(XCB_ATOM_NONE)
+ m_genericEventFilterType(QByteArrayLiteral("xcb_generic_event_t"))
{
}
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index a830829311..4186d77f4d 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -129,7 +129,7 @@ private:
const QByteArray m_genericEventFilterType;
- xcb_atom_t m_sysTraySelectionAtom;
+ xcb_atom_t m_sysTraySelectionAtom = XCB_ATOM_NONE;
static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 0ad9c97521..5e136b5d7e 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -59,7 +59,6 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t
: QXcbObject(connection)
, m_screen(screen)
, m_number(number)
- , m_xSettings(Q_NULLPTR)
{
const QByteArray cmAtomName = "_NET_WM_CM_S" + QByteArray::number(m_number);
m_net_wm_cm_atom = connection->internAtom(cmAtomName.constData());
@@ -175,20 +174,10 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe
, m_virtualDesktop(virtualDesktop)
, m_output(outputId)
, m_crtc(output ? output->crtc : XCB_NONE)
- , m_mode(XCB_NONE)
- , m_primary(false)
- , m_rotation(XCB_RANDR_ROTATION_ROTATE_0)
, m_outputName(getOutputName(output))
, m_outputSizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize())
, m_virtualSize(virtualDesktop->size())
, m_virtualSizeMillimeters(virtualDesktop->physicalSize())
- , m_orientation(Qt::PrimaryOrientation)
- , m_refreshRate(60)
- , m_forcedDpi(-1)
- , m_pixelDensity(1)
- , m_hintStyle(QFontEngine::HintStyle(-1))
- , m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1))
- , m_antialiasingEnabled(-1)
{
if (connection->hasXRandr()) {
xcb_randr_select_input(xcb_connection(), screen()->root, true);
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index 627397fcaf..4163be2969 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -95,12 +95,12 @@ private:
QRect getWorkArea() const;
xcb_screen_t *m_screen;
- int m_number;
+ const int m_number;
QList<QPlatformScreen *> m_screens;
- QXcbXSettings *m_xSettings;
- xcb_atom_t m_net_wm_cm_atom;
- bool m_compositingActive;
+ QXcbXSettings *m_xSettings = nullptr;
+ xcb_atom_t m_net_wm_cm_atom = 0;
+ bool m_compositingActive = false;
QRect m_workArea;
};
@@ -186,9 +186,9 @@ private:
QXcbVirtualDesktop *m_virtualDesktop;
xcb_randr_output_t m_output;
xcb_randr_crtc_t m_crtc;
- xcb_randr_mode_t m_mode;
- bool m_primary;
- uint8_t m_rotation;
+ xcb_randr_mode_t m_mode = XCB_NONE;
+ bool m_primary = false;
+ uint8_t m_rotation = XCB_RANDR_ROTATION_ROTATE_0;
QString m_outputName;
QSizeF m_outputSizeMillimeters;
@@ -197,18 +197,18 @@ private:
QRect m_availableGeometry;
QSize m_virtualSize;
QSizeF m_virtualSizeMillimeters;
- Qt::ScreenOrientation m_orientation;
+ Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
QString m_windowManagerName;
- bool m_syncRequestSupported;
+ bool m_syncRequestSupported = false;
QMap<xcb_visualid_t, xcb_visualtype_t> m_visuals;
QMap<xcb_visualid_t, quint8> m_visualDepths;
QXcbCursor *m_cursor;
- int m_refreshRate;
- int m_forcedDpi;
- int m_pixelDensity;
- QFontEngine::HintStyle m_hintStyle;
- QFontEngine::SubpixelAntialiasingType m_subpixelType;
- int m_antialiasingEnabled;
+ int m_refreshRate = 60;
+ int m_forcedDpi = -1;
+ int m_pixelDensity = 1;
+ QFontEngine::HintStyle m_hintStyle = QFontEngine::HintStyle(-1);
+ QFontEngine::SubpixelAntialiasingType m_subpixelType = QFontEngine::SubpixelAntialiasingType(-1);
+ int m_antialiasingEnabled = -1;
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
index 5522af86de..fb0a4a3939 100644
--- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
+++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
@@ -80,7 +80,6 @@ QXcbSystemTrayTracker::QXcbSystemTrayTracker(QXcbConnection *connection,
, m_selection(selection)
, m_trayAtom(trayAtom)
, m_connection(connection)
- , m_trayWindow(0)
{
}
diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h
index a6131e6d0e..a95b9374e9 100644
--- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h
+++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h
@@ -77,7 +77,7 @@ private:
const xcb_atom_t m_selection;
const xcb_atom_t m_trayAtom;
QXcbConnection *m_connection;
- xcb_window_t m_trayWindow;
+ xcb_window_t m_trayWindow = 0;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 509bc9b038..6365a6e9cb 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -284,6 +284,8 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
free_prop = false;
#if QT_CONFIG(textcodec)
}
+#else
+ Q_UNUSED(dpy);
#endif
return &tp;
}
@@ -314,22 +316,6 @@ static const char *wm_window_role_property_id = "_q_xcb_wm_window_role";
QXcbWindow::QXcbWindow(QWindow *window)
: QPlatformWindow(window)
- , m_window(0)
- , m_cmap(0)
- , m_syncCounter(0)
- , m_gravity(XCB_GRAVITY_STATIC)
- , m_mapped(false)
- , m_transparent(false)
- , m_usingSyncProtocol(false)
- , m_deferredActivation(false)
- , m_embedded(false)
- , m_alertState(false)
- , m_netWmUserTimeWindow(XCB_NONE)
- , m_dirtyFrameMargins(false)
- , m_lastWindowStateEvent(-1)
- , m_syncState(NoSyncNeeded)
- , m_pendingSyncRequest(0)
- , m_currentBitmapCursor(XCB_CURSOR_NONE)
{
setConnection(xcbScreen()->connection());
}
@@ -357,11 +343,6 @@ enum {
void QXcbWindow::create()
{
- if (window()->type() == Qt::ForeignWindow) {
- m_window = window()->winId();
- return;
- }
-
destroy();
m_windowState = Qt::WindowNoState;
@@ -413,7 +394,7 @@ void QXcbWindow::create()
xcb_window_t xcb_parent_id = platformScreen->root();
if (parent()) {
xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window();
- m_embedded = parent()->window()->type() == Qt::ForeignWindow;
+ m_embedded = parent()->isForeignWindow();
QSurfaceFormat parentFormat = parent()->window()->requestedFormat();
if (window()->surfaceType() != QSurface::OpenGLSurface && parentFormat.hasAlpha()) {
@@ -606,9 +587,10 @@ QXcbWindow::~QXcbWindow()
if (m_currentBitmapCursor != XCB_CURSOR_NONE) {
xcb_free_cursor(xcb_connection(), m_currentBitmapCursor);
}
- if (window()->type() != Qt::ForeignWindow)
- destroy();
- else {
+
+ destroy();
+
+ if (isForeignWindow()) {
if (connection()->mouseGrabber() == this)
connection()->setMouseGrabber(Q_NULLPTR);
if (connection()->mousePressWindow() == this)
@@ -1520,7 +1502,7 @@ void QXcbWindow::setParent(const QPlatformWindow *parent)
if (parent) {
const QXcbWindow *qXcbParent = static_cast<const QXcbWindow *>(parent);
xcb_parent_id = qXcbParent->xcb_window();
- m_embedded = qXcbParent->window()->type() == Qt::ForeignWindow;
+ m_embedded = qXcbParent->isForeignWindow();
} else {
xcb_parent_id = xcbScreen()->root();
m_embedded = false;
@@ -1530,8 +1512,8 @@ void QXcbWindow::setParent(const QPlatformWindow *parent)
void QXcbWindow::setWindowTitle(const QString &title)
{
- const QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH
- const QByteArray ba = fullTitle.toUtf8();
+ QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH
+ const QByteArray ba = std::move(fullTitle).toUtf8();
Q_XCB_CALL(xcb_change_property(xcb_connection(),
XCB_PROP_MODE_REPLACE,
m_window,
@@ -2153,12 +2135,9 @@ bool QXcbWindow::isExposed() const
return m_mapped;
}
-bool QXcbWindow::isEmbedded(const QPlatformWindow *parentWindow) const
+bool QXcbWindow::isEmbedded() const
{
- if (!m_embedded)
- return false;
-
- return parentWindow ? (parentWindow == parent()) : true;
+ return m_embedded;
}
QPoint QXcbWindow::mapToGlobal(const QPoint &pos) const
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index d100120d46..b4d947e700 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -87,7 +87,7 @@ public:
void setParent(const QPlatformWindow *window) override;
bool isExposed() const override;
- bool isEmbedded(const QPlatformWindow *parentWindow = 0) const override;
+ bool isEmbedded() const override;
QPoint mapToGlobal(const QPoint &pos) const override;
QPoint mapFromGlobal(const QPoint &pos) const override;
@@ -233,48 +233,48 @@ protected:
void handleLeaveNotifyEvent(int root_x, int root_y,
quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
- xcb_window_t m_window;
- xcb_colormap_t m_cmap;
+ xcb_window_t m_window = 0;
+ xcb_colormap_t m_cmap = 0;
- uint m_depth;
- QImage::Format m_imageFormat;
- bool m_imageRgbSwap;
+ uint m_depth = 0;
+ QImage::Format m_imageFormat = QImage::Format_ARGB32_Premultiplied;
+ bool m_imageRgbSwap = false;
xcb_sync_int64_t m_syncValue;
- xcb_sync_counter_t m_syncCounter;
+ xcb_sync_counter_t m_syncCounter = 0;
- Qt::WindowState m_windowState;
+ Qt::WindowState m_windowState = Qt::WindowNoState;
- xcb_gravity_t m_gravity;
+ xcb_gravity_t m_gravity = XCB_GRAVITY_STATIC;
- bool m_mapped;
- bool m_transparent;
- bool m_usingSyncProtocol;
- bool m_deferredActivation;
- bool m_embedded;
- bool m_alertState;
- xcb_window_t m_netWmUserTimeWindow;
+ bool m_mapped = false;
+ bool m_transparent = false;
+ bool m_usingSyncProtocol = false;
+ bool m_deferredActivation = false;
+ bool m_embedded = false;
+ bool m_alertState = false;
+ xcb_window_t m_netWmUserTimeWindow = XCB_NONE;
QSurfaceFormat m_format;
- mutable bool m_dirtyFrameMargins;
+ mutable bool m_dirtyFrameMargins = false;
mutable QMargins m_frameMargins;
QRegion m_exposeRegion;
QSize m_oldWindowSize;
- xcb_visualid_t m_visualId;
- int m_lastWindowStateEvent;
+ xcb_visualid_t m_visualId = 0;
+ int m_lastWindowStateEvent = -1;
enum SyncState {
NoSyncNeeded,
SyncReceived,
SyncAndConfigureReceived
};
- SyncState m_syncState;
+ SyncState m_syncState = NoSyncNeeded;
- QXcbSyncWindowRequest *m_pendingSyncRequest;
- xcb_cursor_t m_currentBitmapCursor;
+ QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr;
+ xcb_cursor_t m_currentBitmapCursor = XCB_CURSOR_NONE;
};
QT_END_NAMESPACE