]> source.dussan.org Git - tigervnc.git/commitdiff
viewer could aborted when only one scrollbar should be used
authorAdam Tkac <atkac@redhat.com>
Fri, 14 Mar 2008 13:37:09 +0000 (13:37 +0000)
committerAdam Tkac <atkac@redhat.com>
Fri, 14 Mar 2008 13:37:09 +0000 (13:37 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2420 3789f03b-4d11-0410-bbf8-ca57d06f2519

unix/tx/TXViewport.cxx
unix/tx/TXViewport.h

index abe5173402307690fae6d0b609df00cac2727483..2ee2336b098e7bb8bf49ffb3adcd25ee7c69eda9 100644 (file)
@@ -25,7 +25,8 @@
 TXViewport::TXViewport(Display* dpy_, int w, int h, TXWindow* parent_)
   : TXWindow(dpy_, w, h, parent_), child(0), hScrollbar(0),
     vScrollbar(0), scrollbarSize(15), xOff(0), yOff(0), bumpScrollTimer(this),
-    bumpScroll(false), needScrollbars(false), bumpScrollX(0), bumpScrollY(0)
+    bumpScroll(false), needXScrollbar(false), needYScrollbar(false),
+    bumpScrollX(0), bumpScrollY(0)
 {
   clipper = new TXWindow(dpy, width()-scrollbarSize, height()-scrollbarSize,
                          this);
@@ -117,13 +118,23 @@ bool TXViewport::handleTimeout(rfb::Timer* timer) {
 
 void TXViewport::resizeNotify()
 {
-  needScrollbars = (!bumpScroll &&
-                    (width() < child->width() || height() < child->height()) &&
-                    (width() > scrollbarSize && height() > scrollbarSize));
-  if (needScrollbars) {
+  needXScrollbar = (!bumpScroll && width() < child->width() &&
+                   height() > scrollbarSize && width() > scrollbarSize);
+  needYScrollbar = (!bumpScroll && height() < child->height() &&
+                   height() > scrollbarSize && width() > scrollbarSize);
+
+  if (needXScrollbar && needYScrollbar) {
     clipper->resize(width()-scrollbarSize, height()-scrollbarSize);
     hScrollbar->map();
     vScrollbar->map();
+  } else if (needXScrollbar) {
+    clipper->resize(width(), height()-scrollbarSize);
+    hScrollbar->map();
+    vScrollbar->unmap();
+  } else if (needYScrollbar) {
+    clipper->resize(width()-scrollbarSize, height());
+    hScrollbar->unmap();
+    vScrollbar->map();
   } else {
     clipper->resize(width(), height());
     hScrollbar->unmap();
@@ -132,10 +143,13 @@ void TXViewport::resizeNotify()
 
   setOffset(xOff, yOff);
 
-  if (needScrollbars) {
+  if (needXScrollbar) {
     hScrollbar->move(0, height()-scrollbarSize);
     hScrollbar->resize(width()-scrollbarSize, scrollbarSize);
     hScrollbar->set(child->width(), -xOff, width()-scrollbarSize);
+  }
+
+  if (needYScrollbar) {
     vScrollbar->move(width()-scrollbarSize, 0);
     vScrollbar->resize(scrollbarSize, height()-scrollbarSize);
     vScrollbar->set(child->height(), -yOff, height()-scrollbarSize);
index 0c9857d28b4ff0be88e5e6d51d014b1c03e53aa0..823d67af19c091a819b7b0fbc9f6ecf2dd618681 100644 (file)
@@ -71,7 +71,8 @@ private:
   int xOff, yOff;
   rfb::Timer bumpScrollTimer;
   bool bumpScroll;
-  bool needScrollbars;
+  bool needXScrollbar;
+  bool needYScrollbar;
   int bumpScrollX, bumpScrollY;
 };
 #endif