[PATCH weston v2] xwm: Add icon support to the frame

Daniel Stone daniel at fooishbar.org
Mon Feb 13 19:05:45 UTC 2017


Hi Emmanuel,

On 8 December 2016 at 01:55, Emmanuel Gil Peyrot <linkmauve at linkmauve.fr> wrote:
> @@ -1146,6 +1150,48 @@ weston_wm_window_schedule_repaint(struct weston_wm_window *window)
>  }
>
>  static void
> +weston_wm_handle_icon(struct weston_wm *wm, struct weston_wm_window *window)
> +{
> +       xcb_get_property_reply_t *reply;
> +       xcb_get_property_cookie_t cookie;
> +       int length;
> +       unsigned *data, width, height;
> +
> +       /* TODO: icons don’t have any specified order, we should pick the
> +        * closest one to the target dimension instead of the first one. */
> +
> +       cookie = xcb_get_property(wm->conn, 0, window->id,
> +                                 wm->atom.net_wm_icon, XCB_ATOM_ANY, 0, 2048);
> +       reply = xcb_get_property_reply(wm->conn, cookie, NULL);
> +       length = xcb_get_property_value_length(reply);
> +
> +       /* This is in 32-bit words, not in bytes. */
> +       if (length < 2)
> +               return;
> +
> +       data = xcb_get_property_value(reply);
> +       width = *data++;
> +       height = *data++;
> +
> +       if (length < 2 + width * height)
> +               return;
> +
> +       if (window->icon_surface)
> +               cairo_surface_destroy(window->icon_surface);
> +
> +       window->icon_surface =
> +               cairo_image_surface_create_for_data((unsigned char *)data,
> +                                                   CAIRO_FORMAT_ARGB32,
> +                                                   width, height, width * 4);
> +
> +       /* Bail out in case anything wrong happened during surface creation. */
> +       if (cairo_surface_status(window->icon_surface) != CAIRO_STATUS_SUCCESS) {
> +               cairo_surface_destroy(window->icon_surface);
> +               window->icon_surface = NULL;
> +       }
> +}

I think the only thing missing here is scheduling a frame redraw, when
the icon changes. Also it's presumably missing the case where the icon
gets unset?

This is now too late for Weston 2.0, but with those two fixed, I'd
happily review this and get it early into the next cycle.

Cheers,
Daniel


More information about the wayland-devel mailing list