mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
win: fix calculation of window frame region
The geometry returned by xcb_get_geometry doesn't include the window border, so we have to include that when calculating the frame. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
cf3e95f0a4
commit
fb3305fb9b
2 changed files with 9 additions and 5 deletions
12
src/win.c
12
src/win.c
|
@ -211,24 +211,26 @@ void win_get_region_noframe_local(const struct managed_win *w, region_t *res) {
|
|||
|
||||
void win_get_region_frame_local(const struct managed_win *w, region_t *res) {
|
||||
const margin_t extents = win_calc_frame_extents(w);
|
||||
auto outer_width = extents.left + extents.right + w->g.width;
|
||||
auto outer_height = extents.top + extents.bottom + w->g.height;
|
||||
pixman_region32_fini(res);
|
||||
pixman_region32_init_rects(
|
||||
res,
|
||||
(rect_t[]){
|
||||
// top
|
||||
{.x1 = 0, .y1 = 0, .x2 = w->g.width, .y2 = extents.top},
|
||||
{.x1 = 0, .y1 = 0, .x2 = outer_width, .y2 = extents.top},
|
||||
// bottom
|
||||
{.x1 = 0, .y1 = w->g.height - extents.bottom, .x2 = w->g.width, .y2 = w->g.height},
|
||||
{.x1 = 0, .y1 = outer_height - extents.bottom, .x2 = outer_width, .y2 = outer_height},
|
||||
// left
|
||||
{.x1 = 0, .y1 = 0, .x2 = extents.left, .y2 = w->g.height},
|
||||
{.x1 = 0, .y1 = 0, .x2 = extents.left, .y2 = outer_height},
|
||||
// right
|
||||
{.x1 = w->g.width - extents.right, .y1 = 0, .x2 = w->g.width, .y2 = w->g.height},
|
||||
{.x1 = outer_width - extents.right, .y1 = 0, .x2 = outer_width, .y2 = outer_height},
|
||||
},
|
||||
4);
|
||||
|
||||
// limit the frame region to inside the window
|
||||
region_t reg_win;
|
||||
pixman_region32_init_rect(®_win, 0, 0, w->g.width, w->g.height);
|
||||
pixman_region32_init_rects(®_win, (rect_t[]){0, 0, outer_width, outer_height}, 1);
|
||||
pixman_region32_intersect(res, ®_win, res);
|
||||
pixman_region32_fini(®_win);
|
||||
}
|
||||
|
|
|
@ -107,6 +107,8 @@ struct managed_win {
|
|||
winstate_t state;
|
||||
/// Window attributes.
|
||||
xcb_get_window_attributes_reply_t a;
|
||||
/// Reply of xcb_get_geometry, which returns the geometry of the window body,
|
||||
/// excluding the window border.
|
||||
xcb_get_geometry_reply_t g;
|
||||
/// Xinerama screen this window is on.
|
||||
int xinerama_scr;
|
||||
|
|
Loading…
Reference in a new issue