+constrain_window(struct ws_win *win, struct swm_region *r, int resizable)
+{
+ if (win->g.x + win->g.w > r->g.x + r->g.w - border_width) {
+ if (resizable)
+ win->g.w = r->g.x + r->g.w - win->g.x - border_width;
+ else
+ win->g.x = r->g.x + r->g.w - win->g.w - border_width;
+ }
+
+ if (win->g.x < r->g.x - border_width) {
+ if (resizable)
+ win->g.w -= r->g.x - win->g.x - border_width;
+
+ win->g.x = r->g.x - border_width;
+ }
+
+ if (win->g.y + win->g.h > r->g.y + r->g.h - border_width) {
+ if (resizable)
+ win->g.h = r->g.y + r->g.h - win->g.y - border_width;
+ else
+ win->g.y = r->g.y + r->g.h - win->g.h - border_width;
+ }
+
+ if (win->g.y < r->g.y - border_width) {
+ if (resizable)
+ win->g.h -= r->g.y - win->g.y - border_width;
+
+ win->g.y = r->g.y - border_width;
+ }
+
+ if (win->g.w < 1)
+ win->g.w = 1;
+ if (win->g.h < 1)
+ win->g.h = 1;
+}
+
+void
+update_window(struct ws_win *win)