only enable input method when needed to avoid breaking hardware keyboard input
authorchristian <christian@christian-laptop.(none)>
Thu, 12 Aug 2010 14:28:34 +0000 (16:28 +0200)
committerchristian <christian@christian-laptop.(none)>
Thu, 12 Aug 2010 14:28:34 +0000 (16:28 +0200)
debian/changelog
debian/rules
libvnc/config.log
src/connectdialog.cpp [new file with mode: 0644]
src/connectdialog.h [new file with mode: 0644]
src/mainwindow.cpp
src/mainwindow.h
src/preferences.cpp
src/vncview.cpp
src/vncview.h
vnc.pro

index 429ad15..178aad8 100644 (file)
@@ -1,3 +1,9 @@
+presencevnc (0.4) unstable; urgency=low
+
+  * 
+
+ -- Christian Pulvermacher <pulvermacher@gmx.de>  Sat, 07 Aug 2010 11:52:56 +0200
+
 presencevnc (0.3) unstable; urgency=low
 
   * Compatibility fix for RealVNC Personal/Enterprise
index 0af3df8..90f5757 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/
@@ -30,7 +30,7 @@ clean:
        rm -f build
        [ ! -f Makefile ] || $(MAKE) clean
 ifdef buildlibs
-       [ ! -f libvnc/Makefile ] || cd libvnc && make clean
+       [ ! -f libvnc/Makefile ] || ( cd libvnc && make clean )
 endif
        dh_clean
        rm -rf ${BUILDDIR}
