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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 <rfb/Rect.h>
  23. #include "Viewport.h"
  24. #include <FL/Fl.H>
  25. #include <FL/Fl_Window.H>
  26. class CConn;
  27. class Fl_Scroll;
  28. class DesktopWindow : public Fl_Window {
  29. public:
  30. DesktopWindow(int w, int h, const char *name,
  31. const rfb::PixelFormat& serverPF, CConn* cc_);
  32. ~DesktopWindow();
  33. // PixelFormat of incoming write operations
  34. void setServerPF(const rfb::PixelFormat& pf);
  35. // Most efficient format (from DesktopWindow's point of view)
  36. const rfb::PixelFormat &getPreferredPF();
  37. // Flush updates to screen
  38. void updateWindow();
  39. // Methods forwarded from CConn
  40. void setName(const char *name);
  41. void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
  42. void fillRect(const rfb::Rect& r, rfb::Pixel pix) {
  43. viewport->fillRect(r, pix);
  44. }
  45. void imageRect(const rfb::Rect& r, void* pixels) {
  46. viewport->imageRect(r, pixels);
  47. }
  48. void copyRect(const rfb::Rect& r, int srcX, int srcY) {
  49. viewport->copyRect(r, srcX, srcY);
  50. }
  51. rdr::U8* getBufferRW(const rfb::Rect& r, int* stride) {
  52. return viewport->getBufferRW(r, stride);
  53. }
  54. void damageRect(const rfb::Rect& r) {
  55. viewport->damageRect(r);
  56. }
  57. void resizeFramebuffer(int new_w, int new_h);
  58. void setCursor(int width, int height, const rfb::Point& hotspot,
  59. void* data, void* mask);
  60. // Fl_Window callback methods
  61. void resize(int x, int y, int w, int h);
  62. int handle(int event);
  63. void fullscreen_on();
  64. private:
  65. static int fltkHandle(int event, Fl_Window *win);
  66. void grabKeyboard();
  67. void ungrabKeyboard();
  68. static void handleGrab(void *data);
  69. void maximizeWindow();
  70. void handleDesktopSize();
  71. static void handleResizeTimeout(void *data);
  72. void remoteResize(int width, int height);
  73. void repositionViewport();
  74. static void handleClose(Fl_Widget *wnd, void *data);
  75. static void handleOptions(void *data);
  76. static void handleFullscreenTimeout(void *data);
  77. static void handleEdgeScroll(void *data);
  78. private:
  79. CConn* cc;
  80. Fl_Scroll *scroll;
  81. Viewport *viewport;
  82. bool firstUpdate;
  83. bool delayedFullscreen;
  84. bool delayedDesktopSize;
  85. };
  86. #endif