xwm: Fix icon surface ownership

The cairo surface used for the icon must be completely given to the
frame as soon as said frame has been created.  To prevent both the
window and the frame from sharing ownership of the icon, we set
window->icon_surface back to NULL right after creating or changing the
frame, only keeping it there when no frame has been created yet.

Fixes https://lists.freedesktop.org/archives/wayland-devel/2018-January/036655.html
Reported-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
This commit is contained in:
Emmanuel Gil Peyrot
2018-01-24 23:29:53 +01:00
committed by Daniel Stone
parent 5e12b553b1
commit 44fc1be913
3 changed files with 28 additions and 6 deletions
+4
View File
@@ -135,6 +135,10 @@ frame_destroy(struct frame *frame);
int
frame_set_title(struct frame *frame, const char *title);
/* May set FRAME_STATUS_REPAINT */
void
frame_set_icon(struct frame *frame, cairo_surface_t *icon);
/* May set FRAME_STATUS_REPAINT */
void
frame_set_flag(struct frame *frame, enum frame_flag flag);
+14
View File
@@ -448,6 +448,20 @@ frame_set_title(struct frame *frame, const char *title)
return 0;
}
void
frame_set_icon(struct frame *frame, cairo_surface_t *icon)
{
struct frame_button *button;
wl_list_for_each(button, &frame->buttons, link) {
if (button->status_effect != FRAME_STATUS_MENU)
continue;
if (button->icon)
cairo_surface_destroy(button->icon);
button->icon = icon;
frame->status |= FRAME_STATUS_REPAINT;
}
}
void
frame_set_flag(struct frame *frame, enum frame_flag flag)
{