mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:41:17 -07:00
sync
svn path=/trunk/kdenetwork/krfb/; revision=127439
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
METASOURCES = AUTO
|
||||
|
||||
bin_PROGRAMS = krfb
|
||||
krfb_SOURCES = trayicon.cpp XUpdateScanner.cc rfbserver.cpp main.cpp configurationdialog.ui newconnectiondialog.ui configuration.cpp
|
||||
krfb_SOURCES = configuration.cc trayicon.cpp XUpdateScanner.cc rfbconnection.cpp main.cpp configurationdialog.ui newconnectiondialog.ui
|
||||
krfb_LDADD = ./lib/liblib.a $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIBSOCKET)
|
||||
|
||||
SUBDIRS = lib
|
||||
|
||||
EXTRA_DIST = main.cpp krfb.desktop lo32-app-krfb.png lo16-app-krfb.png rfbserver.cpp rfbserver.h eyes-closed24.png eyes-open24.png XUpdateScanner.cc XUpdateScanner.h trayicon.cpp trayicon.h
|
||||
EXTRA_DIST = main.cpp krfb.desktop lo32-app-krfb.png lo16-app-krfb.png rfbserver.cpp rfbserver.h eyes-closed24.png eyes-open24.png XUpdateScanner.cc XUpdateScanner.h trayicon.cpp trayicon.h configuration.h configuration.cpp
|
||||
|
||||
install-data-local:
|
||||
$(mkinstalldirs) $(kde_appsdir)/Applications/
|
||||
@@ -41,8 +43,6 @@ uninstall-local:
|
||||
# set the include path for X, qt and KDE
|
||||
INCLUDES= $(all_includes) -I../include
|
||||
|
||||
METASOURCES = AUTO
|
||||
|
||||
# the library search path.
|
||||
krfb_LDFLAGS = $(all_libraries) $(KDE_RPATH) -lXtst
|
||||
|
||||
@@ -51,15 +51,7 @@ krfb_LDFLAGS = $(all_libraries) $(KDE_RPATH) -lXtst
|
||||
#rcdir = $(kde_datadir)/krfb
|
||||
#rc_DATA = krfbui.rc
|
||||
|
||||
#WARNING: if you use a ui.rc file above, use:
|
||||
|
||||
# messages: rc.cpp
|
||||
|
||||
# instead of
|
||||
|
||||
# messages:
|
||||
|
||||
messages:
|
||||
messages: rc.cpp
|
||||
LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
|
||||
if test -n "$$LIST"; then \
|
||||
$(XGETTEXT) $$LIST -o $(podir)/krfb.pot; \
|
||||
|
||||
@@ -22,7 +22,10 @@
|
||||
#define _hexonet_rfb_XUpdateScanner_h_
|
||||
|
||||
|
||||
#include "rfbServer.h"
|
||||
#include "../include/rfbServer.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
|
||||
|
||||
namespace rfb {
|
||||
|
||||
128
krfb/configuration.cc
Normal file
128
krfb/configuration.cc
Normal file
@@ -0,0 +1,128 @@
|
||||
/***************************************************************************
|
||||
configuration.cpp
|
||||
-------------------
|
||||
begin : Tue Dec 11 2001
|
||||
copyright : (C) 2001 by Tim Jansen
|
||||
email : tim@tjansen.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
#include <kconfig.h>
|
||||
#include <kglobal.h>
|
||||
|
||||
#include <qpushbutton.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qcheckbox.h>
|
||||
|
||||
Configuration::Configuration()
|
||||
{
|
||||
loadFromKConfig();
|
||||
saveToDialog();
|
||||
|
||||
|
||||
portValidator = new QIntValidator(0, 65535,
|
||||
confDlg.displayNumberInput);
|
||||
confDlg.displayNumberInput->setValidator(portValidator);
|
||||
|
||||
connect(confDlg.okButton, SIGNAL(clicked()),
|
||||
SLOT(okPressed()));
|
||||
connect(confDlg.cancelButton, SIGNAL(clicked()),
|
||||
SLOT(cancelPressed()));
|
||||
connect(confDlg.applyButton, SIGNAL(clicked()),
|
||||
SLOT(applyPressed()));
|
||||
}
|
||||
|
||||
Configuration::~Configuration() {
|
||||
}
|
||||
|
||||
void Configuration::loadFromKConfig() {
|
||||
KConfig *config = KGlobal::config();
|
||||
askOnConnectFlag = config->readBoolEntry("askOnConnect", true);
|
||||
allowDesktopControlFlag = config->readBoolEntry("allowDesktopControl",
|
||||
false);
|
||||
showMousePointerFlag = config->readBoolEntry("showMousePointer",
|
||||
true);
|
||||
passwordString = config->readEntry("password", "");
|
||||
portNumber = config->readNumEntry("port", 0);
|
||||
}
|
||||
|
||||
void Configuration::loadFromDialog() {
|
||||
askOnConnectFlag = confDlg.askOnConnectCB->isChecked();
|
||||
allowDesktopControlFlag = confDlg.allowDesktopControlCB->isChecked();
|
||||
showMousePointerFlag = confDlg.showMousePointerCB->isChecked();
|
||||
passwordString = confDlg.passwordInput->text();
|
||||
int p = confDlg.displayNumberInput->text().toInt();
|
||||
if (p != portNumber) {
|
||||
portNumber = p;
|
||||
emit portChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Configuration::saveToKConfig() {
|
||||
KConfig *config = KGlobal::config();
|
||||
config->writeEntry("askOnConnect", askOnConnectFlag);
|
||||
config->writeEntry("allowDesktopControl", allowDesktopControlFlag);
|
||||
config->writeEntry("showMousePointer", showMousePointerFlag);
|
||||
config->writeEntry("password", passwordString);
|
||||
config->writeEntry("port", portNumber);
|
||||
}
|
||||
|
||||
void Configuration::saveToDialog() {
|
||||
confDlg.askOnConnectCB->setChecked(askOnConnectFlag);
|
||||
confDlg.allowDesktopControlCB->setChecked(allowDesktopControlFlag);
|
||||
confDlg.showMousePointerCB->setChecked(showMousePointerFlag);
|
||||
confDlg.passwordInput->setText(passwordString);
|
||||
confDlg.displayNumberInput->setText(QString().setNum(portNumber));
|
||||
}
|
||||
|
||||
bool Configuration::askOnConnect() const {
|
||||
return askOnConnectFlag;
|
||||
}
|
||||
|
||||
bool Configuration::allowDesktopControl() const {
|
||||
return allowDesktopControlFlag;
|
||||
}
|
||||
|
||||
bool Configuration::showMousePointer() const {
|
||||
return showMousePointerFlag;
|
||||
}
|
||||
|
||||
QString Configuration::password() const {
|
||||
return passwordString;
|
||||
}
|
||||
|
||||
int Configuration::port() const {
|
||||
return portNumber;
|
||||
}
|
||||
|
||||
void Configuration::showDialog() {
|
||||
confDlg.show();
|
||||
}
|
||||
|
||||
void Configuration::okPressed() {
|
||||
loadFromDialog();
|
||||
saveToKConfig();
|
||||
confDlg.hide();
|
||||
}
|
||||
|
||||
void Configuration::cancelPressed() {
|
||||
saveToDialog();
|
||||
confDlg.hide();
|
||||
}
|
||||
|
||||
void Configuration::applyPressed() {
|
||||
loadFromDialog();
|
||||
saveToKConfig();
|
||||
}
|
||||
|
||||
#include "configuration.moc"
|
||||
72
krfb/configuration.h
Normal file
72
krfb/configuration.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
configuration.h
|
||||
-------------------
|
||||
begin : Tue Dec 11 2001
|
||||
copyright : (C) 2001 by Tim Jansen
|
||||
email : tim@tjansen.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef CONFIGURATION_H
|
||||
#define CONFIGURATION_H
|
||||
|
||||
#include "configurationdialog.h"
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qvalidator.h>
|
||||
#include <qstring.h>
|
||||
|
||||
/**
|
||||
* This class stores the app's configuration and also 'drives'
|
||||
* the configuration dialog.
|
||||
* @author Tim Jansen
|
||||
*/
|
||||
class Configuration : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Configuration();
|
||||
~Configuration();
|
||||
|
||||
bool askOnConnect() const;
|
||||
bool allowDesktopControl() const;
|
||||
bool showMousePointer() const;
|
||||
|
||||
QString password() const;
|
||||
int port() const;
|
||||
|
||||
signals:
|
||||
void portChanged();
|
||||
|
||||
public slots:
|
||||
void showDialog();
|
||||
|
||||
private:
|
||||
void loadFromKConfig();
|
||||
void loadFromDialog();
|
||||
void saveToKConfig();
|
||||
void saveToDialog();
|
||||
|
||||
ConfigurationDialog confDlg;
|
||||
QIntValidator *portValidator;
|
||||
|
||||
bool askOnConnectFlag;
|
||||
bool allowDesktopControlFlag;
|
||||
bool showMousePointerFlag;
|
||||
QString passwordString;
|
||||
int portNumber;
|
||||
|
||||
private slots:
|
||||
void okPressed();
|
||||
void cancelPressed();
|
||||
void applyPressed();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -11,7 +11,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>390</width>
|
||||
<width>386</width>
|
||||
<height>278</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -352,6 +352,10 @@
|
||||
<name>text</name>
|
||||
<string>&Ok</string>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>default</name>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property>
|
||||
<name>whatsThis</name>
|
||||
<string>Apply changes and close window.</string>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "trayicon.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#include <kpixmap.h>
|
||||
#include <kaction.h>
|
||||
@@ -24,6 +25,7 @@
|
||||
#include <kcmdlineargs.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <klocale.h>
|
||||
#include <qobject.h>
|
||||
|
||||
#define VERSION "0.1"
|
||||
|
||||
@@ -46,7 +48,14 @@ int main(int argc, char *argv[])
|
||||
KCmdLineArgs::addCmdLineOptions( options );
|
||||
|
||||
KApplication app;
|
||||
TrayIcon tray;
|
||||
|
||||
TrayIcon trayicon;
|
||||
Configuration config;
|
||||
|
||||
QObject::connect(&trayicon, SIGNAL(showConfigure()),
|
||||
&config, SLOT(showDialog()));
|
||||
|
||||
QObject::connect(&app, SIGNAL(lastWindowClosed()),
|
||||
&app, SLOT(quit()));
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
<!DOCTYPE UI><UI>
|
||||
<class>myview</class>
|
||||
<widget>
|
||||
<class>QWidget</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>myview</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>geometry</name>
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>11</y>
|
||||
<width>178</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>maximumSize</name>
|
||||
<size>
|
||||
<width>32767</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>minimumSize</name>
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>sizePolicy</name>
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>caption</name>
|
||||
<string>Form1</string>
|
||||
</property>
|
||||
<widget>
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>PushButton1</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>geometry</name>
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Test</string>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>sizePolicy</name>
|
||||
<sizepolicy>
|
||||
<hsizetype>4</hsizetype>
|
||||
<vsizetype>4</vsizetype>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>cursor</name>
|
||||
<cursor>13</cursor>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>maximumSize</name>
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>32767</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</UI>
|
||||
136
krfb/rfbconnection.cpp
Normal file
136
krfb/rfbconnection.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/***************************************************************************
|
||||
rfbconnection.cpp
|
||||
-------------------
|
||||
begin : Sun Dec 9 2001
|
||||
copyright : (C) 2001 by Tim Jansen
|
||||
email : tim@tjansen.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Contains portions & concept from rfb's x0rfbserver.cc
|
||||
* Copyright (C) 2000 heXoNet Support GmbH, D-66424 Homburg.
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "rfbconnection.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
RFBConnection::RFBConnection(Display *dpy, int fd) :
|
||||
Server(),
|
||||
dpy(dpy),
|
||||
fd(fd),
|
||||
buttonMask(0)
|
||||
{
|
||||
bufferedConnection = new BufferedConnection(32768, 32768);
|
||||
connection = bufferedConnection;
|
||||
|
||||
InitBlocks(32, 32);
|
||||
|
||||
XTestGrabControl(dpy, true);
|
||||
createFramebuffer();
|
||||
|
||||
connection->send((unsigned char*) RFB_PROTOCOL_VERSION, 12);
|
||||
}
|
||||
|
||||
RFBConnection::~RFBConnection() {
|
||||
DeleteBlocks();
|
||||
|
||||
destroyFramebuffer();
|
||||
XTestDiscard( dpy );
|
||||
|
||||
delete bufferedConnection;
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void RFBConnection::handleKeyEvent(KeyEvent &keyEvent) {
|
||||
KeyCode kc = XKeysymToKeycode(dpy, keyEvent.key);
|
||||
if (kc != NoSymbol)
|
||||
XTestFakeKeyEvent(dpy,
|
||||
XKeysymToKeycode( dpy, keyEvent.key ),
|
||||
keyEvent.down_flag,
|
||||
CurrentTime);
|
||||
}
|
||||
|
||||
void RFBConnection::handlePointerEvent(PointerEvent &pointerEvent) {
|
||||
XTestFakeMotionEvent(dpy,
|
||||
0,
|
||||
pointerEvent.x_position,
|
||||
pointerEvent.y_position,
|
||||
CurrentTime);
|
||||
int i = 1;
|
||||
while (i <= 5) {
|
||||
if ( (buttonMask & (1 << (i-1))) != (pointerEvent.button_mask & (1 << (i-1))) )
|
||||
XTestFakeButtonEvent( dpy, i,
|
||||
(pointerEvent.button_mask & (1 << (i-1)))? True : False,
|
||||
CurrentTime );
|
||||
i++;
|
||||
}
|
||||
buttonMask = pointerEvent.button_mask;
|
||||
}
|
||||
|
||||
void RFBConnection::createFramebuffer()
|
||||
{
|
||||
framebufferImage = XGetImage(dpy,
|
||||
QApplication::desktop()->winId(),
|
||||
0,
|
||||
0,
|
||||
QApplication::desktop()->width(),
|
||||
QApplication::desktop()->height(),
|
||||
AllPlanes,
|
||||
ZPixmap);
|
||||
framebuffer.width = framebufferImage->width;
|
||||
framebuffer.height = framebufferImage->height;
|
||||
framebuffer.bytesPerLine = framebufferImage->bytes_per_line;
|
||||
framebuffer.data = (unsigned char*) framebufferImage->data;
|
||||
|
||||
framebuffer.pixelFormat.bits_per_pixel =
|
||||
framebufferImage->bits_per_pixel;
|
||||
framebuffer.pixelFormat.depth = framebufferImage->depth;
|
||||
framebuffer.pixelFormat.big_endian_flag =
|
||||
(framebufferImage->bitmap_bit_order == MSBFirst);
|
||||
framebuffer.pixelFormat.true_colour_flag = true;
|
||||
|
||||
if (framebuffer.pixelFormat.bits_per_pixel == 8) {
|
||||
framebuffer.pixelFormat.red_shift = 0;
|
||||
framebuffer.pixelFormat.green_shift = 2;
|
||||
framebuffer.pixelFormat.blue_shift = 5;
|
||||
framebuffer.pixelFormat.red_max = 3;
|
||||
framebuffer.pixelFormat.green_max = 7;
|
||||
framebuffer.pixelFormat.blue_max = 3;
|
||||
} else {
|
||||
framebuffer.pixelFormat.red_shift = 0;
|
||||
if ( framebufferImage->red_mask )
|
||||
while (!(framebufferImage->red_mask & (1 << framebuffer.pixelFormat.red_shift)))
|
||||
framebuffer.pixelFormat.red_shift++;
|
||||
framebuffer.pixelFormat.green_shift = 0;
|
||||
if (framebufferImage->green_mask)
|
||||
while (!(framebufferImage->green_mask & (1 << framebuffer.pixelFormat.green_shift)))
|
||||
framebuffer.pixelFormat.green_shift++;
|
||||
framebuffer.pixelFormat.blue_shift = 0;
|
||||
if (framebufferImage->blue_mask)
|
||||
while (!(framebufferImage->blue_mask & (1 << framebuffer.pixelFormat.blue_shift)))
|
||||
framebuffer.pixelFormat.blue_shift++;
|
||||
framebuffer.pixelFormat.red_max = framebufferImage->red_mask >> framebuffer.pixelFormat.red_shift;
|
||||
framebuffer.pixelFormat.green_max = framebufferImage->green_mask >> framebuffer.pixelFormat.green_shift;
|
||||
framebuffer.pixelFormat.blue_max = framebufferImage->blue_mask >> framebuffer.pixelFormat.blue_shift;
|
||||
}
|
||||
scanner = new XUpdateScanner( dpy, QApplication::desktop()->winId(), &framebuffer );
|
||||
}
|
||||
|
||||
void RFBConnection::destroyFramebuffer()
|
||||
{
|
||||
delete scanner;
|
||||
XDestroyImage(framebufferImage);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
rfbserver.h - description
|
||||
rfbconnection.h
|
||||
-------------------
|
||||
begin : Sun Dec 9 2001
|
||||
copyright : (C) 2001 by Tim Jansen
|
||||
@@ -20,31 +20,53 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef RFBSERVER_H
|
||||
#define RFBSERVER_H
|
||||
#ifndef RFBCONNECTION_H
|
||||
#define RFBCONNECTION_H
|
||||
|
||||
// QT must be first because of conflicts with X11
|
||||
#include <qobject.h>
|
||||
|
||||
#include "XUpdateScanner.h"
|
||||
|
||||
#include "../include/rfbServer.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
|
||||
|
||||
using namespace rfb;
|
||||
|
||||
/**
|
||||
* KDE-specific implementation of the Server base class
|
||||
* @author Tim Jansen
|
||||
*/
|
||||
class RFBServer : public Server {
|
||||
* This is a port from x0rfbserver's BaseServer to KDE. It is called
|
||||
* RFBConnection because the original Server, despite its name, handles only
|
||||
* a single connection after it has been established. This class and its
|
||||
* connections are created and destroyed by RFBController. RFBController is the real
|
||||
* serverk, but I did not want to call it Server and create more confusion.
|
||||
* Unlike the original this one allows only one client, making stuff a little bit
|
||||
* simpler.
|
||||
* @author Tim Jansen
|
||||
*/
|
||||
class RFBConnection : public QObject, public Server {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RFBServer(Display *dpy, int fd);
|
||||
~RFBServer();
|
||||
RFBConnection(Display *dpy, int fd);
|
||||
~RFBConnection();
|
||||
virtual void handleKeyEvent(KeyEvent &keyEvent);
|
||||
virtual void handlePointerEvent(PointerEvent &pointerEvent);
|
||||
|
||||
private:
|
||||
void createFramebuffer();
|
||||
void destroyFramebuffer();
|
||||
|
||||
int fd;
|
||||
int buttonMask;
|
||||
BufferedConnection *bufferedConnection;
|
||||
|
||||
Framebuffer framebuffer;
|
||||
XUpdateScanner *scanner;
|
||||
|
||||
Display *dpy;
|
||||
XImage *framebufferImage;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,70 +0,0 @@
|
||||
/***************************************************************************
|
||||
rfbserver.cpp - description
|
||||
-------------------
|
||||
begin : Sun Dec 9 2001
|
||||
copyright : (C) 2001 by Tim Jansen
|
||||
email : tim@tjansen.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Contains portions & concept from rfb's x0rfbserver.cc
|
||||
* Copyright (C) 2000 heXoNet Support GmbH, D-66424 Homburg.
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "rfbserver.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
RFBServer::RFBServer(Display *dpy, int fd) :
|
||||
Server(),
|
||||
dpy(dpy),
|
||||
fd(fd),
|
||||
buttonMask(0)
|
||||
{
|
||||
connection = bufferedConnection = new BufferedConnection(32768,
|
||||
32768);
|
||||
InitBlocks(32, 32);
|
||||
connection->send((unsigned char*) RFB_PROTOCOL_VERSION, 12);
|
||||
}
|
||||
|
||||
RFBServer::~RFBServer() {
|
||||
DeleteBlocks();
|
||||
delete bufferedConnection;
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void RFBServer::handleKeyEvent(KeyEvent &keyEvent) {
|
||||
KeyCode kc = XKeysymToKeycode(dpy, keyEvent.key);
|
||||
if (kc != NoSymbol)
|
||||
XTestFakeKeyEvent(dpy,
|
||||
XKeysymToKeycode( dpy, keyEvent.key ),
|
||||
keyEvent.down_flag,
|
||||
CurrentTime);
|
||||
}
|
||||
|
||||
void RFBServer::handlePointerEvent(PointerEvent &pointerEvent) {
|
||||
XTestFakeMotionEvent(dpy,
|
||||
0,
|
||||
pointerEvent.x_position,
|
||||
pointerEvent.y_position,
|
||||
CurrentTime);
|
||||
int i = 1;
|
||||
while (i <= 5) {
|
||||
if ( (buttonMask & (1 << (i-1))) != (pointerEvent.button_mask & (1 << (i-1))) )
|
||||
XTestFakeButtonEvent( dpy, i,
|
||||
(pointerEvent.button_mask & (1 << (i-1)))? True : False,
|
||||
CurrentTime );
|
||||
i++;
|
||||
}
|
||||
buttonMask = pointerEvent.button_mask;
|
||||
}
|
||||
@@ -30,6 +30,7 @@ TrayIcon::TrayIcon() : KSystemTray() {
|
||||
configureAction = new KAction(i18n("&Configure KRfb"));
|
||||
configureAction->plug(contextMenu());
|
||||
closeConnectionAction = new KAction(i18n("Close connection"));
|
||||
connect(configureAction, SIGNAL(activated()), SIGNAL(showConfigure()));
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user