1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
diff --git a/proto/wayfire-kill-view.xml b/proto/wayfire-kill-view.xml
index 4fe0c56..8274569 100644
--- a/proto/wayfire-kill-view.xml
+++ b/proto/wayfire-kill-view.xml
@@ -36,6 +36,12 @@
</description>
</request>
+ <request name="top_view_kill">
+ <description summary="send close to the top view">
+ Send close to the top view.
+ </description>
+ </request>
+
<event name="view_pid">
<description summary="Send view pid to a client">
Provide client with a view pid.
diff --git a/src/client/wf-kill.cpp b/src/client/wf-kill.cpp
index 762b7cf..01fe1e8 100644
--- a/src/client/wf-kill.cpp
+++ b/src/client/wf-kill.cpp
@@ -27,6 +27,7 @@
#include <string.h>
#include <sys/types.h>
#include <signal.h>
+#include <getopt.h>
#include "wf-kill.hpp"
@@ -113,11 +114,43 @@ WfKill::WfKill(int argc, char *argv[])
std::cout << "Wayfire kill view protocol not advertised by compositor. Is wf-kill plugin enabled?" << std::endl;
return;
}
- wf_kill_view_base_view_kill(wf_kill_view_manager);
wf_kill_view_base_add_listener(wf_kill_view_manager,
&kill_view_listener, this);
- send_kill = (argc > 1 && !strcmp(argv[1], "-k"));
+ send_kill = false;
+ top_view = false;
+ struct option opts[] = {
+ { "kill-view", no_argument, NULL, 'k' },
+ { "top-view", no_argument, NULL, 't' },
+ { 0, 0, NULL, 0 }
+ };
+
+ int c, i;
+ while((c = getopt_long(argc, argv, "kt", opts, &i)) != -1)
+ {
+ switch(c)
+ {
+ case 'k':
+ send_kill = true;
+ break;
+
+ case 't':
+ top_view = true;
+ break;
+
+ default:
+ std::cerr << "Usage: wf-kill [-k|--kill-view] [-t|--top-view]" << std::endl;
+ return;
+ }
+ }
+ if (top_view)
+ {
+ wf_kill_view_base_top_view_kill(wf_kill_view_manager);
+ } else
+ {
+ wf_kill_view_base_view_kill(wf_kill_view_manager);
+ }
+
running = 1;
while(running)
wl_display_dispatch(display);
diff --git a/src/client/wf-kill.hpp b/src/client/wf-kill.hpp
index 6065675..9b85064 100644
--- a/src/client/wf-kill.hpp
+++ b/src/client/wf-kill.hpp
@@ -35,6 +35,7 @@ class WfKill
int running;
int send_kill;
+ int top_view;
wl_display *display;
wf_kill_view_base *wf_kill_view_manager;
};
diff --git a/src/plugin/wayfire-kill-view.cpp b/src/plugin/wayfire-kill-view.cpp
index e338778..8753a26 100644
--- a/src/plugin/wayfire-kill-view.cpp
+++ b/src/plugin/wayfire-kill-view.cpp
@@ -29,6 +29,7 @@
#include <wayfire/plugin.hpp>
#include <wayfire/output.hpp>
#include <wayfire/output-layout.hpp>
+#include <wayfire/seat.hpp>
#include <wayfire/nonstd/wlroots-full.hpp>
#include <linux/input-event-codes.h>
@@ -43,13 +44,8 @@ wf::plugin_activation_data_t grab_interface{
static void bind_manager(wl_client *client, void *data,
uint32_t version, uint32_t id);
-void wf_kill_view::send_view_info()
+static pid_t get_pid_for_view(wayfire_view view)
{
- wayfire_view view = wf::get_core().get_cursor_focus_view();
- if (!view)
- {
- return;
- }
pid_t pid = 0;
wlr_surface *wlr_surface = view->get_wlr_surface();
#if WF_HAS_XWAYLAND
@@ -62,6 +58,18 @@ void wf_kill_view::send_view_info()
wl_client_get_credentials(view->get_client(), &pid, 0, 0);
}
+ return pid;
+}
+
+void wf_kill_view::send_view_info()
+{
+ wayfire_view view = wf::get_core().get_cursor_focus_view();
+ if (!view)
+ {
+ return;
+ }
+ pid_t pid = get_pid_for_view(view);
+
view->close();
for (auto r : client_resources)
@@ -72,7 +80,6 @@ void wf_kill_view::send_view_info()
void wf_kill_view::send_cancel()
{
-
for (auto r : client_resources)
{
wf_kill_view_base_send_cancel(r);
@@ -161,9 +168,28 @@ static void view_kill(struct wl_client *client, struct wl_resource *resource)
}
}
+static void top_view_kill(struct wl_client *client, struct wl_resource *resource)
+{
+ wf_kill_view *wd = (wf_kill_view*)wl_resource_get_user_data(resource);
+ auto view = wf::get_core().seat->get_active_view();
+ if (!view)
+ {
+ return;
+ }
+ pid_t pid = get_pid_for_view(view);
+
+ view->close();
+
+ for (auto r : wd->client_resources)
+ {
+ wf_kill_view_base_send_view_pid(r, pid);
+ }
+}
+
static const struct wf_kill_view_base_interface wf_kill_view_impl =
{
.view_kill = view_kill,
+ .top_view_kill = top_view_kill,
};
static void destroy_client(wl_resource *resource)
|