Magellan Linux

Contents of /trunk/tigervnc/patches/tigervnc-1.0.1-r3886.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1201 - (show annotations) (download)
Mon Nov 22 23:25:59 2010 UTC (13 years, 5 months ago) by niro
File size: 12742 byte(s)
-patches for 1.0.1 against xorg-server-1.7
1 Index: unix/xserver/hw/vnc/Input.cc
2 ===================================================================
3 --- unix/xserver/hw/vnc/Input.cc (revision 0)
4 +++ unix/xserver/hw/vnc/Input.cc (revision 3886)
5 @@ -0,0 +1,167 @@
6 +/* Copyright (C) 2009 TightVNC Team
7 + * Copyright (C) 2009 Red Hat, Inc.
8 + *
9 + * This is free software; you can redistribute it and/or modify
10 + * it under the terms of the GNU General Public License as published by
11 + * the Free Software Foundation; either version 2 of the License, or
12 + * (at your option) any later version.
13 + *
14 + * This software is distributed in the hope that it will be useful,
15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 + * GNU General Public License for more details.
18 + *
19 + * You should have received a copy of the GNU General Public License
20 + * along with this software; if not, write to the Free Software
21 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 + * USA.
23 + */
24 +
25 +#ifdef HAVE_DIX_CONFIG_H
26 +#include <dix-config.h>
27 +#endif
28 +
29 +#include "Input.h"
30 +#include "xorg-version.h"
31 +
32 +extern "C" {
33 +#include "mi.h"
34 +}
35 +
36 +/* Event queue is shared between all devices. */
37 +#if XORG == 15
38 +static xEvent *eventq = NULL;
39 +#else
40 +static EventList *eventq = NULL;
41 +#endif
42 +
43 +static void initEventq(void)
44 +{
45 + /* eventq is never free()-ed because it exists during server life. */
46 + if (eventq == NULL) {
47 +#if XORG == 15
48 + eventq = (xEvent *)xcalloc(sizeof(xEvent),
49 + GetMaximumEventsNum());
50 + if (!eventq)
51 + FatalError("Couldn't allocate eventq\n");
52 +#else
53 + GetEventList(&eventq);
54 +#endif
55 + }
56 +}
57 +
58 +static void enqueueEvents(DeviceIntPtr dev, int n)
59 +{
60 + int i;
61 +
62 + for (i = 0; i < n; i++) {
63 + /*
64 + * Passing arguments in global variable eventq is probably not
65 + * good programming practise but in this case it is safe and
66 + * clear.
67 + */
68 + mieqEnqueue(dev,
69 +#if XORG == 15
70 + eventq + i
71 +#else
72 + (eventq + i)->event
73 +#endif
74 + );
75 + }
76 +}
77 +
78 +/* Pointer device pre-declarations */
79 +#define BUTTONS 5
80 +static int pointerProc(DeviceIntPtr pDevice, int onoff);
81 +
82 +/* Pointer device methods */
83 +
84 +PointerDevice::PointerDevice(rfb::VNCServerST *_server)
85 + : server(_server), oldButtonMask(0)
86 +{
87 + dev = AddInputDevice(
88 +#if XORG >= 16
89 + serverClient,
90 +#endif
91 + pointerProc, TRUE);
92 + RegisterPointerDevice(dev);
93 + initEventq();
94 +}
95 +
96 +void PointerDevice::ButtonAction(int buttonMask)
97 +{
98 + int i, n;
99 +
100 + for (i = 0; i < BUTTONS; i++) {
101 + if ((buttonMask ^ oldButtonMask) & (1 << i)) {
102 + int action = (buttonMask & (1<<i)) ?
103 + ButtonPress : ButtonRelease;
104 + n = GetPointerEvents(eventq, dev, action, i + 1,
105 + POINTER_RELATIVE, 0, 0, NULL);
106 + enqueueEvents(dev, n);
107 +
108 + }
109 + }
110 +
111 + oldButtonMask = buttonMask;
112 +}
113 +
114 +void PointerDevice::Move(const rfb::Point &pos)
115 +{
116 + int n, valuators[2];
117 +
118 + if (pos.equals(cursorPos))
119 + return;
120 +
121 + valuators[0] = pos.x;
122 + valuators[1] = pos.y;
123 + n = GetPointerEvents(eventq, dev, MotionNotify, 0, POINTER_ABSOLUTE, 0,
124 + 2, valuators);
125 + enqueueEvents(dev, n);
126 +
127 + cursorPos = pos;
128 +}
129 +
130 +void PointerDevice::Sync(void)
131 +{
132 + if (cursorPos.equals(oldCursorPos))
133 + return;
134 +
135 + oldCursorPos = cursorPos;
136 + server->setCursorPos(cursorPos);
137 + server->tryUpdate();
138 +}
139 +
140 +static int pointerProc(DeviceIntPtr pDevice, int onoff)
141 +{
142 + BYTE map[BUTTONS + 1];
143 + DevicePtr pDev = (DevicePtr)pDevice;
144 + int i;
145 +
146 + switch (onoff) {
147 + case DEVICE_INIT:
148 + for (i = 0; i < BUTTONS + 1; i++)
149 + map[i] = i;
150 +
151 + InitPointerDeviceStruct(pDev, map, BUTTONS,
152 +#if XORG == 15
153 + GetMotionHistory,
154 +#endif
155 + (PtrCtrlProcPtr)NoopDDA,
156 + GetMotionHistorySize(), 2);
157 + break;
158 + case DEVICE_ON:
159 + pDev->on = TRUE;
160 + break;
161 + case DEVICE_OFF:
162 + pDev->on = FALSE;
163 + break;
164 +#if 0
165 + case DEVICE_CLOSE:
166 + break;
167 +#endif
168 + }
169 +
170 + return Success;
171 +}
172 +
173 Index: unix/xserver/hw/vnc/Input.h
174 ===================================================================
175 --- unix/xserver/hw/vnc/Input.h (revision 0)
176 +++ unix/xserver/hw/vnc/Input.h (revision 3886)
177 @@ -0,0 +1,61 @@
178 +/* Copyright (C) 2009 TightVNC Team
179 + * Copyright (C) 2009 Red Hat, Inc.
180 + *
181 + * This is free software; you can redistribute it and/or modify
182 + * it under the terms of the GNU General Public License as published by
183 + * the Free Software Foundation; either version 2 of the License, or
184 + * (at your option) any later version.
185 + *
186 + * This software is distributed in the hope that it will be useful,
187 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
188 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
189 + * GNU General Public License for more details.
190 + *
191 + * You should have received a copy of the GNU General Public License
192 + * along with this software; if not, write to the Free Software
193 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
194 + * USA.
195 + */
196 +
197 +/* Make sure macro doesn't conflict with macro in include/input.h. */
198 +#ifndef INPUT_H_
199 +#define INPUT_H_
200 +
201 +#ifdef HAVE_DIX_CONFIG_H
202 +#include <dix-config.h>
203 +#endif
204 +
205 +#include <rfb/VNCServerST.h>
206 +
207 +extern "C" {
208 +#include "input.h"
209 +};
210 +
211 +/* Represents pointer device. */
212 +class PointerDevice {
213 +public:
214 + /* Create new PointerDevice instance. */
215 + PointerDevice(rfb::VNCServerST *_server);
216 +
217 + /*
218 + * Press or release buttons. Relationship between buttonMask and
219 + * buttons is specified in RFB protocol.
220 + */
221 + void ButtonAction(int buttonMask);
222 +
223 + /* Move pointer to target location (point coords are absolute). */
224 + void Move(const rfb::Point &point);
225 +
226 + /*
227 + * Send pointer position to clients. If not called then Move() calls
228 + * won't be visible to clients.
229 + */
230 + void Sync(void);
231 +private:
232 + rfb::VNCServerST *server;
233 + DeviceIntPtr dev;
234 + int oldButtonMask;
235 + rfb::Point cursorPos, oldCursorPos;
236 +};
237 +
238 +#endif
239 Index: unix/xserver/hw/vnc/Makefile.am
240 ===================================================================
241 --- unix/xserver/hw/vnc/Makefile.am (revision 3885)
242 +++ unix/xserver/hw/vnc/Makefile.am (revision 3886)
243 @@ -9,9 +9,11 @@
244
245 noinst_LTLIBRARIES = libvnccommon.la
246
247 -HDRS = RegionHelper.h vncExtInit.h vncHooks.h XserverDesktop.h xorg-version.h
248 +HDRS = RegionHelper.h vncExtInit.h vncHooks.h XserverDesktop.h xorg-version.h \
249 + Input.h
250
251 -libvnccommon_la_SOURCES = $(HDRS) vncExtInit.cc vncHooks.cc XserverDesktop.cc
252 +libvnccommon_la_SOURCES = $(HDRS) vncExtInit.cc vncHooks.cc XserverDesktop.cc \
253 + Input.cc
254
255 libvnccommon_la_CPPFLAGS = -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
256 -DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(LIB_DIR) \
257 Index: unix/xserver/hw/vnc/XserverDesktop.cc
258 ===================================================================
259 --- unix/xserver/hw/vnc/XserverDesktop.cc (revision 3885)
260 +++ unix/xserver/hw/vnc/XserverDesktop.cc (revision 3886)
261 @@ -42,6 +42,7 @@
262 #include "XserverDesktop.h"
263 #include "vncExtInit.h"
264 #include "xorg-version.h"
265 +#include "Input.h"
266
267 extern "C" {
268 #define public c_public
269 @@ -77,7 +78,6 @@
270 }
271
272 static DeviceIntPtr vncKeyboardDevice = NULL;
273 -static DeviceIntPtr vncPointerDevice = NULL;
274 #if XORG == 15
275 static xEvent *eventq = NULL;
276 #else
277 @@ -85,7 +85,6 @@
278 #endif
279
280 static int vfbKeybdProc(DeviceIntPtr pDevice, int onoff);
281 -static int vfbMouseProc(DeviceIntPtr pDevice, int onoff);
282
283 using namespace rfb;
284 using namespace network;
285 @@ -180,7 +179,6 @@
286 listener(listener_), httpListener(httpListener_),
287 cmap(0), deferredUpdateTimerSet(false),
288 grabbing(false), ignoreHooks_(false), directFbptr(true),
289 - oldButtonMask(0),
290 queryConnectId(0)
291 {
292 format = pf;
293 @@ -221,14 +219,7 @@
294 RegisterKeyboardDevice(vncKeyboardDevice);
295 }
296
297 - if (vncPointerDevice == NULL) {
298 - vncPointerDevice = AddInputDevice(
299 -#if XORG >= 16
300 - serverClient,
301 -#endif
302 - vfbMouseProc, TRUE);
303 - RegisterPointerDevice(vncPointerDevice);
304 - }
305 + pointerDevice = new PointerDevice(server);
306 }
307
308 XserverDesktop::~XserverDesktop()
309 @@ -237,6 +228,7 @@
310 delete [] data;
311 TimerFree(deferredUpdateTimer);
312 TimerFree(dummyTimer);
313 + delete pointerDevice;
314 delete httpServer;
315 delete server;
316 }
317 @@ -555,43 +547,9 @@
318 }
319 }
320
321 -void XserverDesktop::positionCursor()
322 -{
323 - if (!cursorPos.equals(oldCursorPos)) {
324 - oldCursorPos = cursorPos;
325 - (*pScreen->SetCursorPosition) (
326 -#if XORG >= 16
327 - vncPointerDevice,
328 -#endif
329 - pScreen, cursorPos.x, cursorPos.y, FALSE);
330 - server->setCursorPos(cursorPos);
331 - server->tryUpdate();
332 - }
333 -}
334 -
335 void XserverDesktop::blockHandler(fd_set* fds)
336 {
337 try {
338 -#if XORG == 15
339 - ScreenPtr screenWithCursor = GetCurrentRootWindow()->drawable.pScreen;
340 -#else
341 - ScreenPtr screenWithCursor =
342 - GetCurrentRootWindow(vncPointerDevice)->drawable.pScreen;
343 -#endif
344 - if (screenWithCursor == pScreen) {
345 - int x, y;
346 - GetSpritePosition(
347 -#if XORG >= 16
348 - vncPointerDevice,
349 -#endif
350 - &x, &y);
351 - if (x != cursorPos.x || y != cursorPos.y) {
352 - cursorPos = oldCursorPos = Point(x, y);
353 - server->setCursorPos(cursorPos);
354 - server->tryUpdate();
355 - }
356 - }
357 -
358 if (listener)
359 FD_SET(listener->getFd(), fds);
360 if (httpListener)
361 @@ -678,7 +636,7 @@
362 }
363 }
364
365 - positionCursor();
366 + pointerDevice->Sync();
367 }
368
369 int timeout = server->checkTimeouts();
370 @@ -737,63 +695,8 @@
371
372 void XserverDesktop::pointerEvent(const Point& pos, int buttonMask)
373 {
374 - int i, j, n, valuators[2];
375 -
376 - // SetCursorPosition seems to be very expensive (at least on XFree86 3.3.6
377 - // for S3), so we delay calling it until positionCursor() is called at the
378 - // end of processing a load of RFB.
379 - //(*pScreen->SetCursorPosition) (pScreen, pos.x, pos.y, FALSE);
380 -
381 - NewCurrentScreen(
382 -#if XORG >= 16
383 - vncPointerDevice,
384 -#endif
385 - pScreen, pos.x, pos.y);
386 -
387 - if (!pos.equals(cursorPos)) {
388 - valuators[0] = pos.x;
389 - valuators[1] = pos.y;
390 -
391 -#if XORG >= 16
392 - GetEventList(&eventq);
393 -#endif
394 - n = GetPointerEvents (eventq, vncPointerDevice, MotionNotify, 0,
395 - POINTER_ABSOLUTE, 0, 2, valuators);
396 -
397 - for (i = 0; i < n; i++) {
398 - mieqEnqueue (vncPointerDevice,
399 -#if XORG == 15
400 - eventq + i
401 -#else
402 - (eventq + i)->event
403 -#endif
404 - );
405 - }
406 - }
407 -
408 - for (i = 0; i < 5; i++) {
409 - if ((buttonMask ^ oldButtonMask) & (1<<i)) {
410 - // Do not use the pointer mapping. Treat VNC buttons as logical
411 - // buttons.
412 - n = GetPointerEvents (eventq, vncPointerDevice,
413 - (buttonMask & (1<<i)) ?
414 - ButtonPress : ButtonRelease,
415 - i + 1, POINTER_RELATIVE, 0, 0, NULL);
416 -
417 - for (j = 0; j < n; j++) {
418 - mieqEnqueue (vncPointerDevice,
419 -#if XORG == 15
420 - eventq + j
421 -#else
422 - (eventq + j)->event
423 -#endif
424 - );
425 - }
426 - }
427 - }
428 -
429 - cursorPos = pos;
430 - oldButtonMask = buttonMask;
431 + pointerDevice->Move(pos);
432 + pointerDevice->ButtonAction(buttonMask);
433 }
434
435 void XserverDesktop::clientCutText(const char* str, int len)
436 @@ -1481,36 +1384,3 @@
437 return Success;
438 }
439
440 -static int vfbMouseProc(DeviceIntPtr pDevice, int onoff)
441 -{
442 - BYTE map[6];
443 - DevicePtr pDev = (DevicePtr)pDevice;
444 -
445 - switch (onoff)
446 - {
447 - case DEVICE_INIT:
448 - map[1] = 1;
449 - map[2] = 2;
450 - map[3] = 3;
451 - map[4] = 4;
452 - map[5] = 5;
453 - InitPointerDeviceStruct(pDev, map, 5,
454 -#if XORG == 15
455 - GetMotionHistory,
456 -#endif
457 - (PtrCtrlProcPtr)NoopDDA, GetMotionHistorySize(), 2);
458 - break;
459 -
460 - case DEVICE_ON:
461 - pDev->on = TRUE;
462 - break;
463 -
464 - case DEVICE_OFF:
465 - pDev->on = FALSE;
466 - break;
467 -
468 - case DEVICE_CLOSE:
469 - break;
470 - }
471 - return Success;
472 -}
473 Index: unix/xserver/hw/vnc/XserverDesktop.h
474 ===================================================================
475 --- unix/xserver/hw/vnc/XserverDesktop.h (revision 3885)
476 +++ unix/xserver/hw/vnc/XserverDesktop.h (revision 3886)
477 @@ -32,6 +32,7 @@
478 #include <rfb/Configuration.h>
479 #include <rfb/VNCServerST.h>
480 #include <rdr/SubstitutingInStream.h>
481 +#include "Input.h"
482
483 extern "C" {
484 #define class c_class
485 @@ -68,7 +69,6 @@
486 void setCursor(CursorPtr cursor);
487 void add_changed(RegionPtr reg);
488 void add_copied(RegionPtr dst, int dx, int dy);
489 - void positionCursor();
490 void ignoreHooks(bool b) { ignoreHooks_ = b; }
491 void blockHandler(fd_set* fds);
492 void wakeupHandler(fd_set* fds, int nfds);
493 @@ -122,6 +122,7 @@
494 pointer arg);
495 void deferUpdate();
496 ScreenPtr pScreen;
497 + PointerDevice *pointerDevice;
498 OsTimerPtr deferredUpdateTimer, dummyTimer;
499 rfb::VNCServerST* server;
500 rfb::HTTPServer* httpServer;
501 @@ -133,8 +134,6 @@
502 bool grabbing;
503 bool ignoreHooks_;
504 bool directFbptr;
505 - int oldButtonMask;
506 - rfb::Point cursorPos, oldCursorPos;
507
508 void* queryConnectId;
509 rfb::CharArray queryConnectAddress;