aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2011-03-09 10:24:12 +0000
committerPierre Ossman <ossman@cendio.se>2011-03-09 10:24:12 +0000
commitc266e5a274b05b347402ca0e2cbc7565f4b7ada3 (patch)
tree5834af56dd7c3210afc9928f12aabd72049cfc30 /vncviewer
parent5156d5e49b88d9a5c0ede2c81897e8a2d3c52523 (diff)
downloadtigervnc-c266e5a274b05b347402ca0e2cbc7565f4b7ada3.tar.gz
tigervnc-c266e5a274b05b347402ca0e2cbc7565f4b7ada3.zip
Handle pointer events.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4346 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer')
-rw-r--r--vncviewer/DesktopWindow.cxx66
-rw-r--r--vncviewer/DesktopWindow.h7
2 files changed, 72 insertions, 1 deletions
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index 28f6c09a..5daac0a2 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -40,7 +40,8 @@ static rfb::LogWriter vlog("DesktopWindow");
DesktopWindow::DesktopWindow(int w, int h, const char *name,
const rfb::PixelFormat& serverPF,
CConn* cc_)
- : Fl_Window(w, h), cc(cc_), frameBuffer(NULL), pixelTrans(NULL)
+ : Fl_Window(w, h), cc(cc_), frameBuffer(NULL), pixelTrans(NULL),
+ lastPointerPos(0, 0), lastButtonMask(0)
{
callback(handleClose, this);
@@ -158,6 +159,44 @@ void DesktopWindow::draw()
}
+int DesktopWindow::handle(int event)
+{
+ int buttonMask, wheelMask;
+
+ switch (event) {
+ case FL_PUSH:
+ case FL_RELEASE:
+ case FL_DRAG:
+ case FL_MOVE:
+ case FL_MOUSEWHEEL:
+ buttonMask = 0;
+ if (Fl::event_button1())
+ buttonMask |= 1;
+ if (Fl::event_button2())
+ buttonMask |= 2;
+ if (Fl::event_button3())
+ buttonMask |= 4;
+
+ if (event == FL_MOUSEWHEEL) {
+ if (Fl::event_dy() < 0)
+ wheelMask = 8;
+ else
+ wheelMask = 16;
+
+ // A quick press of the wheel "button", followed by a immediate
+ // release below
+ handlePointerEvent(Point(Fl::event_x(), Fl::event_y()),
+ buttonMask | wheelMask);
+ }
+
+ handlePointerEvent(Point(Fl::event_x(), Fl::event_y()), buttonMask);
+ return 1;
+ }
+
+ return Fl_Window::handle(event);
+}
+
+
void DesktopWindow::handleUpdateTimeout(void *data)
{
DesktopWindow *self = (DesktopWindow *)data;
@@ -184,3 +223,28 @@ void DesktopWindow::handleClose(Fl_Widget *wnd, void *data)
{
exit_vncviewer();
}
+
+
+void DesktopWindow::handlePointerEvent(const rfb::Point& pos, int buttonMask)
+{
+ if (!viewOnly) {
+ if (pointerEventInterval == 0 || buttonMask != lastButtonMask) {
+ cc->writer()->pointerEvent(pos, buttonMask);
+ } else {
+ if (!Fl::has_timeout(handlePointerTimeout, this))
+ Fl::add_timeout((double)pointerEventInterval/1000.0,
+ handlePointerTimeout, this);
+ }
+ lastPointerPos = pos;
+ lastButtonMask = buttonMask;
+ }
+}
+
+
+void DesktopWindow::handlePointerTimeout(void *data)
+{
+ DesktopWindow *self = (DesktopWindow *)data;
+
+ assert(self);
+
+}
diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h
index de85adde..ba308c05 100644
--- a/vncviewer/DesktopWindow.h
+++ b/vncviewer/DesktopWindow.h
@@ -82,6 +82,7 @@ public:
// Fl_Window callback methods
void draw();
+ int handle(int event);
private:
@@ -96,6 +97,9 @@ private:
static void handleClose(Fl_Widget *wnd, void *data);
+ void handlePointerEvent(const rfb::Point& pos, int buttonMask);
+ static void handlePointerTimeout(void *data);
+
private:
CConn* cc;
@@ -105,6 +109,9 @@ private:
rfb::SimpleColourMap colourMap;
rfb::Region damage;
+
+ rfb::Point lastPointerPos;
+ int lastButtonMask;
};
#endif