From 823ce0d0175b9b14a549117a303cc9e36e81c1a2 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 3 Jul 2007 21:08:07 +0000 Subject: stop gvim from repeatedly resizing tabbed windows --- ChangeLog | 3 +++ src/FbTk/FbPixmap.cc | 15 ++++++++------- src/FbTk/FbWindow.cc | 8 ++++---- src/WinClient.cc | 25 +++++++++++++++++++++++++ src/WinClient.hh | 2 +- src/Window.cc | 9 +++++++++ 6 files changed, 50 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49cb8d6..7b2423f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,11 @@ (Format: Year/Month/Day) Changes for 1.0.0: *07/07/03: + * Avoid some problems with tabbed windows and resize increments (Mark) + Window.cc WinClient.cc/hh * Added utility fluxbox-remote, which takes one argument and has fluxbox execute it just like in the keys file (Mark) + - e.g. fluxbox-remote "CustomMenu ~/.fluxbox/custommenu" Screen.cc util/fluxbox-remote.cc util/Makefile.am * Update systemtray and KDE dockapps in slit when background changes (Mark) Screen.cc/hh Systemtray.cc Slit.cc FbTk/FbPixmap.cc/hh diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index 9143232..0289ddd 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -114,13 +114,14 @@ FbPixmap &FbPixmap::operator = (Pixmap pm) { Window root; int x, y; unsigned int border_width, bpp; - XGetGeometry(display(), - pm, - &root, - &x, &y, - &m_width, &m_height, - &border_width, - &bpp); + if (!XGetGeometry(display(), + pm, + &root, + &x, &y, + &m_width, &m_height, + &border_width, + &bpp)) + return *this; m_depth = bpp; diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index 3dce5b8..2c2bb24 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc @@ -582,10 +582,10 @@ void FbWindow::updateGeometry() { Window root; unsigned int border_width, depth; - XGetGeometry(display(), m_window, &root, &m_x, &m_y, - (unsigned int *)&m_width, (unsigned int *)&m_height, - &border_width, &depth); - m_depth = depth; + if (XGetGeometry(display(), m_window, &root, &m_x, &m_y, + (unsigned int *)&m_width, (unsigned int *)&m_height, + &border_width, &depth)) + m_depth = depth; } void FbWindow::create(Window parent, int x, int y, diff --git a/src/WinClient.cc b/src/WinClient.cc index d4e3e72..989088b 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -884,6 +884,31 @@ void WinClient::applySizeHints(int &width, int &height, *display_height = j; } +// check if the given width and height satisfy the size hints +bool WinClient::checkSizeHints(unsigned int width, unsigned int height) { + if (width < min_width || height < min_height) + return false; + + if (width > max_width || height > max_height) + return false; + + if ((width - base_width) % width_inc != 0) + return false; + + if ((height - base_height) % height_inc != 0) + return false; + + double ratio = (double)width / (double)height; + + if (min_aspect_y > 0 && (double)min_aspect_x / (double)min_aspect_y > ratio) + return false; + + if (max_aspect_y > 0 && (double)max_aspect_x / (double)max_aspect_y < ratio) + return false; + + return true; +} + void WinClient::removeTransientFromWaitingList() { // holds the windows that dont have empty diff --git a/src/WinClient.hh b/src/WinClient.hh index 01517c2..deb98b9 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -89,7 +89,7 @@ public: */ void applySizeHints(int &width, int &height, int *display_width = 0, int *display_height = 0, bool maximizing = false); - + bool checkSizeHints(unsigned int width, unsigned int height); void setGroupLeftWindow(Window win); diff --git a/src/Window.cc b/src/Window.cc index af74074..f6fe225 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2564,6 +2564,15 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) { int cx = frame().x(), cy = frame().y(), ignore = 0; unsigned int cw = frame().width(), ch = frame().height(); + // if this is not m_client and m_client has resize_inc, make sure the new + // size would be ok with m_client + if (client != m_client && cr.value_mask & CWWidth && + cr.value_mask & CWHeight && + !m_client->checkSizeHints(cr.width, cr.height)) { + sendConfigureNotify(); + return; + } + if (cr.value_mask & CWBorderWidth) client->old_bw = cr.border_width; -- cgit v0.11.2