all repos — openbox @ 8deaf1c239bf65221918ac06c77ea6fdec04b27c

openbox fork - make it a bit more like ryudo

respect max/min sizes when fullscreen or maximized
Dana Jansens danakj@orodu.net
commit

8deaf1c239bf65221918ac06c77ea6fdec04b27c

parent

c51d6ebe1152876bfa6d02b5174489e016d2c830

1 files changed, 87 insertions(+), 68 deletions(-)

jump to
M openbox/client.copenbox/client.c

@@ -327,6 +327,7 @@ (self->type == OB_CLIENT_TYPE_NORMAL ||

self->type == OB_CLIENT_TYPE_UTILITY || self->type == OB_CLIENT_TYPE_DIALOG)) { + /* XXX use focus_cycle_valid_target instead... */ activate = TRUE; }

@@ -1578,7 +1579,16 @@ SIZE_SET(self->base_size, size.base_width, size.base_height);

if (size.flags & PResizeInc && size.width_inc && size.height_inc) SIZE_SET(self->size_inc, size.width_inc, size.height_inc); + + ob_debug("Normal hints: min size (%d %d) max size (%d %d)\n " + "size inc (%d %d) base size (%d %d)\n", + self->min_size.width, self->min_size.height, + self->max_size.width, self->max_size.height, + self->size_inc.width, self->size_inc.height, + self->base_size.width, self->base_size.height); } + else + ob_debug("Normal hints: not set\n"); } void client_setup_decor_and_functions(ObClient *self, gboolean reconfig)

@@ -2684,9 +2694,61 @@ anything visible for real, this way the constraints below can work with

the updated frame dimensions. */ frame_adjust_area(self->frame, FALSE, TRUE, TRUE); + /* gets the frame's position */ + frame_client_gravity(self->frame, x, y, *w, *h); + + /* these positions are frame positions, not client positions */ + + /* set the size and position if fullscreen */ + if (self->fullscreen) { + Rect *a; + guint i; + + i = screen_find_monitor(&desired_area); + a = screen_physical_area_monitor(i); + + *x = a->x; + *y = a->y; + *w = a->width; + *h = a->height; + + user = FALSE; /* ignore if the client can't be moved/resized when it + is fullscreening */ + } else if (self->max_horz || self->max_vert) { + Rect *a; + guint i; + + i = screen_find_monitor(&desired_area); + a = screen_area_monitor(self->desktop, i); + + /* set the size and position if maximized */ + if (self->max_horz) { + *x = a->x; + *w = a->width - self->frame->size.left - self->frame->size.right; + } + if (self->max_vert) { + *y = a->y; + *h = a->height - self->frame->size.top - self->frame->size.bottom; + } + + user = FALSE; /* ignore if the client can't be moved/resized when it + is maximizing */ + } + + /* gets the client's position */ + frame_frame_gravity(self->frame, x, y, *w, *h); + /* work within the prefered sizes given by the window */ if (!(*w == self->area.width && *h == self->area.height)) { gint basew, baseh, minw, minh; + gint incw, inch, minratio, maxratio; + + incw = self->fullscreen || self->max_horz ? 1 : self->size_inc.width; + inch = self->fullscreen || self->max_vert ? 1 : self->size_inc.height; + minratio = self->fullscreen || (self->max_horz && self->max_vert) ? + 0 : self->min_ratio; + maxratio = self->fullscreen || (self->max_horz && self->max_vert) ? + 0 : self->max_ratio; /* base size is substituted with min size if not specified */ if (self->base_size.width || self->base_size.height) {

@@ -2718,19 +2780,19 @@ *w -= basew;

*h -= baseh; /* keep to the increments */ - *w /= self->size_inc.width; - *h /= self->size_inc.height; + *w /= incw; + *h /= inch; /* you cannot resize to nothing */ if (basew + *w < 1) *w = 1 - basew; if (baseh + *h < 1) *h = 1 - baseh; /* save the logical size */ - *logicalw = self->size_inc.width > 1 ? *w : *w + basew; - *logicalh = self->size_inc.height > 1 ? *h : *h + baseh; + *logicalw = incw > 1 ? *w : *w + basew; + *logicalh = inch > 1 ? *h : *h + baseh; - *w *= self->size_inc.width; - *h *= self->size_inc.height; + *w *= incw; + *h *= inch; *w += basew; *h += baseh;

@@ -2740,76 +2802,30 @@ for this, min size is not substituted for base size ever. */

*w -= self->base_size.width; *h -= self->base_size.height; - if (!self->fullscreen) { - if (self->min_ratio) - if (*h * self->min_ratio > *w) { - *h = (gint)(*w / self->min_ratio); + if (minratio) + if (*h * minratio > *w) { + *h = (gint)(*w / minratio); - /* you cannot resize to nothing */ - if (*h < 1) { - *h = 1; - *w = (gint)(*h * self->min_ratio); - } + /* you cannot resize to nothing */ + if (*h < 1) { + *h = 1; + *w = (gint)(*h * minratio); } - if (self->max_ratio) - if (*h * self->max_ratio < *w) { - *h = (gint)(*w / self->max_ratio); + } + if (maxratio) + if (*h * maxratio < *w) { + *h = (gint)(*w / maxratio); - /* you cannot resize to nothing */ - if (*h < 1) { - *h = 1; - *w = (gint)(*h * self->min_ratio); - } + /* you cannot resize to nothing */ + if (*h < 1) { + *h = 1; + *w = (gint)(*h * minratio); } - } + } *w += self->base_size.width; *h += self->base_size.height; } - - /* gets the frame's position */ - frame_client_gravity(self->frame, x, y, *w, *h); - - /* these positions are frame positions, not client positions */ - - /* set the size and position if fullscreen */ - if (self->fullscreen) { - Rect *a; - guint i; - - i = screen_find_monitor(&desired_area); - a = screen_physical_area_monitor(i); - - *x = a->x; - *y = a->y; - *w = a->width; - *h = a->height; - - user = FALSE; /* ignore if the client can't be moved/resized when it - is fullscreening */ - } else if (self->max_horz || self->max_vert) { - Rect *a; - guint i; - - i = screen_find_monitor(&desired_area); - a = screen_area_monitor(self->desktop, i); - - /* set the size and position if maximized */ - if (self->max_horz) { - *x = a->x; - *w = a->width - self->frame->size.left - self->frame->size.right; - } - if (self->max_vert) { - *y = a->y; - *h = a->height - self->frame->size.top - self->frame->size.bottom; - } - - user = FALSE; /* ignore if the client can't be moved/resized when it - is maximizing */ - } - - /* gets the client's position */ - frame_frame_gravity(self->frame, x, y, *w, *h); /* these override the above states! if you cant move you can't move! */ if (user) {

@@ -3222,6 +3238,9 @@ client_showhide(self);

/* raise if it was not already on the desktop */ if (old != DESKTOP_ALL) stacking_raise(CLIENT_AS_WINDOW(self)); + /* the new desktop's geometry may be different, so we may need to + resize, for example if we are maximized */ + client_reconfigure(self); if (STRUT_EXISTS(self->strut)) screen_update_areas(); }