blob: 797f3f683664fe5ef62c488fcb6e1527b980d300 [file] [log] [blame]
Constantin Kaplinskyaf1891c2005-09-29 06:18:28 +00001/* Copyright (C) 2004-2005 Constantin Kaplinsky. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19//
20// PollingManager.h
21//
22
23#ifndef __POLLINGMANAGER_H__
24#define __POLLINGMANAGER_H__
25
26#include <X11/Xlib.h>
27#include <rfb/VNCServer.h>
28
29#include <x0vncserver/Image.h>
30
Constantin Kaplinskyfbaab7f2006-02-16 04:51:38 +000031#ifdef DEBUG
32#include <x0vncserver/TimeMillis.h>
33#endif
34
Constantin Kaplinskyaf1891c2005-09-29 06:18:28 +000035using namespace rfb;
36
37class PollingManager {
38
39public:
40
41 PollingManager(Display *dpy, Image *image, ImageFactory *factory);
Constantin Kaplinsky14cd5472005-09-29 17:12:11 +000042 virtual ~PollingManager();
Constantin Kaplinskyaf1891c2005-09-29 06:18:28 +000043
Constantin Kaplinsky14cd5472005-09-29 17:12:11 +000044 void setVNCServer(VNCServer *s);
Constantin Kaplinskyce676c62006-02-08 13:36:58 +000045
46 void setPointerPos(const Point &pos);
47 void unsetPointerPos();
48
Constantin Kaplinskyaf1891c2005-09-29 06:18:28 +000049 void poll();
50
Constantin Kaplinskyce676c62006-02-08 13:36:58 +000051 // Configurable parameters.
52 static BoolParameter pollPointer;
53 static IntParameter pollingType;
54
Constantin Kaplinskyaf1891c2005-09-29 06:18:28 +000055protected:
56
Constantin Kaplinskyc42eab22006-02-01 05:59:21 +000057 //
58 // Implementations of different polling algorithms.
59 // Return value of true reports that some changes were detected.
60 //
61 bool poll_DetectVideo();
62 bool poll_SkipCycles();
63 bool poll_Traditional();
64 bool poll_Dumb();
Constantin Kaplinsky14cd5472005-09-29 17:12:11 +000065
Constantin Kaplinskyce676c62006-02-08 13:36:58 +000066 // Separate polling for the area around current pointer position.
67 void computePointerArea(Rect *r);
68 bool pollPointerArea();
69
Constantin Kaplinsky14cd5472005-09-29 17:12:11 +000070 Display *m_dpy;
71 VNCServer *m_server;
72
73 Image *m_image;
74 int m_width;
75 int m_height;
76 int m_widthTiles;
77 int m_heightTiles;
78
Constantin Kaplinskyce676c62006-02-08 13:36:58 +000079 // Tracking pointer position for polling improvements.
80 bool m_pointerPosKnown;
81 Point m_pointerPos;
Constantin Kaplinskyaf2ebeb2006-02-10 12:19:11 +000082 time_t m_pointerPosTime;
Constantin Kaplinskyce676c62006-02-08 13:36:58 +000083
Constantin Kaplinsky6df69902006-02-03 11:42:00 +000084private:
85
86 void adjustVideoArea();
87
Constantin Kaplinskyce676c62006-02-08 13:36:58 +000088 // Additional images used in polling algorithms.
89 Image *m_rowImage; // One row of the framebuffer
90 Image *m_tileImage; // One tile (32x32 or less)
91 Image *m_areaImage; // Area around the pointer (up to 128x128)
Constantin Kaplinsky14cd5472005-09-29 17:12:11 +000092
93 char *m_statusMatrix;
94
Constantin Kaplinskydc54fc12005-10-19 13:57:16 +000095 char *m_rateMatrix;
96 char *m_videoFlags;
97 char *m_changedFlags;
98
Constantin Kaplinskyaf1891c2005-09-29 06:18:28 +000099 unsigned int m_pollingStep;
100 static const int m_pollingOrder[];
Constantin Kaplinskyaf1891c2005-09-29 06:18:28 +0000101
Constantin Kaplinskyb247d7d2006-02-15 16:14:07 +0000102#ifdef DEBUG
103private:
104
105 void debugBeforePoll();
106 void debugAfterPoll();
107
Constantin Kaplinskyfbaab7f2006-02-16 04:51:38 +0000108 TimeMillis m_timeSaved;
Constantin Kaplinskyb247d7d2006-02-15 16:14:07 +0000109#endif
110
Constantin Kaplinskyaf1891c2005-09-29 06:18:28 +0000111};
112
113#endif // __POLLINGMANAGER_H__