<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jul 21, 2017 at 10:21 AM, Quentin Glidic <span dir="ltr"><<a href="mailto:sardemff7+wayland@sardemff7.net" target="_blank">sardemff7+wayland@sardemff7.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 7/20/17 4:33 PM, Matt Hoosier wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It's useful for the shell implementation to know when these change,<br>
for example to relay the information on to taskbars or similar.<br>
</blockquote>
<br></span>
The idea is good, we need something like that. (But maybe not, see below).<span class=""><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
To avoid ABI changes or the need to make the weston_desktop_surface<br>
definition public, new functions are introduced for attaching<br>
listeners to these signals.<br>
</blockquote>
<br></span>
We don’t care that much about ABI changes, but you’re right that I do care about the struct staying private.<div><div class="h5"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Signed-off-by: Matt Hoosier <<a href="mailto:matt.hoosier@gmail.com" target="_blank">matt.hoosier@gmail.com</a>><br>
---<br>
  libweston-desktop/libweston-de<wbr>sktop.h |  6 ++++++<br>
  libweston-desktop/surface.c           | 21 +++++++++++++++++++++<br>
  2 files changed, 27 insertions(+)<br>
<br>
diff --git a/libweston-desktop/libweston-<wbr>desktop.h b/libweston-desktop/libweston-<wbr>desktop.h<br>
index 03b04c7..e38257e 100644<br>
--- a/libweston-desktop/libweston-<wbr>desktop.h<br>
+++ b/libweston-desktop/libweston-<wbr>desktop.h<br>
@@ -164,6 +164,12 @@ weston_desktop_surface_set_siz<wbr>e(struct weston_desktop_surface *surface,<br>
                                int32_t width, int32_t height);<br>
  void<br>
  weston_desktop_surface_close(s<wbr>truct weston_desktop_surface *surface);<br>
+void<br>
+weston_desktop_surface_add_ti<wbr>tle_listener(struct weston_desktop_surface *surface,<br>
+                                         struct wl_listener *listener);<br>
+void<br>
+weston_desktop_surface_add_ap<wbr>p_id_listener(struct weston_desktop_surface *surface,<br>
+                                          struct wl_listener *listener);<br>
    void *<br>
  weston_desktop_surface_get_use<wbr>r_data(struct weston_desktop_surface *surface);<br>
diff --git a/libweston-desktop/surface.c b/libweston-desktop/surface.c<br>
index d3be936..97a455c 100644<br>
--- a/libweston-desktop/surface.c<br>
+++ b/libweston-desktop/surface.c<br>
@@ -64,6 +64,8 @@ struct weston_desktop_surface {<br>
                char *title;<br>
                char *app_id;<br>
                pid_t pid;<br>
+               struct wl_signal title_signal;<br>
+               struct wl_signal app_id_signal;<br>
        };<br>
        struct {<br>
                struct weston_desktop_surface *parent;<br>
@@ -287,6 +289,9 @@ weston_desktop_surface_create(<wbr>struct weston_desktop *desktop,<br>
        wl_list_init(&surface->view_li<wbr>st);<br>
        wl_list_init(&surface->grab_li<wbr>nk);<br>
  +     wl_signal_init(&surface->titl<wbr>e_signal);<br>
+       wl_signal_init(&surface->app_<wbr>id_signal);<br>
+<br>
        return surface;<br>
  }<br>
  @@ -511,6 +516,20 @@ weston_desktop_surface_close(s<wbr>truct weston_desktop_surface *surface)<br>
                                               surface->implementation_data)<wbr>;<br>
  }<br>
  +WL_EXPORT void<br>
+weston_desktop_surface_add_ti<wbr>tle_listener(struct weston_desktop_surface *surface,<br>
+                                         struct wl_listener *listener)<br>
+{<br>
+       wl_signal_add(&surface-><wbr>title_signal, listener);<br>
+}<br>
+<br>
+WL_EXPORT void<br>
+weston_desktop_surface_add_ap<wbr>p_id_listener(struct weston_desktop_surface *surface,<br>
+                                          struct wl_listener *listener)<br>
+{<br>
+       wl_signal_add(&surface->app_i<wbr>d_signal, listener);<br>
+}<br>
+<br>
  struct weston_desktop_surface *<br>
  weston_desktop_surface_from_cl<wbr>ient_link(struct wl_list *link)<br>
  {<br>
@@ -687,6 +706,7 @@ weston_desktop_surface_set_tit<wbr>le(struct weston_desktop_surface *surface,<br>
        free(surface->title);<br>
        surface->title = tmp;<br>
+       wl_signal_emit(&surface->titl<wbr>e_signal, surface->title);<br>
</blockquote>
<br></div></div>
I would rather pass the surface as the signal data. Just in case we have in the future a value that doesn’t fit in a pointer. And calling a getter is not that bad.<br>
<br>
Also, I prefer to have one signal only, it would reduce the API size (and avoid it growing too much in the future, since it could work in this case).<br>
We can move the free() to keep both pointer around until after the signal fired, and a simple pointer comparison will work (if you stored the "const char *" directly, which you should as with the signal, we guarantee it will exist until destroy or signal).<br></blockquote><div><br></div><div>I'm fine with using just one signal to announce all this. What sort of name seems appropriate? "name_signal" maybe?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
But it raised a question : Jonas, are set_title() and set_app_id() supposed to be active without a commit()?<br>
<br>
If so, maybe should we test equality in libweston-desktop, to avoid sending useless signals? (Just in case a client would be lazy and send the title on every frame.)<br>
And I would like to know if one signal sounds good to you?<br>
<br>
If *not*, then the committed callback is already the place to check for changes, and we need to adjust the code to match that. (And to keep old pointers around for safe comparison.)<br>
<br>
<br>
Cheers,<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  }<br>
    void<br>
@@ -701,6 +721,7 @@ weston_desktop_surface_set_app<wbr>_id(struct weston_desktop_surface *surface,<br>
        free(surface->app_id);<br>
        surface->app_id = tmp;<br>
+       wl_signal_emit(&surface->app_<wbr>id_signal, surface->app_id);<br>
  }<br>
    void<br>
<br>
</blockquote>
<br>
<br>
-- <br>
<br></span>
Quentin “Sardem FF7” Glidic<br></blockquote><div><br></div><div>-Matt </div></div><br></div></div>