return;
}
//kDebug(5011) << "got update" << width() << height();
+
+ /*
static unsigned int frames = 0;
static unsigned int updates = 0;
static QTime time = QTime::currentTime();
if(frames % 100 == 0)
kDebug(5011) << "f/s: " << frames/double(time.elapsed()) * 1000.0;
}
+*/
m_x = x;
m_y = y;
//draw local cursor ourselves, normal mouse pointer doesn't deal with scrolling
if((m_dotCursorState == CursorOn) || m_forceLocalCursor) {
- const uchar bits[] = { 0xff, 0x8e, 0x8e, 0x8e, 0xff };
- const bool little_endian = (Q_BYTE_ORDER == Q_LITTLE_ENDIAN);
- const QBitmap cursorBitmap = QBitmap::fromData(QSize(5,5), bits , little_endian?QImage::Format_Mono:QImage::Format_MonoLSB);
-
+#if QT_VERSION >= 0x040500
painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
- painter.drawPixmap(cursor_x-2, cursor_y-2, cursorBitmap);
- //TODO update position of last cursor_x/y to avoid artifacts
+#endif
+ //rectangle size is 5px = 4px + 1px pen width
+ painter.drawRect(cursor_x*m_horizontalFactor - 2, cursor_y*m_verticalFactor - 2, 4, 4);
}
RemoteView::paintEvent(event);
cursor_y = qRound(e->y()/m_verticalFactor);
vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask); // plain move event
- if(disable_tapping) { //only move cursor
- e->ignore();
- return;
- }
-
- if(e->type() == QEvent::MouseButtonPress or e->type() == QEvent::MouseButtonDblClick) {
- press_time.start();
- if(tap_detected and up_time.elapsed() < DOUBLE_TAP_UP_TIME) {
- tap_detected = false;
- double_tap_detected = true;
+ if(!disable_tapping and e->button() == Qt::LeftButton) { //implement touchpad-like input for left button
+ if(e->type() == QEvent::MouseButtonPress or e->type() == QEvent::MouseButtonDblClick) {
+ press_time.start();
+ if(tap_detected and up_time.elapsed() < DOUBLE_TAP_UP_TIME) {
+ tap_detected = false;
+ double_tap_detected = true;
+
+ QTimer::singleShot(TAP_PRESS_TIME, this, SLOT(mouseEventHandler()));
+ }
+ } else if(e->type() == QEvent::MouseButtonRelease) {
+ if(tap_drag_detected) {
+ m_buttonMask &= 0xfe;
+ vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+ tap_drag_detected = false;
+ } else if(double_tap_detected) { //double click
+ double_tap_detected = false;
+
+ m_buttonMask |= 0x01;
+ vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+ m_buttonMask &= 0xfe;
+ vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+ m_buttonMask |= 0x01;
+ vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+ m_buttonMask &= 0xfe;
+ vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+ } else if(press_time.elapsed() < TAP_PRESS_TIME) { //tap
+ up_time.start();
+ tap_detected = true;
+ QTimer::singleShot(DOUBLE_TAP_UP_TIME, this, SLOT(mouseEventHandler()));
+ }
- QTimer::singleShot(TAP_PRESS_TIME, this, SLOT(mouseEventHandler()));
}
- } else if(e->type() == QEvent::MouseButtonRelease) {
- if(tap_drag_detected) {
- m_buttonMask &= 0xfe;
- vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
- tap_drag_detected = false;
- } else if(double_tap_detected) { //double click
- double_tap_detected = false;
-
- m_buttonMask |= 0x01;
- vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
- m_buttonMask &= 0xfe;
- vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
- m_buttonMask |= 0x01;
- vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
- m_buttonMask &= 0xfe;
- vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
- } else if(press_time.elapsed() < TAP_PRESS_TIME) { //tap
- up_time.start();
- tap_detected = true;
- QTimer::singleShot(DOUBLE_TAP_UP_TIME, this, SLOT(mouseEventHandler()));
+ } else { //middle or right button, send directly
+ if ((e->type() == QEvent::MouseButtonPress)) {
+ if (e->button() & Qt::MidButton)
+ m_buttonMask |= 0x02;
+ if (e->button() & Qt::RightButton)
+ m_buttonMask |= 0x04;
+ } else if (e->type() == QEvent::MouseButtonRelease) {
+ if (e->button() & Qt::MidButton)
+ m_buttonMask &= 0xfd;
+ if (e->button() & Qt::RightButton)
+ m_buttonMask &= 0xfb;
}
-
+ vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
}
-/* for reference:
- if (e->type() != QEvent::MouseMove) {
- if ((e->type() == QEvent::MouseButtonPress)) {
- if (e->button() & Qt::LeftButton)
- m_buttonMask |= 0x01;
- if (e->button() & Qt::MidButton)
- m_buttonMask |= 0x02;
- if (e->button() & Qt::RightButton)
- m_buttonMask |= 0x04;
- } else if (e->type() == QEvent::MouseButtonRelease) {
- if (e->button() & Qt::LeftButton)
- m_buttonMask &= 0xfe;
- if (e->button() & Qt::MidButton)
- m_buttonMask &= 0xfd;
- if (e->button() & Qt::RightButton)
- m_buttonMask &= 0xfb;
- */
+ //prevent local cursor artifacts
+ static int old_cursor_x = cursor_x;
+ static int old_cursor_y = cursor_y;
+ if(((m_dotCursorState == CursorOn) || m_forceLocalCursor)
+ and (cursor_x != old_cursor_x or cursor_y != old_cursor_y)) {
+ //clear last position (plus a few extra pixels)
+ repaint(old_cursor_x*m_horizontalFactor - 3, old_cursor_y*m_verticalFactor - 3, 7, 7);
+ //and refresh new one
+ repaint(cursor_x*m_horizontalFactor - 3, cursor_y*m_verticalFactor - 3, 7, 7);
+
+ old_cursor_x = cursor_x; old_cursor_y = cursor_y;
+ }
}
void VncView::wheelEventHandler(QWheelEvent *event)
const bool pressed = (e->type() == QEvent::KeyPress);
+#ifdef Q_WS_MAEMO_5
+ //don't send ISO_Level3_Shift (would break things like Win+0-9)
+ //also enable IM so symbol key works
+ if(k == 0xfe03) {
+ setAttribute(Qt::WA_InputMethodEnabled, pressed);
+ e->ignore();
+ return;
+ }
+#endif
+
// handle modifiers
if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L) {
if (pressed) {
void VncView::clipboardSelectionChanged()
{
- //kDebug(5011);
-
if (m_status != Connected)
return;
void VncView::clipboardDataChanged()
{
- //kDebug(5011);
-
if (m_status != Connected)
return;
left_zoom = settings.value("left_zoom", 0).toInt();
right_zoom = settings.value("right_zoom", 1).toInt();
disable_tapping = settings.value("disable_tapping", false).toBool();
+
+ bool always_show_local_cursor = settings.value("always_show_local_cursor", false).toBool();
+ if(always_show_local_cursor)
+ showDotCursor(CursorOn);
}
//convert commitString into keyevents