diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 50 |
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 @@ | |||
21 | #include "sway/criteria.h" | 21 | #include "sway/criteria.h" |
22 | #include "sway/ipc-server.h" | 22 | #include "sway/ipc-server.h" |
23 | #include "sway/input.h" | 23 | #include "sway/input.h" |
24 | #include "sway/security.h" | ||
24 | #include "list.h" | 25 | #include "list.h" |
25 | #include "stringop.h" | 26 | #include "stringop.h" |
26 | #include "log.h" | 27 | #include "log.h" |
@@ -385,7 +386,7 @@ static bool handle_view_created(wlc_handle handle) { | |||
385 | struct criteria *crit = criteria->items[i]; | 386 | struct criteria *crit = criteria->items[i]; |
386 | sway_log(L_DEBUG, "for_window '%s' matches new view %p, cmd: '%s'", | 387 | sway_log(L_DEBUG, "for_window '%s' matches new view %p, cmd: '%s'", |
387 | crit->crit_raw, newview, crit->cmdlist); | 388 | crit->crit_raw, newview, crit->cmdlist); |
388 | struct cmd_results *res = handle_command(crit->cmdlist); | 389 | struct cmd_results *res = handle_command(crit->cmdlist, CONTEXT_CRITERIA); |
389 | if (res->status != CMD_SUCCESS) { | 390 | if (res->status != CMD_SUCCESS) { |
390 | sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error); | 391 | sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error); |
391 | } | 392 | } |
@@ -516,8 +517,13 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo | |||
516 | 517 | ||
517 | static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) { | 518 | static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) { |
518 | swayc_t *c = swayc_by_handle(view); | 519 | swayc_t *c = swayc_by_handle(view); |
520 | pid_t pid = wlc_view_get_pid(view); | ||
519 | switch (state) { | 521 | switch (state) { |
520 | case WLC_BIT_FULLSCREEN: | 522 | case WLC_BIT_FULLSCREEN: |
523 | if (!(get_feature_policy(pid) & FEATURE_FULLSCREEN)) { | ||
524 | sway_log(L_INFO, "Denying fullscreen to %d (%s)", pid, c->name); | ||
525 | break; | ||
526 | } | ||
521 | // i3 just lets it become fullscreen | 527 | // i3 just lets it become fullscreen |
522 | wlc_view_set_state(view, state, toggle); | 528 | wlc_view_set_state(view, state, toggle); |
523 | if (c) { | 529 | if (c) { |
@@ -579,7 +585,7 @@ static void handle_binding_command(struct sway_binding *binding) { | |||
579 | reload = true; | 585 | reload = true; |
580 | } | 586 | } |
581 | 587 | ||
582 | struct cmd_results *res = handle_command(binding->command); | 588 | struct cmd_results *res = handle_command(binding->command, CONTEXT_BINDING); |
583 | if (res->status != CMD_SUCCESS) { | 589 | if (res->status != CMD_SUCCESS) { |
584 | sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error); | 590 | sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error); |
585 | } | 591 | } |
@@ -719,6 +725,14 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
719 | } | 725 | } |
720 | 726 | ||
721 | list_free(candidates); | 727 | list_free(candidates); |
728 | |||
729 | swayc_t *focused = get_focused_container(&root_container); | ||
730 | if (focused->type == C_VIEW) { | ||
731 | pid_t pid = wlc_view_get_pid(focused->handle); | ||
732 | if (!(get_feature_policy(pid) & FEATURE_KEYBOARD)) { | ||
733 | return EVENT_HANDLED; | ||
734 | } | ||
735 | } | ||
722 | return EVENT_PASSTHROUGH; | 736 | return EVENT_PASSTHROUGH; |
723 | } | 737 | } |
724 | 738 | ||
@@ -775,6 +789,15 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
775 | } | 789 | } |
776 | 790 | ||
777 | pointer_position_set(&new_origin, false); | 791 | pointer_position_set(&new_origin, false); |
792 | |||
793 | swayc_t *focused = get_focused_container(&root_container); | ||
794 | if (focused->type == C_VIEW) { | ||
795 | pid_t pid = wlc_view_get_pid(focused->handle); | ||
796 | if (!(get_feature_policy(pid) & FEATURE_MOUSE)) { | ||
797 | return EVENT_HANDLED; | ||
798 | } | ||
799 | } | ||
800 | |||
778 | return EVENT_PASSTHROUGH; | 801 | return EVENT_PASSTHROUGH; |
779 | } | 802 | } |
780 | 803 | ||
@@ -842,6 +865,12 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
842 | 865 | ||
843 | // don't change focus or mode if fullscreen | 866 | // don't change focus or mode if fullscreen |
844 | if (swayc_is_fullscreen(focused)) { | 867 | if (swayc_is_fullscreen(focused)) { |
868 | if (focused->type == C_VIEW) { | ||
869 | pid_t pid = wlc_view_get_pid(focused->handle); | ||
870 | if (!(get_feature_policy(pid) & FEATURE_MOUSE)) { | ||
871 | return EVENT_HANDLED; | ||
872 | } | ||
873 | } | ||
845 | return EVENT_PASSTHROUGH; | 874 | return EVENT_PASSTHROUGH; |
846 | } | 875 | } |
847 | 876 | ||
@@ -884,6 +913,13 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
884 | return EVENT_HANDLED; | 913 | return EVENT_HANDLED; |
885 | } | 914 | } |
886 | 915 | ||
916 | if (focused->type == C_VIEW) { | ||
917 | pid_t pid = wlc_view_get_pid(focused->handle); | ||
918 | if (!(get_feature_policy(pid) & FEATURE_MOUSE)) { | ||
919 | return EVENT_HANDLED; | ||
920 | } | ||
921 | } | ||
922 | |||
887 | // Always send mouse release | 923 | // Always send mouse release |
888 | if (state == WLC_BUTTON_STATE_RELEASED) { | 924 | if (state == WLC_BUTTON_STATE_RELEASED) { |
889 | return EVENT_PASSTHROUGH; | 925 | return EVENT_PASSTHROUGH; |
@@ -900,18 +936,18 @@ bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modi | |||
900 | int y_amount = (int)_amount[1]; | 936 | int y_amount = (int)_amount[1]; |
901 | 937 | ||
902 | if (x_amount > 0 && strcmp(config->floating_scroll_up_cmd, "")) { | 938 | if (x_amount > 0 && strcmp(config->floating_scroll_up_cmd, "")) { |
903 | handle_command(config->floating_scroll_up_cmd); | 939 | handle_command(config->floating_scroll_up_cmd, CONTEXT_BINDING); |
904 | return EVENT_HANDLED; | 940 | return EVENT_HANDLED; |
905 | } else if (x_amount < 0 && strcmp(config->floating_scroll_down_cmd, "")) { | 941 | } else if (x_amount < 0 && strcmp(config->floating_scroll_down_cmd, "")) { |
906 | handle_command(config->floating_scroll_down_cmd); | 942 | handle_command(config->floating_scroll_down_cmd, CONTEXT_BINDING); |
907 | return EVENT_HANDLED; | 943 | return EVENT_HANDLED; |
908 | } | 944 | } |
909 | 945 | ||
910 | if (y_amount > 0 && strcmp(config->floating_scroll_right_cmd, "")) { | 946 | if (y_amount > 0 && strcmp(config->floating_scroll_right_cmd, "")) { |
911 | handle_command(config->floating_scroll_right_cmd); | 947 | handle_command(config->floating_scroll_right_cmd, CONTEXT_BINDING); |
912 | return EVENT_HANDLED; | 948 | return EVENT_HANDLED; |
913 | } else if (y_amount < 0 && strcmp(config->floating_scroll_left_cmd, "")) { | 949 | } else if (y_amount < 0 && strcmp(config->floating_scroll_left_cmd, "")) { |
914 | handle_command(config->floating_scroll_left_cmd); | 950 | handle_command(config->floating_scroll_left_cmd, CONTEXT_BINDING); |
915 | return EVENT_HANDLED; | 951 | return EVENT_HANDLED; |
916 | } | 952 | } |
917 | } | 953 | } |
@@ -924,7 +960,7 @@ static void handle_wlc_ready(void) { | |||
924 | config->active = true; | 960 | config->active = true; |
925 | while (config->cmd_queue->length) { | 961 | while (config->cmd_queue->length) { |
926 | char *line = config->cmd_queue->items[0]; | 962 | char *line = config->cmd_queue->items[0]; |
927 | struct cmd_results *res = handle_command(line); | 963 | struct cmd_results *res = handle_command(line, CONTEXT_CONFIG); |
928 | if (res->status != CMD_SUCCESS) { | 964 | if (res->status != CMD_SUCCESS) { |
929 | sway_log(L_ERROR, "Error on line '%s': %s", line, res->error); | 965 | sway_log(L_ERROR, "Error on line '%s': %s", line, res->error); |
930 | } | 966 | } |