shared/frame: Provide a function to get decoration sizes and use it
We need these values to calculate frame extents to properly set _NET_FRAME_EXTENTS, but we don't want to calculate them twice. Break out these bits from frame_resize_inside, and update it to use the new function. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
@@ -161,6 +161,10 @@ frame_width(struct frame *frame);
|
|||||||
int32_t
|
int32_t
|
||||||
frame_height(struct frame *frame);
|
frame_height(struct frame *frame);
|
||||||
|
|
||||||
|
void
|
||||||
|
frame_decoration_sizes(struct frame *frame, int32_t *top, int32_t *bottom,
|
||||||
|
int32_t *left, int32_t *right);
|
||||||
|
|
||||||
void
|
void
|
||||||
frame_interior(struct frame *frame, int32_t *x, int32_t *y,
|
frame_interior(struct frame *frame, int32_t *x, int32_t *y,
|
||||||
int32_t *width, int32_t *height);
|
int32_t *width, int32_t *height);
|
||||||
|
|||||||
+27
-14
@@ -493,27 +493,40 @@ frame_resize(struct frame *frame, int32_t width, int32_t height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
frame_resize_inside(struct frame *frame, int32_t width, int32_t height)
|
frame_decoration_sizes(struct frame *frame, int32_t *top, int32_t *bottom,
|
||||||
|
int32_t *left, int32_t *right)
|
||||||
{
|
{
|
||||||
struct theme *t = frame->theme;
|
struct theme *t = frame->theme;
|
||||||
int decoration_width, decoration_height, titlebar_height;
|
|
||||||
|
|
||||||
|
/* Top may have a titlebar */
|
||||||
if (frame->title || !wl_list_empty(&frame->buttons))
|
if (frame->title || !wl_list_empty(&frame->buttons))
|
||||||
titlebar_height = t->titlebar_height;
|
*top = t->titlebar_height;
|
||||||
else
|
else
|
||||||
titlebar_height = t->width;
|
*top = t->width;
|
||||||
|
|
||||||
if (frame->flags & FRAME_FLAG_MAXIMIZED) {
|
/* All other sides have the basic frame thickness */
|
||||||
decoration_width = t->width * 2;
|
*bottom = t->width;
|
||||||
decoration_height = t->width + titlebar_height;
|
*right = t->width;
|
||||||
} else {
|
*left = t->width;
|
||||||
decoration_width = (t->width + t->margin) * 2;
|
|
||||||
decoration_height = t->width +
|
|
||||||
titlebar_height + t->margin * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_resize(frame, width + decoration_width,
|
if (frame->flags & FRAME_FLAG_MAXIMIZED)
|
||||||
height + decoration_height);
|
return;
|
||||||
|
|
||||||
|
/* Not maximized, add shadows */
|
||||||
|
*top += t->margin;
|
||||||
|
*bottom += t->margin;
|
||||||
|
*left += t->margin;
|
||||||
|
*right += t->margin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
frame_resize_inside(struct frame *frame, int32_t width, int32_t height)
|
||||||
|
{
|
||||||
|
int32_t top, bottom, left, right;
|
||||||
|
|
||||||
|
frame_decoration_sizes(frame, &top, &bottom, &left, &right);
|
||||||
|
frame_resize(frame, width + left + right,
|
||||||
|
height + top + bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
|
|||||||
Reference in New Issue
Block a user