index c30e2af..4c601a3 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/cc4Tdnej.o: In function `main':
+/tmp/ccOMucA4.o: In function `main':
 /home/christian/presencevnc/libvnc/conftest.c:91: undefined reference to `_doprnt'
-/tmp/cc4Tdnej.o:(.data+0x0): undefined reference to `_doprnt'
+/tmp/ccOMucA4.o:(.data+0x0): undefined reference to `_doprnt'
 collect2: ld returned 1 exit status
 configure:27065: $? = 1
 configure: failed program was:
diff --git a/src/connectdialog.cpp b/src/connectdialog.cpp
new file mode 100644 (file)
index 0000000..3843f14
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+    Presence VNC
+    Copyright (C) 2010 Christian Pulvermacher
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+#include <QtGui>
+
+#include "connectdialog.h"
+
+
+ConnectDialog::ConnectDialog(QWidget *parent):
+       QDialog(parent)
+{
+       setWindowTitle("Connect to Host");
+       QSettings settings;
+
+       QHBoxLayout *layout1 = new QHBoxLayout();
+       QVBoxLayout *layout2 = new QVBoxLayout();
+
+       hostname = new QLineEdit(settings.value("last_hostname", "").toString(), this);
+       hostname->setInputMethodHints(Qt::ImhLowercaseOnly);
+       layout2->addWidget(hostname);
+
+       QPushButton *ok = new QPushButton("Done");
+       ok->setMaximumWidth(100);
+
+       layout1->addLayout(layout2);
+       layout1->addWidget(ok);
+
+       setLayout(layout1);
+
+       connect(ok, SIGNAL(clicked()),
+               this, SLOT(accept()));
+}
+
+QString ConnectDialog::getUrl()
+{
+       QSettings settings;
+       settings.setValue("last_hostname", hostname->text());
+       settings.sync();
+
+       return QString("vnc://") + hostname->text();
+}
diff --git a/src/connectdialog.h b/src/connectdialog.h
new file mode 100644 (file)
index 0000000..78aa16a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+    Presence VNC
+    Copyright (C) 2010 Christian Pulvermacher
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef CONNECTDIALOG_H
+#define CONNECTDIALOG_H
+
+#include <QtGui>
+
+class ConnectDialog : public QDialog {
+       Q_OBJECT
+public:
+       ConnectDialog(QWidget *parent);
+       QString getUrl();
+private:
+       QLineEdit *hostname;
+};
+#endif
index 672b5f9..f660963 100644 (file)
@@ -16,6 +16,7 @@
     with this program; if not, write to the Free Software Foundation, Inc.,
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
+#include "connectdialog.h"
 #include "mainwindow.h"
 #include "preferences.h"
 #include "vncview.h"
@@ -42,13 +43,12 @@ MainWindow::MainWindow(QString url, int quality):
 
        //set up toolbar
        toolbar = new QToolBar(0);
-       //toolbar->setAttribute(Qt::WA_InputMethodEnabled, true);
        toolbar->addAction("Mod", this, SLOT(showModifierMenu()));
        toolbar->addAction("Tab", this, SLOT(sendTab()));
        toolbar->addAction("Esc", this, SLOT(sendEsc()));
        toolbar->addAction("PgUp", this, SLOT(sendPgUp()));
        toolbar->addAction("PgDn", this, SLOT(sendPgDn()));
-//     toolbar->addAction("IM", toolbar, SLOT(setFocus())); //doesn't work
+       toolbar->addAction("IM", this, SLOT(showInputPanel()));
        toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/general_fullsize.png"), "", this, SLOT(toggleFullscreen()));
        addToolBar(toolbar);
        toolbar->setVisible(settings.value("show_toolbar", true).toBool());
@@ -80,7 +80,7 @@ MainWindow::MainWindow(QString url, int quality):
        connect(pref_action, SIGNAL(triggered()),
                this, SLOT(showPreferences()));
        connect(connect_action, SIGNAL(triggered()),
-               this, SLOT(connectDialog()));
+               this, SLOT(showConnectDialog()));
        connect(disconnect_action, SIGNAL(triggered()),
                this, SLOT(disconnectFromHost()));
        connect(show_toolbar, SIGNAL(toggled(bool)),
@@ -99,7 +99,7 @@ MainWindow::MainWindow(QString url, int quality):
        if(url.isNull()) {
                disconnect_action->setEnabled(false);
                toolbar->setEnabled(false);
-               connectDialog();
+               showConnectDialog();
        } else {
                vnc_view = new VncView(this, url, RemoteView::Quality(quality));
                connect(scaling, SIGNAL(toggled(bool)),
@@ -139,7 +139,7 @@ void MainWindow::closeEvent(QCloseEvent*) {
 
 void MainWindow::about() {
        QMessageBox::about(this, tr("About Presence VNC"),
-               tr("<center><h1>Presence VNC 0.3</h1>\
+               tr("<center><h1>Presence VNC 0.4</h1>\
 A touchscreen friendly VNC client\
 <small><p>&copy;2010 Christian Pulvermacher &lt;pulvermacher@gmx.de&gt;</p>\
 <p>Based on KRDC, &copy; 2007-2008 Urs Wolfer</p>\
@@ -147,15 +147,24 @@ A touchscreen friendly VNC client\
 <p>This program is free software; License: <a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GNU GPL 2</a> or later.</p>"));
 }
 
-void MainWindow::connectDialog()
+void MainWindow::showConnectDialog()
 {
+       /*
        QSettings settings;
        QString url = QInputDialog::getText(this, "Connect to Host", "VNC Server:", QLineEdit::Normal, settings.value("last_hostname", "").toString());
        if(url.isEmpty()) { //dialog dismissed or nothing entered
                return;
        }
-       settings.setValue("last_hostname", url);
-       url = "vnc://" + url;
+       */
+
+       ConnectDialog *connect_dialog = new ConnectDialog(this);
+       if(!connect_dialog->exec()) { //dialog rejected
+               delete connect_dialog;
+               return;
+       }
+
+       QString url = connect_dialog->getUrl();
+       delete connect_dialog;
 
        disconnectFromHost();
 
@@ -290,3 +299,10 @@ void MainWindow::reloadSettings()
        if(vnc_view)
                vnc_view->reloadSettings();
 }
+
+void MainWindow::showInputPanel()
+{
+       vnc_view->setAttribute(Qt::WA_InputMethodEnabled, true);
+       QEvent event(QEvent::RequestSoftwareInputPanel);
+       QApplication::sendEvent(vnc_view, &event);
+}
index 2801af4..f5aaddc 100644 (file)
@@ -30,7 +30,7 @@ public:
        MainWindow(QString url, int quality);
 public slots:
        void about();
-       void connectDialog();
+       void showConnectDialog();
        void disconnectFromHost();
        void forceResize();
        void forceResizeDelayed();
@@ -38,21 +38,19 @@ public slots:
        void sendEsc() { vnc_view->sendKey(Qt::Key_Escape); }
        void sendPgUp() { vnc_view->sendKey(Qt::Key_PageUp); }
        void sendPgDn() { vnc_view->sendKey(Qt::Key_PageDown); }
+       void showInputPanel();
        void showModifierMenu();
        void showPreferences();
        void statusChanged(RemoteView::RemoteStatus status);
        void toggleFullscreen();
 protected:
-       //virtual bool event(QEvent *event);
        void closeEvent(QCloseEvent*);
 private:
        void grabZoomKeys(bool grab);
        void reloadSettings();
        VncView *vnc_view;
        QScrollArea *scroll_area;
-       //QWidget *menu;
        QToolBar *toolbar;      
-       //QPoint swipe_start;
        QAction *scaling;
        QAction *disconnect_action;
 };
index 893a8e5..8f6cc9b 100644 (file)
@@ -95,7 +95,7 @@ Preferences::Preferences(QWidget *parent):
        disable_tapping->setChecked(settings.value("disable_tapping", false).toBool());
        layout2->addWidget(disable_tapping);
 
-       QPushButton *ok = new QPushButton("OK");
+       QPushButton *ok = new QPushButton("Done");
        ok->setMaximumWidth(100);
 
        layout1->addLayout(layout2);
index 48a05aa..72e87cf 100644 (file)
@@ -106,6 +106,8 @@ bool VncView::eventFilter(QObject *obj, QEvent *event)
                 event->type() == QEvent::MouseMove)
             return true;
     }
+    if(event->type() == 200)
+           kDebug(5011) << "eventFilter: 200";
     return RemoteView::eventFilter(obj, event);
 }
 
@@ -427,6 +429,9 @@ bool VncView::event(QEvent *event)
         wheelEventHandler(static_cast<QWheelEvent*>(event));
         return true;
         break;
+    case QEvent::WindowActivate: //input panel may have been closed, prevent IM from interfering with hardware keyboard
+       setAttribute(Qt::WA_InputMethodEnabled, false);
+       //fall through
     default:
         return RemoteView::event(event);
     }
@@ -441,7 +446,7 @@ void VncView::mouseEventHandler(QMouseEvent *e)
        static QTime press_time;
        static QTime up_time; //used for double clicks/tap&drag, for time after first tap
 
-       const int TAP_PRESS_TIME = 200;
+       const int TAP_PRESS_TIME = 180;
        const int DOUBLE_TAP_UP_TIME = 500;
 
        if(!e) { //flush held taps
@@ -578,6 +583,10 @@ void VncView::keyEventHandler(QKeyEvent *e)
                current_zoom = right_zoom;
        else if (k)
                vncThread.keyEvent(k, pressed);
+       else {
+               kDebug(5011) << "nativeVirtualKey() for '" << e->text() << "' failed.";
+               return;
+       }       
        
        if(current_zoom == -1)
                return;
@@ -707,4 +716,22 @@ void VncView::reloadSettings()
        disable_tapping = settings.value("disable_tapping", false).toBool();
 }
 
+//convert commitString into keyevents
+void VncView::inputMethodEvent(QInputMethodEvent *event)
+{
+       //TODO handle replacements
+       //TODO convert utf8 to X11 keysyms myself, should work with umlauts, kana...
+       //TODO Enter?
+       QString letters = event->commitString();
+       for(int i = 0; i < letters.length(); i++) {
+               char k = letters.at(i).toLatin1(); //works with all 'normal' keys, not umlauts.
+               if(!k) {
+                       kDebug(5011) << "unhandled key";
+                       continue;
+               }
+               vncThread.keyEvent(k, true);
+               vncThread.keyEvent(k, false);
+       }
+}
+
 #include "moc_vncview.cpp"
index 6275bf5..c1c00c6 100644 (file)
@@ -68,6 +68,7 @@ protected:
     bool event(QEvent *event);
     void resizeEvent(QResizeEvent *event);
     bool eventFilter(QObject *obj, QEvent *event);
+    void inputMethodEvent(QInputMethodEvent *event);
 
 private:
     VncClientThread vncThread;
diff --git a/vnc.pro b/vnc.pro
index e4ef7b2..d1cf3a9 100644 (file)
--- a/vnc.pro
+++ b/vnc.pro
@@ -10,5 +10,5 @@ MOC_DIR = $${PWD}/tmp
 VPATH = $${PWD}/src
 INCLUDEPATH = $${PWD}/src
 
-HEADERS += remoteview.h vncclientthread.h vncview.h mainwindow.h preferences.h
-SOURCES += main.cpp remoteview.cpp vncclientthread.cpp vncview.cpp mainwindow.cpp preferences.cpp
+HEADERS += remoteview.h vncclientthread.h vncview.h mainwindow.h preferences.h connectdialog.h
+SOURCES += main.cpp remoteview.cpp vncclientthread.cpp vncview.cpp mainwindow.cpp preferences.cpp connectdialog.cpp