From 96219de3a3d78b83273bdf013ecc299f9ce17a28 Mon Sep 17 00:00:00 2001 From: Marco Wang Date: Mon, 27 Apr 2020 15:06:53 +0800 Subject: [PATCH] client: Constrain window size only for floating clients (#46) --- src/client.cc | 16 +++++++++++----- src/client.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/client.cc b/src/client.cc index 2f0b43f..cddd724 100644 --- a/src/client.cc +++ b/src/client.cc @@ -62,7 +62,7 @@ void Client::Move(int x, int y, bool absolute) const { void Client::Resize(int w, int h, bool absolute) const { if (absolute) { - ConstrainSize(w, h); + ConstrainSizeIfFloating(w, h); XResizeWindow(dpy_, window_, w, h); return; } @@ -71,13 +71,13 @@ void Client::Resize(int w, int h, bool absolute) const { XWindowAttributes attr = GetXWindowAttributes(); w = attr.width + w; h = attr.height + h; - ConstrainSize(w, h); + ConstrainSizeIfFloating(w, h); XResizeWindow(dpy_, window_, w, h); } void Client::MoveResize(int x, int y, int w, int h, bool absolute) const { if (absolute) { - ConstrainSize(w, h); + ConstrainSizeIfFloating(w, h); XMoveResizeWindow(dpy_, window_, x, y, w, h); return; } @@ -86,7 +86,7 @@ void Client::MoveResize(int x, int y, int w, int h, bool absolute) const { XWindowAttributes attr = GetXWindowAttributes(); w = attr.width + w; h = attr.height + h; - ConstrainSize(w, h); + ConstrainSizeIfFloating(w, h); XMoveResizeWindow(dpy_, window_, attr.x + x, attr.y + y, w, h); } @@ -220,7 +220,13 @@ void Client::set_attr_cache(const XWindowAttributes& attr) { attr_cache_ = attr; } -void Client::ConstrainSize(int& w, int& h) const { +void Client::ConstrainSizeIfFloating(int& w, int& h) const { + // Only floating clients should keep to the program specified minimum size + // of their WM_NORMAL_HINTS property, while tiled clients must not. + if (!is_floating_) { + return; + } + const int min_w = (size_hints_.flags & PMinSize) ? size_hints_.min_width : MIN_WINDOW_WIDTH; const int min_h = (size_hints_.flags & PMinSize) ? size_hints_.min_height : MIN_WINDOW_HEIGHT; w = (w < min_w) ? min_w : w; diff --git a/src/client.h b/src/client.h index e2d0e8f..035ac5b 100644 --- a/src/client.h +++ b/src/client.h @@ -67,7 +67,7 @@ class Client { void set_attr_cache(const XWindowAttributes& attr); private: - void ConstrainSize(int& w, int& h) const; + void ConstrainSizeIfFloating(int& w, int& h) const; Display* dpy_; Window window_;