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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #include <rfb/Region.h>
  24. #include <rfb/Pixel.h>
  25. #include <rfb/ColourMap.h>
  26. class Fl_Menu_Button;
  27. class Fl_RGB_Image;
  28. namespace rfb { class PixelTransformer; }
  29. class CConn;
  30. class PlatformPixelBuffer;
  31. class Viewport : public Fl_Widget {
  32. public:
  33. Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_);
  34. ~Viewport();
  35. // PixelFormat of incoming write operations
  36. void setServerPF(const rfb::PixelFormat& pf);
  37. // Most efficient format (from Viewport's point of view)
  38. const rfb::PixelFormat &getPreferredPF();
  39. // Flush updates to screen
  40. void updateWindow();
  41. // Methods forwarded from CConn
  42. void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
  43. void fillRect(const rfb::Rect& r, rfb::Pixel pix);
  44. void imageRect(const rfb::Rect& r, void* pixels);
  45. void copyRect(const rfb::Rect& r, int srcX, int srcY);
  46. rdr::U8* getBufferRW(const rfb::Rect& r, int* stride);
  47. void damageRect(const rfb::Rect& r);
  48. void setCursor(int width, int height, const rfb::Point& hotspot,
  49. void* data, void* mask);
  50. // Fl_Widget callback methods
  51. void draw();
  52. void resize(int x, int y, int w, int h);
  53. int handle(int event);
  54. private:
  55. static void handleUpdateTimeout(void *data);
  56. void commitColourMap();
  57. static void handleClipboardChange(int source, void *data);
  58. void handlePointerEvent(const rfb::Point& pos, int buttonMask);
  59. static void handlePointerTimeout(void *data);
  60. rdr::U32 translateKeyEvent(int keyCode, int origKeyCode, const char *keyText);
  61. void handleKeyEvent(int keyCode, int origKeyCode, const char *keyText, bool down);
  62. void initContextMenu();
  63. void popupContextMenu();
  64. void setMenuKey();
  65. static void handleOptions(void *data);
  66. private:
  67. CConn* cc;
  68. PlatformPixelBuffer* frameBuffer;
  69. rfb::PixelTransformer *pixelTrans;
  70. rfb::SimpleColourMap colourMap;
  71. bool colourMapChange;
  72. rfb::Region damage;
  73. rfb::Point lastPointerPos;
  74. int lastButtonMask;
  75. typedef std::map<int, rdr::U32> DownMap;
  76. DownMap downKeySym;
  77. int menuKeyCode;
  78. Fl_Menu_Button *contextMenu;
  79. bool menuCtrlKey;
  80. bool menuAltKey;
  81. Fl_RGB_Image *cursor;
  82. rfb::Point cursorHotspot;
  83. };
  84. #endif