From d8967bd534ff10a234fed17059fb92d985be9176 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 7 Aug 2002 16:24:13 +0000 Subject: [PATCH] support better resizing a delta value instead of an absolute value --- util/epist/screen.cc | 4 ++-- util/epist/window.cc | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 9068ed31..c4f0520b 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -274,11 +274,11 @@ void screen::handleKeypress(const XEvent &e) { return; case Action::resizeWindowWidth: - window->resize(window->width() + it->number(), window->height()); + window->resize(it->number(), 0); return; case Action::resizeWindowHeight: - window->resize(window->width(), window->height() + it->number()); + window->resize(0, it->number()); return; case Action::toggleshade: diff --git a/util/epist/window.cc b/util/epist/window.cc index ba952073..c8cdf012 100644 --- a/util/epist/window.cc +++ b/util/epist/window.cc @@ -336,6 +336,33 @@ void XWindow::move(int x, int y) const { } +void XWindow::resize(int dwidth, int dheight) const { + // resize in increments if requested by the window + + unsigned int wdest = _rect.width() + (dwidth * _inc_x) / + _inc_x * _inc_x + _base_x; + unsigned int hdest = _rect.height() + (dheight * _inc_y) / + _inc_y * _inc_y + _base_y; + + if (width > wdest) { + while (width > wdest) + wdest += _inc_x; + } else { + while (width < wdest) + wdest -= _inc_x; + } + if (height > hdest) { + while (height > hdest) + hdest += _inc_y; + } else { + while (height < hdest) + hdest -= _inc_y; + } + + XResizeWindow(_epist->getXDisplay(), _window, wdest, hdest); +} + + void XWindow::resize(unsigned int width, unsigned int height) const { // resize in increments if requested by the window -- 2.45.2