Revision: 4991
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4991&view=rev
Author:   ossman_
Date:     2012-09-03 09:25:07 +0000 (Mon, 03 Sep 2012)
Log Message:
-----------
Restore edge/bump scrolling when we are in full screen mode as it is easier
to use.

Modified Paths:
--------------
    trunk/vncviewer/DesktopWindow.cxx
    trunk/vncviewer/DesktopWindow.h

Modified: trunk/vncviewer/DesktopWindow.cxx
===================================================================
--- trunk/vncviewer/DesktopWindow.cxx   2012-09-01 21:15:26 UTC (rev 4990)
+++ trunk/vncviewer/DesktopWindow.cxx   2012-09-03 09:25:07 UTC (rev 4991)
@@ -46,6 +46,9 @@
 #include "cocoa.h"
 #endif
 
+#define EDGE_SCROLL_SIZE 32
+#define EDGE_SCROLL_SPEED 20
+
 using namespace rfb;
 
 static rfb::LogWriter vlog("DesktopWindow");
@@ -56,7 +59,7 @@
   : Fl_Window(w, h), cc(cc_), firstUpdate(true),
     delayedFullscreen(false), delayedDesktopSize(false)
 {
-  Fl_Scroll *scroll = new Fl_Scroll(0, 0, w, h);
+  scroll = new Fl_Scroll(0, 0, w, h);
   scroll->color(FL_BLACK);
 
   // Automatically adjust the scroll box to the window
@@ -164,6 +167,7 @@
   Fl::remove_timeout(handleGrab, this);
   Fl::remove_timeout(handleResizeTimeout, this);
   Fl::remove_timeout(handleFullscreenTimeout, this);
+  Fl::remove_timeout(handleEdgeScroll, this);
 
   OptionsDialog::removeCallback(handleOptions);
 
@@ -308,6 +312,11 @@
   case FL_FULLSCREEN:
     fullScreen.setParam(fullscreen_active());
 
+    if (fullscreen_active())
+      scroll->type(0);
+    else
+      scroll->type(Fl_Scroll::BOTH);
+
     if (!fullscreenSystemKeys)
       break;
 
@@ -317,7 +326,23 @@
       ungrabKeyboard();
 
     break;
+
+  case FL_ENTER:
+  case FL_LEAVE:
+  case FL_DRAG:
+  case FL_MOVE:
+    if (fullscreen_active()) {
+      if (((viewport->x() < 0) && (Fl::event_x() < EDGE_SCROLL_SIZE)) ||
+          ((viewport->x() + viewport->w() > w()) && (Fl::event_x() > w() - 
EDGE_SCROLL_SIZE)) ||
+          ((viewport->y() < 0) && (Fl::event_y() < EDGE_SCROLL_SIZE)) ||
+          ((viewport->y() + viewport->h() > h()) && (Fl::event_y() > h() - 
EDGE_SCROLL_SIZE))) {
+        if (!Fl::has_timeout(handleEdgeScroll, this))
+          Fl::add_timeout(0.1, handleEdgeScroll, this);
+      }
+    }
+    return 1;
 #endif
+
   case FL_SHORTCUT:
     // Sometimes the focus gets out of whack and we fall through to the
     // shortcut dispatching. Try to make things sane again...
@@ -773,3 +798,59 @@
     self->delayedDesktopSize = false;
   }
 }
+
+void DesktopWindow::handleEdgeScroll(void *data)
+{
+#ifdef HAVE_FLTK_FULLSCREEN
+  DesktopWindow *self = (DesktopWindow *)data;
+
+  int mx, my;
+  int dx, dy;
+
+  assert(self);
+
+  if (!self->fullscreen_active())
+    return;
+
+  mx = Fl::event_x();
+  my = Fl::event_y();
+
+  dx = dy = 0;
+
+  // Clamp mouse position in case it is outside the window
+  if (mx < 0)
+    mx = 0;
+  if (mx > self->w())
+    mx = self->w();
+  if (my < 0)
+    my = 0;
+  if (my > self->h())
+    my = self->h();
+
+  if ((self->viewport->x() < 0) && (mx < EDGE_SCROLL_SIZE))
+    dx = EDGE_SCROLL_SPEED - EDGE_SCROLL_SPEED * mx / EDGE_SCROLL_SIZE;
+  if ((self->viewport->x() + self->viewport->w() > self->w()) && (mx > 
self->w() - EDGE_SCROLL_SIZE))
+    dx = EDGE_SCROLL_SPEED * (self->w() - mx) / EDGE_SCROLL_SIZE - 
EDGE_SCROLL_SPEED;
+  if ((self->viewport->y() < 0) && (my < EDGE_SCROLL_SIZE))
+    dy = EDGE_SCROLL_SPEED - EDGE_SCROLL_SPEED * my / EDGE_SCROLL_SIZE;
+  if ((self->viewport->y() + self->viewport->h() > self->h()) && (my > 
self->h() - EDGE_SCROLL_SIZE))
+    dy = EDGE_SCROLL_SPEED * (self->h() - my) / EDGE_SCROLL_SIZE - 
EDGE_SCROLL_SPEED;
+
+  if ((dx == 0) && (dy == 0))
+    return;
+
+  // Make sure we don't move the viewport too much
+  if (self->viewport->x() + dx > 0)
+    dx = -self->viewport->x();
+  if (self->viewport->x() + dx + self->viewport->w() < self->w())
+    dx = self->w() - (self->viewport->x() + self->viewport->w());
+  if (self->viewport->y() + dy > 0)
+    dy = -self->viewport->y();
+  if (self->viewport->y() + dy + self->viewport->h() < self->h())
+    dy = self->h() - (self->viewport->y() + self->viewport->h());
+
+  self->scroll->scroll_to(self->scroll->xposition() - dx, 
self->scroll->yposition() - dy);
+
+  Fl::repeat_timeout(0.1, handleEdgeScroll, data);
+#endif
+}

Modified: trunk/vncviewer/DesktopWindow.h
===================================================================
--- trunk/vncviewer/DesktopWindow.h     2012-09-01 21:15:26 UTC (rev 4990)
+++ trunk/vncviewer/DesktopWindow.h     2012-09-03 09:25:07 UTC (rev 4991)
@@ -30,6 +30,7 @@
 #include <FL/Fl_Window.H>
 
 class CConn;
+class Fl_Scroll;
 
 class DesktopWindow : public Fl_Window {
 public:
@@ -102,8 +103,11 @@
 
   static void handleFullscreenTimeout(void *data);
 
+  static void handleEdgeScroll(void *data);
+
 private:
   CConn* cc;
+  Fl_Scroll *scroll;
   Viewport *viewport;
 
   bool firstUpdate;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Tigervnc-commits mailing list
Tigervnc-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to