您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. // New image for the locally rendered cursor
  50. void setCursor(int width, int height, const rfb::Point& hotspot,
  51. const rdr::U8* data);
  52. // Fl_Window callback methods
  53. void draw();
  54. void resize(int x, int y, int w, int h);
  55. int handle(int event);
  56. void fullscreen_on();
  57. private:
  58. static void menuOverlay(void *data);
  59. void setOverlay(const char *text, ...) __printf_attr(2, 3);
  60. static void updateOverlay(void *data);
  61. static int fltkHandle(int event, Fl_Window *win);
  62. void grabKeyboard();
  63. void ungrabKeyboard();
  64. static void handleGrab(void *data);
  65. void maximizeWindow();
  66. void handleDesktopSize();
  67. static void handleResizeTimeout(void *data);
  68. void remoteResize(int width, int height);
  69. void repositionWidgets();
  70. static void handleClose(Fl_Widget *wnd, void *data);
  71. static void handleOptions(void *data);
  72. static void handleFullscreenTimeout(void *data);
  73. void scrollTo(int x, int y);
  74. static void handleScroll(Fl_Widget *wnd, void *data);
  75. static void handleEdgeScroll(void *data);
  76. static void handleStatsTimeout(void *data);
  77. private:
  78. CConn* cc;
  79. Fl_Scrollbar *hscroll, *vscroll;
  80. Viewport *viewport;
  81. Surface *offscreen;
  82. Surface *overlay;
  83. unsigned char overlayAlpha;
  84. struct timeval overlayStart;
  85. bool firstUpdate;
  86. bool delayedFullscreen;
  87. bool delayedDesktopSize;
  88. struct statsEntry {
  89. unsigned fps;
  90. unsigned pps;
  91. unsigned bps;
  92. };
  93. struct statsEntry stats[100];
  94. struct timeval statsLastTime;
  95. unsigned statsLastFrame;
  96. unsigned statsLastPixels;
  97. unsigned statsLastPosition;
  98. Surface *statsGraph;
  99. };
  100. #endif