fix redrawing after connecting
authorChristian Pulvermacher <christian@hazel.(none)>
Wed, 6 Oct 2010 21:23:33 +0000 (23:23 +0200)
committerChristian Pulvermacher <christian@hazel.(none)>
Wed, 6 Oct 2010 21:23:33 +0000 (23:23 +0200)
src/mainwindow.cpp
src/vncclientthread.cpp
src/vncview.cpp
src/vncview.h

index c24e389..fb9d4c8 100644 (file)
@@ -141,6 +141,8 @@ MainWindow::MainWindow(QString url, int quality):
                vnc_view->start();
                key_menu = new KeyMenu(this);
        }
+
+       //QTimer::singleShot(500, this, SLOT(close()));
 }
 
 void MainWindow::grabZoomKeys(bool grab)
@@ -235,13 +237,8 @@ void MainWindow::statusChanged(RemoteView::RemoteStatus status)
 #ifdef Q_WS_MAEMO_5
                setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
 #endif
-               /* TODO: still needed?
-               if(!scaling->isChecked()) {
-                       //ugly hack to force a refresh (forceFullRepaint() doesn't repaint?? -> vnc_view hidden???)
-                       vnc_view->resize(scroll_area->size());
-                       vnc_view->enableScaling(false);
-               }
-               */
+               vnc_view->setZoomLevel(zoom_slider->value());
+               vnc_view->forceFullRepaint();
                break;
        case RemoteView::Disconnecting:
                if(old_status != RemoteView::Disconnected) { //Disconnecting also occurs while connecting, so check last state
index 2954084..dadf93d 100644 (file)
@@ -91,6 +91,9 @@ void VncClientThread::updatefb(rfbClient* cl, int x, int y, int w, int h)
     VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0);
     Q_ASSERT(t);
 
+    if (t->m_stopped)
+        return; //sending data to a stopped thread is not a good idea
+
     t->setImage(img);
 
     t->emitUpdated(x, y, w, h);
@@ -99,7 +102,7 @@ void VncClientThread::updatefb(rfbClient* cl, int x, int y, int w, int h)
 void VncClientThread::cuttext(rfbClient* cl, const char *text, int textlen)
 {
     const QString cutText = QString::fromUtf8(text, textlen);
-    kDebug(5011) << cutText;
+    kDebug(5011) << "cuttext: " << cutText;
 
     if (!cutText.isEmpty()) {
         VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0);
index 9d3866b..c4cc1c3 100644 (file)
@@ -133,28 +133,6 @@ QSize VncView::minimumSizeHint() const
     return size();
 }
 
-void VncView::scaleResize(int w, int h)
-{
-    RemoteView::scaleResize(w, h);
-    
-    kDebug(5011) << "scaleResize(): " <<w << h;
-    if (m_scale) {
-        m_verticalFactor = (qreal) h / m_frame.height();
-        m_horizontalFactor = (qreal) w / m_frame.width();
-
-        m_verticalFactor = m_horizontalFactor = qMin(m_verticalFactor, m_horizontalFactor);
-
-        const qreal newW = m_frame.width() * m_horizontalFactor;
-        const qreal newH = m_frame.height() * m_verticalFactor;
-       /*
-        setMaximumSize(newW, newH); //This is a hack to force Qt to center the view in the scroll area
-       //also causes the widget's size to flicker
-       */
-        resize(newW, newH);
-    } 
-}
-
-
 void VncView::startQuitting()
 {
     kDebug(5011) << "about to quit";
@@ -359,12 +337,7 @@ if(x == 0 and y == 0) {
 //         emit framebufferSizeChanged(m_frame.width(), m_frame.height());
         emit connected();
         
-        if (m_scale) {
-            if (parentWidget())
-                scaleResize(parentWidget()->width(), parentWidget()->height());
-           else
-                scaleResize(width(), height());
-        } 
+               resize(width(), height());
         
         m_initDone = true;
 
@@ -374,16 +347,7 @@ if(x == 0 and y == 0) {
     if ((y == 0 && x == 0) && (m_frame.size() != old_frame_size)) {
            old_frame_size = m_frame.size();
         kDebug(5011) << "Updating framebuffer size";
-        if (m_scale) {
-            //setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
-            if (parentWidget())
-                scaleResize(parentWidget()->width(), parentWidget()->height());
-        } else {
-            kDebug(5011) << "Resizing: " << m_frame.width() << m_frame.height();
-            resize(m_frame.width(), m_frame.height());
-            //setMaximumSize(m_frame.width(), m_frame.height()); //This is a hack to force Qt to center the view in the scroll area
-            //setMinimumSize(m_frame.width(), m_frame.height());
-        }
+               setZoomLevel();
         emit framebufferSizeChanged(m_frame.width(), m_frame.height());
     }
 
@@ -421,6 +385,10 @@ void VncView::setZoomLevel(int level)
 {
        Q_ASSERT(parentWidget() != 0);
 
+       if(level == -1) { //handle resize
+               resize(m_frame.width()*m_horizontalFactor, m_frame.height()*m_verticalFactor);
+               return;
+       }
 
        double factor; //actual magnification
        if(level > 95) {
@@ -441,6 +409,10 @@ void VncView::setZoomLevel(int level)
                kDebug(5011) << "remote display smaller than local?";
                factor = 1.0;
        }
+       if(factor != factor) //nan
+               factor = 1.0;
+       
+       kDebug(5011) << "factor" << factor;
 
        m_verticalFactor = m_horizontalFactor = factor;
        resize(m_frame.width()*factor, m_frame.height()*factor);
@@ -514,10 +486,6 @@ void VncView::paintEvent(QPaintEvent *event)
 void VncView::resizeEvent(QResizeEvent *event)
 {
     RemoteView::resizeEvent(event);
-       /*
-    scaleResize(event->size().width(), event->size().height());
-    forceFullRepaint();
-       */
 }
 
 bool VncView::event(QEvent *event)
index d98a72c..6bcc2ff 100644 (file)
@@ -60,8 +60,7 @@ public:
     
 public slots:
     void enableScaling(bool scale); //TODO: i may want to remove this
-    void setZoomLevel(int level); //'level' doesn't correspond to actual magnification, though mapping is done here
-    void scaleResize(int w, int h);
+    void setZoomLevel(int level = -1); //'level' doesn't correspond to actual magnification, though mapping is done here
     void sendKey(Qt::Key key);
     void sendKeySequence(QKeySequence keys);
     void forceFullRepaint();