add middle click option to zoom buttons, disable_tapping option, various fixes
authorchristian <christian@christian-laptop.(none)>
Wed, 4 Aug 2010 18:20:51 +0000 (20:20 +0200)
committerchristian <christian@christian-laptop.(none)>
Wed, 4 Aug 2010 18:20:51 +0000 (20:20 +0200)
debian/changelog
debian/rules
libvnc/config.log
libvnc/libvncclient/vncviewer.c
src/mainwindow.cpp
src/preferences.cpp
src/preferences.h
src/remoteview.cpp
src/vncview.cpp
src/vncview.h
vnc.pro

index fd0fd49..b5fe04b 100644 (file)
@@ -1,6 +1,8 @@
 presencevnc (0.3) unstable; urgency=low
 
   * Compatibility fix for RealVNC Personal/Enterprise
+  * Fix crash on exit
+  * Add option to disable tapping
 
  -- Christian Pulvermacher <pulvermacher@gmx.de>  Tue, 03 Aug 2010 18:35:57 +0200
 
index 0d0166c..0af3df8 100755 (executable)
@@ -5,7 +5,7 @@ export DH_VERBOSE=1
 #currently builds a maemo-only package
 
 #comment this line for quick builds
-#buildlibs=foo
+buildlibs=foo
 
 SOURCEDIR=./
 BUILDDIR=debian/build/
@@ -42,7 +42,7 @@ binary-arch: build install
        dh_testroot
        dh_installdocs
        dh_installchangelogs
-       #dh_strip
+       dh_strip
        dh_compress
        dh_fixperms
        dh_installdeb
index 007f7dc..6d5c04f 100644 (file)
@@ -1383,9 +1383,9 @@ configure:26983: $? = 0
 configure:26995: result: yes
 configure:27002: checking for _doprnt
 configure:27059: gcc -o conftest -g -O2   conftest.c -lpthread -lz -ljpeg  >&5
