mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:31:16 -07:00
Add bidirectional text-clipboard support
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
#include "rfbserver.h"
|
||||
#include "rfbservermanager.h"
|
||||
#include <QtCore/QSocketNotifier>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <KDebug>
|
||||
|
||||
struct RfbServer::Private
|
||||
@@ -136,6 +138,8 @@ bool RfbServer::start()
|
||||
d->notifier = new QSocketNotifier(d->screen->listenSock, QSocketNotifier::Read, this);
|
||||
d->notifier->setEnabled(true);
|
||||
connect(d->notifier, SIGNAL(activated(int)), this, SLOT(onListenSocketActivated()));
|
||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()),
|
||||
this, SLOT(krfbSendServerCutText()));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -201,6 +205,15 @@ void RfbServer::updateCursorPosition(const QPoint & position)
|
||||
}
|
||||
}
|
||||
|
||||
void RfbServer::krfbSendServerCutText()
|
||||
{
|
||||
if(d->screen) {
|
||||
QString text = QApplication::clipboard()->text();
|
||||
rfbSendServerCutText(d->screen,
|
||||
text.toLocal8Bit().data(),text.length());
|
||||
}
|
||||
}
|
||||
|
||||
void RfbServer::onListenSocketActivated()
|
||||
{
|
||||
rfbProcessNewConnection(d->screen);
|
||||
@@ -263,7 +276,7 @@ void RfbServer::pointerHook(int bm, int x, int y, rfbClientPtr cl)
|
||||
//static
|
||||
void RfbServer::clipboardHook(char *str, int len, rfbClientPtr cl)
|
||||
{
|
||||
//TODO implement me
|
||||
QApplication::clipboard()->setText(QString::fromLocal8Bit(str,len));
|
||||
}
|
||||
|
||||
#include "rfbserver.moc"
|
||||
|
||||
@@ -47,6 +47,7 @@ public Q_SLOTS:
|
||||
void updateCursorPosition(const QPoint & position);
|
||||
|
||||
private Q_SLOTS:
|
||||
void krfbSendServerCutText();
|
||||
void onListenSocketActivated();
|
||||
void pendingClientFinished(RfbClient *client);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user