aboutsummaryrefslogtreecommitdiff
path: root/sway/handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c50
1 files changed, 43 insertions, 7 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 2235bc8b..ee52ba38 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -21,6 +21,7 @@
#include "sway/criteria.h"
#include "sway/ipc-server.h"
#include "sway/input.h"
+#include "sway/security.h"
#include "list.h"
#include "stringop.h"
#include "log.h"
@@ -385,7 +386,7 @@ static bool handle_view_created(wlc_handle handle) {
struct criteria *crit = criteria->items[i];
sway_log(L_DEBUG, "for_window '%s' matches new view %p, cmd: '%s'",
crit->crit_raw, newview, crit->cmdlist);
- struct cmd_results *res = handle_command(crit->cmdlist);
+ struct cmd_results *res = handle_command(crit->cmdlist, CONTEXT_CRITERIA);
if (res->status != CMD_SUCCESS) {
sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error);
}
@@ -516,8 +517,13 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo
static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) {
swayc_t *c = swayc_by_handle(view);
+ pid_t pid = wlc_view_get_pid(view);
switch (state) {
case WLC_BIT_FULLSCREEN:
+ if (!(get_feature_policy(pid) & FEATURE_FULLSCREEN)) {
+ sway_log(L_INFO, "Denying fullscreen to %d (%s)", pid, c->name);
+ break;
+ }
// i3 just lets it become fullscreen
wlc_view_set_state(view, state, toggle);
if (c) {
@@ -579,7 +585,7 @@ static void handle_binding_command(struct sway_binding *binding) {
reload = true;
}
- struct cmd_results *res = handle_command(binding->command);
+ struct cmd_results *res = handle_command(binding->command, CONTEXT_BINDING);
if (res->status != CMD_SUCCESS) {
sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error);
}
@@ -719,6 +725,14 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
}
list_free(candidates);
+
+ swayc_t *focused = get_focused_container(&root_container);
+ if (focused->type == C_VIEW) {
+ pid_t pid = wlc_view_get_pid(focused->handle);
+ if (!(get_feature_policy(pid) & FEATURE_KEYBOARD)) {
+ return EVENT_HANDLED;
+ }
+ }
return EVENT_PASSTHROUGH;
}
@@ -775,6 +789,15 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
}
pointer_position_set(&new_origin, false);
+
+ swayc_t *focused = get_focused_container(&root_container);
+ if (focused->type == C_VIEW) {
+ pid_t pid = wlc_view_get_pid(focused->handle);
+ if (!(get_feature_policy(pid) & FEATURE_MOUSE)) {
+ return EVENT_HANDLED;
+ }
+ }
+
return EVENT_PASSTHROUGH;
}
@@ -842,6 +865,12 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
// don't change focus or mode if fullscreen
if (swayc_is_fullscreen(focused)) {
+ if (focused->type == C_VIEW) {
+ pid_t pid = wlc_view_get_pid(focused->handle);
+ if (!(get_feature_policy(pid) & FEATURE_MOUSE)) {
+ return EVENT_HANDLED;
+ }
+ }
return EVENT_PASSTHROUGH;
}
@@ -884,6 +913,13 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
return EVENT_HANDLED;
}
+ if (focused->type == C_VIEW) {
+ pid_t pid = wlc_view_get_pid(focused->handle);
+ if (!(get_feature_policy(pid) & FEATURE_MOUSE)) {
+ return EVENT_HANDLED;
+ }
+ }
+
// Always send mouse release
if (state == WLC_BUTTON_STATE_RELEASED) {
return EVENT_PASSTHROUGH;
@@ -900,18 +936,18 @@ bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modi
int y_amount = (int)_amount[1];
if (x_amount > 0 && strcmp(config->floating_scroll_up_cmd, "")) {
- handle_command(config->floating_scroll_up_cmd);
+ handle_command(config->floating_scroll_up_cmd, CONTEXT_BINDING);
return EVENT_HANDLED;
} else if (x_amount < 0 && strcmp(config->floating_scroll_down_cmd, "")) {
- handle_command(config->floating_scroll_down_cmd);
+ handle_command(config->floating_scroll_down_cmd, CONTEXT_BINDING);
return EVENT_HANDLED;
}
if (y_amount > 0 && strcmp(config->floating_scroll_right_cmd, "")) {
- handle_command(config->floating_scroll_right_cmd);
+ handle_command(config->floating_scroll_right_cmd, CONTEXT_BINDING);
return EVENT_HANDLED;
} else if (y_amount < 0 && strcmp(config->floating_scroll_left_cmd, "")) {
- handle_command(config->floating_scroll_left_cmd);
+ handle_command(config->floating_scroll_left_cmd, CONTEXT_BINDING);
return EVENT_HANDLED;
}
}
@@ -924,7 +960,7 @@ static void handle_wlc_ready(void) {
config->active = true;
while (config->cmd_queue->length) {
char *line = config->cmd_queue->items[0];
- struct cmd_results *res = handle_command(line);
+ struct cmd_results *res = handle_command(line, CONTEXT_CONFIG);
if (res->status != CMD_SUCCESS) {
sway_log(L_ERROR, "Error on line '%s': %s", line, res->error);
}