]> git.mdlowis.com Git - proto/labwc.git/commitdiff
implement Kill action
authorbi4k8 <bi4k8@github>
Tue, 15 Mar 2022 15:47:46 +0000 (15:47 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 8 Dec 2022 19:33:09 +0000 (19:33 +0000)
this action sends SIGTERM to a client's process

src/action.c

index b6440a5a6a4ef20e6dcfe88f7823607d9073f8e1..c1dacb6e92992d01a5fc636fd4010f49fd432c54 100644 (file)
@@ -37,6 +37,7 @@ enum action_type {
        ACTION_TYPE_INVALID = 0,
        ACTION_TYPE_NONE,
        ACTION_TYPE_CLOSE,
+       ACTION_TYPE_KILL,
        ACTION_TYPE_DEBUG,
        ACTION_TYPE_EXECUTE,
        ACTION_TYPE_EXIT,
@@ -63,6 +64,7 @@ const char *action_names[] = {
        "INVALID",
        "None",
        "Close",
+       "Kill",
        "Debug",
        "Execute",
        "Exit",
@@ -244,6 +246,17 @@ actions_run(struct view *activator, struct server *server,
                                view_close(view);
                        }
                        break;
+               case ACTION_TYPE_KILL:
+                       if (view && view->surface) {
+                               /* Send SIGTERM to the process associated with the surface */
+                               pid_t pid = -1;
+                               struct wl_client *client = view->surface->resource->client;
+                               wl_client_get_credentials(client, &pid, NULL, NULL);
+                               if (pid != -1) {
+                                       kill(pid, SIGTERM);
+                               }
+                       }
+                       break;
                case ACTION_TYPE_DEBUG:
                        debug_dump_scene(server);
                        break;