2015-01-27 19:23 GMT+02:00 Jasper St. Pierre <[email protected]>: > Are you still not using XKillClient for some reason?
This patch is not about killing X clients, it's about passing the pid to the shell, so not sure what relevance it has. > > On Tue, Jan 27, 2015 at 12:10 PM, Giulio Camuffo <[email protected]> > 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. >> --- >> >> v5: added the check on the hostname >> >> desktop-shell/shell.c | 7 +++++++ >> src/compositor.h | 1 + >> xwayland/window-manager.c | 30 ++++++++++++++++++++++-------- >> 3 files changed, 30 insertions(+), 8 deletions(-) >> >> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c >> index a7514f7..6bb9af8 100644 >> --- a/desktop-shell/shell.c >> +++ b/desktop-shell/shell.c >> @@ -2248,6 +2248,12 @@ set_title(struct shell_surface *shsurf, const char >> *title) >> } >> >> static void >> +set_pid(struct shell_surface *shsurf, pid_t pid) >> +{ >> + /* We have no use for it */ >> +} >> + >> +static void >> set_type(struct shell_surface *shsurf, enum shell_surface_type t) >> { >> shsurf->type = t; >> @@ -6624,6 +6630,7 @@ module_init(struct weston_compositor *ec, >> ec->shell_interface.resize = surface_resize; >> ec->shell_interface.set_title = set_title; >> ec->shell_interface.set_window_geometry = set_window_geometry; >> + ec->shell_interface.set_pid = set_pid; >> >> weston_layer_init(&shell->fullscreen_layer, >> &ec->cursor_layer.link); >> weston_layer_init(&shell->panel_layer, >> &shell->fullscreen_layer.link); >> diff --git a/src/compositor.h b/src/compositor.h >> index aa87ec0..0223f41 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); >> }; >> >> struct weston_animation { >> diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c >> index 6f1996f..c966fd5 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,28 @@ weston_wm_window_read_properties(struct >> weston_wm_window *window) >> free(reply); >> } >> >> + if (window->pid > 0) { >> + gethostname(name, sizeof(name)); >> + for (i = 0; i < sizeof(name); i++) { >> + if (name[i] == '\0') >> + break; >> + } >> + if (i == sizeof(name)) >> + name[0] = '\0'; /* ignore stupid hostnames */ >> + >> + /* 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 (!window->machine || 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 +670,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) >> kill(window->pid, SIGKILL); >> } >> >> @@ -2333,6 +2345,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.2 >> >> _______________________________________________ >> wayland-devel mailing list >> [email protected] >> http://lists.freedesktop.org/mailman/listinfo/wayland-devel > > > > > -- > Jasper _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
