You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PollingManager.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. // PollingManager.h
  20. //
  21. #ifndef __POLLINGMANAGER_H__
  22. #define __POLLINGMANAGER_H__
  23. #include <X11/Xlib.h>
  24. #include <rfb/VNCServer.h>
  25. #include <x0vncserver/Image.h>
  26. #ifdef DEBUG
  27. #include <x0vncserver/TimeMillis.h>
  28. #endif
  29. using namespace rfb;
  30. class PollingManager {
  31. public:
  32. PollingManager(Display *dpy, Image *image, ImageFactory *factory);
  33. virtual ~PollingManager();
  34. void setVNCServer(VNCServer *s);
  35. void setPointerPos(const Point &pos);
  36. void unsetPointerPos();
  37. void poll();
  38. // Configurable parameters.
  39. static BoolParameter pollPointer;
  40. static IntParameter pollingType;
  41. protected:
  42. //
  43. // Implementations of different polling algorithms.
  44. // Return value of true reports that some changes were detected.
  45. //
  46. bool poll_DetectVideo();
  47. bool poll_SkipCycles();
  48. bool poll_Traditional();
  49. bool poll_Dumb();
  50. // Separate polling for the area around current pointer position.
  51. void computePointerArea(Rect *r);
  52. bool pollPointerArea();
  53. Display *m_dpy;
  54. VNCServer *m_server;
  55. Image *m_image;
  56. int m_width;
  57. int m_height;
  58. int m_widthTiles;
  59. int m_heightTiles;
  60. // Tracking pointer position for polling improvements.
  61. bool m_pointerPosKnown;
  62. Point m_pointerPos;
  63. time_t m_pointerPosTime;
  64. private:
  65. void adjustVideoArea();
  66. // Additional images used in polling algorithms.
  67. Image *m_rowImage; // One row of the framebuffer
  68. Image *m_tileImage; // One tile (32x32 or less)
  69. Image *m_areaImage; // Area around the pointer (up to 128x128)
  70. char *m_statusMatrix;
  71. char *m_rateMatrix;
  72. char *m_videoFlags;
  73. char *m_changedFlags;
  74. unsigned int m_pollingStep;
  75. static const int m_pollingOrder[];
  76. #ifdef DEBUG
  77. private:
  78. void debugBeforePoll();
  79. void debugAfterPoll();
  80. TimeMillis m_timeSaved;
  81. #endif
  82. };
  83. #endif // __POLLINGMANAGER_H__