-/tmp/cc6wOTSk.o: In function `main':
+/tmp/ccUTRY7o.o: In function `main':
 /home/christian/presencevnc/libvnc/conftest.c:91: undefined reference to `_doprnt'
-/tmp/cc6wOTSk.o:(.data+0x0): undefined reference to `_doprnt'
+/tmp/ccUTRY7o.o:(.data+0x0): undefined reference to `_doprnt'
 collect2: ld returned 1 exit status
 configure:27065: $? = 1
 configure: failed program was:
index 82ba909..553028f 100644 (file)
@@ -317,10 +317,9 @@ void rfbClientCleanup(rfbClient* client) {
 #endif
 
  
- /*
   if (client->sock >= 0)
     close(client->sock);
-    */
+
   free(client->desktopName);
   free(client->serverHost);
   free(client);
index a9e4828..672b5f9 100644 (file)
@@ -35,6 +35,9 @@ MainWindow::MainWindow(QString url, int quality):
 {
        setWindowTitle("Presence VNC");
        setAttribute(Qt::WA_Maemo5StackedWindow);
+
+       migrateConfiguration();
+
        QSettings settings;
 
        //set up toolbar
@@ -54,8 +57,8 @@ MainWindow::MainWindow(QString url, int quality):
        QMenuBar *menu = new QMenuBar(this);
        QAction *connect_action = new QAction("Connect", this);
        disconnect_action = new QAction("Disconnect", this);
-//     menu->addAction(connect_action);
-//     menu->addAction(disconnect_action);
+       menu->addAction(connect_action);
+       menu->addAction(disconnect_action);
        scaling = new QAction("Fit to Screen", this);
        scaling->setCheckable(true);
        scaling->setChecked(settings.value("rescale", true).toBool());
@@ -107,9 +110,6 @@ MainWindow::MainWindow(QString url, int quality):
                vnc_view->start();
                vnc_view->enableScaling(scaling->isChecked());
        }
-
-       if(!vnc_view) //not connected
-               QTimer::singleShot(100, this, SLOT(close()));
 }
 
 void MainWindow::grabZoomKeys(bool grab)
@@ -160,12 +160,12 @@ void MainWindow::connectDialog()
        disconnectFromHost();
 
        vnc_view = new VncView(this, url, RemoteView::Quality(2)); //TODO: get quality in dialog
-       scroll_area->setWidget(vnc_view);
 
        connect(scaling, SIGNAL(toggled(bool)),
                vnc_view, SLOT(enableScaling(bool)));
        connect(vnc_view, SIGNAL(statusChanged(RemoteView::RemoteStatus)),
                this, SLOT(statusChanged(RemoteView::RemoteStatus)));
+       scroll_area->setWidget(vnc_view);
        vnc_view->start();
        vnc_view->enableScaling(scaling->isChecked());
        disconnect_action->setEnabled(true);
@@ -177,7 +177,6 @@ void MainWindow::disconnectFromHost()
        if(!vnc_view)
                return;
 
-//     vnc_view->startQuitting();
        scroll_area->setWidget(0);
 
        vnc_view->disconnect(); //remove all signal-slot connections
@@ -197,11 +196,26 @@ void MainWindow::statusChanged(RemoteView::RemoteStatus status)
                break;
        case RemoteView::Connected:
                setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+               if(!scaling->isChecked()) {
+                       //if remote desktop is shown in full size, 2nd connection will have black screen
+                       //ugly hack to force a refresh (forceFullRepaint() doesn't repaint?? -> vnc_view hidden???)
+                       vnc_view->resize(scroll_area->size());
+                       vnc_view->enableScaling(false);
+               }
                break;
        case RemoteView::Disconnecting:
                if(old_status != RemoteView::Disconnected) { //Disconnecting also occurs while connecting, so check last state
                        QMaemo5InformationBox::information(this, "Connection lost");
-                       close();
+                       
+                       //clean up
+                       scroll_area->setWidget(0);
+                       vnc_view = 0;
+                       disconnect_action->setEnabled(false);
+                       toolbar->setEnabled(false);
+
+                       //exit fullscreen mode
+                       if(windowState() & Qt::WindowFullScreen)
+                               setWindowState(windowState() ^ Qt::WindowFullScreen);
                }
                break;
        case RemoteView::Disconnected:
index 6c97a4f..893a8e5 100644 (file)
 
 #include "preferences.h"
 
+#include <iostream>
+
+void migrateConfiguration()
+{
+       QSettings settings;
+       int config_ver = settings.value("config_version", 0).toInt();
+       if(config_ver == 1) //config file up-to-date
+               return;
+
+       std::cout << "Migrating from configuration ver. " << config_ver << "\n";
+
+       if(config_ver == 0) {
+               int left_zoom = settings.value("left_zoom", 0).toInt();
+               int right_zoom = settings.value("left_zoom", 0).toInt();
+               if(left_zoom >= 2)
+                       settings.setValue("left_zoom", left_zoom+1);
+               if(right_zoom >= 2)
+                       settings.setValue("left_zoom", right_zoom+1);
+               config_ver = 1;
+       }
+       settings.setValue("config_version", config_ver);
+       settings.sync();
+}
+
+
 Preferences::Preferences(QWidget *parent):
        QDialog(parent)
 {
@@ -45,12 +70,13 @@ Preferences::Preferences(QWidget *parent):
        QMaemo5ValueButton *leftzoom = new QMaemo5ValueButton(tr("Left Zoom Button"), this);
        leftzoom_selector = new QMaemo5ListPickSelector(this);
        QStandardItemModel *key_model = new QStandardItemModel(0, 1, this);
-       key_model->appendRow(new QStandardItem(tr("Left Click"))); //0
-       key_model->appendRow(new QStandardItem(tr("Right Click")));//1
-       key_model->appendRow(new QStandardItem(tr("Wheel Up")));//2
-       key_model->appendRow(new QStandardItem(tr("Wheel Down")));//3
-       key_model->appendRow(new QStandardItem(tr("Page Up")));//4
-       key_model->appendRow(new QStandardItem(tr("Page Down")));//5
+       key_model->insertRow(0, new QStandardItem(tr("Left Click")));
+       key_model->insertRow(1, new QStandardItem(tr("Right Click")));
+       key_model->insertRow(2, new QStandardItem(tr("Middle Click")));
+       key_model->insertRow(3, new QStandardItem(tr("Wheel Up")));
+       key_model->insertRow(4, new QStandardItem(tr("Wheel Down")));
+       key_model->insertRow(5, new QStandardItem(tr("Page Up")));
+       key_model->insertRow(6, new QStandardItem(tr("Page Down")));
        leftzoom_selector->setModel(key_model);
        leftzoom_selector->setCurrentIndex(settings.value("left_zoom", 0).toInt());
        leftzoom->setPickSelector(leftzoom_selector);
@@ -65,6 +91,10 @@ Preferences::Preferences(QWidget *parent):
        rightzoom->setValueLayout(QMaemo5ValueButton::ValueBesideText);
        layout2->addWidget(rightzoom);
 
+       disable_tapping = new QCheckBox(tr("Disable Tapping"), this);
+       disable_tapping->setChecked(settings.value("disable_tapping", false).toBool());
+       layout2->addWidget(disable_tapping);
+
        QPushButton *ok = new QPushButton("OK");
        ok->setMaximumWidth(100);
 
@@ -86,6 +116,7 @@ void Preferences::save()
        settings.setValue("screen_rotation", rotation_selector->currentIndex());
        settings.setValue("left_zoom", leftzoom_selector->currentIndex());
        settings.setValue("right_zoom", rightzoom_selector->currentIndex());
+       settings.setValue("disable_tapping", disable_tapping->isChecked());
 
        settings.sync();
 }
index bf7f5ea..b7483f7 100644 (file)
@@ -24,6 +24,8 @@
 
 class QMaemo5ListPickSelector;
 
+void migrateConfiguration(); //checks for old configuration and migrates them if necessary
+
 class Preferences : public QDialog {
        Q_OBJECT
 public:
@@ -36,5 +38,6 @@ private:
        QMaemo5ListPickSelector *rotation_selector;
        QMaemo5ListPickSelector *leftzoom_selector;
        QMaemo5ListPickSelector *rightzoom_selector;
+       QCheckBox *disable_tapping;
 };
 #endif
index 0580a58..9b75743 100644 (file)
@@ -245,7 +245,17 @@ void RemoteView::saveWalletPassword(const QString &password, bool fromUserNameOn
 QCursor RemoteView::localDotCursor() const
 {
 #ifdef QTONLY
-    return QCursor(); //TODO
+const uchar bits[] =
+{ 0xffffffff, 0xffffffff, 0xffffffff,
+  0xffffffff, 0xff000000, 0xffffffff,
+  0xffffffff, 0xffffffff, 0xffffffff };
+
+    QBitmap cursorBitmap = QBitmap::fromData(QSize(3,3), bits , QImage::Format_RGB32);
+    QBitmap cursorMask(QSize(3,3));
+    cursorMask.clear();
+
+    return QCursor(cursorBitmap, cursorMask);
+    //return QCursor(); //TODO
 #else
     QBitmap cursorBitmap(KGlobal::dirs()->findResource("appdata",
                                                        "pics/pointcursor.png"));
index 51fbfa4..48a05aa 100644 (file)
@@ -83,18 +83,13 @@ VncView::~VncView()
 
     // Disconnect all signals so that we don't get any more callbacks from the client thread
     vncThread.disconnect();
-    /*
-    disconnect(&vncThread, SIGNAL(imageUpdated(int, int, int, int)), this, SLOT(updateImage(int, int, int, int)));
-    disconnect(&vncThread, SIGNAL(gotCut(const QString&)), this, SLOT(setCut(const QString&)));
-    disconnect(&vncThread, SIGNAL(passwordRequest()), this, SLOT(requestPassword()));
-    disconnect(&vncThread, SIGNAL(outputErrorMessage(QString)), this, SLOT(outputErrorMessage(QString)));
-    */
 
     startQuitting();
 }
 
 void VncView::forceFullRepaint()
 {
+       kDebug(5011) << "forceFullRepaint()";
        force_full_repaint = true;
        repaint();
 }
@@ -150,16 +145,6 @@ void VncView::scaleResize(int w, int h)
     } 
 }
 
-void VncView::updateConfiguration()
-{
-    RemoteView::updateConfiguration();
-
-    // Update the scaling mode in case KeepAspectRatio changed
-    if(parentWidget())
-           scaleResize(parentWidget()->width(), parentWidget()->height());
-    else
-       scaleResize(width(), height());
-}
 
 void VncView::startQuitting()
 {
@@ -371,7 +356,7 @@ void VncView::setCut(const QString &text)
 
 void VncView::paintEvent(QPaintEvent *event)
 {
-//     kDebug(5011) << "paint event: x: " << m_x << ", y: " << m_y << ", w: " << m_w << ", h: " << m_h;
+     //kDebug(5011) << "paint event: x: " << m_x << ", y: " << m_y << ", w: " << m_w << ", h: " << m_h;
     if (m_frame.isNull() || m_frame.format() == QImage::Format_Invalid) {
         kDebug(5011) << "no valid image to paint";
         RemoteView::paintEvent(event);
@@ -382,7 +367,7 @@ void VncView::paintEvent(QPaintEvent *event)
 
     QPainter painter(this);
 
-    if (m_repaint) {
+    if (m_repaint and !force_full_repaint) {
 //         kDebug(5011) << "normal repaint";
         painter.drawImage(QRect(qRound(m_x*m_horizontalFactor), qRound(m_y*m_verticalFactor),
                                 qRound(m_w*m_horizontalFactor), qRound(m_h*m_verticalFactor)), 
@@ -447,7 +432,7 @@ bool VncView::event(QEvent *event)
     }
 }
 
-
+//call with e == 0 to flush held events
 void VncView::mouseEventHandler(QMouseEvent *e)
 {
        static bool tap_detected = false;
@@ -485,6 +470,11 @@ void VncView::mouseEventHandler(QMouseEvent *e)
        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) {
@@ -605,17 +595,23 @@ void VncView::keyEventHandler(QKeyEvent *e)
                else
                        m_buttonMask &= 0xfb;
                vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
-       } else if(current_zoom == 2 and pressed) { //wheel up
+       } else if(current_zoom == 2) { //middle click
+               if(pressed)
+                       m_buttonMask |= 0x02;
+               else
+                       m_buttonMask &= 0xfd;
+               vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+       } else if(current_zoom == 3 and pressed) { //wheel up
                int eb = 0x8;
                vncThread.mouseEvent(cursor_x, cursor_y, eb | m_buttonMask);
                vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
-       } else if(current_zoom == 3 and pressed) { //wheel down
+       } else if(current_zoom == 4 and pressed) { //wheel down
                int eb = 0x10;
                vncThread.mouseEvent(cursor_x, cursor_y, eb | m_buttonMask);
                vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
-       } else if(current_zoom == 4) { //page up
+       } else if(current_zoom == 5) { //page up
                vncThread.keyEvent(0xff55, pressed);
-       } else if(current_zoom == 5) { //page down
+       } else if(current_zoom == 6) { //page down
                vncThread.keyEvent(0xff56, pressed);
        }
 }
@@ -708,6 +704,7 @@ 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();
 }
 
 #include "moc_vncview.cpp"
index 1f76385..6275bf5 100644 (file)
@@ -58,8 +58,6 @@ public:
     void showDotCursor(DotCursorState state);
     void sendKey(Qt::Key key);
     
-    virtual void updateConfiguration();
-
 public slots:
     void enableScaling(bool scale);
     void scaleResize(int w, int h);
@@ -90,6 +88,7 @@ private:
     bool force_full_repaint;
     RemoteView::Quality quality;
     int left_zoom, right_zoom;
+    bool disable_tapping;
 
     void keyEventHandler(QKeyEvent *e);
     void unpressModifiers();
diff --git a/vnc.pro b/vnc.pro
index 3edce47..e4ef7b2 100644 (file)
--- a/vnc.pro
+++ b/vnc.pro
@@ -3,7 +3,7 @@ TARGET = presencevnc-bin
 LIBS += -Llibvnc/libvncclient/.libs -lvncclient
 DEFINES += QTONLY
 QT += maemo5
-CONFIG += silent debug
+CONFIG += silent release
 
 OBJECTS_DIR = $${PWD}/tmp
 MOC_DIR = $${PWD}/tmp