From: Dana Jansens Date: Tue, 5 Aug 2003 10:31:20 +0000 (+0000) Subject: a couple frame layout bugfixes hidden inside all this.. wee X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=2494762dbf89e0ea8eb72c460c6f7281fa0a2204;p=chaz%2Fopenbox a couple frame layout bugfixes hidden inside all this.. wee fixes for maximizing windows: - when you toggledecor, it will reconfigure once, but the new constraints from the decor changes would not be in effect when the window was resized to the contranits. fixed by calling frame_adjust_area first thing ni client_configure_fulll with fake=TRUE which will recalc all the frame geometry without resizing/redrawing anything in the frame. this way the decor can take effect in the geometries. - when maxed horizontally, make the client fill the screen, but dont do this by just making it wider than the screen, fit it to the screen and adjust the titlebar/handle as appropriate to keep it all on the screen. - when maxed horizontally and vertically, remove the handle from the decorations --- diff --git a/openbox/client.c b/openbox/client.c index ebff0bae..685545a6 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -1712,6 +1712,11 @@ void client_configure_full(ObClient *self, ObCorner anchor, { gboolean moved = FALSE, resized = FALSE; + /* make the frame recalculate its dimentions n shit without changing + anything visible for real, this way the constraints below can work with + the updated frame dimensions. */ + frame_adjust_area(self->frame, TRUE, TRUE, TRUE); + /* gets the frame's position */ frame_client_gravity(self->frame, &x, &y); @@ -1757,8 +1762,8 @@ void client_configure_full(ObClient *self, ObCorner anchor, /* set the size and position if maximized */ if (self->max_horz) { - x = a->x - self->frame->size.left; - w = a->width; + x = a->x; + w = a->width - self->frame->size.left - self->frame->size.right; } if (self->max_vert) { y = a->y; @@ -1900,7 +1905,7 @@ void client_configure_full(ObClient *self, ObCorner anchor, moved = resized = TRUE; if (moved || resized) - frame_adjust_area(self->frame, moved, resized); + frame_adjust_area(self->frame, moved, resized, FALSE); if (!resized && (force_reply || ((!user && moved) || (user && final)))) { @@ -2170,7 +2175,7 @@ void client_shade(ObClient *self, gboolean shade) self->shaded = shade; client_change_state(self); /* resize the frame to just the titlebar */ - frame_adjust_area(self->frame, FALSE, FALSE); + frame_adjust_area(self->frame, FALSE, FALSE, FALSE); } void client_close(ObClient *self) diff --git a/openbox/frame.c b/openbox/frame.c index 4317f919..bdae34e3 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -14,7 +14,7 @@ EnterWindowMask | LeaveWindowMask) #define FRAME_HANDLE_Y(f) (f->innersize.top + f->client->area.height + \ - f->cbwidth) + f->cbwidth_y) static void layout_title(ObFrame *self); @@ -86,7 +86,8 @@ ObFrame *frame_new() /* set colors/appearance/sizes for stuff that doesn't change */ XSetWindowBorder(ob_display, self->window, ob_rr_theme->b_color->pixel); - XSetWindowBorder(ob_display, self->label, ob_rr_theme->b_color->pixel); + XSetWindowBorder(ob_display, self->title, ob_rr_theme->b_color->pixel); + XSetWindowBorder(ob_display, self->handle, ob_rr_theme->b_color->pixel); XSetWindowBorder(ob_display, self->rgrip, ob_rr_theme->b_color->pixel); XSetWindowBorder(ob_display, self->lgrip, ob_rr_theme->b_color->pixel); @@ -183,18 +184,18 @@ void frame_adjust_shape(ObFrame *self) num = 0; if (self->decorations & OB_FRAME_DECOR_TITLEBAR) { - xrect[0].x = -ob_rr_theme->bevel; - xrect[0].y = -ob_rr_theme->bevel; - xrect[0].width = self->width + self->bwidth * 2; + xrect[0].x = -ob_rr_theme->bwidth; + xrect[0].y = -ob_rr_theme->bwidth; + xrect[0].width = self->width + self->rbwidth * 2; xrect[0].height = ob_rr_theme->title_height + self->bwidth * 2; ++num; } if (self->decorations & OB_FRAME_DECOR_HANDLE) { - xrect[1].x = -ob_rr_theme->bevel; + xrect[1].x = -ob_rr_theme->bwidth; xrect[1].y = FRAME_HANDLE_Y(self); - xrect[1].width = self->width + self->bwidth * 2; + xrect[1].width = self->width + self->rbwidth * 2; xrect[1].height = ob_rr_theme->handle_height + self->bwidth * 2; ++num; @@ -207,31 +208,51 @@ void frame_adjust_shape(ObFrame *self) #endif } -void frame_adjust_area(ObFrame *self, gboolean moved, gboolean resized) +void frame_adjust_area(ObFrame *self, gboolean moved, + gboolean resized, gboolean fake) { if (resized) { self->decorations = self->client->decorations; + if (self->decorations & OB_FRAME_DECOR_BORDER) { self->bwidth = ob_rr_theme->bwidth; - self->cbwidth = ob_rr_theme->cbwidth; + self->cbwidth_x = self->cbwidth_y = ob_rr_theme->cbwidth; } else { - self->bwidth = self->cbwidth = 0; + self->bwidth = self->cbwidth_x = self->cbwidth_y = 0; } - STRUT_SET(self->innersize, self->cbwidth, self->cbwidth, - self->cbwidth, self->cbwidth); - self->width = self->client->area.width + self->cbwidth * 2; - g_assert(self->width > 0); + self->rbwidth = self->bwidth; + + if (self->client->max_vert && self->client->max_horz) + self->decorations &= ~OB_FRAME_DECOR_HANDLE; + + if (self->client->max_horz) + self->bwidth = self->cbwidth_x = 0; + + STRUT_SET(self->innersize, + self->cbwidth_x, + self->cbwidth_y, + self->cbwidth_x, + self->cbwidth_y); + self->width = self->client->area.width + self->cbwidth_x * 2 - + (self->client->max_horz ? self->rbwidth * 2 : 0); + self->width = MAX(self->width, 1); /* no lower than 1 */ /* set border widths */ - XSetWindowBorderWidth(ob_display, self->plate, self->cbwidth); - XSetWindowBorderWidth(ob_display, self->window, self->bwidth); - XSetWindowBorderWidth(ob_display, self->title, self->bwidth); - XSetWindowBorderWidth(ob_display, self->handle, self->bwidth); - XSetWindowBorderWidth(ob_display, self->lgrip, self->bwidth); - XSetWindowBorderWidth(ob_display, self->rgrip, self->bwidth); - - /* position/size and map/unmap all the windows */ + if (!fake) { + XSetWindowBorderWidth(ob_display, self->window, self->bwidth); + XSetWindowBorderWidth(ob_display, self->title, self->rbwidth); + XSetWindowBorderWidth(ob_display, self->handle, self->rbwidth); + XSetWindowBorderWidth(ob_display, self->lgrip, self->rbwidth); + XSetWindowBorderWidth(ob_display, self->rgrip, self->rbwidth); + } + if (self->decorations & OB_FRAME_DECOR_TITLEBAR) + self->innersize.top += ob_rr_theme->title_height + self->rbwidth + + (self->rbwidth - self->bwidth); + if (self->decorations & OB_FRAME_DECOR_HANDLE) + self->innersize.bottom += ob_rr_theme->handle_height + + self->rbwidth + (self->rbwidth - self->bwidth); + /* they all default off, they're turned on in layout_title */ self->icon_x = -1; self->desk_x = -1; @@ -241,59 +262,65 @@ void frame_adjust_area(ObFrame *self, gboolean moved, gboolean resized) self->max_x = -1; self->close_x = -1; - if (self->decorations & OB_FRAME_DECOR_TITLEBAR) { - XMoveResizeWindow(ob_display, self->title, - -self->bwidth, -self->bwidth, - self->width, ob_rr_theme->title_height); - self->innersize.top += ob_rr_theme->title_height + self->bwidth; - XMapWindow(ob_display, self->title); + /* position/size and map/unmap all the windows */ + + if (!fake) { + if (self->decorations & OB_FRAME_DECOR_TITLEBAR) { + XMoveResizeWindow(ob_display, self->title, + -self->bwidth, -self->bwidth, + self->width, ob_rr_theme->title_height); + XMapWindow(ob_display, self->title); - XMoveWindow(ob_display, self->tlresize, 0, 0); - XMoveWindow(ob_display, self->trresize, - self->width - ob_rr_theme->grip_width, 0); + XMoveWindow(ob_display, self->tlresize, 0, 0); + XMoveWindow(ob_display, self->trresize, + self->width - ob_rr_theme->grip_width, 0); + + } else + XUnmapWindow(ob_display, self->title); + } + if (self->decorations & OB_FRAME_DECOR_TITLEBAR) /* layout the title bar elements */ layout_title(self); - } else - XUnmapWindow(ob_display, self->title); - if (self->decorations & OB_FRAME_DECOR_HANDLE) { - XMoveResizeWindow(ob_display, self->handle, - -self->bwidth, FRAME_HANDLE_Y(self), - self->width, ob_rr_theme->handle_height); - self->innersize.bottom += ob_rr_theme->handle_height + - self->bwidth; - XMapWindow(ob_display, self->handle); - - if (self->decorations & OB_FRAME_DECOR_GRIPS) { - XMoveWindow(ob_display, self->lgrip, - -self->bwidth, -self->bwidth); - XMoveWindow(ob_display, self->rgrip, - -self->bwidth + self->width - - ob_rr_theme->grip_width, -self->bwidth); - XMapWindow(ob_display, self->lgrip); - XMapWindow(ob_display, self->rgrip); - } else { - XUnmapWindow(ob_display, self->lgrip); - XUnmapWindow(ob_display, self->rgrip); - } - - /* XXX make a subwindow with these dimentions? - ob_rr_theme->grip_width + self->bwidth, 0, - self->width - (ob_rr_theme->grip_width + self->bwidth) * 2, - ob_rr_theme->handle_height); - */ - } else - XUnmapWindow(ob_display, self->handle); - - /* move and resize the plate */ - XMoveResizeWindow(ob_display, self->plate, - self->innersize.left - self->cbwidth, - self->innersize.top - self->cbwidth, - self->client->area.width, - self->client->area.height); - /* when the client has StaticGravity, it likes to move around. */ - XMoveWindow(ob_display, self->client->window, 0, 0); + if (!fake) { + if (self->decorations & OB_FRAME_DECOR_HANDLE) { + XMoveResizeWindow(ob_display, self->handle, + -self->bwidth, FRAME_HANDLE_Y(self), + self->width, ob_rr_theme->handle_height); + XMapWindow(ob_display, self->handle); + + if (self->decorations & OB_FRAME_DECOR_GRIPS) { + XMoveWindow(ob_display, self->lgrip, + -self->rbwidth, -self->rbwidth); + XMoveWindow(ob_display, self->rgrip, + -self->rbwidth + self->width - + ob_rr_theme->grip_width, -self->rbwidth); + XMapWindow(ob_display, self->lgrip); + XMapWindow(ob_display, self->rgrip); + } else { + XUnmapWindow(ob_display, self->lgrip); + XUnmapWindow(ob_display, self->rgrip); + } + + /* XXX make a subwindow with these dimentions? + ob_rr_theme->grip_width + self->bwidth, 0, + self->width - (ob_rr_theme->grip_width + self->bwidth) * 2, + ob_rr_theme->handle_height); + */ + } else + XUnmapWindow(ob_display, self->handle); + + /* move and resize the plate */ + XMoveResizeWindow(ob_display, self->plate, + self->innersize.left - self->cbwidth_x, + self->innersize.top - self->cbwidth_y, + self->client->area.width + self->cbwidth_x * 2, + self->client->area.height + self->cbwidth_y * 2); + /* when the client has StaticGravity, it likes to move around. */ + XMoveWindow(ob_display, self->client->window, + self->cbwidth_x, self->cbwidth_y); + } STRUT_SET(self->size, self->innersize.left + self->bwidth, @@ -319,17 +346,19 @@ void frame_adjust_area(ObFrame *self, gboolean moved, gboolean resized) frame_client_gravity(self, &self->area.x, &self->area.y); } - /* move and resize the top level frame. - shading can change without being moved or resized */ - XMoveResizeWindow(ob_display, self->window, - self->area.x, self->area.y, - self->width, - self->area.height - self->bwidth * 2); + if (!fake) { + /* move and resize the top level frame. + shading can change without being moved or resized */ + XMoveResizeWindow(ob_display, self->window, + self->area.x, self->area.y, + self->area.width - self->bwidth * 2, + self->area.height - self->bwidth * 2); - if (resized) { - framerender_frame(self); + if (resized) { + framerender_frame(self); - frame_adjust_shape(self); + frame_adjust_shape(self); + } } } @@ -378,7 +407,7 @@ void frame_grab_client(ObFrame *self, ObClient *client) /* map the client so it maps when the frame does */ XMapWindow(ob_display, client->window); - frame_adjust_area(self, TRUE, TRUE); + frame_adjust_area(self, TRUE, TRUE, FALSE); /* set all the windows for the frame in the window_map */ g_hash_table_insert(window_map, &self->window, client); diff --git a/openbox/frame.h b/openbox/frame.h index 8eacbb1b..6bb69599 100644 --- a/openbox/frame.h +++ b/openbox/frame.h @@ -93,7 +93,9 @@ struct _ObFrame gint max_x; /* x-position of the window maximize button */ gint close_x; /* x-position of the window close button */ gint bwidth; /* border width */ - gint cbwidth; /* client border width */ + gint rbwidth; /* title border width */ + gint cbwidth_x; /* client border width */ + gint cbwidth_y; /* client border width */ gboolean max_press; gboolean close_press; @@ -113,7 +115,8 @@ ObFrame *frame_new(); void frame_show(ObFrame *self); void frame_hide(ObFrame *self); void frame_adjust_shape(ObFrame *self); -void frame_adjust_area(ObFrame *self, gboolean moved, gboolean resized); +void frame_adjust_area(ObFrame *self, gboolean moved, + gboolean resized, gboolean fake); void frame_adjust_state(ObFrame *self); void frame_adjust_focus(ObFrame *self, gboolean hilite); void frame_adjust_title(ObFrame *self); diff --git a/openbox/framerender.c b/openbox/framerender.c index f2814a07..b2aba5ea 100644 --- a/openbox/framerender.c +++ b/openbox/framerender.c @@ -21,7 +21,6 @@ void framerender_frame(ObFrame *self) px = (self->focused ? RrColorPixel(ob_rr_theme->cb_focused_color) : RrColorPixel(ob_rr_theme->cb_unfocused_color)); - XSetWindowBorder(ob_display, self->plate, px); XSetWindowBackground(ob_display, self->plate, px); }