critical(parent, caption, message)
#include <QApplication>
+#include <QBitmap>
#include <QCheckBox>
#include <QDialog>
#include <QImage>
}
//kDebug(5011) << "got update" << width() << height();
+ /*
+ static unsigned int frames = 0;
+ static unsigned int updates = 0;
+ static QTime time = QTime::currentTime();
+ updates++;
+ if(updates % 100 == 0)
+ kDebug(5011) << "u/s: " << updates/double(time.elapsed()) * 1000.0;
+if(x == 0 and y == 0) {
+ frames++;
+ if(frames % 100 == 0)
+ kDebug(5011) << "f/s: " << frames/double(time.elapsed()) * 1000.0;
+}
+*/
+
m_x = x;
m_y = y;
m_w = w;
}
}
+ //draw local cursor ourselves, normal mouse pointer doesn't deal with scrolling
+ if((m_dotCursorState == CursorOn) || m_forceLocalCursor) {
+#if QT_VERSION >= 0x040500
+ painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
+#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 int x = qRound(event->x() / m_horizontalFactor);
const int y = qRound(event->y() / m_verticalFactor);
- kDebug(5011) << "Wheelevent";
vncThread.mouseEvent(x, y, eb | m_buttonMask);
vncThread.mouseEvent(x, y, m_buttonMask);
}
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;
//fake key events
void VncView::sendKey(Qt::Key key)
{
- int k = 0; //X11 keysym
+ //convert Qt::Key into x11 keysym
+ int k = 0;
switch(key) {
case Qt::Key_Escape:
k = 0xff1b;
case Qt::Key_Return:
k = 0xff0d;
break;
- case Qt::Key_Meta: //TODO: test this.
+ case Qt::Key_Insert:
+ k = 0xff63;
+ break;
+ case Qt::Key_Delete:
+ k = 0xffff;
+ break;
+ case Qt::Key_Home:
+ k = 0xff50;
+ break;
+ case Qt::Key_End:
+ k = 0xff57;
+ break;
+ case Qt::Key_Backspace:
+ k = 0xff08;
+ break;
+ case Qt::Key_F1:
+ case Qt::Key_F2:
+ case Qt::Key_F3:
+ case Qt::Key_F4:
+ case Qt::Key_F5:
+ case Qt::Key_F6:
+ case Qt::Key_F7:
+ case Qt::Key_F8:
+ case Qt::Key_F9:
+ case Qt::Key_F10:
+ case Qt::Key_F11:
+ case Qt::Key_F12:
+ k = 0xffbe + int(key - Qt::Key_F1);
+ break;
+ case Qt::Key_Meta:
+ case Qt::MetaModifier:
k = XK_Super_L;
break;
case Qt::Key_Alt:
+ case Qt::AltModifier:
k = XK_Alt_L;
break;
+ case Qt::Key_Control:
+ case Qt::ControlModifier:
+ k = XK_Control_L;
+ break;
default:
kDebug(5011) << "sendKey(): Unhandled Qt::Key value " << key;
return;
}
}
+void VncView::sendKeySequence(QKeySequence keys)
+{
+ Q_ASSERT(keys.count() <= 1); //we can only handle a single combination
+
+ //to get at individual key presses, we split 'keys' into its components
+ QList<int> key_list;
+ for(int i = 0; ; i++) {
+ QString k = keys.toString().section('+', i, i);
+ if(k.isEmpty())
+ break;
+ //kDebug(5011) << "found key: " << k;
+ if(k == "Alt") {
+ key_list.append(Qt::Key_Alt);
+ } else if(k == "Ctrl") {
+ key_list.append(Qt::Key_Control);
+ } else if(k == "Meta") {
+ key_list.append(Qt::Key_Meta);
+ } else {
+ key_list.append(QKeySequence(k)[0]);
+ }
+ }
+
+ for(int i = 0; i < key_list.count(); i++)
+ sendKey(Qt::Key(key_list.at(i)));
+
+ //release modifiers (everything before final key)
+ for(int i = key_list.count()-2; i >= 0; i--)
+ sendKey(Qt::Key(key_list.at(i)));
+}
+
void VncView::reloadSettings()
{
QSettings settings;
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