all repos — fluxbox @ e5c61a72799485d6751000a127163bd6390d44ba

custom fork of the fluxbox windowmanager

move some frame size calculations to FbWinFrame
Mark Tiefenbruck mark@fluxbox.org
commit

e5c61a72799485d6751000a127163bd6390d44ba

parent

1dab657708cd8246c2ce5a6aaa05cc5733e09c54

6 files changed, 32 insertions(+), 36 deletions(-)

jump to
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -1668,6 +1668,20 @@ }

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 @@

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<signed>(width - base_width) / width_inc; - j = static_cast<signed>(height - base_height) / height_inc; + i = (width - base_width) / width_inc; + j = (height - base_height) / height_inc; }
M src/FbWinFrame.hhsrc/FbWinFrame.hh

@@ -99,7 +99,7 @@ typedef struct SizeHints {

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;

@@ -207,6 +207,10 @@ void removeEventHandler();

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();
M src/Screen.ccsrc/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;
M src/Screen.hhsrc/Screen.hh

@@ -390,7 +390,7 @@ /// show position window centered on the screen with "X x Y" text

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
M src/Window.ccsrc/Window.cc

@@ -1690,7 +1690,7 @@ // but we do fix size hints when restoring the window to normal size

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 @@ int old_resize_y = m_last_resize_y;

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 @@ m_last_resize_y = frame().y() - diff/2;

} } - 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 @@ m_last_resize_x, m_last_resize_y,

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 @@ grabPointer(fbWindow().window(),

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 @@ m_last_resize_y = frame().y();

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 @@ }

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 @@ if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP ||

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,
M src/Window.hhsrc/Window.hh

@@ -538,7 +538,7 @@

// 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();