From 9a155ea7b5cf1b76aa7b9864aa3c1a7342f1f67c Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 5 Oct 2003 09:03:43 +0000 Subject: fix window size when changing titlebar height --- ChangeLog | 3 +++ src/FbWinFrame.cc | 44 +++++++++++++++++++++++++++++--------------- src/FbWinFrame.hh | 15 ++++++++------- src/Window.cc | 24 ++++++++++++++---------- 4 files changed, 54 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8af4f33..be3bb98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ (Format: Year/Month/Day) Changes for 0.9.6: *03/10/05: + * Fix frame size when changing titlebar size (Simon) + - also send configure notify when toggling decorations + FbWinFrame.hh/cc Window.cc * Move a bunch of functionality from Keys into FbTk::KeyUtil (Simon) - also fix issue where Capslock mod was taken to be whatever caps key was mapped to (why??). Now uses LockMask (ditto num,scroll). diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index ce92813..5cfd751 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.56 2003/10/02 14:14:45 rathnor Exp $ +// $Id: FbWinFrame.cc,v 1.57 2003/10/05 09:03:43 rathnor Exp $ #include "FbWinFrame.hh" @@ -391,9 +391,9 @@ void FbWinFrame::setClientWindow(Window win) { } -void FbWinFrame::hideTitlebar() { +bool FbWinFrame::hideTitlebar() { if (!m_use_titlebar) - return; + return false; m_titlebar.hide(); m_use_titlebar = false; @@ -402,11 +402,12 @@ void FbWinFrame::hideTitlebar() { // 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()); + return true; } -void FbWinFrame::showTitlebar() { +bool FbWinFrame::showTitlebar() { if (m_use_titlebar) - return; + return false; m_titlebar.show(); m_use_titlebar = true; @@ -414,24 +415,26 @@ void FbWinFrame::showTitlebar() { // only add 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()); + return true; } -void FbWinFrame::hideHandle() { +bool FbWinFrame::hideHandle() { if (!m_use_handle) - return; + return false; m_handle.hide(); m_grip_left.hide(); m_grip_right.hide(); m_use_handle = false; m_window.resize(m_window.width(), m_window.height() - m_handle.height() - m_handle.borderWidth()); + return true; } -void FbWinFrame::showHandle() { +bool FbWinFrame::showHandle() { if (m_use_handle) - return; + return false; m_handle.show(); m_handle.showSubwindows(); // shows grips @@ -439,22 +442,29 @@ void FbWinFrame::showHandle() { m_use_handle = true; m_window.resize(m_window.width(), m_window.height() + m_handle.height() + m_handle.borderWidth()); + return true; } -void FbWinFrame::hideAllDecorations() { - hideHandle(); - hideTitlebar(); +bool FbWinFrame::hideAllDecorations() { + bool changed = false; + changed |= hideHandle(); + changed |= hideTitlebar(); // resize done by hide* reconfigure(); + + return changed; } -void FbWinFrame::showAllDecorations() { +bool FbWinFrame::showAllDecorations() { + bool changed = false; if (!m_use_handle) - showHandle(); + changed |= showHandle(); if (!m_use_titlebar) - showTitlebar(); + changed |= showTitlebar(); // resize shouldn't be necessary reconfigure(); + + return changed; } /** @@ -740,12 +750,16 @@ void FbWinFrame::reconfigureTitlebar() { if (!m_use_titlebar) return; + int orig_height = m_titlebar.height(); // resize titlebar to window size with font height int title_height = m_theme.font().height() == 0 ? 16 : m_theme.font().height() + m_bevel*2 + 2; if (m_theme.titleHeight() != 0) title_height = m_theme.titleHeight(); + // if the titlebar grows in size, make sure the whole window does too + if (orig_height != title_height) + m_window.resize(m_window.width(), m_window.height()-orig_height+title_height); m_titlebar.moveResize(-m_titlebar.borderWidth(), -m_titlebar.borderWidth(), m_window.width(), title_height); diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 6d218d4..f1ca769 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrame.hh,v 1.22 2003/10/02 14:14:46 rathnor Exp $ +// $Id: FbWinFrame.hh,v 1.23 2003/10/05 09:03:43 rathnor Exp $ #ifndef FBWINFRAME_HH #define FBWINFRAME_HH @@ -118,12 +118,13 @@ public: /// remove any handler for the windows void removeEventHandler(); - void hideTitlebar(); - void showTitlebar(); - void hideHandle(); - void showHandle(); - void hideAllDecorations(); - void showAllDecorations(); + // these return true/false for if something changed + bool hideTitlebar(); + bool showTitlebar(); + bool hideHandle(); + bool showHandle(); + bool hideAllDecorations(); + bool showAllDecorations(); // this function translates its arguments according to win_gravity // if win_gravity is negative, it does an inverse translation diff --git a/src/Window.cc b/src/Window.cc index e104ae6..ccf52a2 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.239 2003/10/05 02:31:22 rathnor Exp $ +// $Id: Window.cc,v 1.240 2003/10/05 09:03:43 rathnor Exp $ #include "Window.hh" @@ -512,7 +512,6 @@ void FluxboxWindow::init() { if (!place_window) moveResize(frame().x(), frame().y(), frame().width(), frame().height()); - screen().getWorkspace(m_workspace_number)->addWindow(*this, place_window); if (shaded) { // start shaded @@ -2627,6 +2626,7 @@ void FluxboxWindow::setDecoration(Decoration decoration) { // commit current decoration values to actual displayed things void FluxboxWindow::applyDecorations(bool initial) { frame().clientArea().setBorderWidth(0); // client area bordered by other things + bool client_move = false; int grav_x=0, grav_y=0; // negate gravity @@ -2636,28 +2636,34 @@ void FluxboxWindow::applyDecorations(bool initial) { if (decorations.border) border_width = frame().theme().border().width(); - if (initial || frame().window().borderWidth() != border_width) + if (initial || frame().window().borderWidth() != border_width) { + client_move = true; frame().setBorderWidth(border_width); + } // we rely on frame not doing anything if it is already shown/hidden if (decorations.titlebar) - frame().showTitlebar(); + client_move |= frame().showTitlebar(); else - frame().hideTitlebar(); + client_move |= frame().hideTitlebar(); if (decorations.handle) { - frame().showHandle(); + client_move |= frame().showHandle(); } else - frame().hideHandle(); + client_move |= frame().hideHandle(); // apply gravity once more frame().gravityTranslate(grav_x, grav_y, m_client->gravity(), false); // if the location changes, shift it - if (grav_x != 0 || grav_y != 0) + if (grav_x != 0 || grav_y != 0) { move(grav_x + frame().x(), grav_y + frame().y()); + client_move = true; + } frame().reconfigure(); + if (client_move) + sendConfigureNotify(); } void FluxboxWindow::toggleDecoration() { @@ -2989,8 +2995,6 @@ void FluxboxWindow::attachTo(int x, int y) { if (client) attach_to_win = client->fbwindow(); - cerr<<"client = "<