From b3ba75792908cbc14555001d7495828206a23fdc Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 23 Feb 2003 13:40:22 +0000 Subject: various frame size, and window resize/moving/outline bugs --- ChangeLog | 2 ++ src/FbWinFrame.cc | 88 +++++++++++++++++++++++++++++++++---------------------- src/Window.cc | 60 ++++++++++++++++++++++--------------- 3 files changed, 92 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c04175..689c952 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 0.1.15: *03/02/22: + * Fix frame size and window moving/resizing/outline bugs (Simon) + Window.cc FbWinFrame.cc * s/""/'' so the shell does not have to expand the contents of the string in fluxbox_generatemenu (Han) * Added portability notes in fluxbox_generatemenu (Han) diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 05c6f00..1444438 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrame.cc,v 1.12 2003/02/23 00:57:55 fluxgen Exp $ +// $Id: FbWinFrame.cc,v 1.13 2003/02/23 13:40:22 rathnor Exp $ #include "FbWinFrame.hh" #include "ImageControl.hh" @@ -170,16 +170,16 @@ void FbWinFrame::resize(unsigned int width, unsigned int height) { } void FbWinFrame::resizeForClient(unsigned int width, unsigned int height) { - // total height for frame without client - int handle_height = m_handle.height() + m_handle.borderWidth(); - int titlebar_height = m_titlebar.height() + m_titlebar.borderWidth(); - unsigned int total_height = handle_height + titlebar_height; - // resize frame height with total height + specified height - if (!m_use_titlebar) - total_height -= titlebar_height; - if (!m_use_handle) - total_height -= handle_height; - resize(width, total_height + height); + // total height for frame + unsigned int total_height = height; + + // having a titlebar = 1 extra border + titlebar height + if (m_use_titlebar) + total_height += m_titlebar.height() + m_titlebar.borderWidth(); + // having a handle = 1 extra border + handle height + if (m_use_handle) + total_height += m_handle.height() + m_handle.borderWidth(); + resize(width, total_height); } void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int height) { @@ -280,8 +280,10 @@ void FbWinFrame::hideTitlebar() { m_titlebar.hide(); m_use_titlebar = false; m_clientarea.raise(); + + // only take away one borderwidth (as the other border is still the "top" border) m_window.resize(m_window.width(), m_window.height() - m_titlebar.height() - - m_titlebar.borderWidth()*2); + m_titlebar.borderWidth()); #ifdef DEBUG cerr<<__FILE__<<": Hide Titlebar"<display(), m_clientwin, 0, 0, m_clientarea.width(), m_clientarea.height()); - } + } + if (!m_use_handle) // no need to do anything more return; @@ -444,19 +463,18 @@ void FbWinFrame::reconfigure() { // align handle and grips const int grip_height = m_handle.height(); const int grip_width = 20; //TODO - - const int ypos = m_window.height() - grip_height; - m_grip_left.moveResize(0, ypos, + const int ypos = m_window.height() - grip_height - m_handle.borderWidth(); + + m_grip_left.moveResize(-m_handle.borderWidth(), ypos, grip_width, grip_height); m_handle.moveResize(grip_width, ypos, - m_window.width() - grip_width*2, grip_height); - - m_grip_right.moveResize(m_window.width() - grip_width, ypos, + m_window.width() - grip_width*2 - m_handle.borderWidth()*2, grip_height); + + m_grip_right.moveResize(m_window.width() - grip_width - m_handle.borderWidth(), ypos, grip_width, grip_height); - // render the theme renderButtons(); renderHandles(); diff --git a/src/Window.cc b/src/Window.cc index 8871253..f0e3393 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.125 2003/02/22 21:40:35 fluxgen Exp $ +// $Id: Window.cc,v 1.126 2003/02/23 13:40:22 rathnor Exp $ #include "Window.hh" @@ -349,6 +349,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, } setState(current_state); + m_frame.resizeForClient(wattrib.width, wattrib.height); // no focus default setFocusFlag(false); @@ -497,21 +498,22 @@ void FluxboxWindow::reconfigure() { void FluxboxWindow::positionWindows() { m_frame.window().setBorderWidth(screen->getBorderWidth()); - m_frame.clientArea().setBorderWidth(screen->getFrameWidth()); + m_frame.clientArea().setBorderWidth(0); // client area bordered by other things + m_frame.titlebar().setBorderWidth(screen->getBorderWidth()); if (decorations.titlebar) { - m_frame.titlebar().setBorderWidth(screen->getBorderWidth()); m_frame.showTitlebar(); } else { m_frame.hideTitlebar(); } + + m_frame.handle().setBorderWidth(screen->getBorderWidth()); + m_frame.gripLeft().setBorderWidth(screen->getBorderWidth()); + m_frame.gripRight().setBorderWidth(screen->getBorderWidth()); - if (decorations.handle) { - m_frame.handle().setBorderWidth(screen->getBorderWidth()); - m_frame.gripLeft().setBorderWidth(screen->getBorderWidth()); - m_frame.gripRight().setBorderWidth(screen->getBorderWidth()); + if (decorations.handle) m_frame.showHandle(); - } else + else m_frame.hideHandle(); m_frame.reconfigure(); @@ -2111,11 +2113,13 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { if (! screen->doOpaqueMove()) { XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), last_move_x, last_move_y, - m_frame.width(), m_frame.height()); + m_frame.width() + 2*frame().window().borderWidth(), + m_frame.height() + 2*frame().window().borderWidth()); XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), dx, dy, - m_frame.width(), m_frame.height()); + m_frame.width() + 2*frame().window().borderWidth(), + m_frame.height() + 2*frame().window().borderWidth()); last_move_x = dx; last_move_y = dy; } else { @@ -2138,7 +2142,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { // draw over old rect XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), last_resize_x, last_resize_y, - last_resize_w - 1, last_resize_h-1); + last_resize_w - 1 + 2 * m_frame.window().borderWidth(), + last_resize_h - 1 + 2 * m_frame.window().borderWidth()); // move rectangle @@ -2165,7 +2170,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { // draw resize rectangle XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), last_resize_x, last_resize_y, - last_resize_w - 1, last_resize_h - 1); + last_resize_w - 1 + 2 * m_frame.window().borderWidth(), + last_resize_h - 1 + 2 * m_frame.window().borderWidth()); if (screen->doShowWindowPos()) screen->showGeometry(gx, gy); @@ -2304,7 +2310,8 @@ void FluxboxWindow::startMoving(Window win) { if (! screen->doOpaqueMove()) { XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), frame().x(), frame().y(), - frame().width(), frame().height()); + frame().width() + 2*frame().window().borderWidth(), + frame().height() + 2*frame().window().borderWidth()); screen->showPosition(frame().x(), frame().y()); } } @@ -2319,7 +2326,8 @@ void FluxboxWindow::stopMoving() { if (! screen->doOpaqueMove()) { XDrawRectangle(FbTk::App::instance()->display(), screen->getRootWindow(), screen->getOpGC(), last_move_x, last_move_y, - frame().width(), frame().height()); + frame().width() + 2*frame().window().borderWidth(), + frame().height() + 2*frame().window().borderWidth()); moveResize(last_move_x, last_move_y, m_frame.width(), m_frame.height()); } else moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height()); @@ -2349,12 +2357,12 @@ void FluxboxWindow::startResizing(Window win, int x, int y, bool left) { CurrentTime); int gx = 0, gy = 0; - button_grab_x = x - screen->getBorderWidth(); - button_grab_y = y - screen->getBorderWidth2x(); + button_grab_x = x; + button_grab_y = y; last_resize_x = m_frame.x(); last_resize_y = m_frame.y(); - last_resize_w = m_frame.width() + screen->getBorderWidth2x(); - last_resize_h = m_frame.height() + screen->getBorderWidth2x(); + last_resize_w = m_frame.width(); + last_resize_h = m_frame.height(); if (left) left_fixsize(&gx, &gy); @@ -2366,7 +2374,8 @@ void FluxboxWindow::startResizing(Window win, int x, int y, bool left) { XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), last_resize_x, last_resize_y, - last_resize_w - 1, last_resize_h - 1); + last_resize_w - 1 + 2 * m_frame.window().borderWidth(), + last_resize_h - 1 + 2 * m_frame.window().borderWidth()); } void FluxboxWindow::stopResizing(Window win) { @@ -2374,7 +2383,8 @@ void FluxboxWindow::stopResizing(Window win) { XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), last_resize_x, last_resize_y, - last_resize_w - 1, last_resize_h - 1); + last_resize_w - 1 + 2 * m_frame.window().borderWidth(), + last_resize_h - 1 + 2 * m_frame.window().borderWidth()); screen->hideGeometry(); @@ -2385,8 +2395,8 @@ void FluxboxWindow::stopResizing(Window win) { moveResize(last_resize_x, last_resize_y, - last_resize_w - screen->getBorderWidth2x(), - last_resize_h - screen->getBorderWidth2x()); + last_resize_w; + last_resize_h; XUngrabPointer(display, CurrentTime); } @@ -2596,7 +2606,11 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) { int titlebar_height = (decorations.titlebar ? frame().titlebar().height() + frame().titlebar().borderWidth() : 0); int handle_height = (decorations.handle ? frame().handle().height() + frame().handle().borderWidth() : 0); int decoration_height = titlebar_height + handle_height; + + // dx is new width = current width + difference between new and old x values int dx = m_frame.width() + m_frame.x() - last_resize_x; + + // dy = new height (w/o decorations), similarly int dy = last_resize_h - client.base_height - decoration_height; // check minimum size @@ -2617,7 +2631,7 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) { if (client.height_inc == 0) client.height_inc = 1; - // set snaping + // set snapping dx /= client.width_inc; dy /= client.height_inc; -- cgit v0.11.2