| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 4 |
|
| 5 |
#ifndef QXCBCONNECTION_H |
| 6 |
#define QXCBCONNECTION_H |
| 7 |
|
| 8 |
#include <xcb/xcb.h> |
| 9 |
#include <xcb/randr.h> |
| 10 |
|
| 11 |
#include "qxcbexport.h" |
| 12 |
#include <QHash> |
| 13 |
#include <QList> |
| 14 |
#include <QMutex> |
| 15 |
#include <QObject> |
| 16 |
#include <QThread> |
| 17 |
#include <QVector> |
| 18 |
#include <QVarLengthArray> |
| 19 |
#include <qpa/qwindowsysteminterface.h> |
| 20 |
#include <QtCore/QLoggingCategory> |
| 21 |
|
| 22 |
// This is needed to make Qt compile together with XKB. xkb.h is using a variable |
| 23 |
// which is called 'explicit', this is a reserved keyword in c++ |
| 24 |
#ifndef QT_NO_XKB |
| 25 |
#define explicit dont_use_cxx_explicit |
| 26 |
#include <xcb/xkb.h> |
| 27 |
#undef explicit |
| 28 |
#endif |
| 29 |
|
| 30 |
#ifndef QT_NO_TABLETEVENT |
| 31 |
#include <QTabletEvent> |
| 32 |
#endif |
| 33 |
|
| 34 |
#if XCB_USE_XINPUT2 |
| 35 |
#include <X11/extensions/XI2.h> |
| 36 |
#ifdef XIScrollClass |
| 37 |
#define XCB_USE_XINPUT21 // XI 2.1 adds smooth scrolling support |
| 38 |
#ifdef XI_TouchBeginMask |
| 39 |
#define XCB_USE_XINPUT22 // XI 2.2 adds multi-point touch support |
| 40 |
#endif |
| 41 |
#endif |
| 42 |
struct XInput2TouchDeviceData; |
| 43 |
#endif // XCB_USE_XINPUT2 |
| 44 |
|
| 45 |
struct xcb_randr_get_output_info_reply_t; |
| 46 |
|
| 47 |
//#define Q_XCB_DEBUG |
| 48 |
|
| 49 |
QT_BEGIN_NAMESPACE |
| 50 |
|
| 51 |
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInput) |
| 52 |
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInputDevices) |
| 53 |
Q_DECLARE_LOGGING_CATEGORY(lcQpaScreen) |
| 54 |
|
| 55 |
class QXcbVirtualDesktop; |
| 56 |
class QXcbScreen; |
| 57 |
class QXcbWindow; |
| 58 |
class QXcbDrag; |
| 59 |
class QXcbKeyboard; |
| 60 |
class QXcbClipboard; |
| 61 |
class QXcbWMSupport; |
| 62 |
class QXcbNativeInterface; |
| 63 |
class QXcbSystemTrayTracker; |
| 64 |
class QXcbGlIntegration; |
| 65 |
|
| 66 |
namespace QXcbAtom { |
| 67 |
enum Atom { |
| 68 |
// window-manager <-> client protocols |
| 69 |
WM_PROTOCOLS, |
| 70 |
WM_DELETE_WINDOW, |
| 71 |
WM_TAKE_FOCUS, |
| 72 |
_NET_WM_PING, |
| 73 |
_NET_WM_CONTEXT_HELP, |
| 74 |
_NET_WM_SYNC_REQUEST, |
| 75 |
_NET_WM_SYNC_REQUEST_COUNTER, |
| 76 |
MANAGER, // System tray notification |
| 77 |
_NET_SYSTEM_TRAY_OPCODE, // System tray operation |
| 78 |
|
| 79 |
// ICCCM window state |
| 80 |
WM_STATE, |
| 81 |
WM_CHANGE_STATE, |
| 82 |
WM_CLASS, |
| 83 |
WM_NAME, |
| 84 |
|
| 85 |
// Session management |
| 86 |
WM_CLIENT_LEADER, |
| 87 |
WM_WINDOW_ROLE, |
| 88 |
SM_CLIENT_ID, |
| 89 |
|
| 90 |
// Clipboard |
| 91 |
CLIPBOARD, |
| 92 |
INCR, |
| 93 |
TARGETS, |
| 94 |
MULTIPLE, |
| 95 |
TIMESTAMP, |
| 96 |
SAVE_TARGETS, |
| 97 |
CLIP_TEMPORARY, |
| 98 |
_QT_SELECTION, |
| 99 |
_QT_CLIPBOARD_SENTINEL, |
| 100 |
_QT_SELECTION_SENTINEL, |
| 101 |
CLIPBOARD_MANAGER, |
| 102 |
|
| 103 |
RESOURCE_MANAGER, |
| 104 |
|
| 105 |
_XSETROOT_ID, |
| 106 |
|
| 107 |
_QT_SCROLL_DONE, |
| 108 |
_QT_INPUT_ENCODING, |
| 109 |
|
| 110 |
// Qt/XCB specific |
| 111 |
_QT_CLOSE_CONNECTION, |
| 112 |
|
| 113 |
_MOTIF_WM_HINTS, |
| 114 |
|
| 115 |
DTWM_IS_RUNNING, |
| 116 |
ENLIGHTENMENT_DESKTOP, |
| 117 |
_DT_SAVE_MODE, |
| 118 |
_SGI_DESKS_MANAGER, |
| 119 |
|
| 120 |
// EWMH (aka NETWM) |
| 121 |
_NET_SUPPORTED, |
| 122 |
_NET_VIRTUAL_ROOTS, |
| 123 |
_NET_WORKAREA, |
| 124 |
|
| 125 |
_NET_MOVERESIZE_WINDOW, |
| 126 |
_NET_WM_MOVERESIZE, |
| 127 |
|
| 128 |
_NET_WM_NAME, |
| 129 |
_NET_WM_ICON_NAME, |
| 130 |
_NET_WM_ICON, |
| 131 |
|
| 132 |
_NET_WM_PID, |
| 133 |
|
| 134 |
_NET_WM_WINDOW_OPACITY, |
| 135 |
|
| 136 |
_NET_WM_STATE, |
| 137 |
_NET_WM_STATE_ABOVE, |
| 138 |
_NET_WM_STATE_BELOW, |
| 139 |
_NET_WM_STATE_FULLSCREEN, |
| 140 |
_NET_WM_STATE_MAXIMIZED_HORZ, |
| 141 |
_NET_WM_STATE_MAXIMIZED_VERT, |
| 142 |
_NET_WM_STATE_MODAL, |
| 143 |
_NET_WM_STATE_STAYS_ON_TOP, |
| 144 |
_NET_WM_STATE_DEMANDS_ATTENTION, |
| 145 |
|
| 146 |
_NET_WM_USER_TIME, |
| 147 |
_NET_WM_USER_TIME_WINDOW, |
| 148 |
_NET_WM_FULL_PLACEMENT, |
| 149 |
|
| 150 |
_NET_WM_WINDOW_TYPE, |
| 151 |
_NET_WM_WINDOW_TYPE_DESKTOP, |
| 152 |
_NET_WM_WINDOW_TYPE_DOCK, |
| 153 |
_NET_WM_WINDOW_TYPE_TOOLBAR, |
| 154 |
_NET_WM_WINDOW_TYPE_MENU, |
| 155 |
_NET_WM_WINDOW_TYPE_UTILITY, |
| 156 |
_NET_WM_WINDOW_TYPE_SPLASH, |
| 157 |
_NET_WM_WINDOW_TYPE_DIALOG, |
| 158 |
_NET_WM_WINDOW_TYPE_DROPDOWN_MENU, |
| 159 |
_NET_WM_WINDOW_TYPE_POPUP_MENU, |
| 160 |
_NET_WM_WINDOW_TYPE_TOOLTIP, |
| 161 |
_NET_WM_WINDOW_TYPE_NOTIFICATION, |
| 162 |
_NET_WM_WINDOW_TYPE_COMBO, |
| 163 |
_NET_WM_WINDOW_TYPE_DND, |
| 164 |
_NET_WM_WINDOW_TYPE_NORMAL, |
| 165 |
_KDE_NET_WM_WINDOW_TYPE_OVERRIDE, |
| 166 |
|
| 167 |
_KDE_NET_WM_FRAME_STRUT, |
| 168 |
_NET_FRAME_EXTENTS, |
| 169 |
|
| 170 |
_NET_STARTUP_INFO, |
| 171 |
_NET_STARTUP_INFO_BEGIN, |
| 172 |
|
| 173 |
_NET_SUPPORTING_WM_CHECK, |
| 174 |
|
| 175 |
_NET_WM_CM_S0, |
| 176 |
|
| 177 |
_NET_SYSTEM_TRAY_VISUAL, |
| 178 |
|
| 179 |
_NET_ACTIVE_WINDOW, |
| 180 |
|
| 181 |
// Property formats |
| 182 |
TEXT, |
| 183 |
UTF8_STRING, |
| 184 |
CARDINAL, |
| 185 |
|
| 186 |
// Xdnd |
| 187 |
XdndEnter, |
| 188 |
XdndPosition, |
| 189 |
XdndStatus, |
| 190 |
XdndLeave, |
| 191 |
XdndDrop, |
| 192 |
XdndFinished, |
| 193 |
XdndTypelist, |
| 194 |
XdndActionList, |
| 195 |
|
| 196 |
XdndSelection, |
| 197 |
|
| 198 |
XdndAware, |
| 199 |
XdndProxy, |
| 200 |
|
| 201 |
XdndActionCopy, |
| 202 |
XdndActionLink, |
| 203 |
XdndActionMove, |
| 204 |
XdndActionPrivate, |
| 205 |
|
| 206 |
// Motif DND |
| 207 |
_MOTIF_DRAG_AND_DROP_MESSAGE, |
| 208 |
_MOTIF_DRAG_INITIATOR_INFO, |
| 209 |
_MOTIF_DRAG_RECEIVER_INFO, |
| 210 |
_MOTIF_DRAG_WINDOW, |
| 211 |
_MOTIF_DRAG_TARGETS, |
| 212 |
|
| 213 |
XmTRANSFER_SUCCESS, |
| 214 |
XmTRANSFER_FAILURE, |
| 215 |
|
| 216 |
// Xkb |
| 217 |
_XKB_RULES_NAMES, |
| 218 |
|
| 219 |
// XEMBED |
| 220 |
_XEMBED, |
| 221 |
_XEMBED_INFO, |
| 222 |
|
| 223 |
// XInput2 |
| 224 |
ButtonLeft, |
| 225 |
ButtonMiddle, |
| 226 |
ButtonRight, |
| 227 |
ButtonWheelUp, |
| 228 |
ButtonWheelDown, |
| 229 |
ButtonHorizWheelLeft, |
| 230 |
ButtonHorizWheelRight, |
| 231 |
AbsMTPositionX, |
| 232 |
AbsMTPositionY, |
| 233 |
AbsMTTouchMajor, |
| 234 |
AbsMTTouchMinor, |
| 235 |
AbsMTPressure, |
| 236 |
AbsMTTrackingID, |
| 237 |
MaxContacts, |
| 238 |
RelX, |
| 239 |
RelY, |
| 240 |
// XInput2 tablet |
| 241 |
AbsX, |
| 242 |
AbsY, |
| 243 |
AbsPressure, |
| 244 |
AbsTiltX, |
| 245 |
AbsTiltY, |
| 246 |
AbsWheel, |
| 247 |
AbsDistance, |
| 248 |
WacomSerialIDs, |
| 249 |
INTEGER, |
| 250 |
RelHorizWheel, |
| 251 |
RelVertWheel, |
| 252 |
RelHorizScroll, |
| 253 |
RelVertScroll, |
| 254 |
|
| 255 |
_XSETTINGS_SETTINGS, |
| 256 |
|
| 257 |
_COMPIZ_DECOR_PENDING, |
| 258 |
_COMPIZ_DECOR_REQUEST, |
| 259 |
_COMPIZ_DECOR_DELETE_PIXMAP, |
| 260 |
_COMPIZ_TOOLKIT_ACTION, |
| 261 |
|
| 262 |
NPredefinedAtoms, |
| 263 |
|
| 264 |
_QT_SETTINGS_TIMESTAMP = NPredefinedAtoms, |
| 265 |
NAtoms |
| 266 |
}; |
| 267 |
} |
| 268 |
|
| 269 |
typedef QVarLengthArray<xcb_generic_event_t *, 64> QXcbEventArray; |
| 270 |
|
| 271 |
class QXcbConnection; |
| 272 |
class QXcbEventReader : public QThread |
| 273 |
{ |
| 274 |
Q_OBJECT |
| 275 |
public: |
| 276 |
QXcbEventReader(QXcbConnection *connection); |
| 277 |
|
| 278 |
void run() Q_DECL_OVERRIDE; |
| 279 |
|
| 280 |
QXcbEventArray *lock(); |
| 281 |
void unlock(); |
| 282 |
|
| 283 |
void start(); |
| 284 |
|
| 285 |
void registerEventDispatcher(QAbstractEventDispatcher *dispatcher); |
| 286 |
|
| 287 |
signals: |
| 288 |
void eventPending(); |
| 289 |
|
| 290 |
private slots: |
| 291 |
void registerForEvents(); |
| 292 |
|
| 293 |
private: |
| 294 |
void addEvent(xcb_generic_event_t *event); |
| 295 |
|
| 296 |
QMutex m_mutex; |
| 297 |
QXcbEventArray m_events; |
| 298 |
QXcbConnection *m_connection; |
| 299 |
}; |
| 300 |
|
| 301 |
class QXcbWindowEventListener |
| 302 |
{ |
| 303 |
public: |
| 304 |
virtual ~QXcbWindowEventListener() {} |
| 305 |
virtual bool handleGenericEvent(xcb_generic_event_t *, long *) { return false; } |
| 306 |
|
| 307 |
virtual void handleExposeEvent(const xcb_expose_event_t *) {} |
| 308 |
virtual void handleClientMessageEvent(const xcb_client_message_event_t *) {} |
| 309 |
virtual void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *) {} |
| 310 |
virtual void handleMapNotifyEvent(const xcb_map_notify_event_t *) {} |
| 311 |
virtual void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *) {} |
| 312 |
virtual void handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *) {} |
| 313 |
virtual void handleButtonPressEvent(const xcb_button_press_event_t *) {} |
| 314 |
virtual void handleButtonReleaseEvent(const xcb_button_release_event_t *) {} |
| 315 |
virtual void handleMotionNotifyEvent(const xcb_motion_notify_event_t *) {} |
| 316 |
virtual void handleEnterNotifyEvent(const xcb_enter_notify_event_t *) {} |
| 317 |
virtual void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *) {} |
| 318 |
virtual void handleFocusInEvent(const xcb_focus_in_event_t *) {} |
| 319 |
virtual void handleFocusOutEvent(const xcb_focus_out_event_t *) {} |
| 320 |
virtual void handlePropertyNotifyEvent(const xcb_property_notify_event_t *) {} |
| 321 |
virtual void handleXIMouseEvent(xcb_ge_event_t *) {} |
| 322 |
|
| 323 |
virtual QXcbWindow *toWindow() { return 0; } |
| 324 |
}; |
| 325 |
|
| 326 |
typedef QHash<xcb_window_t, QXcbWindowEventListener *> WindowMapper; |
| 327 |
|
| 328 |
class QXcbSyncWindowRequest : public QEvent |
| 329 |
{ |
| 330 |
public: |
| 331 |
QXcbSyncWindowRequest(QXcbWindow *w) : QEvent(QEvent::Type(QEvent::User + 1)), m_window(w) { } |
| 332 |
|
| 333 |
QXcbWindow *window() const { return m_window; } |
| 334 |
void invalidate(); |
| 335 |
|
| 336 |
private: |
| 337 |
QXcbWindow *m_window; |
| 338 |
}; |
| 339 |
|
| 340 |
class QAbstractEventDispatcher; |
| 341 |
class Q_XCB_EXPORT QXcbConnection : public QObject |
| 342 |
{ |
| 343 |
Q_OBJECT |
| 344 |
public: |
| 345 |
QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName = 0); |
| 346 |
~QXcbConnection(); |
| 347 |
|
| 348 |
QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); } |
| 349 |
|
| 350 |
const QList<QXcbVirtualDesktop *> &virtualDesktops() const { return m_virtualDesktops; } |
| 351 |
const QList<QXcbScreen *> &screens() const { return m_screens; } |
| 352 |
int primaryScreenNumber() const { return m_primaryScreenNumber; } |
| 353 |
QXcbVirtualDesktop *primaryVirtualDesktop() const { return m_virtualDesktops.value(m_primaryScreenNumber); } |
| 354 |
QXcbScreen *primaryScreen() const; |
| 355 |
|
| 356 |
inline xcb_atom_t atom(QXcbAtom::Atom atom) const { return m_allAtoms[atom]; } |
| 357 |
QXcbAtom::Atom qatom(xcb_atom_t atom) const; |
| 358 |
xcb_atom_t internAtom(const char *name); |
| 359 |
QByteArray atomName(xcb_atom_t atom); |
| 360 |
|
| 361 |
const char *displayName() const { return m_displayName.constData(); } |
| 362 |
xcb_connection_t *xcb_connection() const { return m_connection; } |
| 363 |
const xcb_setup_t *setup() const { return m_setup; } |
| 364 |
const xcb_format_t *formatForDepth(uint8_t depth) const; |
| 365 |
|
| 366 |
QXcbKeyboard *keyboard() const { return m_keyboard; } |
| 367 |
|
| 368 |
#ifndef QT_NO_CLIPBOARD |
| 369 |
QXcbClipboard *clipboard() const { return m_clipboard; } |
| 370 |
#endif |
| 371 |
#ifndef QT_NO_DRAGANDDROP |
| 372 |
QXcbDrag *drag() const { return m_drag; } |
| 373 |
#endif |
| 374 |
|
| 375 |
QXcbWMSupport *wmSupport() const { return m_wmSupport.data(); } |
| 376 |
xcb_window_t rootWindow(); |
| 377 |
xcb_window_t clientLeader(); |
| 378 |
|
| 379 |
bool hasDefaultVisualId() const { return m_defaultVisualId != UINT_MAX; } |
| 380 |
xcb_visualid_t defaultVisualId() const { return m_defaultVisualId; } |
| 381 |
|
| 382 |
#ifdef XCB_USE_XLIB |
| 383 |
void *xlib_display() const; |
| 384 |
void *createVisualInfoForDefaultVisualId() const; |
| 385 |
#endif |
| 386 |
|
| 387 |
#if defined(XCB_USE_XINPUT2) |
| 388 |
void xi2Select(xcb_window_t window); |
| 389 |
#endif |
| 390 |
#ifdef XCB_USE_XINPUT21 |
| 391 |
bool isAtLeastXI21() const { return m_xi2Enabled && m_xi2Minor >= 1; } |
| 392 |
#else |
| 393 |
bool isAtLeastXI21() const { return false; } |
| 394 |
#endif |
| 395 |
#ifdef XCB_USE_XINPUT22 |
| 396 |
bool isAtLeastXI22() const { return m_xi2Enabled && m_xi2Minor >= 2; } |
| 397 |
#else |
| 398 |
bool isAtLeastXI22() const { return false; } |
| 399 |
#endif |
| 400 |
|
| 401 |
void sync(); |
| 402 |
|
| 403 |
void handleXcbError(xcb_generic_error_t *error); |
| 404 |
void handleXcbEvent(xcb_generic_event_t *event); |
| 405 |
|
| 406 |
void addWindowEventListener(xcb_window_t id, QXcbWindowEventListener *eventListener); |
| 407 |
void removeWindowEventListener(xcb_window_t id); |
| 408 |
QXcbWindowEventListener *windowEventListenerFromId(xcb_window_t id); |
| 409 |
QXcbWindow *platformWindowFromId(xcb_window_t id); |
| 410 |
|
| 411 |
xcb_generic_event_t *checkEvent(int type); |
| 412 |
template<typename T> |
| 413 |
inline xcb_generic_event_t *checkEvent(T &checker); |
| 414 |
|
| 415 |
typedef bool (*PeekFunc)(QXcbConnection *, xcb_generic_event_t *); |
| 416 |
void addPeekFunc(PeekFunc f); |
| 417 |
|
| 418 |
inline xcb_timestamp_t time() const { return m_time; } |
| 419 |
inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; } |
| 420 |
|
| 421 |
inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; } |
| 422 |
inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; } |
| 423 |
|
| 424 |
bool hasXFixes() const { return xfixes_first_event > 0; } |
| 425 |
bool hasXShape() const { return has_shape_extension; } |
| 426 |
bool hasXRandr() const { return has_randr_extension; } |
| 427 |
bool hasInputShape() const { return has_input_shape; } |
| 428 |
bool hasXKB() const { return has_xkb; } |
| 429 |
|
| 430 |
bool supportsThreadedRendering() const { return m_reader->isRunning(); } |
| 431 |
bool threadedEventHandling() const { return m_reader->isRunning(); } |
| 432 |
|
| 433 |
xcb_timestamp_t getTimestamp(); |
| 434 |
xcb_window_t getSelectionOwner(xcb_atom_t atom) const; |
| 435 |
xcb_window_t getQtSelectionOwner(); |
| 436 |
|
| 437 |
void setButton(Qt::MouseButton button, bool down) { if (down) m_buttons |= button; else m_buttons &= ~button; } |
| 438 |
Qt::MouseButtons buttons() const { return m_buttons; } |
| 439 |
Qt::MouseButton translateMouseButton(xcb_button_t s); |
| 440 |
|
| 441 |
QXcbWindow *focusWindow() const { return m_focusWindow; } |
| 442 |
void setFocusWindow(QXcbWindow *); |
| 443 |
QXcbWindow *mouseGrabber() const { return m_mouseGrabber; } |
| 444 |
void setMouseGrabber(QXcbWindow *); |
| 445 |
|
| 446 |
QByteArray startupId() const { return m_startupId; } |
| 447 |
void setStartupId(const QByteArray &nextId) { m_startupId = nextId; } |
| 448 |
void clearStartupId() { m_startupId.clear(); } |
| 449 |
|
| 450 |
void grabServer(); |
| 451 |
void ungrabServer(); |
| 452 |
|
| 453 |
QXcbNativeInterface *nativeInterface() const { return m_nativeInterface; } |
| 454 |
|
| 455 |
QXcbSystemTrayTracker *systemTrayTracker() const; |
| 456 |
static bool xEmbedSystemTrayAvailable(); |
| 457 |
static bool xEmbedSystemTrayVisualHasAlphaChannel(); |
| 458 |
|
| 459 |
#ifdef XCB_USE_XINPUT2 |
| 460 |
void handleEnterEvent(const xcb_enter_notify_event_t *); |
| 461 |
#endif |
| 462 |
|
| 463 |
#ifdef XCB_USE_XINPUT22 |
| 464 |
bool xi2SetMouseGrabEnabled(xcb_window_t w, bool grab); |
| 465 |
#endif |
| 466 |
Qt::MouseButton xiToQtMouseButton(uint32_t b); |
| 467 |
|
| 468 |
QXcbEventReader *eventReader() const { return m_reader; } |
| 469 |
|
| 470 |
bool canGrab() const { return m_canGrabServer; } |
| 471 |
|
| 472 |
QXcbGlIntegration *glIntegration() const { return m_glIntegration; } |
| 473 |
|
| 474 |
bool xi2MouseEvents() const; |
| 475 |
|
| 476 |
protected: |
| 477 |
bool event(QEvent *e) Q_DECL_OVERRIDE; |
| 478 |
|
| 479 |
public slots: |
| 480 |
void flush() { xcb_flush(m_connection); } |
| 481 |
|
| 482 |
private slots: |
| 483 |
void processXcbEvents(); |
| 484 |
|
| 485 |
private: |
| 486 |
void initializeAllAtoms(); |
| 487 |
void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0); |
| 488 |
void initializeXFixes(); |
| 489 |
void initializeXRender(); |
| 490 |
void initializeXRandr(); |
| 491 |
void initializeXinerama(); |
| 492 |
void initializeXShape(); |
| 493 |
void initializeXKB(); |
| 494 |
void handleClientMessageEvent(const xcb_client_message_event_t *event); |
| 495 |
QXcbScreen* findScreenForCrtc(xcb_window_t rootWindow, xcb_randr_crtc_t crtc); |
| 496 |
QXcbScreen* findScreenForOutput(xcb_window_t rootWindow, xcb_randr_output_t output); |
| 497 |
QXcbVirtualDesktop* virtualDesktopForRootWindow(xcb_window_t rootWindow); |
| 498 |
void updateScreens(const xcb_randr_notify_event_t *event); |
| 499 |
bool checkOutputIsPrimary(xcb_window_t rootWindow, xcb_randr_output_t output); |
| 500 |
void updateScreen(QXcbScreen *screen, const xcb_randr_output_change_t &outputChange); |
| 501 |
QXcbScreen *createScreen(QXcbVirtualDesktop *virtualDesktop, |
| 502 |
const xcb_randr_output_change_t &outputChange, |
| 503 |
xcb_randr_get_output_info_reply_t *outputInfo); |
| 504 |
void destroyScreen(QXcbScreen *screen); |
| 505 |
void initializeScreens(); |
| 506 |
bool compressEvent(xcb_generic_event_t *event, int currentIndex, QXcbEventArray *eventqueue) const; |
| 507 |
|
| 508 |
bool m_xi2Enabled; |
| 509 |
int m_xi2Minor; |
| 510 |
#ifdef XCB_USE_XINPUT2 |
| 511 |
void initializeXInput2(); |
| 512 |
void finalizeXInput2(); |
| 513 |
void xi2SetupDevices(); |
| 514 |
XInput2TouchDeviceData *touchDeviceForId(int id); |
| 515 |
void xi2HandleEvent(xcb_ge_event_t *event); |
| 516 |
void xi2HandleHierachyEvent(void *event); |
| 517 |
void xi2HandleDeviceChangedEvent(void *event); |
| 518 |
int m_xiOpCode, m_xiEventBase, m_xiErrorBase; |
| 519 |
#ifdef XCB_USE_XINPUT22 |
| 520 |
void xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindow); |
| 521 |
#endif // XCB_USE_XINPUT22 |
| 522 |
#ifndef QT_NO_TABLETEVENT |
| 523 |
struct TabletData { |
| 524 |
TabletData() : deviceId(0), pointerType(QTabletEvent::UnknownPointer), |
| 525 |
tool(QTabletEvent::Stylus), buttons(0), serialId(0), inProximity(false) { } |
| 526 |
int deviceId; |
| 527 |
QTabletEvent::PointerType pointerType; |
| 528 |
QTabletEvent::TabletDevice tool; |
| 529 |
Qt::MouseButtons buttons; |
| 530 |
qint64 serialId; |
| 531 |
bool inProximity; |
| 532 |
struct ValuatorClassInfo { |
| 533 |
ValuatorClassInfo() : minVal(0.), maxVal(0.), curVal(0.) { } |
| 534 |
double minVal; |
| 535 |
double maxVal; |
| 536 |
double curVal; |
| 537 |
int number; |
| 538 |
}; |
| 539 |
QHash<int, ValuatorClassInfo> valuatorInfo; |
| 540 |
}; |
| 541 |
bool xi2HandleTabletEvent(void *event, TabletData *tabletData, QXcbWindowEventListener *eventListener); |
| 542 |
void xi2ReportTabletEvent(TabletData &tabletData, void *event); |
| 543 |
QVector<TabletData> m_tabletData; |
| 544 |
#endif // !QT_NO_TABLETEVENT |
| 545 |
struct ScrollingDevice { |
| 546 |
ScrollingDevice() : deviceId(0), verticalIndex(0), horizontalIndex(0), orientations(0), legacyOrientations(0) { } |
| 547 |
int deviceId; |
| 548 |
int verticalIndex, horizontalIndex; |
| 549 |
double verticalIncrement, horizontalIncrement; |
| 550 |
Qt::Orientations orientations; |
| 551 |
Qt::Orientations legacyOrientations; |
| 552 |
QPointF lastScrollPosition; |
| 553 |
}; |
| 554 |
void updateScrollingDevice(ScrollingDevice& scrollingDevice, int num_classes, void *classes); |
| 555 |
void xi2HandleScrollEvent(void *event, ScrollingDevice &scrollingDevice); |
| 556 |
QHash<int, ScrollingDevice> m_scrollingDevices; |
| 557 |
|
| 558 |
static bool xi2GetValuatorValueIfSet(void *event, int valuatorNum, double *value); |
| 559 |
static void xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *event); |
| 560 |
#endif |
| 561 |
|
| 562 |
xcb_connection_t *m_connection; |
| 563 |
const xcb_setup_t *m_setup; |
| 564 |
bool m_canGrabServer; |
| 565 |
xcb_visualid_t m_defaultVisualId; |
| 566 |
|
| 567 |
QList<QXcbVirtualDesktop *> m_virtualDesktops; |
| 568 |
QList<QXcbScreen *> m_screens; |
| 569 |
int m_primaryScreenNumber; |
| 570 |
|
| 571 |
xcb_atom_t m_allAtoms[QXcbAtom::NAtoms]; |
| 572 |
|
| 573 |
xcb_timestamp_t m_time; |
| 574 |
xcb_timestamp_t m_netWmUserTime; |
| 575 |
|
| 576 |
QByteArray m_displayName; |
| 577 |
|
| 578 |
QXcbKeyboard *m_keyboard; |
| 579 |
#ifndef QT_NO_CLIPBOARD |
| 580 |
QXcbClipboard *m_clipboard; |
| 581 |
#endif |
| 582 |
#ifndef QT_NO_DRAGANDDROP |
| 583 |
QXcbDrag *m_drag; |
| 584 |
#endif |
| 585 |
QScopedPointer<QXcbWMSupport> m_wmSupport; |
| 586 |
QXcbNativeInterface *m_nativeInterface; |
| 587 |
|
| 588 |
#if defined(XCB_USE_XLIB) |
| 589 |
void *m_xlib_display; |
| 590 |
#endif |
| 591 |
QXcbEventReader *m_reader; |
| 592 |
#if defined(XCB_USE_XINPUT2) |
| 593 |
QHash<int, XInput2TouchDeviceData*> m_touchDevices; |
| 594 |
#endif |
| 595 |
#ifdef Q_XCB_DEBUG |
| 596 |
struct CallInfo { |
| 597 |
int sequence; |
| 598 |
QByteArray file; |
| 599 |
int line; |
| 600 |
}; |
| 601 |
QVector<CallInfo> m_callLog; |
| 602 |
QMutex m_callLogMutex; |
| 603 |
void log(const char *file, int line, int sequence); |
| 604 |
template <typename cookie_t> |
| 605 |
friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); |
| 606 |
#endif |
| 607 |
|
| 608 |
WindowMapper m_mapper; |
| 609 |
|
| 610 |
QVector<PeekFunc> m_peekFuncs; |
| 611 |
|
| 612 |
uint32_t xfixes_first_event; |
| 613 |
uint32_t xrandr_first_event; |
| 614 |
uint32_t xkb_first_event; |
| 615 |
|
| 616 |
bool has_xinerama_extension; |
| 617 |
bool has_shape_extension; |
| 618 |
bool has_randr_extension; |
| 619 |
bool has_input_shape; |
| 620 |
bool has_xkb; |
| 621 |
|
| 622 |
Qt::MouseButtons m_buttons; |
| 623 |
|
| 624 |
QXcbWindow *m_focusWindow; |
| 625 |
QXcbWindow *m_mouseGrabber; |
| 626 |
|
| 627 |
xcb_window_t m_clientLeader; |
| 628 |
QByteArray m_startupId; |
| 629 |
QXcbSystemTrayTracker *m_systemTrayTracker; |
| 630 |
QXcbGlIntegration *m_glIntegration; |
| 631 |
bool m_xiGrab; |
| 632 |
|
| 633 |
xcb_window_t m_qtSelectionOwner; |
| 634 |
|
| 635 |
friend class QXcbEventReader; |
| 636 |
}; |
| 637 |
|
| 638 |
#define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display())) |
| 639 |
#define CREATE_VISUALINFO_FROM_DEFAULT_VISUALID(object) ((XVisualInfo *)(object->connection()->createVisualInfoForDefaultVisualId())) |
| 640 |
|
| 641 |
template<typename T> |
| 642 |
xcb_generic_event_t *QXcbConnection::checkEvent(T &checker) |
| 643 |
{ |
| 644 |
QXcbEventArray *eventqueue = m_reader->lock(); |
| 645 |
|
| 646 |
for (int i = 0; i < eventqueue->size(); ++i) { |
| 647 |
xcb_generic_event_t *event = eventqueue->at(i); |
| 648 |
if (checker.checkEvent(event)) { |
| 649 |
(*eventqueue)[i] = 0; |
| 650 |
m_reader->unlock(); |
| 651 |
return event; |
| 652 |
} |
| 653 |
} |
| 654 |
m_reader->unlock(); |
| 655 |
return 0; |
| 656 |
} |
| 657 |
|
| 658 |
class QXcbConnectionGrabber |
| 659 |
{ |
| 660 |
public: |
| 661 |
QXcbConnectionGrabber(QXcbConnection *connection); |
| 662 |
~QXcbConnectionGrabber(); |
| 663 |
void release(); |
| 664 |
private: |
| 665 |
QXcbConnection *m_connection; |
| 666 |
}; |
| 667 |
|
| 668 |
#ifdef Q_XCB_DEBUG |
| 669 |
template <typename cookie_t> |
| 670 |
cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line) |
| 671 |
{ |
| 672 |
connection->log(file, line, cookie.sequence); |
| 673 |
return cookie; |
| 674 |
} |
| 675 |
#define Q_XCB_CALL(x) q_xcb_call_template(x, connection(), __FILE__, __LINE__) |
| 676 |
#define Q_XCB_CALL2(x, connection) q_xcb_call_template(x, connection, __FILE__, __LINE__) |
| 677 |
#define Q_XCB_NOOP(c) q_xcb_call_template(xcb_no_operation(c->xcb_connection()), c, __FILE__, __LINE__); |
| 678 |
#else |
| 679 |
#define Q_XCB_CALL(x) x |
| 680 |
#define Q_XCB_CALL2(x, connection) x |
| 681 |
#define Q_XCB_NOOP(c) (void)c; |
| 682 |
#endif |
| 683 |
|
| 684 |
QT_END_NAMESPACE |
| 685 |
|
| 686 |
#endif |