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

Method MouseEvent

Service/InputDeviceXLib.cpp:192–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190//}
191
192int CInputDeviceXLib::MouseEvent(MouseButtons buttons, QPoint pos)
193{
194 Display *display = XOpenDisplay(NULL);
195 if(display == NULL)
196 {
197 qCritical(LogInput) << "Open display fail";
198 return -1;
199 }
200 Window root = DefaultRootWindow(display);
201
202 // - Has the pointer moved since the last event?
203 if (m_LastPostion != pos)
204#ifdef HAVE_XTEST
205 XTestFakeMotionEvent(display, DefaultScreen(display),
206 pos.x(),
207 pos.y(),
208 CurrentTime);
209#else
210 XWarpPointer (display, root, root, 0, 0, 0, 0, pos.x(), pos.y());
211#endif
212
213 // Check the left button on change state
214 if((m_LastButtons & LeftButton) != (LeftButton & buttons))
215 {
216 if(buttons & LeftButton)
217 click(display, Button1, true);
218 else
219 click(display, Button1, false);
220 }
221
222 // Check the middle button on change state
223 if((m_LastButtons & MiddleButton) != (MiddleButton & buttons))
224 {
225 if(buttons & MiddleButton)
226 click(display, Button2, true);
227 else
228 click(display, Button2, false);
229 }
230
231 // Check the right button on change state
232 if((m_LastButtons & RightButton) != (RightButton & buttons))
233 {
234 if(buttons & RightButton)
235 click(display, Button3, true);
236 else
237 click(display, Button3, false);
238 }
239 m_LastButtons = buttons;
240 XCloseDisplay(display);
241 return 0;
242}
243
244int CInputDeviceXLib::MouseEvent(MouseButtons buttons, int x, int y)
245{

Callers 2

pointerEventMethod · 0.45
pointerEventMethod · 0.45

Calls 1

clickFunction · 0.85

Tested by

no test coverage detected