summaryrefslogtreecommitdiffstats
path: root/vncviewer/Viewport.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2011-06-09 08:32:49 +0000
committerPierre Ossman <ossman@cendio.se>2011-06-09 08:32:49 +0000
commitf741d34b7fdbad1e94e205dd1199c26560d575ae (patch)
tree475c833c6e9aa49d495f2a673e95f3b1e242e05a /vncviewer/Viewport.cxx
parentda38956b3bc61c02e8e198414005d73921fd9a1f (diff)
downloadtigervnc-f741d34b7fdbad1e94e205dd1199c26560d575ae.tar.gz
tigervnc-f741d34b7fdbad1e94e205dd1199c26560d575ae.zip
Implement dot cursor in new viewer.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4477 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer/Viewport.cxx')
-rw-r--r--vncviewer/Viewport.cxx84
1 files changed, 56 insertions, 28 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 474ae14d..5ca9f0e0 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -117,7 +117,8 @@ Viewport::~Viewport()
delete pixelTrans;
if (cursor) {
- delete [] cursor->array;
+ if (!cursor->alloc_array)
+ delete [] cursor->array;
delete cursor;
}
@@ -178,43 +179,70 @@ void Viewport::updateWindow()
damage.clear();
}
+#ifdef HAVE_FLTK_CURSOR
+static const char * dotcursor_xpm[] = {
+ "5 5 2 1",
+ ". c #000000",
+ " c #FFFFFF",
+ " ",
+ " ... ",
+ " ... ",
+ " ... ",
+ " "};
+#endif
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;
+ if (!cursor->alloc_array)
+ delete [] cursor->array;
delete cursor;
}
- cursor = new Fl_RGB_Image(buffer, width, height, 4);
+ int mask_len = ((width+7)/8) * height;
+ int i;
+
+ for (i = 0; i < mask_len; i++)
+ if (((rdr::U8*)mask)[i]) break;
+
+ if (i == mask_len) {
+ if (dotWhenNoCursor)
+ vlog.debug("cursor is empty - using dot");
+
+ Fl_Pixmap pxm(dotcursor_xpm);
+ cursor = new Fl_RGB_Image(&pxm);
+ cursorHotspot.x = cursorHotspot.y = 2;
+ } else {
+ 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;
+ }
+ }
+
+ cursor = new Fl_RGB_Image(buffer, width, height, 4);
- cursorHotspot = hotspot;
+ cursorHotspot = hotspot;
+ }
if (Fl::belowmouse() == this)
window()->cursor(cursor, cursorHotspot.x, cursorHotspot.y);