1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
/***************************************************************************
kremoteview.h - widget that shows the remote framebuffer
-------------------
begin : Wed Dec 25 23:58:12 CET 2002
copyright : (C) 2002-2003 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 KREMOTEVIEW_H
#define KREMOTEVIEW_H
#include <tqwidget.h>
#include <kkeynative.h>
#include "events.h"
typedef enum {
TQUALITY_UNKNOWN=0,
TQUALITY_HIGH=1,
TQUALITY_MEDIUM=2,
TQUALITY_LOW=3
} Quality;
/**
* Describes the state of a local cursor, if there is such a concept in the backend.
* With local cursors, there are two cursors: the cursor on the local machine (client),
* and the cursor on the remote machine (server). Because there is usually some lag,
* some backends show both cursors simultanously. In the VNC backend the local cursor
* is a dot and the remote cursor is the 'real' cursor, usually an arrow.
*/
enum DotCursorState {
DOT_CURSOR_ON, ///< Always show local cursor (and the remote one).
DOT_CURSOR_OFF, ///< Never show local cursor, only the remote one.
/// Try to measure the lag and enable the local cursor if the latency is too high.
DOT_CURSOR_AUTO
};
/**
* Generic widget that displays a remote framebuffer.
* Implement this if you want to add another backend.
*
* Things to take care of:
* @li The KRemoteView is responsible for its size. In
* non-scaling mode, set the fixed size of the widget
* to the remote resolution. In scaling mode, set the
* maximum size to the remote size and minimum size to the
* smallest resolution that your scaler can handle.
* @li if you override mouseMoveEvent()
* you must ignore the TQEvent, because the KRDC widget will
* need it for stuff like toolbar auto-hide and bump
* scrolling. If you use x11Event(), make sure that
* MotionNotify events will be forwarded.
*
*/
class KRemoteView : public TQWidget
{
Q_OBJECT
TQ_OBJECT
public:
KRemoteView(TQWidget *parent = 0,
const char *name = 0,
WFlags f = 0);
virtual ~KRemoteView();
/**
* Checks whether the backend supports scaling. The
* default implementation returns false.
* @return true if scaling is supported
* @see scaling()
*/
virtual bool supportsScaling() const;
/**
* Checks whether the widget is in scale mode. The
* default implementation always returns false.
* @return true if scaling is activated. Must always be
* false if @ref supportsScaling() returns false
* @see supportsScaling()
*/
virtual bool scaling() const;
/**
* Checks whether the backend supports the concept of local cursors. The
* default implementation returns false.
* @return true if local cursors are supported/known
* @see DotCursorState
* @see showDotCursor()
* @see dotCursorState()
*/
virtual bool supportsLocalCursor() const;
/**
* Sets the state of the dot cursor, if supported by the backend.
* The default implementation does nothing.
* @param state the new state (DOT_CURSOR_ON, DOT_CURSOR_OFF or
* DOT_CURSOR_AUTO)
* @see dotCursorState()
* @see supportsLocalCursor()
*/
virtual void showDotCursor(DotCursorState state);
/**
* Returns the state of the local cursor. The default implementation returns
* always DOT_CURSOR_OFF.
* @return true if local cursors are supported/known
* @see showDotCursor()
* @see supportsLocalCursor()
*/
virtual DotCursorState dotCursorState() const;
/**
* Checks whether the view is in view-only mode. This means
* that all input is ignored.
*/
virtual bool viewOnly() = 0;
/**
* Checks whether the view is requesting full screen mode.
*/
virtual bool startFullscreen() = 0;
/**
* Returns the resolution of the remote framebuffer.
* It should return a null @ref TQSize when the size
* is not known.
* The backend must also emit a @ref changeSize()
* when the size of the framebuffer becomes available
* for the first time or the size changed.
* @return the remote framebuffer size, a null TQSize
* if unknown
*/
virtual TQSize framebufferSize() = 0;
/**
* Initiate the disconnection. This doesn't need to happen
* immediately. The call must not block.
* @see isQuitting()
*/
virtual void startQuitting() = 0;
/**
* Checks whether the view is currently quitting.
* @return true if it is quitting
* @see startQuitting()
* @see setStatus()
*/
virtual bool isQuitting() = 0;
/**
* Returns the host the view is connected to.
* @return the host the view is connected to
*/
virtual TQString host() = 0;
/**
* Returns the port the view is connected to.
* @return the port the view is connected to
*/
virtual int port() = 0;
/**
* Initialize the view (for example by showing configuration
* dialogs to the user) and start connecting. Should not block
* without running the event loop (so displaying a dialog is ok).
* When the view starts connecting the application must call
* @ref setStatus() with the status REMOTE_VIEW_CONNECTING.
* @return true if successful (so far), false
* otherwise
* @see connected()
* @see disconnected()
* @see disconnectedError()
* @see statusChanged()
*/
virtual bool start() = 0;
/**
* Returns the current status of the connection.
* @return the status of the connection
* @see setStatus()
*/
enum RemoteViewStatus status();
public slots:
/**
* Called to enable or disable scaling.
* Ignored if @ref supportsScaling() is false.
* The default implementation does nothing.
* @param s true to enable, false to disable.
* @see supportsScaling()
* @see scaling()
*/
virtual void enableScaling(bool s);
/**
* Enables/disables the view-only mode.
* Ignored if @ref supportsScaling() is false.
* The default implementation does nothing.
* @param s true to enable, false to disable.
* @see supportsScaling()
* @see viewOnly()
*/
virtual void setViewOnly(bool s) = 0;
/**
* Called to let the backend know it when
* we switch from/to fullscreen.
* @param on true when switching to fullscreen,
* false when switching from fullscreen.
*/
virtual void switchFullscreen(bool on);
/**
* Sends a key to the remote server.
* @param k the key to send
*/
virtual void pressKey(XEvent *k) = 0;
signals:
/**
* Emitted when the size of the remote screen changes. Also
* called when the size is known for the first time.
* @param x the width of the screen
* @param y the height of the screen
*/
void changeSize(int w, int h);
/**
* Emitted when the view connected successfully.
*/
void connected();
/**
* Emitted when the view disconnected without error.
*/
void disconnected();
/**
* Emitted when the view disconnected with error.
*/
void disconnectedError();
/**
* Emitted when the status of the view changed.
* @param s the new status
*/
void statusChanged(RemoteViewStatus s);
/**
* Emitted when the password dialog is shown or hidden.
* @param b true when the dialog is shown, false when it has
* been hidden
*/
void showingPasswordDialog(bool b);
/**
* Emitted when the mouse on the remote side has been moved.
* @param x the new x coordinate
* @param y the new y coordinate
* @param buttonMask the mask of mouse buttons (bit 0 for first mouse
* button, 1 for second button etc)a
*/
void mouseStateChanged(int x, int y, int buttonMask);
protected:
/**
* The status of the remote view.
*/
enum RemoteViewStatus m_status;
/**
* Set the status of the connection.
* Emits a statusChanged() signal.
* Note that the states need to be set in a certain order,
* see @ref RemoteViewStatus. setStatus() will try to do this
* transition automatically, so if you are in REMOTE_VIEW_CONNECTING
* and call setStatus(REMOTE_VIEW_PREPARING), setStatus() will
* emit a REMOTE_VIEW_AUTHENTICATING and then REMOTE_VIEW_PREPARING.
* If you transition backwards, it will emit a
* REMOTE_VIEW_DISCONNECTED before doing the transition.
* @param s the new status
*/
virtual void setStatus(RemoteViewStatus s);
};
#endif
|