summaryrefslogtreecommitdiffstats
path: root/krdc/vnc/kvncview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'krdc/vnc/kvncview.cpp')
-rw-r--r--krdc/vnc/kvncview.cpp142
1 files changed, 73 insertions, 69 deletions
diff --git a/krdc/vnc/kvncview.cpp b/krdc/vnc/kvncview.cpp
index 22960423..b7ca3685 100644
--- a/krdc/vnc/kvncview.cpp
+++ b/krdc/vnc/kvncview.cpp
@@ -2,7 +2,8 @@
kvncview.cpp - main widget
-------------------
begin : Thu Dec 20 15:11:42 CET 2001
- copyright : (C) 2001-2003 by Tim Jansen
+ copyright : (C) 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2001-2003 by Tim Jansen
email : tim@tjansen.de
***************************************************************************/
@@ -34,6 +35,8 @@
#include <tqbitmap.h>
#include <tqmutex.h>
#include <tqvbox.h>
+#include <tqtimer.h>
+#include <tqpainter.h>
#include <tqwaitcondition.h>
#include "vncviewer.h"
@@ -47,7 +50,6 @@ bool launch_Fullscreen_vnc = false;
* application resource specs. The AppData structure is defined in the header
* file.
*/
-AppData appData;
bool appDataConfigured = false;
Display* dpy;
@@ -73,8 +75,7 @@ KVncView::KVncView(TQWidget *parent,
DotCursorState dotCursorState,
const TQString &encodings) :
KRemoteView(parent, name, TQt::WResizeNoErase | TQt::WRepaintNoErase | TQt::WStaticContents),
- m_cthread(this, m_wthread, m_quitFlag),
- m_wthread(this, m_quitFlag),
+ m_cthreadObject(this, m_quitFlag),
m_quitFlag(false),
m_enableFramebufferLocking(false),
m_scaling(false),
@@ -147,8 +148,6 @@ int KVncView::port() {
void KVncView::startQuitting() {
m_quitFlag = true;
- m_wthread.kick();
- m_cthread.kick();
}
bool KVncView::isQuitting() {
@@ -157,44 +156,37 @@ bool KVncView::isQuitting() {
void KVncView::configureApp(Quality q, const TQString specialEncodings) {
appDataConfigured = true;
- appData.shareDesktop = 1;
- appData.viewOnly = 0;
+ m_cthreadObject.cl->appData.shareDesktop = 1;
+ m_cthreadObject.cl->appData.viewOnly = 0;
if (q == QUALITY_LOW) {
- appData.useBGR233 = 1;
- appData.encodingsString = "background copyrect softcursor tight zlib hextile raw";
- appData.compressLevel = -1;
- appData.qualityLevel = 1;
- appData.dotCursor = 1;
+ m_cthreadObject.cl->appData.useBGR233 = 1;
+ m_cthreadObject.cl->appData.encodingsString = "tight zrle ultra copyrect hextile zlib corre rre raw";
+ m_cthreadObject.cl->appData.compressLevel = 9;
+ m_cthreadObject.cl->appData.qualityLevel = 1;
+ m_cthreadObject.cl->appData.useRemoteCursor = 1;
}
else if (q == QUALITY_MEDIUM) {
- appData.useBGR233 = 0;
- appData.encodingsString = "background copyrect softcursor tight zlib hextile raw";
- appData.compressLevel = -1;
- appData.qualityLevel = 7;
- appData.dotCursor = 1;
+ m_cthreadObject.cl->appData.useBGR233 = 0;
+ m_cthreadObject.cl->appData.encodingsString = "tight zrle ultra copyrect hextile zlib corre rre raw";
+ m_cthreadObject.cl->appData.compressLevel = 5;
+ m_cthreadObject.cl->appData.qualityLevel = 7;
+ m_cthreadObject.cl->appData.useRemoteCursor = 1;
}
else if ((q == QUALITY_HIGH) || (q == QUALITY_UNKNOWN)) {
- appData.useBGR233 = 0;
- appData.encodingsString = "copyrect softcursor hextile raw";
- appData.compressLevel = -1;
- appData.qualityLevel = 9;
- appData.dotCursor = 1;
+ m_cthreadObject.cl->appData.useBGR233 = 0;
+ m_cthreadObject.cl->appData.encodingsString = "copyrect hextile raw";
+ m_cthreadObject.cl->appData.compressLevel = 0;
+ m_cthreadObject.cl->appData.qualityLevel = 9;
+ m_cthreadObject.cl->appData.useRemoteCursor = 1;
}
- if (!specialEncodings.isNull())
- appData.encodingsString = specialEncodings.latin1();
-
- appData.nColours = 256;
- appData.useSharedColours = 1;
- appData.requestedDepth = 0;
-
- appData.rawDelay = 0;
- appData.copyRectDelay = 0;
+ if (!specialEncodings.isNull()) {
+ m_cthreadObject.cl->appData.encodingsString = specialEncodings.latin1();
+ }
- if (!appData.dotCursor)
- m_cursorState = DOT_CURSOR_OFF;
- showDotCursorInternal();
+ m_cthreadObject.cl->appData.nColours = 256;
+ m_cthreadObject.cl->appData.requestedDepth = 0;
}
bool KVncView::checkLocalKRfb() {
@@ -297,7 +289,10 @@ bool KVncView::start() {
setStatus(REMOTE_VIEW_CONNECTING);
+ m_cthreadObject.moveToThread(&m_cthread);
+ TQTimer::singleShot(0, &m_cthreadObject, SLOT(run()));
m_cthread.start();
+
setBackgroundMode(TQt::NoBackground);
return true;
}
@@ -306,8 +301,6 @@ KVncView::~KVncView()
{
startQuitting();
m_cthread.wait();
- m_wthread.wait();
- freeResources();
}
bool KVncView::supportsLocalCursor() const {
@@ -354,9 +347,16 @@ void KVncView::enableScaling(bool s) {
setMaximumSize(m_framebufferSize);
setMinimumSize(m_framebufferSize.width()/16,
m_framebufferSize.height()/16);
+
+ m_cthreadObject.setScaling(width(), height());
}
- else
+ else {
setFixedSize(m_framebufferSize);
+ m_cthreadObject.setScaling(-1, -1);
+ }
+
+ // Force full redraw
+ drawRegion(0, 0, width(), height());
}
}
@@ -367,12 +367,18 @@ void KVncView::paintEvent(TQPaintEvent *e) {
e->rect().height());
}
+void KVncView::resizeEvent(TQResizeEvent *e) {
+ if (m_scaling) {
+ m_cthreadObject.setScaling(width(), height());
+
+ // Force full redraw
+ drawRegion(0, 0, width(), height());
+ }
+}
+
void KVncView::drawRegion(int x, int y, int w, int h) {
- if (m_scaling)
- DrawZoomedScreenRegionX11Thread(winId(), width(), height(),
- x, y, w, h);
- else
- DrawScreenRegionX11Thread(winId(), x, y, w, h);
+ TQPainter painter(this);
+ painter.drawImage(TQRect(x, y, w, h), m_cthreadObject.image(x, y, w, h));
}
void KVncView::customEvent(TQCustomEvent *e)
@@ -387,9 +393,6 @@ void KVncView::customEvent(TQCustomEvent *e)
setFixedSize(m_framebufferSize);
emit changeSize(sre->width(), sre->height());
}
- else if (e->type() == DesktopInitEventType) {
- m_cthread.desktopInit();
- }
else if (e->type() == StatusChangeEventType) {
StatusChangeEvent *sce = (StatusChangeEvent*) e;
setStatus(sce->status());
@@ -562,10 +565,13 @@ void KVncView::mouseEvent(TQMouseEvent *e) {
x = (x * m_framebufferSize.width()) / width();
y = (y * m_framebufferSize.height()) / height();
}
- m_wthread.queueMouseEvent(x, y, m_buttonMask);
+ m_cthreadObject.queueMouseEvent(x, y, m_buttonMask);
- if (m_enableClientCursor)
- DrawCursorX11Thread(x, y); // in rfbproto.c
+ if (m_enableClientCursor) {
+ // FIXME
+ // How to draw soft cursor?
+ // DrawCursorX11Thread(x, y); // in rfbproto.c
+ }
}
void KVncView::mousePressEvent(TQMouseEvent *e) {
@@ -606,8 +612,8 @@ void KVncView::wheelEvent(TQWheelEvent *e) {
x = (x * m_framebufferSize.width()) / width();
y = (y * m_framebufferSize.height()) / height();
}
- m_wthread.queueMouseEvent(x, y, eb|m_buttonMask);
- m_wthread.queueMouseEvent(x, y, m_buttonMask);
+ m_cthreadObject.queueMouseEvent(x, y, eb|m_buttonMask);
+ m_cthreadObject.queueMouseEvent(x, y, m_buttonMask);
e->accept();
}
@@ -620,25 +626,25 @@ void KVncView::pressKey(XEvent *xe) {
KKeyNative k(xe);
uint mod = k.mod();
if (mod & KKeyNative::modX(KKey::SHIFT))
- m_wthread.queueKeyEvent(XK_Shift_L, true);
+ m_cthreadObject.queueKeyEvent(XK_Shift_L, true);
if (mod & KKeyNative::modX(KKey::CTRL))
- m_wthread.queueKeyEvent(XK_Control_L, true);
+ m_cthreadObject.queueKeyEvent(XK_Control_L, true);
if (mod & KKeyNative::modX(KKey::ALT))
- m_wthread.queueKeyEvent(XK_Alt_L, true);
+ m_cthreadObject.queueKeyEvent(XK_Alt_L, true);
if (mod & KKeyNative::modX(KKey::WIN))
- m_wthread.queueKeyEvent(XK_Meta_L, true);
+ m_cthreadObject.queueKeyEvent(XK_Meta_L, true);
- m_wthread.queueKeyEvent(k.sym(), true);
- m_wthread.queueKeyEvent(k.sym(), false);
+ m_cthreadObject.queueKeyEvent(k.sym(), true);
+ m_cthreadObject.queueKeyEvent(k.sym(), false);
if (mod & KKeyNative::modX(KKey::WIN))
- m_wthread.queueKeyEvent(XK_Meta_L, false);
+ m_cthreadObject.queueKeyEvent(XK_Meta_L, false);
if (mod & KKeyNative::modX(KKey::ALT))
- m_wthread.queueKeyEvent(XK_Alt_L, false);
+ m_cthreadObject.queueKeyEvent(XK_Alt_L, false);
if (mod & KKeyNative::modX(KKey::CTRL))
- m_wthread.queueKeyEvent(XK_Control_L, false);
+ m_cthreadObject.queueKeyEvent(XK_Control_L, false);
if (mod & KKeyNative::modX(KKey::SHIFT))
- m_wthread.queueKeyEvent(XK_Shift_L, false);
+ m_cthreadObject.queueKeyEvent(XK_Shift_L, false);
m_mods.clear();
}
@@ -671,7 +677,7 @@ bool KVncView::x11Event(XEvent *e) {
else
unpressModifiers();
}
- m_wthread.queueKeyEvent(s, pressed);
+ m_cthreadObject.queueKeyEvent(s, pressed);
}
return true;
}
@@ -680,7 +686,7 @@ void KVncView::unpressModifiers() {
TQValueList<unsigned int> keys = m_mods.keys();
TQValueList<unsigned int>::const_iterator it = keys.begin();
while (it != keys.end()) {
- m_wthread.queueKeyEvent(*it, false);
+ m_cthreadObject.queueKeyEvent(*it, false);
it++;
}
m_mods.clear();
@@ -713,7 +719,7 @@ void KVncView::clipboardChanged() {
if (text.length() > MAX_SELECTION_LENGTH)
return;
- m_wthread.queueClientCut(text);
+ m_cthreadObject.queueClientCut(text);
}
void KVncView::selectionChanged() {
@@ -727,7 +733,7 @@ void KVncView::selectionChanged() {
if (text.length() > MAX_SELECTION_LENGTH)
return;
- m_wthread.queueClientCut(text);
+ m_cthreadObject.queueClientCut(text);
}
@@ -759,7 +765,7 @@ void KVncView::enableClientCursor(bool enable) {
locks and signals are there to protect against deadlocks and other
horribleness. Be careful making changes here.
*/
-int getPassword(char *passwd, int pwlen) {
+int getPassword(char * &passwd) {
int retV = 0;
//Prepare the system
@@ -786,9 +792,7 @@ int getPassword(char *passwd, int pwlen) {
//Process the password if we got it, clear it if we didn't
if (retV) {
- strncpy(passwd, (const char*)password, pwlen);
- } else {
- passwd[0] = 0;
+ passwd = strdup((const char*)password);
}
//Pack up and go home