From b33e79e72dc3f9d81fa3eee5b809891b9a357baf Mon Sep 17 00:00:00 2001 From: Adam Tkac Date: Fri, 14 Mar 2008 13:37:09 +0000 Subject: [PATCH] viewer could aborted when only one scrollbar should be used git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2420 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- unix/tx/TXViewport.cxx | 26 ++++++++++++++++++++------ unix/tx/TXViewport.h | 3 ++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/unix/tx/TXViewport.cxx b/unix/tx/TXViewport.cxx index abe51734..2ee2336b 100644 --- a/unix/tx/TXViewport.cxx +++ b/unix/tx/TXViewport.cxx @@ -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); diff --git a/unix/tx/TXViewport.h b/unix/tx/TXViewport.h index 0c9857d2..823d67af 100644 --- a/unix/tx/TXViewport.h +++ b/unix/tx/TXViewport.h @@ -71,7 +71,8 @@ private: int xOff, yOff; rfb::Timer bumpScrollTimer; bool bumpScroll; - bool needScrollbars; + bool needXScrollbar; + bool needYScrollbar; int bumpScrollX, bumpScrollY; }; #endif -- 2.39.5