Debian Codegraph @

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