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.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/krdc/vnc/kvncview.cpp b/krdc/vnc/kvncview.cpp
index 30cb2356..223cd5cc 100644
--- a/krdc/vnc/kvncview.cpp
+++ b/krdc/vnc/kvncview.cpp
@@ -645,6 +645,57 @@ void KVncView::pressKey(XEvent *xe) {
m_mods.clear();
}
+bool KVncView::supportsSendString() const
+{
+ return true;
+}
+
+void KVncView::sendString(const TQString &s)
+{
+ if (m_status != REMOTE_VIEW_CONNECTED)
+ return;
+ if (m_viewOnly)
+ return;
+
+ for(uint i = 0; i < s.length(); ++i)
+ {
+ /* X11 reserves keysyms 0x01000000 to 0x0110FFFF for Unicode code-points
+ * (see keysymdef.h).
+ */
+ uint sym = s[i].unicode() + 0x01000000;
+
+ /* Convert line breaks to return (enter). */
+ if(s[i] == '\n')
+ {
+ sym = XK_Return;
+ }
+
+ /* If the character is upper-case and below code-point 0x3000 (most western
+ * languages), assume the shift key is required (based on kkeyserver_x11.cpp).
+ */
+ bool shift = false;
+ if(s[i].unicode() < 0x3000 && s[i].isLetter() && s[i].lower() != s[i].upper() && s[i] == s[i].upper())
+ {
+ m_cthreadObject.queueKeyEvent(XK_Shift_L, true);
+ shift = true;
+ }
+
+ m_cthreadObject.queueKeyEvent(sym, true);
+ m_cthreadObject.queueKeyEvent(sym, false);
+
+ if(shift)
+ {
+ m_cthreadObject.queueKeyEvent(XK_Shift_L, false);
+ }
+
+ #if 0
+ fprintf(stderr, "Sent character: '%s' (sym = %u, shift = %s)\n",
+ (const char*)(TQString(s[i]).local8Bit()),
+ (unsigned)(sym), (shift ? "yes" : "no"));
+ #endif
+ }
+}
+
bool KVncView::x11Event(XEvent *e) {
bool pressed;
if (e->type == KeyPress)