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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 <rfb/Pixel.h>
  25. #include <FL/Fl_Window.H>
  26. namespace rfb { class ModifiablePixelBuffer; }
  27. class CConn;
  28. class Surface;
  29. class Viewport;
  30. class Fl_Scrollbar;
  31. #ifdef __GNUC__
  32. # define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b)))
  33. #else
  34. # define __printf_attr(a, b)
  35. #endif // __GNUC__
  36. class DesktopWindow : public Fl_Window {
  37. public:
  38. DesktopWindow(int w, int h, const char *name,
  39. const rfb::PixelFormat& serverPF, CConn* cc_);
  40. ~DesktopWindow();
  41. // Most efficient format (from DesktopWindow's point of view)
  42. const rfb::PixelFormat &getPreferredPF();
  43. // Flush updates to screen
  44. void updateWindow();
  45. // Updated session title
  46. void setName(const char *name);
  47. // Resize the current framebuffer, but retain the contents
  48. void resizeFramebuffer(int new_w, int new_h);
  49. // Incoming clipboard from server
  50. void serverCutText(const char* str);
  51. // New image for the locally rendered cursor
  52. void setCursor(int width, int height, const rfb::Point& hotspot,
  53. const rdr::U8* data);
  54. // Change client LED state
  55. void setLEDState(unsigned int state);
  56. // Fl_Window callback methods
  57. void draw();
  58. void resize(int x, int y, int w, int h);
  59. int handle(int event);
  60. void fullscreen_on();
  61. private:
  62. static void menuOverlay(void *data);
  63. void setOverlay(const char *text, ...) __printf_attr(2, 3);
  64. static void updateOverlay(void *data);
  65. static int fltkHandle(int event, Fl_Window *win);
  66. void grabKeyboard();
  67. void ungrabKeyboard();
  68. void grabPointer();
  69. void ungrabPointer();
  70. static void handleGrab(void *data);
  71. void maximizeWindow();
  72. void handleDesktopSize();
  73. static void handleResizeTimeout(void *data);
  74. void remoteResize(int width, int height);
  75. void repositionWidgets();
  76. static void handleClose(Fl_Widget *wnd, void *data);
  77. static void handleOptions(void *data);
  78. static void handleFullscreenTimeout(void *data);
  79. void scrollTo(int x, int y);
  80. static void handleScroll(Fl_Widget *wnd, void *data);
  81. static void handleEdgeScroll(void *data);
  82. static void handleStatsTimeout(void *data);
  83. private:
  84. CConn* cc;
  85. Fl_Scrollbar *hscroll, *vscroll;
  86. Viewport *viewport;
  87. Surface *offscreen;
  88. Surface *overlay;
  89. unsigned char overlayAlpha;
  90. struct timeval overlayStart;
  91. bool firstUpdate;
  92. bool delayedFullscreen;
  93. bool delayedDesktopSize;
  94. bool keyboardGrabbed;
  95. bool mouseGrabbed;
  96. struct statsEntry {
  97. unsigned ups;
  98. unsigned pps;
  99. unsigned bps;
  100. };
  101. struct statsEntry stats[100];
  102. struct timeval statsLastTime;
  103. unsigned statsLastUpdates;
  104. unsigned statsLastPixels;
  105. unsigned statsLastPosition;
  106. Surface *statsGraph;
  107. };
  108. #endif