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

Function XGrabPointer

src/library/inputs/xpointer.cpp:68–105  ·  view source on GitHub ↗

Override */

Source from the content-addressed store, hash-verified

66}
67
68/* Override */ int XGrabPointer(Display* display, Window w, Bool owner_events, unsigned int event_mask, int, int,
69 Window confine_to, Cursor, Time)
70{
71 LOGTRACE(LCF_MOUSE);
72
73 pointer_grab_window = w;
74 std::shared_ptr<XlibEventQueue> queue = xlibEventQueueList.getQueue(display);
75 queue->grabPointer(pointer_grab_window, event_mask, owner_events);
76
77 if (confine_to != None) {
78 XWindowAttributes clip_attr;
79 NATIVECALL(MYASSERT(XGetWindowAttributes(display, confine_to, &clip_attr) != 0));
80 Inputs::pointer_clipping = true;
81 Inputs::clipping_x = clip_attr.x;
82 Inputs::clipping_y = clip_attr.y;
83 Inputs::clipping_w = clip_attr.width;
84 Inputs::clipping_h = clip_attr.height;
85
86 if (Inputs::game_ai.pointer.x < Inputs::clipping_x) {
87 LOG(LL_DEBUG, LCF_MOUSE, " warping pointer x from %d to %d", Inputs::game_ai.pointer.x, Inputs::clipping_x);
88 Inputs::game_ai.pointer.x = Inputs::clipping_x;
89 }
90 else if (Inputs::game_ai.pointer.x >= (Inputs::clipping_x + Inputs::clipping_w)) {
91 LOG(LL_DEBUG, LCF_MOUSE, " warping pointer x from %d to %d", Inputs::game_ai.pointer.x, Inputs::clipping_x + Inputs::clipping_w - 1);
92 Inputs::game_ai.pointer.x = Inputs::clipping_x + Inputs::clipping_w - 1;
93 }
94
95 if (Inputs::game_ai.pointer.y < Inputs::clipping_y) {
96 LOG(LL_DEBUG, LCF_MOUSE, " warping pointer y from %d to %d", Inputs::game_ai.pointer.y, Inputs::clipping_y);
97 Inputs::game_ai.pointer.y = Inputs::clipping_y;
98 }
99 else if (Inputs::game_ai.pointer.y >= (Inputs::clipping_y + Inputs::clipping_h)) {
100 LOG(LL_DEBUG, LCF_MOUSE, " warping pointer y from %d to %d", Inputs::game_ai.pointer.y, Inputs::clipping_y + Inputs::clipping_h - 1);
101 Inputs::game_ai.pointer.y = Inputs::clipping_y + Inputs::clipping_h - 1;
102 }
103 }
104 return GrabSuccess;
105}
106
107/* Override */ int XUngrabPointer(Display* display, Time)
108{

Callers

nothing calls this directly

Calls 3

XGetWindowAttributesFunction · 0.85
grabPointerMethod · 0.80
getQueueMethod · 0.45

Tested by

no test coverage detected