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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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, rdr::U32 len);
  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. virtual void show();
  58. virtual void draw();
  59. virtual void resize(int x, int y, int w, int h);
  60. virtual int handle(int event);
  61. void fullscreen_on();
  62. private:
  63. static void menuOverlay(void *data);
  64. void setOverlay(const char *text, ...) __printf_attr(2, 3);
  65. static void updateOverlay(void *data);
  66. static int fltkHandle(int event, Fl_Window *win);
  67. void grabKeyboard();
  68. void ungrabKeyboard();
  69. void grabPointer();
  70. void ungrabPointer();
  71. static void handleGrab(void *data);
  72. void maximizeWindow();
  73. void handleDesktopSize();
  74. static void handleResizeTimeout(void *data);
  75. void remoteResize(int width, int height);
  76. void repositionWidgets();
  77. static void handleClose(Fl_Widget *wnd, void *data);
  78. static void handleOptions(void *data);
  79. static void handleFullscreenTimeout(void *data);
  80. void scrollTo(int x, int y);
  81. static void handleScroll(Fl_Widget *wnd, void *data);
  82. static void handleEdgeScroll(void *data);
  83. static void handleStatsTimeout(void *data);
  84. private:
  85. CConn* cc;
  86. Fl_Scrollbar *hscroll, *vscroll;
  87. Viewport *viewport;
  88. Surface *offscreen;
  89. Surface *overlay;
  90. unsigned char overlayAlpha;
  91. struct timeval overlayStart;
  92. bool firstUpdate;
  93. bool delayedFullscreen;
  94. bool delayedDesktopSize;
  95. bool keyboardGrabbed;
  96. bool mouseGrabbed;
  97. struct statsEntry {
  98. unsigned ups;
  99. unsigned pps;
  100. unsigned bps;
  101. };
  102. struct statsEntry stats[100];
  103. struct timeval statsLastTime;
  104. unsigned statsLastUpdates;
  105. unsigned statsLastPixels;
  106. unsigned statsLastPosition;
  107. Surface *statsGraph;
  108. };
  109. #endif