From e5c61a72799485d6751000a127163bd6390d44ba Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Fri, 15 Aug 2008 04:24:03 -0700 Subject: move some frame size calculations to FbWinFrame --- src/FbWinFrame.cc | 20 +++++++++++++++++--- src/FbWinFrame.hh | 6 +++++- src/Screen.cc | 3 +-- src/Screen.hh | 2 +- src/Window.cc | 35 +++++++---------------------------- src/Window.hh | 2 +- 6 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index eb8510e..9136d20 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -1668,6 +1668,20 @@ int FbWinFrame::yOffset() const { return 0; } +void FbWinFrame::applySizeHints(unsigned int &width, unsigned int &height, + bool maximizing) const { + height -= titlebarHeight() + handleHeight(); + sizeHints().apply(width, height, maximizing); + height += titlebarHeight() + handleHeight(); +} + +void FbWinFrame::displaySize(unsigned int width, unsigned int height) const { + unsigned int i, j; + sizeHints().displaySize(i, j, + width, height - titlebarHeight() - handleHeight()); + m_screen.showGeometry(i, j); +} + /* For aspect ratios Note that its slightly simplified in that only the line gradient is given - this is because for aspect @@ -1804,8 +1818,8 @@ bool FbWinFrame::SizeHints::valid(unsigned int w, unsigned int h) const { return true; } -void FbWinFrame::SizeHints::displaySize(int &i, int &j, +void FbWinFrame::SizeHints::displaySize(unsigned int &i, unsigned int &j, unsigned int width, unsigned int height) const { - i = static_cast(width - base_width) / width_inc; - j = static_cast(height - base_height) / height_inc; + i = (width - base_width) / width_inc; + j = (height - base_height) / height_inc; } diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 70f0a4c..23a8141 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -99,7 +99,7 @@ public: void apply(unsigned int &w, unsigned int &h, bool maximizing = false) const; bool valid(unsigned int width, unsigned int height) const; - void displaySize(int &i, int &j, + void displaySize(unsigned int &i, unsigned int &j, unsigned int width, unsigned int height) const; unsigned int min_width; unsigned int max_width; @@ -208,6 +208,10 @@ public: const SizeHints &sizeHints() const { return m_size_hints; } void setSizeHints(const SizeHints &hint) { m_size_hints = hint; } + void applySizeHints(unsigned int &width, unsigned int &height, + bool maximizing) const; + void displaySize(unsigned int width, unsigned int height) const; + void setDecorationMask(unsigned int mask) { m_decoration_mask = mask; } void applyDecorations(); diff --git a/src/Screen.cc b/src/Screen.cc index 838a313..271539d 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1820,8 +1820,7 @@ void BScreen::hidePosition() { m_pos_window->hide(); } -// can be negative when base_width/height > min_width/height -void BScreen::showGeometry(int gx, int gy) { +void BScreen::showGeometry(unsigned int gx, unsigned int gy) { if (!doShowWindowPos()) return; diff --git a/src/Screen.hh b/src/Screen.hh index bfdfd69..2cd9ca9 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -390,7 +390,7 @@ public: void showPosition(int x, int y); void hidePosition(); /// show geomentry with "width x height"-text, not size of window - void showGeometry(int width, int height); + void showGeometry(unsigned int width, unsigned int height); void hideGeometry(); /// @param text the text to be displayed in the tooltip window diff --git a/src/Window.cc b/src/Window.cc index 2a2dbd9..ef6cd73 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -1690,7 +1690,7 @@ void FluxboxWindow::setMaximizedState(int type) { if (!screen().getMaxIgnoreIncrement() || !maximized) { ResizeDirection old_resize_corner = m_resize_corner; m_resize_corner = NOCORNER; - fixsize(0, 0, (maximized ? true : false)); + fixsize(maximized ? true : false); m_resize_corner = old_resize_corner; } @@ -2835,9 +2835,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { unsigned int old_resize_w = m_last_resize_w; unsigned int old_resize_h = m_last_resize_h; - // move rectangle - int gx = 0, gy = 0; - int dx = me.x - m_button_grab_x; int dy = me.y - m_button_grab_y; if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || @@ -2870,7 +2867,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { } } - fixsize(&gx, &gy); + fixsize(); + frame().displaySize(m_last_resize_w, m_last_resize_h); if (old_resize_x != m_last_resize_x || old_resize_y != m_last_resize_y || @@ -2889,7 +2887,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { m_last_resize_w - 1 + 2 * frame().window().borderWidth(), m_last_resize_h - 1 + 2 * frame().window().borderWidth()); - screen().showGeometry(gx, gy); } } } else if (m_attaching_tab != 0) { @@ -3413,7 +3410,6 @@ void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) { false, ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); - int gx = 0, gy = 0; m_button_grab_x = x; m_button_grab_y = y; m_last_resize_x = frame().x(); @@ -3421,9 +3417,8 @@ void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) { m_last_resize_w = frame().width(); m_last_resize_h = frame().height(); - fixsize(&gx, &gy); - - screen().showGeometry(gx, gy); + fixsize(); + frame().displaySize(m_last_resize_w, m_last_resize_h); parent().drawRectangle(screen().rootTheme()->opGC(), m_last_resize_x, m_last_resize_y, @@ -3720,23 +3715,8 @@ unsigned int FluxboxWindow::normalHeight() const { int FluxboxWindow::initialState() const { return m_client->initial_state; } -void FluxboxWindow::fixsize(int *user_w, int *user_h, bool maximizing) { - int decoration_height = frame().titlebarHeight() + frame().handleHeight(); - - // dx is new width = current width + difference between new and old x values - //int dx = frame().width() + frame().x() - m_last_resize_x; - unsigned int dw = m_last_resize_w; - - // dy = new height (w/o decorations), similarly - unsigned int dh = m_last_resize_h - decoration_height; - - frame().sizeHints().apply(dw, dh, maximizing); - if (user_w && user_h) - frame().sizeHints().displaySize(*user_w, *user_h, dw, dh); - - // update last resize - m_last_resize_w = dw; - m_last_resize_h = dh + decoration_height; +void FluxboxWindow::fixsize(bool maximizing) { + frame().applySizeHints(m_last_resize_w, m_last_resize_h, maximizing); // move X if necessary if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || @@ -3748,7 +3728,6 @@ void FluxboxWindow::fixsize(int *user_w, int *user_h, bool maximizing) { m_resize_corner == TOP) { m_last_resize_y = frame().y() + frame().height() - m_last_resize_h; } - } void FluxboxWindow::moveResizeClient(WinClient &client, int x, int y, diff --git a/src/Window.hh b/src/Window.hh index 8085622..5129da8 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -538,7 +538,7 @@ private: // modifies left and top if snap is necessary void doSnapping(int &left, int &top); // user_w/h return the values that should be shown to the user - void fixsize(int *user_w = 0, int *user_h = 0, bool maximizing = false); + void fixsize(bool maximizing = false); void moveResizeClient(WinClient &client, int x, int y, unsigned int width, unsigned int height); /// sends configurenotify to all clients void sendConfigureNotify(); -- cgit v0.11.2