| 190 | //} |
| 191 | |
| 192 | int 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 | |
| 244 | int CInputDeviceXLib::MouseEvent(MouseButtons buttons, int x, int y) |
| 245 | { |
no test coverage detected