aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer/Viewport.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2011-06-08 17:02:36 +0000
committerPierre Ossman <ossman@cendio.se>2011-06-08 17:02:36 +0000
commit835b4ef7cdf7df1f91aa0d337a5a4537011d4742 (patch)
tree9131abc63a9f55bc265c6d77aba6bada7911ba71 /vncviewer/Viewport.cxx
parent494271583e29d6d15036989322c62f88f941bc32 (diff)
downloadtigervnc-835b4ef7cdf7df1f91aa0d337a5a4537011d4742.tar.gz
tigervnc-835b4ef7cdf7df1f91aa0d337a5a4537011d4742.zip
Add support for cursors to the new viewer.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4472 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer/Viewport.cxx')
-rw-r--r--vncviewer/Viewport.cxx61
1 files changed, 60 insertions, 1 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 95d883ca..474ae14d 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -47,6 +47,7 @@
#include "keysym2ucs.h"
using namespace rfb;
+using namespace rdr;
extern void exit_vncviewer();
extern void about_vncviewer();
@@ -60,7 +61,7 @@ enum { ID_EXIT, ID_FULLSCREEN, ID_CTRL, ID_ALT, ID_MENUKEY, ID_CTRLALTDEL,
Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_)
: Fl_Widget(0, 0, w, h), cc(cc_), frameBuffer(NULL), pixelTrans(NULL),
- lastPointerPos(0, 0), lastButtonMask(0)
+ lastPointerPos(0, 0), lastButtonMask(0), cursor(NULL)
{
// FLTK STR #2599 must be fixed for proper dead keys support
#ifdef HAVE_FLTK_DEAD_KEYS
@@ -115,6 +116,11 @@ Viewport::~Viewport()
if (pixelTrans)
delete pixelTrans;
+ if (cursor) {
+ delete [] cursor->array;
+ delete cursor;
+ }
+
// FLTK automatically deletes all child widgets, so we shouldn't touch
// them ourselves here
}
@@ -173,6 +179,49 @@ void Viewport::updateWindow()
}
+void Viewport::setCursor(int width, int height, const Point& hotspot,
+ void* data, void* mask)
+{
+#ifdef HAVE_FLTK_CURSOR
+ U8 *buffer = new U8[width*height*4];
+ U8 *i, *o, *m;
+ int m_width;
+
+ const PixelFormat &pf = frameBuffer->getPF();
+
+ i = (U8*)data;
+ o = buffer;
+ m = (U8*)mask;
+ m_width = (width+7)/8;
+ for (int y = 0;y < height;y++) {
+ for (int x = 0;x < width;x++) {
+ pf.rgbFromBuffer(o, i, 1, &colourMap);
+
+ if (m[(m_width*y)+(x/8)] & 0x80>>(x%8))
+ o[3] = 255;
+ else
+ o[3] = 0;
+
+ o += 4;
+ i += pf.bpp/8;
+ }
+ }
+
+ if (cursor) {
+ delete [] cursor->array;
+ delete cursor;
+ }
+
+ cursor = new Fl_RGB_Image(buffer, width, height, 4);
+
+ cursorHotspot = hotspot;
+
+ if (Fl::belowmouse() == this)
+ window()->cursor(cursor, cursorHotspot.x, cursorHotspot.y);
+#endif
+}
+
+
void Viewport::draw()
{
int X, Y, W, H;
@@ -263,7 +312,17 @@ int Viewport::handle(int event)
case FL_ENTER:
// Yes, we would like some pointer events please!
+#ifdef HAVE_FLTK_CURSOR
+ window()->cursor(cursor, cursorHotspot.x, cursorHotspot.y);
+#endif
return 1;
+
+ case FL_LEAVE:
+#ifdef HAVE_FLTK_CURSOR
+ window()->cursor(FL_CURSOR_DEFAULT);
+#endif
+ return 1;
+
case FL_PUSH:
case FL_RELEASE:
case FL_DRAG: