Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.7.0/qxcbconnection.h

raw
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 AbsMTOrientation,
236 AbsMTPressure,
237 AbsMTTrackingID,
238 MaxContacts,
239 RelX,
240 RelY,
241 // XInput2 tablet
242 AbsX,
243 AbsY,
244 AbsPressure,
245 AbsTiltX,
246 AbsTiltY,
247 AbsWheel,
248 AbsDistance,
249 WacomSerialIDs,
250 INTEGER,
251 RelHorizWheel,
252 RelVertWheel,
253 RelHorizScroll,
254 RelVertScroll,
255
256 _XSETTINGS_SETTINGS,
257
258 _COMPIZ_DECOR_PENDING,
259 _COMPIZ_DECOR_REQUEST,
260 _COMPIZ_DECOR_DELETE_PIXMAP,
261 _COMPIZ_TOOLKIT_ACTION,
262 _GTK_LOAD_ICONTHEMES,
263
264 NPredefinedAtoms,
265
266 _QT_SETTINGS_TIMESTAMP = NPredefinedAtoms,
267 NAtoms
268 };
269 }
270
271 typedef QVarLengthArray<xcb_generic_event_t *, 64> QXcbEventArray;
272
273 class QXcbConnection;
274 class QXcbEventReader : public QThread
275 {
276 Q_OBJECT
277 public:
278 QXcbEventReader(QXcbConnection *connection);
279
280 void run() Q_DECL_OVERRIDE;
281
282 QXcbEventArray *lock();
283 void unlock();
284
285 void start();
286
287 void registerEventDispatcher(QAbstractEventDispatcher *dispatcher);
288
289 signals:
290 void eventPending();
291
292 private slots:
293 void registerForEvents();
294
295 private:
296 void addEvent(xcb_generic_event_t *event);
297
298 QMutex m_mutex;
299 QXcbEventArray m_events;
300 QXcbConnection *m_connection;
301 };
302
303 class QXcbWindowEventListener
304 {
305 public:
306 virtual ~QXcbWindowEventListener() {}
307 virtual bool handleGenericEvent(xcb_generic_event_t *, long *) { return false; }
308
309 virtual void handleExposeEvent(const xcb_expose_event_t *) {}
310 virtual void handleClientMessageEvent(const xcb_client_message_event_t *) {}
311 virtual void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *) {}
312 virtual void handleMapNotifyEvent(const xcb_map_notify_event_t *) {}
313 virtual void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *) {}
314 virtual void handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *) {}
315 virtual void handleButtonPressEvent(const xcb_button_press_event_t *) {}
316 virtual void handleButtonReleaseEvent(const xcb_button_release_event_t *) {}
317 virtual void handleMotionNotifyEvent(const xcb_motion_notify_event_t *) {}
318 virtual void handleEnterNotifyEvent(const xcb_enter_notify_event_t *) {}
319 virtual void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *) {}
320 virtual void handleFocusInEvent(const xcb_focus_in_event_t *) {}
321 virtual void handleFocusOutEvent(const xcb_focus_out_event_t *) {}
322 virtual void handlePropertyNotifyEvent(const xcb_property_notify_event_t *) {}
323 #ifdef XCB_USE_XINPUT22
324 virtual void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource = Qt::MouseEventNotSynthesized) {}
325 virtual void handleXIEnterLeave(xcb_ge_event_t *) {}
326 #endif
327 virtual QXcbWindow *toWindow() { return 0; }
328 };
329
330 typedef QHash<xcb_window_t, QXcbWindowEventListener *> WindowMapper;
331
332 class QXcbSyncWindowRequest : public QEvent
333 {
334 public:
335 QXcbSyncWindowRequest(QXcbWindow *w) : QEvent(QEvent::Type(QEvent::User + 1)), m_window(w) { }
336
337 QXcbWindow *window() const { return m_window; }
338 void invalidate();
339
340 private:
341 QXcbWindow *m_window;
342 };
343
344 class QAbstractEventDispatcher;
345 class Q_XCB_EXPORT QXcbConnection : public QObject
346 {
347 Q_OBJECT
348 public:
349 QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName = 0);
350 ~QXcbConnection();
351
352 QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); }
353
354 const QList<QXcbVirtualDesktop *> &virtualDesktops() const { return m_virtualDesktops; }
355 const QList<QXcbScreen *> &screens() const { return m_screens; }
356 int primaryScreenNumber() const { return m_primaryScreenNumber; }
357 QXcbVirtualDesktop *primaryVirtualDesktop() const { return m_virtualDesktops.value(m_primaryScreenNumber); }
358 QXcbScreen *primaryScreen() const;
359
360 inline xcb_atom_t atom(QXcbAtom::Atom atom) const { return m_allAtoms[atom]; }
361 QXcbAtom::Atom qatom(xcb_atom_t atom) const;
362 xcb_atom_t internAtom(const char *name);
363 QByteArray atomName(xcb_atom_t atom);
364
365 const char *displayName() const { return m_displayName.constData(); }
366 xcb_connection_t *xcb_connection() const { return m_connection; }
367 const xcb_setup_t *setup() const { return m_setup; }
368 const xcb_format_t *formatForDepth(uint8_t depth) const;
369
370 QXcbKeyboard *keyboard() const { return m_keyboard; }
371
372 #ifndef QT_NO_CLIPBOARD
373 QXcbClipboard *clipboard() const { return m_clipboard; }
374 #endif
375 #ifndef QT_NO_DRAGANDDROP
376 QXcbDrag *drag() const { return m_drag; }
377 #endif
378
379 QXcbWMSupport *wmSupport() const { return m_wmSupport.data(); }
380 xcb_window_t rootWindow();
381 xcb_window_t clientLeader();
382
383 bool hasDefaultVisualId() const { return m_defaultVisualId != UINT_MAX; }
384 xcb_visualid_t defaultVisualId() const { return m_defaultVisualId; }
385
386 #ifdef XCB_USE_XLIB
387 void *xlib_display() const;
388 void *createVisualInfoForDefaultVisualId() const;
389 #endif
390
391 #if defined(XCB_USE_XINPUT2)
392 void xi2Select(xcb_window_t window);
393 #endif
394 #ifdef XCB_USE_XINPUT21
395 bool isAtLeastXI21() const { return m_xi2Enabled && m_xi2Minor >= 1; }
396 #else
397 bool isAtLeastXI21() const { return false; }
398 #endif
399 #ifdef XCB_USE_XINPUT22
400 bool isAtLeastXI22() const { return m_xi2Enabled && m_xi2Minor >= 2; }
401 #else
402 bool isAtLeastXI22() const { return false; }
403 #endif
404
405 void sync();
406
407 void handleXcbError(xcb_generic_error_t *error);
408 void handleXcbEvent(xcb_generic_event_t *event);
409
410 void addWindowEventListener(xcb_window_t id, QXcbWindowEventListener *eventListener);
411 void removeWindowEventListener(xcb_window_t id);
412 QXcbWindowEventListener *windowEventListenerFromId(xcb_window_t id);
413 QXcbWindow *platformWindowFromId(xcb_window_t id);
414
415 xcb_generic_event_t *checkEvent(int type);
416 template<typename T>
417 inline xcb_generic_event_t *checkEvent(T &checker);
418
419 typedef bool (*PeekFunc)(QXcbConnection *, xcb_generic_event_t *);
420 void addPeekFunc(PeekFunc f);
421
422 inline xcb_timestamp_t time() const { return m_time; }
423 inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; }
424
425 inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; }
426 inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; }
427
428 bool hasXFixes() const { return xfixes_first_event > 0; }
429 bool hasXShape() const { return has_shape_extension; }
430 bool hasXRandr() const { return has_randr_extension; }
431 bool hasInputShape() const { return has_input_shape; }
432 bool hasXKB() const { return has_xkb; }
433
434 bool supportsThreadedRendering() const { return m_reader->isRunning(); }
435 bool threadedEventHandling() const { return m_reader->isRunning(); }
436
437 xcb_timestamp_t getTimestamp();
438 xcb_window_t getSelectionOwner(xcb_atom_t atom) const;
439 xcb_window_t getQtSelectionOwner();
440
441 void setButton(Qt::MouseButton button, bool down) { m_buttons.setFlag(button, down); }
442 Qt::MouseButtons buttons() const { return m_buttons; }
443 Qt::MouseButton translateMouseButton(xcb_button_t s);
444
445 QXcbWindow *focusWindow() const { return m_focusWindow; }
446 void setFocusWindow(QXcbWindow *);
447 QXcbWindow *mouseGrabber() const { return m_mouseGrabber; }
448 void setMouseGrabber(QXcbWindow *);
449 QXcbWindow *mousePressWindow() const { return m_mousePressWindow; }
450 void setMousePressWindow(QXcbWindow *);
451
452 QByteArray startupId() const { return m_startupId; }
453 void setStartupId(const QByteArray &nextId) { m_startupId = nextId; }
454 void clearStartupId() { m_startupId.clear(); }
455
456 void grabServer();
457 void ungrabServer();
458
459 QXcbNativeInterface *nativeInterface() const { return m_nativeInterface; }
460
461 QXcbSystemTrayTracker *systemTrayTracker() const;
462 static bool xEmbedSystemTrayAvailable();
463 static bool xEmbedSystemTrayVisualHasAlphaChannel();
464
465 #ifdef XCB_USE_XINPUT21
466 void handleEnterEvent();
467 #endif
468
469 #ifdef XCB_USE_XINPUT22
470 bool xi2SetMouseGrabEnabled(xcb_window_t w, bool grab);
471 #endif
472 Qt::MouseButton xiToQtMouseButton(uint32_t b);
473
474 QXcbEventReader *eventReader() const { return m_reader; }
475
476 bool canGrab() const { return m_canGrabServer; }
477
478 QXcbGlIntegration *glIntegration() const { return m_glIntegration; }
479
480 #ifdef XCB_USE_XINPUT22
481 bool xi2MouseEvents() const;
482 #endif
483
484 protected:
485 bool event(QEvent *e) Q_DECL_OVERRIDE;
486
487 public slots:
488 void flush() { xcb_flush(m_connection); }
489
490 private slots:
491 void processXcbEvents();
492
493 private:
494 void initializeAllAtoms();
495 void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0);
496 void initializeXFixes();
497 void initializeXRender();
498 void initializeXRandr();
499 void initializeXinerama();
500 void initializeXShape();
501 void initializeXKB();
502 void handleClientMessageEvent(const xcb_client_message_event_t *event);
503 QXcbScreen* findScreenForCrtc(xcb_window_t rootWindow, xcb_randr_crtc_t crtc) const;
504 QXcbScreen* findScreenForOutput(xcb_window_t rootWindow, xcb_randr_output_t output) const;
505 QXcbVirtualDesktop* virtualDesktopForRootWindow(xcb_window_t rootWindow) const;
506 void updateScreens(const xcb_randr_notify_event_t *event);
507 bool checkOutputIsPrimary(xcb_window_t rootWindow, xcb_randr_output_t output);
508 void updateScreen(QXcbScreen *screen, const xcb_randr_output_change_t &outputChange);
509 QXcbScreen *createScreen(QXcbVirtualDesktop *virtualDesktop,
510 const xcb_randr_output_change_t &outputChange,
511 xcb_randr_get_output_info_reply_t *outputInfo);
512 void destroyScreen(QXcbScreen *screen);
513 void initializeScreens();
514 bool compressEvent(xcb_generic_event_t *event, int currentIndex, QXcbEventArray *eventqueue) const;
515
516 #ifdef XCB_USE_XINPUT2
517 bool m_xi2Enabled;
518 int m_xi2Minor;
519 void initializeXInput2();
520 void finalizeXInput2();
521 void xi2SetupDevices();
522 XInput2TouchDeviceData *touchDeviceForId(int id);
523 void xi2HandleEvent(xcb_ge_event_t *event);
524 void xi2HandleHierachyEvent(void *event);
525 void xi2HandleDeviceChangedEvent(void *event);
526 int m_xiOpCode, m_xiEventBase, m_xiErrorBase;
527 #ifdef XCB_USE_XINPUT22
528 void xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindow);
529 #endif // XCB_USE_XINPUT22
530 #ifndef QT_NO_TABLETEVENT
531 struct TabletData {
532 TabletData() : deviceId(0), pointerType(QTabletEvent::UnknownPointer),
533 tool(QTabletEvent::Stylus), buttons(0), serialId(0), inProximity(false) { }
534 int deviceId;
535 QTabletEvent::PointerType pointerType;
536 QTabletEvent::TabletDevice tool;
537 Qt::MouseButtons buttons;
538 qint64 serialId;
539 bool inProximity;
540 struct ValuatorClassInfo {
541 ValuatorClassInfo() : minVal(0.), maxVal(0.), curVal(0.) { }
542 double minVal;
543 double maxVal;
544 double curVal;
545 int number;
546 };
547 QHash<int, ValuatorClassInfo> valuatorInfo;
548 };
549 bool xi2HandleTabletEvent(const void *event, TabletData *tabletData);
550 void xi2ReportTabletEvent(const void *event, TabletData *tabletData);
551 QVector<TabletData> m_tabletData;
552 TabletData *tabletDataForDevice(int id);
553 #endif // !QT_NO_TABLETEVENT
554 struct ScrollingDevice {
555 ScrollingDevice() : deviceId(0), verticalIndex(0), horizontalIndex(0), orientations(0), legacyOrientations(0) { }
556 int deviceId;
557 int verticalIndex, horizontalIndex;
558 double verticalIncrement, horizontalIncrement;
559 Qt::Orientations orientations;
560 Qt::Orientations legacyOrientations;
561 QPointF lastScrollPosition;
562 };
563 void updateScrollingDevice(ScrollingDevice& scrollingDevice, int num_classes, void *classes);
564 void xi2HandleScrollEvent(void *event, ScrollingDevice &scrollingDevice);
565 QHash<int, ScrollingDevice> m_scrollingDevices;
566
567 static bool xi2GetValuatorValueIfSet(const void *event, int valuatorNum, double *value);
568 static void xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *event);
569 #endif
570
571 xcb_connection_t *m_connection;
572 const xcb_setup_t *m_setup;
573 bool m_canGrabServer;
574 xcb_visualid_t m_defaultVisualId;
575
576 QList<QXcbVirtualDesktop *> m_virtualDesktops;
577 QList<QXcbScreen *> m_screens;
578 int m_primaryScreenNumber;
579
580 xcb_atom_t m_allAtoms[QXcbAtom::NAtoms];
581
582 xcb_timestamp_t m_time;
583 xcb_timestamp_t m_netWmUserTime;
584
585 QByteArray m_displayName;
586
587 QXcbKeyboard *m_keyboard;
588 #ifndef QT_NO_CLIPBOARD
589 QXcbClipboard *m_clipboard;
590 #endif
591 #ifndef QT_NO_DRAGANDDROP
592 QXcbDrag *m_drag;
593 #endif
594 QScopedPointer<QXcbWMSupport> m_wmSupport;
595 QXcbNativeInterface *m_nativeInterface;
596
597 #if defined(XCB_USE_XLIB)
598 void *m_xlib_display;
599 #endif
600 QXcbEventReader *m_reader;
601 #if defined(XCB_USE_XINPUT2)
602 QHash<int, XInput2TouchDeviceData*> m_touchDevices;
603 #endif
604 #ifdef Q_XCB_DEBUG
605 struct CallInfo {
606 int sequence;
607 QByteArray file;
608 int line;
609 };
610 QVector<CallInfo> m_callLog;
611 QMutex m_callLogMutex;
612 void log(const char *file, int line, int sequence);
613 template <typename cookie_t>
614 friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection,
615 const char *file, int line);
616 template <typename reply_t>
617 friend reply_t *q_xcb_call_template(reply_t *reply, QXcbConnection *connection,
618 const char *file, int line);
619 #endif
620
621 WindowMapper m_mapper;
622
623 QVector<PeekFunc> m_peekFuncs;
624
625 uint32_t xfixes_first_event;
626 uint32_t xrandr_first_event;
627 uint32_t xkb_first_event;
628
629 bool has_xinerama_extension;
630 bool has_shape_extension;
631 bool has_randr_extension;
632 bool has_input_shape;
633 bool has_xkb;
634
635 Qt::MouseButtons m_buttons;
636
637 QXcbWindow *m_focusWindow;
638 QXcbWindow *m_mouseGrabber;
639 QXcbWindow *m_mousePressWindow;
640
641 xcb_window_t m_clientLeader;
642 QByteArray m_startupId;
643 QXcbSystemTrayTracker *m_systemTrayTracker;
644 QXcbGlIntegration *m_glIntegration;
645 bool m_xiGrab;
646
647 xcb_window_t m_qtSelectionOwner;
648
649 friend class QXcbEventReader;
650 };
651
652 #define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display()))
653 #define CREATE_VISUALINFO_FROM_DEFAULT_VISUALID(object) ((XVisualInfo *)(object->connection()->createVisualInfoForDefaultVisualId()))
654
655 template<typename T>
656 xcb_generic_event_t *QXcbConnection::checkEvent(T &checker)
657 {
658 QXcbEventArray *eventqueue = m_reader->lock();
659
660 for (int i = 0; i < eventqueue->size(); ++i) {
661 xcb_generic_event_t *event = eventqueue->at(i);
662 if (checker.checkEvent(event)) {
663 (*eventqueue)[i] = 0;
664 m_reader->unlock();
665 return event;
666 }
667 }
668 m_reader->unlock();
669 return 0;
670 }
671
672 class QXcbConnectionGrabber
673 {
674 public:
675 QXcbConnectionGrabber(QXcbConnection *connection);
676 ~QXcbConnectionGrabber();
677 void release();
678 private:
679 QXcbConnection *m_connection;
680 };
681
682 #ifdef Q_XCB_DEBUG
683 template <typename cookie_t>
684 cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file,
685 int line)
686 {
687 connection->log(file, line, cookie.sequence);
688 return cookie;
689 }
690
691 template <typename reply_t>
692 reply_t *q_xcb_call_template(reply_t *reply, QXcbConnection *connection, const char *file, int line)
693 {
694 connection->log(file, line, reply->sequence);
695 return reply;
696 }
697 #define Q_XCB_CALL(x) q_xcb_call_template(x, connection(), __FILE__, __LINE__)
698 #define Q_XCB_CALL2(x, connection) q_xcb_call_template(x, connection, __FILE__, __LINE__)
699 #define Q_XCB_NOOP(c) q_xcb_call_template(xcb_no_operation(c->xcb_connection()), c, __FILE__, __LINE__);
700 #else
701 #define Q_XCB_CALL(x) x
702 #define Q_XCB_CALL2(x, connection) x
703 #define Q_XCB_NOOP(c) (void)c;
704 #endif
705
706 QT_END_NAMESPACE
707
708 #endif