diff --git a/src/backend/wayland/wl_framebuf.c b/src/backend/wayland/wl_framebuf.c index 2a8cd16..ecb4340 100644 --- a/src/backend/wayland/wl_framebuf.c +++ b/src/backend/wayland/wl_framebuf.c @@ -588,6 +588,7 @@ wl_frame_paint(struct WFrameWindow *fwin) int state = fwin->flags.state; int total_w = fb->width; int total_h = fb->height; + int tb_in_parent = 0; /* Clear the buffer to transparent black. */ pixman_color_t clear = {0, 0, 0, 0}; /* transparent */ pixman_image_fill_rectangles(PIXMAN_OP_SRC, fb->image, &clear, @@ -614,11 +615,12 @@ wl_frame_paint(struct WFrameWindow *fwin) wlr_scene_node_set_position(&tb_fb->scene_buf->node, 0, 0); } - /* If titlebar buffer is too narrow, draw directly into the - * parent frame buffer to avoid unsafe in-place resize. */ - if (tb_fb && tb_fb->width < tb_w) { + /* If titlebar buffer is too small, draw directly into the + * parent frame buffer to avoid buffer overflow. */ + if (tb_fb && (tb_fb->width < tb_w || tb_fb->height < tb_h)) { tb_img = fb->image; tb_fb = NULL; + tb_in_parent = 1; } WTexture *tex = fwin->title_texture[state]; @@ -815,9 +817,9 @@ wl_frame_paint(struct WFrameWindow *fwin) /* Commit the parent frame buffer when it has visible content: * resizebar pixels (unshaded) or titlebar fallback (when the titlebar - * child buffer is too narrow and we drew into the parent instead). */ + * child buffer was too small and we drew into the parent instead). */ if (fb->scene_buf) { - if (show_resizebar || !fwin->titlebar || !frame_buf_find(fwin->titlebar->window)) { + if (show_resizebar || tb_in_parent) { wlr_scene_buffer_set_buffer_with_damage(fb->scene_buf, &fb->base, NULL); wlr_scene_node_set_enabled(&fb->scene_buf->node, true); } else {