MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / click

Function click

Service/InputDeviceXLib.cpp:116–149  ·  view source on GitHub ↗

Simulate mouse click

Source from the content-addressed store, hash-verified

114
115// Simulate mouse click
116void click(Display *display, int button, bool press)
117{
118#ifdef HAVE_XTEST
119 XTestFakeButtonEvent(display, button, press, CurrentTime);
120#else
121 // Create and setting up the event
122 XEvent event;
123 memset (&event, 0, sizeof (event));
124 event.xbutton.button = button;
125 event.xbutton.same_screen = True;
126 event.xbutton.subwindow = DefaultRootWindow (display);
127 while (event.xbutton.subwindow)
128 {
129 event.xbutton.window = event.xbutton.subwindow;
130 XQueryPointer (display, event.xbutton.window,
131 &event.xbutton.root, &event.xbutton.subwindow,
132 &event.xbutton.x_root, &event.xbutton.y_root,
133 &event.xbutton.x, &event.xbutton.y,
134 &event.xbutton.state);
135 }
136 // Press
137 if(press)
138 {
139 event.type = ButtonPress;
140 if (XSendEvent (display, PointerWindow, True, ButtonPressMask, &event) == 0)
141 fprintf (stderr, "Error to send the event!\n");
142 } else {
143 if (XSendEvent (display, PointerWindow, True, ButtonReleaseMask, &event) == 0)
144 fprintf (stderr, "Error to send the event!\n");
145 XFlush (display);
146 }
147 XFlush (display);
148#endif
149}
150
151// Get mouse coordinates
152void coords (Display *display, int *x, int *y)

Callers 1

MouseEventMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected