Constantin Kaplinsky | af1891c | 2005-09-29 06:18:28 +0000 | [diff] [blame] | 1 | /* 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 | |
| 31 | using namespace rfb; |
| 32 | |
| 33 | class PollingManager { |
| 34 | |
| 35 | public: |
| 36 | |
| 37 | PollingManager(Display *dpy, Image *image, ImageFactory *factory); |
Constantin Kaplinsky | 14cd547 | 2005-09-29 17:12:11 +0000 | [diff] [blame] | 38 | virtual ~PollingManager(); |
Constantin Kaplinsky | af1891c | 2005-09-29 06:18:28 +0000 | [diff] [blame] | 39 | |
Constantin Kaplinsky | 14cd547 | 2005-09-29 17:12:11 +0000 | [diff] [blame] | 40 | void setVNCServer(VNCServer *s); |
Constantin Kaplinsky | ce676c6 | 2006-02-08 13:36:58 +0000 | [diff] [blame^] | 41 | |
| 42 | void setPointerPos(const Point &pos); |
| 43 | void unsetPointerPos(); |
| 44 | |
Constantin Kaplinsky | af1891c | 2005-09-29 06:18:28 +0000 | [diff] [blame] | 45 | void pollDebug(); |
| 46 | void poll(); |
| 47 | |
Constantin Kaplinsky | ce676c6 | 2006-02-08 13:36:58 +0000 | [diff] [blame^] | 48 | // Configurable parameters. |
| 49 | static BoolParameter pollPointer; |
| 50 | static IntParameter pollingType; |
| 51 | |
Constantin Kaplinsky | af1891c | 2005-09-29 06:18:28 +0000 | [diff] [blame] | 52 | protected: |
| 53 | |
Constantin Kaplinsky | c42eab2 | 2006-02-01 05:59:21 +0000 | [diff] [blame] | 54 | // |
| 55 | // Implementations of different polling algorithms. |
| 56 | // Return value of true reports that some changes were detected. |
| 57 | // |
| 58 | bool poll_DetectVideo(); |
| 59 | bool poll_SkipCycles(); |
| 60 | bool poll_Traditional(); |
| 61 | bool poll_Dumb(); |
Constantin Kaplinsky | 14cd547 | 2005-09-29 17:12:11 +0000 | [diff] [blame] | 62 | |
Constantin Kaplinsky | ce676c6 | 2006-02-08 13:36:58 +0000 | [diff] [blame^] | 63 | // Separate polling for the area around current pointer position. |
| 64 | void computePointerArea(Rect *r); |
| 65 | bool pollPointerArea(); |
| 66 | |
Constantin Kaplinsky | 14cd547 | 2005-09-29 17:12:11 +0000 | [diff] [blame] | 67 | Display *m_dpy; |
| 68 | VNCServer *m_server; |
| 69 | |
| 70 | Image *m_image; |
| 71 | int m_width; |
| 72 | int m_height; |
| 73 | int m_widthTiles; |
| 74 | int m_heightTiles; |
| 75 | |
Constantin Kaplinsky | ce676c6 | 2006-02-08 13:36:58 +0000 | [diff] [blame^] | 76 | // Tracking pointer position for polling improvements. |
| 77 | bool m_pointerPosKnown; |
| 78 | Point m_pointerPos; |
| 79 | |
Constantin Kaplinsky | 6df6990 | 2006-02-03 11:42:00 +0000 | [diff] [blame] | 80 | private: |
| 81 | |
| 82 | void adjustVideoArea(); |
| 83 | |
Constantin Kaplinsky | ce676c6 | 2006-02-08 13:36:58 +0000 | [diff] [blame^] | 84 | // Additional images used in polling algorithms. |
| 85 | Image *m_rowImage; // One row of the framebuffer |
| 86 | Image *m_tileImage; // One tile (32x32 or less) |
| 87 | Image *m_areaImage; // Area around the pointer (up to 128x128) |
Constantin Kaplinsky | 14cd547 | 2005-09-29 17:12:11 +0000 | [diff] [blame] | 88 | |
| 89 | char *m_statusMatrix; |
| 90 | |
Constantin Kaplinsky | dc54fc1 | 2005-10-19 13:57:16 +0000 | [diff] [blame] | 91 | char *m_rateMatrix; |
| 92 | char *m_videoFlags; |
| 93 | char *m_changedFlags; |
| 94 | |
Constantin Kaplinsky | af1891c | 2005-09-29 06:18:28 +0000 | [diff] [blame] | 95 | unsigned int m_pollingStep; |
| 96 | static const int m_pollingOrder[]; |
Constantin Kaplinsky | af1891c | 2005-09-29 06:18:28 +0000 | [diff] [blame] | 97 | |
| 98 | }; |
| 99 | |
| 100 | #endif // __POLLINGMANAGER_H__ |