<div dir="ltr">Are you still not using XKillClient for some reason?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 27, 2015 at 12:10 PM, Giulio Camuffo <span dir="ltr"><<a href="mailto:giuliocamuffo@gmail.com" target="_blank">giuliocamuffo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">All the surfaces from all the X clients share the same wl_client so<br>
wl_client_get_credentials can't be used to get the pid of the X<br>
clients.<br>
The shell may need to know the pid to be able to associate a surface<br>
with e.g. a DBus service.<br>
---<br>
<br>
</span>v5: added the check on the hostname<br>
<span class=""><br>
 desktop-shell/shell.c     |  7 +++++++<br>
 src/compositor.h          |  1 +<br>
</span> xwayland/window-manager.c | 30 ++++++++++++++++++++++--------<br>
 3 files changed, 30 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c<br>
index a7514f7..6bb9af8 100644<br>
<span class="">--- a/desktop-shell/shell.c<br>
+++ b/desktop-shell/shell.c<br>
@@ -2248,6 +2248,12 @@ set_title(struct shell_surface *shsurf, const char *title)<br>
 }<br>
<br>
 static void<br>
+set_pid(struct shell_surface *shsurf, pid_t pid)<br>
+{<br>
+       /* We have no use for it */<br>
+}<br>
+<br>
+static void<br>
 set_type(struct shell_surface *shsurf, enum shell_surface_type t)<br>
 {<br>
        shsurf->type = t;<br>
</span>@@ -6624,6 +6630,7 @@ module_init(struct weston_compositor *ec,<br>
<span class="">        ec->shell_interface.resize = surface_resize;<br>
        ec->shell_interface.set_title = set_title;<br>
        ec->shell_interface.set_window_geometry = set_window_geometry;<br>
+       ec->shell_interface.set_pid = set_pid;<br>
<br>
        weston_layer_init(&shell->fullscreen_layer, &ec->cursor_layer.link);<br>
        weston_layer_init(&shell->panel_layer, &shell->fullscreen_layer.link);<br>
diff --git a/src/compositor.h b/src/compositor.h<br>
</span>index aa87ec0..0223f41 100644<br>
<span class="">--- a/src/compositor.h<br>
+++ b/src/compositor.h<br>
@@ -121,6 +121,7 @@ struct weston_shell_interface {<br>
        void (*set_window_geometry)(struct shell_surface *shsurf,<br>
                                    int32_t x, int32_t y,<br>
                                    int32_t width, int32_t height);<br>
+       void (*set_pid)(struct shell_surface *shsurf, pid_t pid);<br>
 };<br>
<br>
 struct weston_animation {<br>
diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c<br>
</span>index 6f1996f..c966fd5 100644<br>
<span class="">--- a/xwayland/window-manager.c<br>
+++ b/xwayland/window-manager.c<br>
@@ -401,6 +401,7 @@ weston_wm_window_read_properties(struct weston_wm_window *window)<br>
        uint32_t *xid;<br>
        xcb_atom_t *atom;<br>
        uint32_t i;<br>
+       char name[1024];<br>
<br>
        if (!window->properties_dirty)<br>
                return;<br>
</span>@@ -487,10 +488,28 @@ weston_wm_window_read_properties(struct weston_wm_window *window)<br>
                free(reply);<br>
        }<br>
<br>
<span class="">+       if (window->pid > 0) {<br>
</span>+               gethostname(name, sizeof(name));<br>
+               for (i = 0; i < sizeof(name); i++) {<br>
+                       if (name[i] == '\0')<br>
+                               break;<br>
+               }<br>
+               if (i == sizeof(name))<br>
+                       name[0] = '\0'; /* ignore stupid hostnames */<br>
<span class="">+<br>
+               /* this is only one heuristic to guess the PID of a client is<br>
</span>+               * valid, assuming it's compliant with icccm and ewmh.<br>
+               * Non-compliants and remote applications of course fail. */<br>
<span class="">+               if (!window->machine || strcmp(window->machine, name))<br>
+                       window->pid = 0;<br>
+       }<br>
+<br>
        if (window->shsurf && window->name)<br>
                shell_interface->set_title(window->shsurf, window->name);<br>
        if (window->frame && window->name)<br>
                frame_set_title(window->frame, window->name);<br>
+       if (window->shsurf && window->pid > 0)<br>
+               shell_interface->set_pid(window->shsurf, window->pid);<br>
 }<br>
<br>
 static void<br>
</span>@@ -651,17 +670,10 @@ weston_wm_kill_client(struct wl_listener *listener, void *data)<br>
<span class=""> {<br>
        struct weston_surface *surface = data;<br>
        struct weston_wm_window *window = get_wm_window(surface);<br>
-       char name[1024];<br>
-<br>
        if (!window)<br>
                return;<br>
<br>
-       gethostname(name, 1024);<br>
-<br>
-       /* this is only one heuristic to guess the PID of a client is valid,<br>
-        * assuming it's compliant with icccm and ewmh. Non-compliants and<br>
-        * remote applications of course fail. */<br>
-       if (!strcmp(window->machine, name) && window->pid != 0)<br>
+       if (window->pid > 0)<br>
                kill(window->pid, SIGKILL);<br>
 }<br>
<br>
</span>@@ -2333,6 +2345,8 @@ xserver_map_shell_surface(struct weston_wm_window *window,<br>
<span class=""><br>
        if (window->name)<br>
                shell_interface->set_title(window->shsurf, window->name);<br>
+       if (window->pid > 0)<br>
+               shell_interface->set_pid(window->shsurf, window->pid);<br>
<br>
        if (window->fullscreen) {<br>
                window->saved_width = window->width;<br>
--<br>
</span>2.2.2<br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">  Jasper<br></div>
</div>