1 /****************************************************************************
3 ** Copyright (C) 2007-2008 Urs Wolfer <uwolfer @ kde.org>
5 ** This file is part of KDE.
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; see the file COPYING. If not, write to
19 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ** Boston, MA 02110-1301, USA.
22 ****************************************************************************/
26 #include <QMessageBox>
27 #include <QInputDialog>
28 #define KMessageBox QMessageBox
29 #define error(parent, message, caption) \
30 critical(parent, caption, message)
32 #include <QApplication>
37 #include <QHBoxLayout>
38 #include <QVBoxLayout>
40 #include <QMouseEvent>
41 #include <QPushButton>
48 // Definition of key modifier mask constants
49 #define KMOD_Alt_R 0x01
50 #define KMOD_Alt_L 0x02
51 #define KMOD_Meta_L 0x04
52 #define KMOD_Control_L 0x08
53 #define KMOD_Shift_L 0x10
55 //local cursor width/height in px, should be an odd number
56 const int cursor_size = 7;
58 VncView::VncView(QWidget *parent, const KUrl &url, RemoteView::Quality quality)
66 m_firstPasswordTry(true),
67 m_dontSendClipboard(false),
68 m_horizontalFactor(1.0),
69 m_verticalFactor(1.0),
70 m_forceLocalCursor(false),
71 force_full_repaint(false),
78 connect(&vncThread, SIGNAL(imageUpdated(int, int, int, int)), this, SLOT(updateImage(int, int, int, int)), Qt::BlockingQueuedConnection);
79 connect(&vncThread, SIGNAL(gotCut(const QString&)), this, SLOT(setCut(const QString&)), Qt::BlockingQueuedConnection);
80 connect(&vncThread, SIGNAL(passwordRequest()), this, SLOT(requestPassword()), Qt::BlockingQueuedConnection);
81 connect(&vncThread, SIGNAL(outputErrorMessage(QString)), this, SLOT(outputErrorMessage(QString)));
83 m_clipboard = QApplication::clipboard();
84 connect(m_clipboard, SIGNAL(selectionChanged()), this, SLOT(clipboardSelectionChanged()));
85 connect(m_clipboard, SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
94 // Disconnect all signals so that we don't get any more callbacks from the client thread
95 vncThread.disconnect();
100 void VncView::forceFullRepaint()
102 force_full_repaint = true;
106 bool VncView::eventFilter(QObject *obj, QEvent *event)
109 if (event->type() == QEvent::KeyPress ||
110 event->type() == QEvent::KeyRelease ||
111 event->type() == QEvent::MouseButtonDblClick ||
112 event->type() == QEvent::MouseButtonPress ||
113 event->type() == QEvent::MouseButtonRelease ||
114 event->type() == QEvent::Wheel ||
115 event->type() == QEvent::MouseMove)
118 return RemoteView::eventFilter(obj, event);
121 QSize VncView::framebufferSize()
123 return m_frame.size();
126 QSize VncView::sizeHint() const
131 QSize VncView::minimumSizeHint() const
136 void VncView::startQuitting()
138 kDebug(5011) << "about to quit";
140 const bool connected = status() == RemoteView::Connected;
142 setStatus(Disconnecting);
147 kDebug(5011) << "stopping vncThread";
153 const bool quitSuccess = vncThread.wait(700);
155 kDebug(5011) << "startQuitting(): Quit VNC thread success:" << quitSuccess;
157 setStatus(Disconnected);
160 bool VncView::isQuitting()
165 bool VncView::start()
167 vncThread.setHost(m_host);
168 vncThread.setPort(m_port);
170 vncThread.setQuality(quality);
172 // set local cursor on by default because low quality mostly means slow internet connection
173 if (quality == RemoteView::Low) {
174 showDotCursor(RemoteView::CursorOn);
177 setStatus(Connecting);
183 bool VncView::supportsScaling() const
188 bool VncView::supportsLocalCursor() const
193 void VncView::requestPassword()
195 kDebug(5011) << "request password";
197 setStatus(Authenticating);
199 if (!m_url.password().isNull()) {
200 vncThread.setPassword(m_url.password());
205 settings.beginGroup("hosts");
206 QString password = settings.value(QString("%1/password").arg(m_host), "").toString();
207 //check for saved password
208 if(m_firstPasswordTry and !password.isEmpty()) {
209 kDebug(5011) << "Trying saved password";
210 m_firstPasswordTry = false;
211 vncThread.setPassword(password);
214 m_firstPasswordTry = false;
217 QDialog dialog(this);
218 dialog.setWindowTitle(tr("Password required"));
220 QLineEdit passwordbox;
221 passwordbox.setEchoMode(QLineEdit::Password);
222 passwordbox.setText(password);
223 QCheckBox save_password(tr("Save Password"));
224 save_password.setChecked(!password.isEmpty()); //offer to overwrite saved password
225 QPushButton ok_button(tr("Done"));
226 ok_button.setMaximumWidth(100);
227 connect(&ok_button, SIGNAL(clicked()),
228 &dialog, SLOT(accept()));
232 layout2.addWidget(&passwordbox);
233 layout2.addWidget(&save_password);
234 layout1.addLayout(&layout2);
235 layout1.addWidget(&ok_button);
236 dialog.setLayout(&layout1);
238 if(dialog.exec()) { //dialog accepted
239 password = passwordbox.text();
241 if(save_password.isChecked()) {
242 kDebug(5011) << "Saving password for host '" << m_host << "'";
244 settings.setValue(QString("%1/password").arg(m_host), password);
248 vncThread.setPassword(password);
254 void VncView::outputErrorMessage(const QString &message)
256 kDebug(5011) << message;
258 if (message == "INTERNAL:APPLE_VNC_COMPATIBILTY") {
259 setCursor(localDotCursor());
260 m_forceLocalCursor = true;
266 emit errorMessage(i18n("VNC failure"), message);
269 void VncView::updateImage(int x, int y, int w, int h)
271 if(!QApplication::focusWidget()) { //no focus, we're probably minimized
274 //kDebug(5011) << "got update" << width() << height();
277 static unsigned int frames = 0;
278 static unsigned int updates = 0;
279 static QTime time = QTime::currentTime();
281 if(updates % 100 == 0)
282 kDebug(5011) << "u/s: " << updates/double(time.elapsed()) * 1000.0;
283 if(x == 0 and y == 0) {
285 if(frames % 100 == 0)
286 kDebug(5011) << "f/s: " << frames/double(time.elapsed()) * 1000.0;
296 //with scaled view, artefacts occur because of rounding errors
297 //we'll try to only update chunks of screen space that correspond to integer pixel sizes in m_frame
298 //put this into paintEvent
300 int frame_x = x/m_horizontalFactor;
301 int frame_w = w/m_horizontalFactor;
302 int frame_y = y/m_verticalFactor;
303 int frame_h = h/m_verticalFactor;
305 m_x = frame_x*m_horizontalFactor;
306 m_y = frame_y*m_verticalFactor;
308 m_w = (frame_w+2)*m_horizontalFactor;
309 m_h = (frame_h+2)*m_verticalFactor;
310 kDebug(5011)<< "update);
314 if (m_horizontalFactor != 1.0 || m_verticalFactor != 1.0) {
315 // If the view is scaled, grow the update rectangle to avoid artifacts
316 int x_extrapixels = 1.0/m_horizontalFactor + 1;
317 int y_extrapixels = 1.0/m_verticalFactor + 1;
321 m_w+=2*x_extrapixels;
322 m_h+=2*y_extrapixels;
325 m_frame = vncThread.image();
328 setAttribute(Qt::WA_StaticContents);
329 setAttribute(Qt::WA_OpaquePaintEvent);
330 installEventFilter(this);
332 setCursor(((m_dotCursorState == CursorOn) || m_forceLocalCursor) ? localDotCursor() : Qt::BlankCursor);
334 setMouseTracking(true); // get mouse events even when there is no mousebutton pressed
335 setFocusPolicy(Qt::WheelFocus);
336 setStatus(Connected);
337 // emit framebufferSizeChanged(m_frame.width(), m_frame.height());
340 resize(width(), height());
346 static QSize old_frame_size = QSize();
347 if ((y == 0 && x == 0) && (m_frame.size() != old_frame_size)) {
348 old_frame_size = m_frame.size();
349 kDebug(5011) << "Updating framebuffer size";
351 emit framebufferSizeChanged(m_frame.width(), m_frame.height());
355 repaint(qRound(m_x * m_horizontalFactor), qRound(m_y * m_verticalFactor), qRound(m_w * m_horizontalFactor), qRound(m_h * m_verticalFactor));
359 void VncView::setViewOnly(bool viewOnly)
361 RemoteView::setViewOnly(viewOnly);
363 m_dontSendClipboard = viewOnly;
366 setCursor(Qt::ArrowCursor);
368 setCursor(m_dotCursorState == CursorOn ? localDotCursor() : Qt::BlankCursor);
371 void VncView::showDotCursor(DotCursorState state)
373 RemoteView::showDotCursor(state);
375 setCursor(state == CursorOn ? localDotCursor() : Qt::BlankCursor);
378 void VncView::enableScaling(bool scale)
380 RemoteView::enableScaling(scale);
383 //level should be in [0, 100]
384 void VncView::setZoomLevel(int level)
386 Q_ASSERT(parentWidget() != 0);
388 if(level == -1) { //handle resize
389 resize(m_frame.width()*m_horizontalFactor, m_frame.height()*m_verticalFactor);
393 double factor; //actual magnification
396 } else if(level > 90) {
399 const double min_horiz_factor = double(parentWidget()->width())/m_frame.width();
400 const double min_vert_factor = double(parentWidget()->height())/m_frame.height();
401 const double fit_screen_factor = qMin(min_horiz_factor, min_vert_factor);
403 //level=900 => factor=1.0, level=0 => factor=fit_screen_factor
404 factor = (level)/90.0*(1.0 - fit_screen_factor) + fit_screen_factor;
408 //remote display smaller than local?
409 kDebug(5011) << "remote display smaller than local?";
412 if(factor != factor) //nan
415 kDebug(5011) << "factor" << factor;
417 m_verticalFactor = m_horizontalFactor = factor;
418 resize(m_frame.width()*factor, m_frame.height()*factor);
421 void VncView::setCut(const QString &text)
423 m_dontSendClipboard = true;
424 m_clipboard->setText(text, QClipboard::Clipboard);
425 m_clipboard->setText(text, QClipboard::Selection);
426 m_dontSendClipboard = false;
429 void VncView::paintEvent(QPaintEvent *event)
431 //kDebug(5011) << "paint event: x: " << m_x << ", y: " << m_y << ", w: " << m_w << ", h: " << m_h;
432 if (m_frame.isNull() || m_frame.format() == QImage::Format_Invalid) {
433 kDebug(5011) << "no valid image to paint";
434 RemoteView::paintEvent(event);
440 QPainter painter(this);
442 Qt::TransformationMode transformation_mode = Qt::SmoothTransformation;
443 if( m_horizontalFactor >= 1.0 )
444 transformation_mode = Qt::FastTransformation;
446 if (m_repaint and !force_full_repaint) {
447 // kDebug(5011) << "normal repaint";
448 painter.drawImage(QRect(qRound(m_x*m_horizontalFactor), qRound(m_y*m_verticalFactor),
449 qRound(m_w*m_horizontalFactor), qRound(m_h*m_verticalFactor)),
450 m_frame.copy(m_x, m_y, m_w, m_h).scaled(qRound(m_w*m_horizontalFactor),
451 qRound(m_h*m_verticalFactor),
452 Qt::IgnoreAspectRatio, transformation_mode));
454 //kDebug(5011) << "resize repaint";
455 QRect rect = event->rect();
456 if (!force_full_repaint and (rect.width() != width() || rect.height() != height())) {
457 // kDebug(5011) << "Partial repaint";
458 const int sx = rect.x()/m_horizontalFactor;
459 const int sy = rect.y()/m_verticalFactor;
460 const int sw = rect.width()/m_horizontalFactor;
461 const int sh = rect.height()/m_verticalFactor;
462 painter.drawImage(rect,
463 m_frame.copy(sx, sy, sw, sh).scaled(rect.width(), rect.height(),
464 Qt::IgnoreAspectRatio, transformation_mode));
466 kDebug(5011) << "Full repaint" << width() << height() << m_frame.width() << m_frame.height();
467 painter.drawImage(QRect(0, 0, width(), height()),
468 m_frame.scaled(m_frame.width() * m_horizontalFactor, m_frame.height() * m_verticalFactor,
469 Qt::IgnoreAspectRatio, transformation_mode));
470 force_full_repaint = false;
474 //draw local cursor ourselves, normal mouse pointer doesn't deal with scrolling
475 if((m_dotCursorState == CursorOn) || m_forceLocalCursor) {
476 #if QT_VERSION >= 0x040500
477 painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
479 //rectangle size includes 1px pen width
480 painter.drawRect(cursor_x*m_horizontalFactor - cursor_size/2, cursor_y*m_verticalFactor - cursor_size/2, cursor_size-1, cursor_size-1);
483 RemoteView::paintEvent(event);
486 void VncView::resizeEvent(QResizeEvent *event)
488 RemoteView::resizeEvent(event);
491 bool VncView::event(QEvent *event)
493 switch (event->type()) {
494 case QEvent::KeyPress:
495 case QEvent::KeyRelease:
496 // kDebug(5011) << "keyEvent";
497 keyEventHandler(static_cast<QKeyEvent*>(event));
500 case QEvent::MouseButtonDblClick:
501 case QEvent::MouseButtonPress:
502 case QEvent::MouseButtonRelease:
503 case QEvent::MouseMove:
504 // kDebug(5011) << "mouseEvent";
505 mouseEventHandler(static_cast<QMouseEvent*>(event));
509 // kDebug(5011) << "wheelEvent";
510 wheelEventHandler(static_cast<QWheelEvent*>(event));
513 case QEvent::WindowActivate: //input panel may have been closed, prevent IM from interfering with hardware keyboard
514 setAttribute(Qt::WA_InputMethodEnabled, false);
517 return RemoteView::event(event);
521 //call with e == 0 to flush held events
522 void VncView::mouseEventHandler(QMouseEvent *e)
524 static bool tap_detected = false;
525 static bool double_tap_detected = false;
526 static bool tap_drag_detected = false;
527 static QTime press_time;
528 static QTime up_time; //used for double clicks/tap&drag, for time after first tap
530 const int TAP_PRESS_TIME = 180;
531 const int DOUBLE_TAP_UP_TIME = 500;
533 if(!e) { //flush held taps
535 m_buttonMask |= 0x01;
536 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
537 m_buttonMask &= 0xfe;
538 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
539 tap_detected = false;
540 } else if(double_tap_detected and press_time.elapsed() > TAP_PRESS_TIME) { //got tap + another press -> tap & drag
541 m_buttonMask |= 0x01;
542 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
543 double_tap_detected = false;
544 tap_drag_detected = true;
550 if(e->x() < 0 or e->y() < 0) { //QScrollArea tends to send invalid events sometimes...
555 cursor_x = qRound(e->x()/m_horizontalFactor);
556 cursor_y = qRound(e->y()/m_verticalFactor);
557 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask); // plain move event
559 if(!disable_tapping and e->button() == Qt::LeftButton) { //implement touchpad-like input for left button
560 if(e->type() == QEvent::MouseButtonPress or e->type() == QEvent::MouseButtonDblClick) {
562 if(tap_detected and up_time.elapsed() < DOUBLE_TAP_UP_TIME) {
563 tap_detected = false;
564 double_tap_detected = true;
566 QTimer::singleShot(TAP_PRESS_TIME, this, SLOT(mouseEventHandler()));
568 } else if(e->type() == QEvent::MouseButtonRelease) {
569 if(tap_drag_detected) {
570 m_buttonMask &= 0xfe;
571 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
572 tap_drag_detected = false;
573 } else if(double_tap_detected) { //double click
574 double_tap_detected = false;
576 m_buttonMask |= 0x01;
577 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
578 m_buttonMask &= 0xfe;
579 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
580 m_buttonMask |= 0x01;
581 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
582 m_buttonMask &= 0xfe;
583 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
584 } else if(press_time.elapsed() < TAP_PRESS_TIME) { //tap
587 QTimer::singleShot(DOUBLE_TAP_UP_TIME, this, SLOT(mouseEventHandler()));
591 } else { //middle or right button, send directly
592 if ((e->type() == QEvent::MouseButtonPress)) {
593 if (e->button() & Qt::MidButton)
594 m_buttonMask |= 0x02;
595 if (e->button() & Qt::RightButton)
596 m_buttonMask |= 0x04;
597 } else if (e->type() == QEvent::MouseButtonRelease) {
598 if (e->button() & Qt::MidButton)
599 m_buttonMask &= 0xfd;
600 if (e->button() & Qt::RightButton)
601 m_buttonMask &= 0xfb;
603 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
606 //prevent local cursor artifacts
607 static int old_cursor_x = cursor_x;
608 static int old_cursor_y = cursor_y;
609 if(((m_dotCursorState == CursorOn) || m_forceLocalCursor)
610 and (cursor_x != old_cursor_x or cursor_y != old_cursor_y)) {
611 //clear last position
612 repaint(old_cursor_x*m_horizontalFactor - cursor_size/2, old_cursor_y*m_verticalFactor - cursor_size/2, cursor_size, cursor_size);
613 //and refresh new one
614 repaint(cursor_x*m_horizontalFactor - cursor_size/2, cursor_y*m_verticalFactor - cursor_size/2, cursor_size, cursor_size);
616 old_cursor_x = cursor_x; old_cursor_y = cursor_y;
620 void VncView::wheelEventHandler(QWheelEvent *event)
623 if (event->delta() < 0)
628 const int x = qRound(event->x() / m_horizontalFactor);
629 const int y = qRound(event->y() / m_verticalFactor);
631 vncThread.mouseEvent(x, y, eb | m_buttonMask);
632 vncThread.mouseEvent(x, y, m_buttonMask);
635 void VncView::keyEventHandler(QKeyEvent *e)
637 // strip away autorepeating KeyRelease; see bug #206598
638 if (e->isAutoRepeat() && (e->type() == QEvent::KeyRelease)) {
642 // parts of this code are based on http://italc.sourcearchive.com/documentation/1.0.9.1/vncview_8cpp-source.html
643 rfbKeySym k = e->nativeVirtualKey();
645 // we do not handle Key_Backtab separately as the Shift-modifier
646 // is already enabled
647 if (e->key() == Qt::Key_Backtab) {
651 const bool pressed = (e->type() == QEvent::KeyPress);
654 //don't send ISO_Level3_Shift (would break things like Win+0-9)
655 //also enable IM so symbol key works
657 setAttribute(Qt::WA_InputMethodEnabled, pressed);
664 if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L) {
667 } else if (m_mods.contains(k)) {
675 int current_zoom = -1;
676 if(e->key() == Qt::Key_F8)
677 current_zoom = left_zoom;
678 else if(e->key() == Qt::Key_F7)
679 current_zoom = right_zoom;
681 // kDebug(5011) << "got '" << e->text() << "'.";
682 vncThread.keyEvent(k, pressed);
684 kDebug(5011) << "nativeVirtualKey() for '" << e->text() << "' failed.";
688 if(current_zoom == -1)
691 //handle zoom buttons
692 if(current_zoom == 0) { //left click
694 m_buttonMask |= 0x01;
696 m_buttonMask &= 0xfe;
697 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
698 } else if(current_zoom == 1) { //right click
700 m_buttonMask |= 0x04;
702 m_buttonMask &= 0xfb;
703 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
704 } else if(current_zoom == 2) { //middle click
706 m_buttonMask |= 0x02;
708 m_buttonMask &= 0xfd;
709 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
710 } else if(current_zoom == 3 and pressed) { //wheel up
712 vncThread.mouseEvent(cursor_x, cursor_y, eb | m_buttonMask);
713 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
714 } else if(current_zoom == 4 and pressed) { //wheel down
716 vncThread.mouseEvent(cursor_x, cursor_y, eb | m_buttonMask);
717 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
718 } else if(current_zoom == 5) { //page up
719 vncThread.keyEvent(0xff55, pressed);
720 } else if(current_zoom == 6) { //page down
721 vncThread.keyEvent(0xff56, pressed);
725 void VncView::unpressModifiers()
727 const QList<unsigned int> keys = m_mods.keys();
728 QList<unsigned int>::const_iterator it = keys.constBegin();
729 while (it != keys.end()) {
730 vncThread.keyEvent(*it, false);
736 void VncView::clipboardSelectionChanged()
738 if (m_status != Connected)
741 if (m_clipboard->ownsSelection() || m_dontSendClipboard)
744 const QString text = m_clipboard->text(QClipboard::Selection);
746 vncThread.clientCut(text);
749 void VncView::clipboardDataChanged()
751 if (m_status != Connected)
754 if (m_clipboard->ownsClipboard() || m_dontSendClipboard)
757 const QString text = m_clipboard->text(QClipboard::Clipboard);
759 vncThread.clientCut(text);
763 void VncView::sendKey(Qt::Key key)
765 //convert Qt::Key into x11 keysym
777 case Qt::Key_PageDown:
795 case Qt::Key_Backspace:
810 k = 0xffbe + int(key - Qt::Key_F1);
822 case Qt::MetaModifier:
826 case Qt::AltModifier:
829 case Qt::Key_Control:
830 case Qt::ControlModifier:
834 kDebug(5011) << "sendKey(): Unhandled Qt::Key value " << key;
838 if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L || k == XK_Super_L) {
839 if (m_mods.contains(k)) { //release
841 vncThread.keyEvent(k, false);
844 vncThread.keyEvent(k, true);
846 } else { //normal key
847 vncThread.keyEvent(k, true);
848 vncThread.keyEvent(k, false);
852 void VncView::sendKeySequence(QKeySequence keys)
854 Q_ASSERT(keys.count() <= 1); //we can only handle a single combination
856 //to get at individual key presses, we split 'keys' into its components
858 for(int i = 0; ; i++) {
859 QString k = keys.toString().section('+', i, i);
862 //kDebug(5011) << "found key: " << k;
864 key_list.append(Qt::Key_Alt);
865 } else if(k == "Ctrl") {
866 key_list.append(Qt::Key_Control);
867 } else if(k == "Meta") {
868 key_list.append(Qt::Key_Meta);
870 key_list.append(QKeySequence(k)[0]);
874 for(int i = 0; i < key_list.count(); i++)
875 sendKey(Qt::Key(key_list.at(i)));
877 //release modifiers (everything before final key)
878 for(int i = key_list.count()-2; i >= 0; i--)
879 sendKey(Qt::Key(key_list.at(i)));
882 void VncView::reloadSettings()
885 left_zoom = settings.value("left_zoom", 0).toInt();
886 right_zoom = settings.value("right_zoom", 1).toInt();
887 disable_tapping = settings.value("disable_tapping", false).toBool();
889 bool always_show_local_cursor = settings.value("always_show_local_cursor", false).toBool();
890 if(always_show_local_cursor)
891 showDotCursor(CursorOn);
896 //convert commitString into keyevents
897 void VncView::inputMethodEvent(QInputMethodEvent *event)
899 //TODO handle replacements
900 //NOTE for the return key to work Qt needs to enable multiline input, which only works for Q(Plain)TextEdit
902 //kDebug(5011) << event->commitString() << "|" << event->preeditString() << "|" << event->replacementLength() << "|" << event->replacementStart();
903 QString letters = event->commitString();
904 for(int i = 0; i < letters.length(); i++) {
905 char k = letters.at(i).toLatin1(); //works with all 'normal' keys, not umlauts.
907 kDebug(5011) << "unhandled key";
910 vncThread.keyEvent(k, true);
911 vncThread.keyEvent(k, false);
916 #include "moc_vncview.cpp"