diff options
author | fluxgen <fluxgen> | 2003-02-22 18:28:32 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-02-22 18:28:32 (GMT) |
commit | f3879a838724360b81ec8d0f2d9ca07ca88300ce (patch) | |
tree | ff0712ecd80d1246497c8767e48f8cdf21ec745a /src/Window.cc | |
parent | fc67d00fa677e7ad26615b324a4d6fbe3bb3d168 (diff) | |
download | fluxbox_pavel-f3879a838724360b81ec8d0f2d9ca07ca88300ce.zip fluxbox_pavel-f3879a838724360b81ec8d0f2d9ca07ca88300ce.tar.bz2 |
fixed resize bug
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/src/Window.cc b/src/Window.cc index ec0d7f3..bc16271 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Window.cc,v 1.123 2003/02/22 15:10:43 rathnor Exp $ | 25 | // $Id: Window.cc,v 1.124 2003/02/22 18:28:32 fluxgen Exp $ |
26 | 26 | ||
27 | #include "Window.hh" | 27 | #include "Window.hh" |
28 | 28 | ||
@@ -245,8 +245,6 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, | |||
245 | client.width = wattrib.width; | 245 | client.width = wattrib.width; |
246 | client.height = wattrib.height; | 246 | client.height = wattrib.height; |
247 | 247 | ||
248 | m_frame.move(wattrib.x, wattrib.y); | ||
249 | m_frame.resizeForClient(wattrib.width, wattrib.height); | ||
250 | 248 | ||
251 | Fluxbox *fluxbox = Fluxbox::instance(); | 249 | Fluxbox *fluxbox = Fluxbox::instance(); |
252 | 250 | ||
@@ -316,7 +314,8 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, | |||
316 | 314 | ||
317 | positionWindows(); | 315 | positionWindows(); |
318 | 316 | ||
319 | 317 | m_frame.move(wattrib.x, wattrib.y); | |
318 | m_frame.resizeForClient(wattrib.width, wattrib.height); | ||
320 | 319 | ||
321 | if (workspace_number < 0 || workspace_number >= screen->getCount()) | 320 | if (workspace_number < 0 || workspace_number >= screen->getCount()) |
322 | workspace_number = screen->getCurrentWorkspaceID(); | 321 | workspace_number = screen->getCurrentWorkspaceID(); |
@@ -1148,7 +1147,8 @@ void FluxboxWindow::maximize() { | |||
1148 | unsigned int max_width = screen->getMaxRight(); | 1147 | unsigned int max_width = screen->getMaxRight(); |
1149 | unsigned int max_top = screen->getMaxTop(); | 1148 | unsigned int max_top = screen->getMaxTop(); |
1150 | moveResize(left_x, max_top, | 1149 | moveResize(left_x, max_top, |
1151 | max_width - left_x, screen->getMaxBottom() - max_top - m_frame.window().borderWidth()); | 1150 | max_width - left_x, |
1151 | screen->getMaxBottom() - max_top - m_frame.window().borderWidth()); | ||
1152 | } else { // demaximize, restore to old values | 1152 | } else { // demaximize, restore to old values |
1153 | moveResize(m_old_pos_x, m_old_pos_y, | 1153 | moveResize(m_old_pos_x, m_old_pos_y, |
1154 | m_old_width, m_old_height); | 1154 | m_old_width, m_old_height); |
@@ -1171,7 +1171,8 @@ void FluxboxWindow::maximizeHorizontal() { | |||
1171 | void FluxboxWindow::maximizeVertical() { | 1171 | void FluxboxWindow::maximizeVertical() { |
1172 | unsigned int max_top = screen->getMaxTop(); | 1172 | unsigned int max_top = screen->getMaxTop(); |
1173 | moveResize(m_frame.x(), max_top, | 1173 | moveResize(m_frame.x(), max_top, |
1174 | m_frame.width() - m_frame.window().borderWidth(), screen->getMaxBottom() - max_top); | 1174 | m_frame.width() - m_frame.window().borderWidth(), |
1175 | screen->getMaxBottom() - max_top); | ||
1175 | } | 1176 | } |
1176 | 1177 | ||
1177 | 1178 | ||
@@ -1611,7 +1612,7 @@ void FluxboxWindow::restoreAttributes() { | |||
1611 | } | 1612 | } |
1612 | 1613 | ||
1613 | if (blackbox_attrib.flags & BaseDisplay::ATTRIB_STACK) { | 1614 | if (blackbox_attrib.flags & BaseDisplay::ATTRIB_STACK) { |
1614 | //TODO check value? | 1615 | //!! TODO check value? |
1615 | m_layernum = blackbox_attrib.stack; | 1616 | m_layernum = blackbox_attrib.stack; |
1616 | } | 1617 | } |
1617 | 1618 | ||
@@ -1915,7 +1916,7 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) { | |||
1915 | 1916 | ||
1916 | if ((client.normal_hint_flags & PMinSize) && | 1917 | if ((client.normal_hint_flags & PMinSize) && |
1917 | (client.normal_hint_flags & PMaxSize)) { | 1918 | (client.normal_hint_flags & PMaxSize)) { |
1918 | 1919 | ||
1919 | if (client.max_width != 0 && client.max_width <= client.min_width && | 1920 | if (client.max_width != 0 && client.max_width <= client.min_width && |
1920 | client.max_height != 0 && client.max_height <= client.min_height) { | 1921 | client.max_height != 0 && client.max_height <= client.min_height) { |
1921 | decorations.maximize = false; | 1922 | decorations.maximize = false; |
@@ -1973,7 +1974,9 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) { | |||
1973 | 1974 | ||
1974 | int cx = m_frame.x(), cy = m_frame.y(); | 1975 | int cx = m_frame.x(), cy = m_frame.y(); |
1975 | unsigned int cw = m_frame.width(), ch = m_frame.height(); | 1976 | unsigned int cw = m_frame.width(), ch = m_frame.height(); |
1976 | 1977 | unsigned int titlebar_y = (decorations.titlebar ? | |
1978 | m_frame.titlebar().height() + frame().titlebar().borderWidth() | ||
1979 | : 0); | ||
1977 | if (cr.value_mask & CWBorderWidth) | 1980 | if (cr.value_mask & CWBorderWidth) |
1978 | client.old_bw = cr.border_width; | 1981 | client.old_bw = cr.border_width; |
1979 | 1982 | ||
@@ -1981,7 +1984,7 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) { | |||
1981 | cx = cr.x; | 1984 | cx = cr.x; |
1982 | 1985 | ||
1983 | if (cr.value_mask & CWY) | 1986 | if (cr.value_mask & CWY) |
1984 | cy = cr.y - (decorations.titlebar ? m_frame.titlebar().height() : 0); | 1987 | cy = cr.y - titlebar_y; |
1985 | 1988 | ||
1986 | if (cr.value_mask & CWWidth) | 1989 | if (cr.value_mask & CWWidth) |
1987 | cw = cr.width; | 1990 | cw = cr.width; |
@@ -1996,8 +1999,6 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) { | |||
1996 | if (frame().x() != cx || frame().y() != cy) | 1999 | if (frame().x() != cx || frame().y() != cy) |
1997 | move(cx, cy); | 2000 | move(cx, cy); |
1998 | 2001 | ||
1999 | |||
2000 | |||
2001 | if (cr.value_mask & CWStackMode) { | 2002 | if (cr.value_mask & CWStackMode) { |
2002 | switch (cr.detail) { | 2003 | switch (cr.detail) { |
2003 | case Above: | 2004 | case Above: |
@@ -2181,11 +2182,11 @@ void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) { | |||
2181 | return; | 2182 | return; |
2182 | } | 2183 | } |
2183 | 2184 | ||
2184 | if (ev.window == getFrameWindow() || | 2185 | if (ev.window == frame().window() || |
2185 | (!getFrameWindow() && ev.window == client.window)) { | 2186 | ev.window == client.window) { |
2186 | if ((screen->isSloppyFocus() || screen->isSemiSloppyFocus()) | 2187 | if ((screen->isSloppyFocus() || screen->isSemiSloppyFocus()) |
2187 | && !isFocused()) { | 2188 | && !isFocused()) { |
2188 | Fluxbox::instance()->grab(); | 2189 | |
2189 | 2190 | ||
2190 | // check that there aren't any subsequent leave notify events in the | 2191 | // check that there aren't any subsequent leave notify events in the |
2191 | // X event queue | 2192 | // X event queue |
@@ -2198,14 +2199,14 @@ void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) { | |||
2198 | if ((!sa.leave || sa.inferior) && setInputFocus()) | 2199 | if ((!sa.leave || sa.inferior) && setInputFocus()) |
2199 | installColormap(True); | 2200 | installColormap(True); |
2200 | 2201 | ||
2201 | Fluxbox::instance()->ungrab(); | 2202 | |
2202 | } | 2203 | } |
2203 | } | 2204 | } |
2204 | } | 2205 | } |
2205 | 2206 | ||
2206 | void FluxboxWindow::leaveNotifyEvent(XCrossingEvent &ev) { | 2207 | void FluxboxWindow::leaveNotifyEvent(XCrossingEvent &ev) { |
2207 | if (ev.window == getFrameWindow()) | 2208 | if (ev.window == frame().window()) |
2208 | installColormap(False); | 2209 | installColormap(false); |
2209 | } | 2210 | } |
2210 | 2211 | ||
2211 | // TODO: functions should not be affected by decoration | 2212 | // TODO: functions should not be affected by decoration |
@@ -2546,9 +2547,6 @@ void FluxboxWindow::upsize() { | |||
2546 | m_frame.handle().resize(m_frame.handle().width(), screen->getHandleWidth()); | 2547 | m_frame.handle().resize(m_frame.handle().width(), screen->getHandleWidth()); |
2547 | m_frame.gripLeft().resize(m_frame.buttonHeight(), screen->getHandleWidth()); | 2548 | m_frame.gripLeft().resize(m_frame.buttonHeight(), screen->getHandleWidth()); |
2548 | m_frame.gripRight().resize(m_frame.gripLeft().width(), m_frame.gripLeft().height()); | 2549 | m_frame.gripRight().resize(m_frame.gripLeft().width(), m_frame.gripLeft().height()); |
2549 | // convert client.width/height into frame sizes | ||
2550 | m_frame.resizeForClient(client.width, client.height); | ||
2551 | |||
2552 | } | 2550 | } |
2553 | 2551 | ||
2554 | 2552 | ||
@@ -2562,8 +2560,10 @@ void FluxboxWindow::right_fixsize(int *gx, int *gy) { | |||
2562 | // calculate the size of the client window and conform it to the | 2560 | // calculate the size of the client window and conform it to the |
2563 | // size specified by the size hints of the client window... | 2561 | // size specified by the size hints of the client window... |
2564 | int dx = last_resize_w - client.base_width; | 2562 | int dx = last_resize_w - client.base_width; |
2565 | int dy = last_resize_h - client.base_height; | 2563 | int titlebar_height = (decorations.titlebar ? frame().titlebar().height() + frame().titlebar().borderWidth() : 0); |
2564 | int handle_height = (decorations.handle ? frame().handle().height() + frame().handle().borderWidth() : 0); | ||
2566 | 2565 | ||
2566 | int dy = last_resize_h - client.base_height - titlebar_height - handle_height; | ||
2567 | if (dx < (signed) client.min_width) | 2567 | if (dx < (signed) client.min_width) |
2568 | dx = client.min_width; | 2568 | dx = client.min_width; |
2569 | if (dy < (signed) client.min_height) | 2569 | if (dy < (signed) client.min_height) |
@@ -2574,6 +2574,12 @@ void FluxboxWindow::right_fixsize(int *gx, int *gy) { | |||
2574 | dy = client.max_height; | 2574 | dy = client.max_height; |
2575 | 2575 | ||
2576 | // make it snap | 2576 | // make it snap |
2577 | |||
2578 | if (client.width_inc == 0) | ||
2579 | client.width_inc = 1; | ||
2580 | if (client.height_inc == 0) | ||
2581 | client.height_inc = 1; | ||
2582 | |||
2577 | dx /= client.width_inc; | 2583 | dx /= client.width_inc; |
2578 | dy /= client.height_inc; | 2584 | dy /= client.height_inc; |
2579 | 2585 | ||
@@ -2581,15 +2587,17 @@ void FluxboxWindow::right_fixsize(int *gx, int *gy) { | |||
2581 | if (gy) *gy = dy; | 2587 | if (gy) *gy = dy; |
2582 | 2588 | ||
2583 | dx = (dx * client.width_inc) + client.base_width; | 2589 | dx = (dx * client.width_inc) + client.base_width; |
2584 | dy = (dy * client.height_inc) + client.base_height; | 2590 | dy = (dy * client.height_inc) + client.base_height + titlebar_height + handle_height; |
2585 | |||
2586 | last_resize_w = dx; | 2591 | last_resize_w = dx; |
2587 | last_resize_h = dy; | 2592 | last_resize_h = dy; |
2588 | } | 2593 | } |
2589 | 2594 | ||
2590 | void FluxboxWindow::left_fixsize(int *gx, int *gy) { | 2595 | void FluxboxWindow::left_fixsize(int *gx, int *gy) { |
2596 | int titlebar_height = (decorations.titlebar ? frame().titlebar().height() + frame().titlebar().borderWidth() : 0); | ||
2597 | int handle_height = (decorations.handle ? frame().handle().height() + frame().handle().borderWidth() : 0); | ||
2598 | int decoration_height = titlebar_height + handle_height; | ||
2591 | int dx = m_frame.width() + m_frame.x() - last_resize_x; | 2599 | int dx = m_frame.width() + m_frame.x() - last_resize_x; |
2592 | int dy = last_resize_h - client.base_height; | 2600 | int dy = last_resize_h - client.base_height - decoration_height; |
2593 | 2601 | ||
2594 | // check minimum size | 2602 | // check minimum size |
2595 | if (dx < static_cast<signed int>(client.min_width)) | 2603 | if (dx < static_cast<signed int>(client.min_width)) |
@@ -2621,7 +2629,7 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) { | |||
2621 | 2629 | ||
2622 | // snapping | 2630 | // snapping |
2623 | dx = dx * client.width_inc + client.base_width; | 2631 | dx = dx * client.width_inc + client.base_width; |
2624 | dy = dy * client.height_inc + client.base_height; | 2632 | dy = dy * client.height_inc + client.base_height + decoration_height; |
2625 | 2633 | ||
2626 | // update last resize | 2634 | // update last resize |
2627 | last_resize_w = dx; | 2635 | last_resize_w = dx; |