From 8f6434efa67b2f11548c9862aaa0d29488645500 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 3 Jul 2007 21:09:05 +0000 Subject: stop gvim from repeatedly resizing tabbed windows --- src/FbTk/FbPixmap.cc | 15 ++++++++------- src/FbTk/FbWindow.cc | 8 ++++---- src/WinClient.cc | 25 +++++++++++++++++++++++++ src/WinClient.hh | 2 +- src/Window.cc | 9 +++++++++ util/fluxbox-remote.cc | 20 ++++++++++++++------ 6 files changed, 61 insertions(+), 18 deletions(-) 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 ddf0599..a9d5865 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -905,6 +905,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 d3555d1..9c29e78 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -93,7 +93,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 e9d57c2..632c1e7 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2570,6 +2570,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; diff --git a/util/fluxbox-remote.cc b/util/fluxbox-remote.cc index eb7a413..67c2193 100644 --- a/util/fluxbox-remote.cc +++ b/util/fluxbox-remote.cc @@ -24,15 +24,21 @@ #include #include #include +#include +#include int main(int argc, char **argv) { - if (argc <= 1) - return 1; + if (argc <= 1) { + printf("fluxbox-remote \n"); + return EXIT_SUCCESS; + } Display *disp = XOpenDisplay(NULL); - if (!disp) - return 1; + if (!disp) { + perror("error, can't open display."); + return EXIT_FAILURE; + } Atom fbcmd_atom = XInternAtom(disp, "_FLUXBOX_COMMAND", False); Window root = DefaultRootWindow(disp); @@ -44,6 +50,8 @@ int main(int argc, char **argv) { XCloseDisplay(disp); if (ret == Success) - return 0; - return 1; + return EXIT_SUCCESS; + + return EXIT_FAILURE; } + -- cgit v0.11.2