Skip to content

Commit

Permalink
client: Constrain window size only for floating clients (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
aesophor committed Apr 27, 2020
1 parent f2ec399 commit 96219de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

This comment has been minimized.

Copy link
@aesophor

aesophor Apr 27, 2020

Author Owner

I hope this new method name won't seem too stupid...


Display* dpy_;
Window window_;
Expand Down

0 comments on commit 96219de

Please sign in to comment.