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.

Viewport.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2011-2019 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 __VIEWPORT_H__
  20. #define __VIEWPORT_H__
  21. #include <map>
  22. #include <rfb/Rect.h>
  23. #include <FL/Fl_Widget.H>
  24. class Fl_Menu_Button;
  25. class Fl_RGB_Image;
  26. class CConn;
  27. class PlatformPixelBuffer;
  28. class Surface;
  29. class Viewport : public Fl_Widget {
  30. public:
  31. Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_);
  32. ~Viewport();
  33. // Most efficient format (from Viewport's point of view)
  34. const rfb::PixelFormat &getPreferredPF();
  35. // Flush updates to screen
  36. void updateWindow();
  37. // New image for the locally rendered cursor
  38. void setCursor(int width, int height, const rfb::Point& hotspot,
  39. const rdr::U8* data);
  40. // Change client LED state
  41. void setLEDState(unsigned int state);
  42. void draw(Surface* dst);
  43. // Clipboard events
  44. void handleClipboardRequest();
  45. void handleClipboardAnnounce(bool available);
  46. void handleClipboardData(const char* data);
  47. // Fl_Widget callback methods
  48. void draw();
  49. void resize(int x, int y, int w, int h);
  50. int handle(int event);
  51. private:
  52. bool hasFocus();
  53. unsigned int getModifierMask(unsigned int keysym);
  54. static void handleClipboardChange(int source, void *data);
  55. void flushPendingClipboard();
  56. void handlePointerEvent(const rfb::Point& pos, int buttonMask);
  57. static void handlePointerTimeout(void *data);
  58. void handleKeyPress(int keyCode, rdr::U32 keySym);
  59. void handleKeyRelease(int keyCode);
  60. static int handleSystemEvent(void *event, void *data);
  61. #ifdef WIN32
  62. static void handleAltGrTimeout(void *data);
  63. #endif
  64. void pushLEDState();
  65. void initContextMenu();
  66. void popupContextMenu();
  67. void setMenuKey();
  68. static void handleOptions(void *data);
  69. private:
  70. CConn* cc;
  71. PlatformPixelBuffer* frameBuffer;
  72. rfb::Point lastPointerPos;
  73. int lastButtonMask;
  74. typedef std::map<int, rdr::U32> DownMap;
  75. DownMap downKeySym;
  76. #ifdef WIN32
  77. bool altGrArmed;
  78. unsigned int altGrCtrlTime;
  79. #endif
  80. bool firstLEDState;
  81. bool pendingServerClipboard;
  82. bool pendingClientClipboard;
  83. int clipboardSource;
  84. rdr::U32 menuKeySym;
  85. int menuKeyCode, menuKeyFLTK;
  86. Fl_Menu_Button *contextMenu;
  87. bool menuCtrlKey;
  88. bool menuAltKey;
  89. Fl_RGB_Image *cursor;
  90. rfb::Point cursorHotspot;
  91. };
  92. #endif