X-Git-Url: http://git.maemo.org/git/?p=presencevnc;a=blobdiff_plain;f=src%2Fvncview.cpp;h=85027481e8d2ce3ac9cce7b3af7a8555aa40bc40;hp=891950f4ff115fa0a8b98e7ef25e520ded6f22cb;hb=f3262a352123422b5641b7dbaf8275b8c4f6b349;hpb=50833eb3160388d2d254cb680e6425f97a83d273 diff --git a/src/vncview.cpp b/src/vncview.cpp index 891950f..8502748 100644 --- a/src/vncview.cpp +++ b/src/vncview.cpp @@ -110,7 +110,7 @@ bool VncView::eventFilter(QObject *obj, QEvent *event) return RemoteView::eventFilter(obj, event); } -QSize VncView::framebufferSize() +QSize VncView::framebufferSize() const { return m_frame.size(); } @@ -150,7 +150,7 @@ void VncView::startQuitting() setStatus(Disconnected); } -bool VncView::isQuitting() +bool VncView::isQuitting() const { return m_quitFlag; } @@ -254,9 +254,9 @@ void VncView::outputErrorMessage(const QString &message) return; } - startQuitting(); - emit errorMessage(i18n("VNC failure"), message); + + startQuitting(); } void VncView::updateImage(int x, int y, int w, int h) @@ -362,11 +362,11 @@ void VncView::setZoomLevel(int level) magnification = (level)/90.0*(1.0 - fit_screen_magnification) + fit_screen_magnification; } - if(magnification < 0 //remote display smaller than local? - or magnification != magnification) //nan + //remote display smaller than local (or NAN)? + if(magnification < 0 or magnification != magnification) magnification = 1.0; - m_verticalFactor = m_horizontalFactor = magnification; + m_verticalFactor = m_horizontalFactor = magnification; resize(m_frame.width()*magnification, m_frame.height()*magnification); } @@ -390,7 +390,17 @@ void VncView::paintEvent(QPaintEvent *event) //split update region into smaller non-intersecting rectangles and only paint those QPainter painter(this); - foreach(const QRect& update_rect, event->region().rects()) { + foreach(QRect update_rect, event->region().rects()) { + if(m_horizontalFactor == 2.0 and m_verticalFactor == 2.0) { + //grow client side updates to multiples of 2 to avoid artifacts + update_rect.adjust( + -update_rect.x()%2, + -update_rect.y()%2, + 0, 0); + update_rect.adjust(0, 0, + (update_rect.x()+update_rect.width())%2, + (update_rect.y()+update_rect.height())%2); + } const int sx = qRound(update_rect.x()/m_horizontalFactor); const int sy = qRound(update_rect.y()/m_verticalFactor); const int sw = qRound(update_rect.width()/m_horizontalFactor); @@ -568,9 +578,10 @@ void VncView::keyEventHandler(QKeyEvent *e) return; } -// parts of this code are based on http://italc.sourcearchive.com/documentation/1.0.9.1/vncview_8cpp-source.html + // parts of this code are based on http://italc.sourcearchive.com/documentation/1.0.9.1/vncview_8cpp-source.html rfbKeySym k = e->nativeVirtualKey(); + // we do not handle Key_Backtab separately as the Shift-modifier // is already enabled if (e->key() == Qt::Key_Backtab) { @@ -607,7 +618,7 @@ void VncView::keyEventHandler(QKeyEvent *e) else if(e->key() == Qt::Key_F7) current_zoom = right_zoom; else if (k) { - // kDebug(5011) << "got '" << e->text() << "'."; + //kDebug(5011) << "got '" << e->text() << "', nativeVirtualKey: " << k; vncThread.keyEvent(k, pressed); } else { kDebug(5011) << "nativeVirtualKey() for '" << e->text() << "' failed."; @@ -746,15 +757,12 @@ void VncView::sendKey(Qt::Key key) k = 0xff67; 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: @@ -781,7 +789,7 @@ 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 key_list; + QList key_list; int pos = 0; while(true) { QString k = keys.toString().section('+', pos, pos); @@ -796,18 +804,18 @@ void VncView::sendKeySequence(QKeySequence keys) } else if(k == "Meta") { key_list.append(Qt::Key_Meta); } else { - key_list.append(QKeySequence(k)[0]); + key_list.append((Qt::Key)QKeySequence(k)[0]); } pos++; } for(int i = 0; i < key_list.count(); i++) - sendKey(Qt::Key(key_list.at(i))); + sendKey(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))); + sendKey(key_list.at(i)); } void VncView::reloadSettings()