[PATCH v2] xwm: tell the shell the pid of the X clients

Giulio Camuffo giuliocamuffo at gmail.com
Sun Jan 11 02:26:26 PST 2015


2015-01-11 10:33 GMT+02:00 Jasper St. Pierre <jstpierre at mecheye.net>:
> In the case of X clients, using XKillClient instead of killing the PID would
> be much nicer.
>
> On Sat, Jan 10, 2015 at 3:27 AM, Giulio Camuffo <giuliocamuffo at gmail.com>
> wrote:
>>
>> All the surfaces from all the X clients share the same wl_client so
>> wl_client_get_credentials can't be used to get the pid of the X
>> clients.
>> The shell may need to know the pid to be able to associate a surface
>> with e.g. a DBus service.
>> ---
>>  src/compositor.h          |  1 +
>>  xwayland/window-manager.c | 21 +++++++++++++--------
>>  2 files changed, 14 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/compositor.h b/src/compositor.h
>> index 900d2a5..3b1e490 100644
>> --- a/src/compositor.h
>> +++ b/src/compositor.h
>> @@ -121,6 +121,7 @@ struct weston_shell_interface {
>>         void (*set_window_geometry)(struct shell_surface *shsurf,
>>                                     int32_t x, int32_t y,
>>                                     int32_t width, int32_t height);
>> +       void (*set_pid)(struct shell_surface *shsurf, pid_t pid);
>
>
> I don't see anywhere you fill this in?

You're right, i forgor the shell part.

>
>>
>>  };
>>
>>  struct weston_animation {
>> diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
>> index f362eac..b819b04 100644
>> --- a/xwayland/window-manager.c
>> +++ b/xwayland/window-manager.c
>> @@ -401,6 +401,7 @@ weston_wm_window_read_properties(struct
>> weston_wm_window *window)
>>         uint32_t *xid;
>>         xcb_atom_t *atom;
>>         uint32_t i;
>> +       char name[1024];
>>
>>         if (!window->properties_dirty)
>>                 return;
>> @@ -487,10 +488,19 @@ weston_wm_window_read_properties(struct
>> weston_wm_window *window)
>>                 free(reply);
>>         }
>>
>> +       gethostname(name, 1024);
>> +       /* this is only one heuristic to guess the PID of a client is
>> valid,
>> +        * assuming it's compliant with icccm and ewmh. Non-compliants and
>> +        * remote applications of course fail. */
>> +       if (strcmp(window->machine, name))
>> +               window->pid = 0;
>> +
>>         if (window->shsurf && window->name)
>>                 shell_interface->set_title(window->shsurf, window->name);
>>         if (window->frame && window->name)
>>                 frame_set_title(window->frame, window->name);
>> +       if (window->shsurf && window->pid > 0)
>> +               shell_interface->set_pid(window->shsurf, window->pid);
>>  }
>>
>>  static void
>> @@ -651,17 +661,10 @@ weston_wm_kill_client(struct wl_listener *listener,
>> void *data)
>>  {
>>         struct weston_surface *surface = data;
>>         struct weston_wm_window *window = get_wm_window(surface);
>> -       char name[1024];
>> -
>>         if (!window)
>>                 return;
>>
>> -       gethostname(name, 1024);
>> -
>> -       /* this is only one heuristic to guess the PID of a client is
>> valid,
>> -        * assuming it's compliant with icccm and ewmh. Non-compliants and
>> -        * remote applications of course fail. */
>> -       if (!strcmp(window->machine, name) && window->pid != 0)
>> +       if (!window->pid > 0)
>
>
> This looks very wrong.

Why? if the hostname check fails the pid is set to 0 so the if here will fail.

>
>>
>>                 kill(window->pid, SIGKILL);
>>  }
>>
>> @@ -2350,6 +2353,8 @@ xserver_map_shell_surface(struct weston_wm_window
>> *window,
>>
>>         if (window->name)
>>                 shell_interface->set_title(window->shsurf, window->name);
>> +       if (window->pid > 0)
>> +               shell_interface->set_pid(window->shsurf, window->pid);
>>
>>         if (window->fullscreen) {
>>                 window->saved_width = window->width;
>> --
>> 2.2.1
>>
>> _______________________________________________
>> wayland-devel mailing list
>> wayland-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
>
>
>
> --
>   Jasper


More information about the wayland-devel mailing list