return RemoteView::eventFilter(obj, event);
}
-QSize VncView::framebufferSize()
+QSize VncView::framebufferSize() const
{
return m_frame.size();
}
setStatus(Disconnected);
}
-bool VncView::isQuitting()
+bool VncView::isQuitting() const
{
return m_quitFlag;
}
return;
}
- startQuitting();
-
emit errorMessage(i18n("VNC failure"), message);
+
+ startQuitting();
}
void VncView::updateImage(int x, int y, int w, int h)
{
+#ifdef Q_WS_MAEMO_5
//don't update if window is out of focus / display is off
if(!QApplication::focusWidget() || display_off) {
return;
}
+#endif
//kDebug(5011) << "got update" << width() << height();
m_frame = vncThread.image();
if (!m_initDone) { //TODO this seems an odd place for initialization
- setAttribute(Qt::WA_StaticContents);
- setAttribute(Qt::WA_OpaquePaintEvent);
+ setAttribute(Qt::WA_NoSystemBackground);
installEventFilter(this);
setCursor(((m_dotCursorState == CursorOn) || m_forceLocalCursor) ? localDotCursor() : Qt::BlankCursor);
emit framebufferSizeChanged(m_frame.width(), m_frame.height());
}
- repaint(qRound(m_x * m_horizontalFactor), qRound(m_y * m_verticalFactor), qRound(m_w * m_horizontalFactor), qRound(m_h * m_verticalFactor));
+ update(qRound(m_x * m_horizontalFactor), qRound(m_y * m_verticalFactor), qRound(m_w * m_horizontalFactor), qRound(m_h * m_verticalFactor));
}
void VncView::setViewOnly(bool viewOnly)
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);
}
event->accept();
- const QRect update_rect = event->rect();
+ //split update region into smaller non-intersecting rectangles and only paint those
QPainter painter(this);
- if (update_rect != rect()) {
- // kDebug(5011) << "Partial repaint";
+ 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);
const int sh = qRound(update_rect.height()/m_verticalFactor);
+ //kDebug(5011) << "Partial repaint, widget x,y,w,h:" << update_rect.x() << update_rect.y() << update_rect.width() << update_rect.height() << "orig: " << sx << sy << sw << sh;
+
painter.drawImage(update_rect,
m_frame.copy(sx, sy, sw, sh)
.scaled(update_rect.size(), Qt::IgnoreAspectRatio, transformation_mode));
- } else {
- //kDebug(5011) << "Full repaint" << width() << height() << m_frame.width() << m_frame.height();
-
- painter.drawImage(rect(),
- m_frame.scaled(size(), Qt::IgnoreAspectRatio, transformation_mode));
}
//draw local cursor ourselves, normal mouse pointer doesn't deal with scrolling
if(((m_dotCursorState == CursorOn) || m_forceLocalCursor)
and (cursor_x != old_cursor_x or cursor_y != old_cursor_y)) {
//clear last position
- repaint(old_cursor_x*m_horizontalFactor - CURSOR_SIZE/2, old_cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
+ update(old_cursor_x*m_horizontalFactor - CURSOR_SIZE/2, old_cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
//and refresh new one
- repaint(cursor_x*m_horizontalFactor - CURSOR_SIZE/2, cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
+ update(cursor_x*m_horizontalFactor - CURSOR_SIZE/2, cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
old_cursor_x = cursor_x;
old_cursor_y = cursor_y;
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) {
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.";
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);
+ showDotCursor(always_show_local_cursor?CursorOn:CursorOff);
enableScaling(true);
}