bool MouseDevice::releaseButton(Button button) { mPressedButtons[button] = false; #ifdef Q_WS_X11 if(!XTestFakeButtonEvent(QX11Info::display(), toX11Button(button), False, CurrentTime)) return false; XFlush(QX11Info::display()); #endif #ifdef Q_WS_WIN INPUT input; input.type = INPUT_MOUSE; input.mi.dx = 0; input.mi.dy = 0; input.mi.mouseData = 0; input.mi.dwFlags = toWinButton(button, false); input.mi.time = 0; if(!SendInput(1, &input, sizeof(INPUT))) return false; #endif return true; }
bool MouseDevice::pressButton(Button button) { mPressedButtons[button] = true; #ifdef Q_OS_LINUX if(!XTestFakeButtonEvent(QX11Info::display(), toX11Button(button), True, CurrentTime)) return false; XFlush(QX11Info::display()); #endif #ifdef Q_OS_WIN INPUT input; SecureZeroMemory(&input, sizeof(INPUT)); input.type = INPUT_MOUSE; input.mi.dwFlags = toWinButton(button, true); if(!SendInput(1, &input, sizeof(INPUT))) return false; #endif return true; }