diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-15 11:24:03 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-15 11:24:03 (GMT) |
commit | e5c61a72799485d6751000a127163bd6390d44ba (patch) | |
tree | 06846dffe135e57f958dc69e9731e1f68fb56615 | |
parent | 1dab657708cd8246c2ce5a6aaa05cc5733e09c54 (diff) | |
download | fluxbox-e5c61a72799485d6751000a127163bd6390d44ba.zip fluxbox-e5c61a72799485d6751000a127163bd6390d44ba.tar.bz2 |
move some frame size calculations to FbWinFrame
-rw-r--r-- | src/FbWinFrame.cc | 20 | ||||
-rw-r--r-- | src/FbWinFrame.hh | 6 | ||||
-rw-r--r-- | src/Screen.cc | 3 | ||||
-rw-r--r-- | src/Screen.hh | 2 | ||||
-rw-r--r-- | src/Window.cc | 35 | ||||
-rw-r--r-- | 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 { | |||
1668 | return 0; | 1668 | return 0; |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | void FbWinFrame::applySizeHints(unsigned int &width, unsigned int &height, | ||
1672 | bool maximizing) const { | ||
1673 | height -= titlebarHeight() + handleHeight(); | ||
1674 | sizeHints().apply(width, height, maximizing); | ||
1675 | height += titlebarHeight() + handleHeight(); | ||
1676 | } | ||
1677 | |||
1678 | void FbWinFrame::displaySize(unsigned int width, unsigned int height) const { | ||
1679 | unsigned int i, j; | ||
1680 | sizeHints().displaySize(i, j, | ||
1681 | width, height - titlebarHeight() - handleHeight()); | ||
1682 | m_screen.showGeometry(i, j); | ||
1683 | } | ||
1684 | |||
1671 | /* For aspect ratios | 1685 | /* For aspect ratios |
1672 | Note that its slightly simplified in that only the | 1686 | Note that its slightly simplified in that only the |
1673 | line gradient is given - this is because for aspect | 1687 | line gradient is given - this is because for aspect |
@@ -1804,8 +1818,8 @@ bool FbWinFrame::SizeHints::valid(unsigned int w, unsigned int h) const { | |||
1804 | return true; | 1818 | return true; |
1805 | } | 1819 | } |
1806 | 1820 | ||
1807 | void FbWinFrame::SizeHints::displaySize(int &i, int &j, | 1821 | void FbWinFrame::SizeHints::displaySize(unsigned int &i, unsigned int &j, |
1808 | unsigned int width, unsigned int height) const { | 1822 | unsigned int width, unsigned int height) const { |
1809 | i = static_cast<signed>(width - base_width) / width_inc; | 1823 | i = (width - base_width) / width_inc; |
1810 | j = static_cast<signed>(height - base_height) / height_inc; | 1824 | j = (height - base_height) / height_inc; |
1811 | } | 1825 | } |
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: | |||
99 | void apply(unsigned int &w, unsigned int &h, | 99 | void apply(unsigned int &w, unsigned int &h, |
100 | bool maximizing = false) const; | 100 | bool maximizing = false) const; |
101 | bool valid(unsigned int width, unsigned int height) const; | 101 | bool valid(unsigned int width, unsigned int height) const; |
102 | void displaySize(int &i, int &j, | 102 | void displaySize(unsigned int &i, unsigned int &j, |
103 | unsigned int width, unsigned int height) const; | 103 | unsigned int width, unsigned int height) const; |
104 | unsigned int min_width; | 104 | unsigned int min_width; |
105 | unsigned int max_width; | 105 | unsigned int max_width; |
@@ -208,6 +208,10 @@ public: | |||
208 | const SizeHints &sizeHints() const { return m_size_hints; } | 208 | const SizeHints &sizeHints() const { return m_size_hints; } |
209 | void setSizeHints(const SizeHints &hint) { m_size_hints = hint; } | 209 | void setSizeHints(const SizeHints &hint) { m_size_hints = hint; } |
210 | 210 | ||
211 | void applySizeHints(unsigned int &width, unsigned int &height, | ||
212 | bool maximizing) const; | ||
213 | void displaySize(unsigned int width, unsigned int height) const; | ||
214 | |||
211 | void setDecorationMask(unsigned int mask) { m_decoration_mask = mask; } | 215 | void setDecorationMask(unsigned int mask) { m_decoration_mask = mask; } |
212 | void applyDecorations(); | 216 | void applyDecorations(); |
213 | 217 | ||
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() { | |||
1820 | m_pos_window->hide(); | 1820 | m_pos_window->hide(); |
1821 | } | 1821 | } |
1822 | 1822 | ||
1823 | // can be negative when base_width/height > min_width/height | 1823 | void BScreen::showGeometry(unsigned int gx, unsigned int gy) { |
1824 | void BScreen::showGeometry(int gx, int gy) { | ||
1825 | if (!doShowWindowPos()) | 1824 | if (!doShowWindowPos()) |
1826 | return; | 1825 | return; |
1827 | 1826 | ||
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: | |||
390 | void showPosition(int x, int y); | 390 | void showPosition(int x, int y); |
391 | void hidePosition(); | 391 | void hidePosition(); |
392 | /// show geomentry with "width x height"-text, not size of window | 392 | /// show geomentry with "width x height"-text, not size of window |
393 | void showGeometry(int width, int height); | 393 | void showGeometry(unsigned int width, unsigned int height); |
394 | void hideGeometry(); | 394 | void hideGeometry(); |
395 | 395 | ||
396 | /// @param text the text to be displayed in the tooltip window | 396 | /// @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) { | |||
1690 | if (!screen().getMaxIgnoreIncrement() || !maximized) { | 1690 | if (!screen().getMaxIgnoreIncrement() || !maximized) { |
1691 | ResizeDirection old_resize_corner = m_resize_corner; | 1691 | ResizeDirection old_resize_corner = m_resize_corner; |
1692 | m_resize_corner = NOCORNER; | 1692 | m_resize_corner = NOCORNER; |
1693 | fixsize(0, 0, (maximized ? true : false)); | 1693 | fixsize(maximized ? true : false); |
1694 | m_resize_corner = old_resize_corner; | 1694 | m_resize_corner = old_resize_corner; |
1695 | } | 1695 | } |
1696 | 1696 | ||
@@ -2835,9 +2835,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2835 | unsigned int old_resize_w = m_last_resize_w; | 2835 | unsigned int old_resize_w = m_last_resize_w; |
2836 | unsigned int old_resize_h = m_last_resize_h; | 2836 | unsigned int old_resize_h = m_last_resize_h; |
2837 | 2837 | ||
2838 | // move rectangle | ||
2839 | int gx = 0, gy = 0; | ||
2840 | |||
2841 | int dx = me.x - m_button_grab_x; | 2838 | int dx = me.x - m_button_grab_x; |
2842 | int dy = me.y - m_button_grab_y; | 2839 | int dy = me.y - m_button_grab_y; |
2843 | if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || | 2840 | if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || |
@@ -2870,7 +2867,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2870 | } | 2867 | } |
2871 | } | 2868 | } |
2872 | 2869 | ||
2873 | fixsize(&gx, &gy); | 2870 | fixsize(); |
2871 | frame().displaySize(m_last_resize_w, m_last_resize_h); | ||
2874 | 2872 | ||
2875 | if (old_resize_x != m_last_resize_x || | 2873 | if (old_resize_x != m_last_resize_x || |
2876 | old_resize_y != m_last_resize_y || | 2874 | old_resize_y != m_last_resize_y || |
@@ -2889,7 +2887,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2889 | m_last_resize_w - 1 + 2 * frame().window().borderWidth(), | 2887 | m_last_resize_w - 1 + 2 * frame().window().borderWidth(), |
2890 | m_last_resize_h - 1 + 2 * frame().window().borderWidth()); | 2888 | m_last_resize_h - 1 + 2 * frame().window().borderWidth()); |
2891 | 2889 | ||
2892 | screen().showGeometry(gx, gy); | ||
2893 | } | 2890 | } |
2894 | } | 2891 | } |
2895 | } else if (m_attaching_tab != 0) { | 2892 | } else if (m_attaching_tab != 0) { |
@@ -3413,7 +3410,6 @@ void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) { | |||
3413 | false, ButtonMotionMask | ButtonReleaseMask, | 3410 | false, ButtonMotionMask | ButtonReleaseMask, |
3414 | GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); | 3411 | GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); |
3415 | 3412 | ||
3416 | int gx = 0, gy = 0; | ||
3417 | m_button_grab_x = x; | 3413 | m_button_grab_x = x; |
3418 | m_button_grab_y = y; | 3414 | m_button_grab_y = y; |
3419 | m_last_resize_x = frame().x(); | 3415 | m_last_resize_x = frame().x(); |
@@ -3421,9 +3417,8 @@ void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) { | |||
3421 | m_last_resize_w = frame().width(); | 3417 | m_last_resize_w = frame().width(); |
3422 | m_last_resize_h = frame().height(); | 3418 | m_last_resize_h = frame().height(); |
3423 | 3419 | ||
3424 | fixsize(&gx, &gy); | 3420 | fixsize(); |
3425 | 3421 | frame().displaySize(m_last_resize_w, m_last_resize_h); | |
3426 | screen().showGeometry(gx, gy); | ||
3427 | 3422 | ||
3428 | parent().drawRectangle(screen().rootTheme()->opGC(), | 3423 | parent().drawRectangle(screen().rootTheme()->opGC(), |
3429 | m_last_resize_x, m_last_resize_y, | 3424 | m_last_resize_x, m_last_resize_y, |
@@ -3720,23 +3715,8 @@ unsigned int FluxboxWindow::normalHeight() const { | |||
3720 | 3715 | ||
3721 | int FluxboxWindow::initialState() const { return m_client->initial_state; } | 3716 | int FluxboxWindow::initialState() const { return m_client->initial_state; } |
3722 | 3717 | ||
3723 | void FluxboxWindow::fixsize(int *user_w, int *user_h, bool maximizing) { | 3718 | void FluxboxWindow::fixsize(bool maximizing) { |
3724 | int decoration_height = frame().titlebarHeight() + frame().handleHeight(); | 3719 | frame().applySizeHints(m_last_resize_w, m_last_resize_h, maximizing); |
3725 | |||
3726 | // dx is new width = current width + difference between new and old x values | ||
3727 | //int dx = frame().width() + frame().x() - m_last_resize_x; | ||
3728 | unsigned int dw = m_last_resize_w; | ||
3729 | |||
3730 | // dy = new height (w/o decorations), similarly | ||
3731 | unsigned int dh = m_last_resize_h - decoration_height; | ||
3732 | |||
3733 | frame().sizeHints().apply(dw, dh, maximizing); | ||
3734 | if (user_w && user_h) | ||
3735 | frame().sizeHints().displaySize(*user_w, *user_h, dw, dh); | ||
3736 | |||
3737 | // update last resize | ||
3738 | m_last_resize_w = dw; | ||
3739 | m_last_resize_h = dh + decoration_height; | ||
3740 | 3720 | ||
3741 | // move X if necessary | 3721 | // move X if necessary |
3742 | if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || | 3722 | if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || |
@@ -3748,7 +3728,6 @@ void FluxboxWindow::fixsize(int *user_w, int *user_h, bool maximizing) { | |||
3748 | m_resize_corner == TOP) { | 3728 | m_resize_corner == TOP) { |
3749 | m_last_resize_y = frame().y() + frame().height() - m_last_resize_h; | 3729 | m_last_resize_y = frame().y() + frame().height() - m_last_resize_h; |
3750 | } | 3730 | } |
3751 | |||
3752 | } | 3731 | } |
3753 | 3732 | ||
3754 | void FluxboxWindow::moveResizeClient(WinClient &client, int x, int y, | 3733 | 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: | |||
538 | // modifies left and top if snap is necessary | 538 | // modifies left and top if snap is necessary |
539 | void doSnapping(int &left, int &top); | 539 | void doSnapping(int &left, int &top); |
540 | // user_w/h return the values that should be shown to the user | 540 | // user_w/h return the values that should be shown to the user |
541 | void fixsize(int *user_w = 0, int *user_h = 0, bool maximizing = false); | 541 | void fixsize(bool maximizing = false); |
542 | void moveResizeClient(WinClient &client, int x, int y, unsigned int width, unsigned int height); | 542 | void moveResizeClient(WinClient &client, int x, int y, unsigned int width, unsigned int height); |
543 | /// sends configurenotify to all clients | 543 | /// sends configurenotify to all clients |
544 | void sendConfigureNotify(); | 544 | void sendConfigureNotify(); |