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 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 __VIEWPORT_H__
  20. #define __VIEWPORT_H__
  21. #include <map>
  22. #include <FL/Fl_Widget.H>
  23. class Fl_Menu_Button;
  24. class Fl_RGB_Image;
  25. class CConn;
  26. class PlatformPixelBuffer;
  27. class Viewport : public Fl_Widget {
  28. public:
  29. Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_);
  30. ~Viewport();
  31. // Most efficient format (from Viewport's point of view)
  32. const rfb::PixelFormat &getPreferredPF();
  33. // Flush updates to screen
  34. void updateWindow();
  35. // New image for the locally rendered cursor
  36. void setCursor(int width, int height, const rfb::Point& hotspot,
  37. void* data, void* mask);
  38. // Fl_Widget callback methods
  39. void draw();
  40. void resize(int x, int y, int w, int h);
  41. int handle(int event);
  42. private:
  43. static void handleClipboardChange(int source, void *data);
  44. void handlePointerEvent(const rfb::Point& pos, int buttonMask);
  45. static void handlePointerTimeout(void *data);
  46. void handleKeyPress(int keyCode, rdr::U32 keySym);
  47. void handleKeyRelease(int keyCode);
  48. static int handleSystemEvent(void *event, void *data);
  49. void initContextMenu();
  50. void popupContextMenu();
  51. void setMenuKey();
  52. static void handleOptions(void *data);
  53. private:
  54. CConn* cc;
  55. PlatformPixelBuffer* frameBuffer;
  56. rfb::Point lastPointerPos;
  57. int lastButtonMask;
  58. typedef std::map<int, rdr::U32> DownMap;
  59. DownMap downKeySym;
  60. rdr::U32 menuKeySym;
  61. int menuKeyCode;
  62. Fl_Menu_Button *contextMenu;
  63. bool menuCtrlKey;
  64. bool menuAltKey;
  65. Fl_RGB_Image *cursor;
  66. rfb::Point cursorHotspot;
  67. };
  68. #endif