MCPcopy Create free account
hub / github.com/clementgallet/libTAS / insert

Method insert

src/library/xlib/XlibEventQueue.cpp:71–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69#define EVENTQUEUE_MAXLEN 1024
70
71int XlibEventQueue::insert(XEvent* event)
72{
73 std::lock_guard<std::recursive_mutex> lock(mutex);
74
75 /* Check if pointer event and pointer is grabbed */
76 if ((grab_window != 0) &&
77 ((event->type == MotionNotify) || (event->type == ButtonPress) ||
78 (event->type == ButtonRelease) || (event->type == EnterNotify) ||
79 (event->type == LeaveNotify) || (event->type == KeymapNotify))) {
80
81 /* Check grab mask */
82 if (isTypeOfMask(event->type, grab_event_mask)) {
83 /* Register event to the grab window */
84 event->xany.window = grab_window;
85
86 /* Check the size of the queue */
87 if (eventQueue.size() > 1024) {
88 LOG(LL_DEBUG, LCF_EVENTS, "We reached the limit of the event queue size!");
89 return -1;
90 }
91
92 /* Specify the display */
93 event->xany.display = display;
94
95 /* Push the event at the beginning of the queue */
96 eventQueue.push_front(*event);
97
98 /* If grab was set with owner_events being False, only report to
99 * the grab window, or discard */
100 if (!grab_owner_events)
101 return 1;
102 }
103 else {
104 if (!grab_owner_events)
105 return 0;
106 }
107 }
108
109 /* Check if the window can produce such event */
110
111 /* We are supposed to check if the parent window has SubstructureNotifyMask
112 * so that current window can receive ConfigureNotify events, but I'm lazy,
113 * so we are always returning those events */
114
115 if (event->type != ConfigureNotify) {
116 auto mask = eventMasks.find(event->xany.window);
117 if (mask != eventMasks.end()) {
118 if (!isTypeOfMask(event->type, mask->second))
119 return 0;
120 }
121 else {
122 /* Check unmaskable events */
123 if (!isTypeOfMask(event->type, 0))
124 return 0;
125 }
126 }
127
128 /* Check the size of the queue */

Callers 1

pushNativeXlibEventsFunction · 0.45

Calls 3

sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected