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.

DesktopWindow.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
  3. *
  4. * This is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This software is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this software; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  17. * USA.
  18. */
  19. #ifndef __DESKTOPWINDOW_H__
  20. #define __DESKTOPWINDOW_H__
  21. #include <map>
  22. #include <sys/time.h>
  23. #include <rfb/Rect.h>
  24. #include <FL/Fl_Window.H>
  25. namespace rfb { class ModifiablePixelBuffer; }
  26. class CConn;
  27. class Surface;
  28. class Viewport;
  29. class Fl_Scrollbar;
  30. class DesktopWindow : public Fl_Window {
  31. public:
  32. DesktopWindow(int w, int h, const char *name,
  33. const rfb::PixelFormat& serverPF, CConn* cc_);
  34. ~DesktopWindow();
  35. // Most efficient format (from DesktopWindow's point of view)
  36. const rfb::PixelFormat &getPreferredPF();
  37. // Flush updates to screen
  38. void updateWindow();
  39. // Updated session title
  40. void setName(const char *name);
  41. // Resize the current framebuffer, but retain the contents
  42. void resizeFramebuffer(int new_w, int new_h);
  43. // New image for the locally rendered cursor
  44. void setCursor(int width, int height, const rfb::Point& hotspot,
  45. const uint8_t* data);
  46. // Server-provided cursor position
  47. void setCursorPos(const rfb::Point& pos);
  48. // Change client LED state
  49. void setLEDState(unsigned int state);
  50. // Clipboard events
  51. void handleClipboardRequest();
  52. void handleClipboardAnnounce(bool available);
  53. void handleClipboardData(const char* data);
  54. // Fl_Window callback methods
  55. virtual void show();
  56. virtual void draw();
  57. virtual void resize(int x, int y, int w, int h);
  58. virtual int handle(int event);
  59. void fullscreen_on();
  60. private:
  61. static void menuOverlay(void *data);
  62. void setOverlay(const char *text, ...)
  63. __attribute__((__format__ (__printf__, 2, 3)));
  64. static void updateOverlay(void *data);
  65. static int fltkDispatch(int event, Fl_Window *win);
  66. static int fltkHandle(int event);
  67. bool hasFocus();
  68. void maybeGrabKeyboard();
  69. void grabKeyboard();
  70. void ungrabKeyboard();
  71. void grabPointer();
  72. void ungrabPointer();
  73. static void handleGrab(void *data);
  74. void maximizeWindow();
  75. void handleDesktopSize();
  76. static void handleResizeTimeout(void *data);
  77. static void reconfigureFullscreen(void *data);
  78. void remoteResize(int width, int height);
  79. void repositionWidgets();
  80. static void handleClose(Fl_Widget *wnd, void *data);
  81. static void handleOptions(void *data);
  82. static void handleFullscreenTimeout(void *data);
  83. void scrollTo(int x, int y);
  84. static void handleScroll(Fl_Widget *wnd, void *data);
  85. static void handleEdgeScroll(void *data);
  86. static void handleStatsTimeout(void *data);
  87. private:
  88. CConn* cc;
  89. Fl_Scrollbar *hscroll, *vscroll;
  90. Viewport *viewport;
  91. Surface *offscreen;
  92. Surface *overlay;
  93. unsigned char overlayAlpha;
  94. struct timeval overlayStart;
  95. bool firstUpdate;
  96. bool delayedFullscreen;
  97. bool delayedDesktopSize;
  98. bool keyboardGrabbed;
  99. bool mouseGrabbed;
  100. struct statsEntry {
  101. unsigned ups;
  102. unsigned pps;
  103. unsigned bps;
  104. };
  105. struct statsEntry stats[100];
  106. struct timeval statsLastTime;
  107. unsigned statsLastUpdates;
  108. unsigned statsLastPixels;
  109. unsigned statsLastPosition;
  110. Surface *statsGraph;
  111. };
  112. #endif