Do not VTs switch, block tty access

This commit is contained in:
Tuyen Pham 2021-07-07 16:37:15 +00:00
parent 4832fc937f
commit 8a56b699ad
8 changed files with 41 additions and 2 deletions

View file

@ -104,6 +104,7 @@ sway_cmd cmd_exec_validate;
sway_cmd cmd_exec_process; sway_cmd cmd_exec_process;
sway_cmd cmd_assign; sway_cmd cmd_assign;
sway_cmd cmd_ttyaccess;
sway_cmd cmd_bar; sway_cmd cmd_bar;
sway_cmd cmd_bindcode; sway_cmd cmd_bindcode;
sway_cmd cmd_bindswitch; sway_cmd cmd_bindswitch;

View file

@ -506,6 +506,7 @@ struct sway_config {
enum focus_follows_mouse_mode focus_follows_mouse; enum focus_follows_mouse_mode focus_follows_mouse;
enum mouse_warping_mode mouse_warping; enum mouse_warping_mode mouse_warping;
enum focus_wrapping_mode focus_wrapping; enum focus_wrapping_mode focus_wrapping;
bool ttyaccess;
bool active; bool active;
bool failed; bool failed;
bool reloading; bool reloading;

View file

@ -44,6 +44,7 @@ struct cmd_results *checkarg(int argc, const char *name, enum expected_args type
/* Keep alphabetized */ /* Keep alphabetized */
static const struct cmd_handler handlers[] = { static const struct cmd_handler handlers[] = {
{ "assign", cmd_assign }, { "assign", cmd_assign },
{ "ttyaccess", cmd_ttyaccess },
{ "bar", cmd_bar }, { "bar", cmd_bar },
{ "bindcode", cmd_bindcode }, { "bindcode", cmd_bindcode },
{ "bindswitch", cmd_bindswitch }, { "bindswitch", cmd_bindswitch },

23
sway/commands/ttyaccess.c Normal file
View file

@ -0,0 +1,23 @@
#include <string.h>
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/tree/arrange.h"
#include "sway/tree/view.h"
#include "sway/tree/container.h"
#include "log.h"
#include "stringop.h"
#include "util.h"
struct cmd_results *cmd_no_titlebars(int argc, char **argv) {
struct cmd_results *error = checkarg(argc, "ttyaccess", EXPECTED_EQUAL_TO, 1);
if (error) {
return error;
}
config->ttyaccess = parse_boolean(argv[0], config->ttyaccess);
arrange_root();
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -254,6 +254,7 @@ static void config_defaults(struct sway_config *config) {
// Flags // Flags
config->focus_follows_mouse = FOLLOWS_YES; config->focus_follows_mouse = FOLLOWS_YES;
config->ttyaccess = false;
config->mouse_warping = WARP_OUTPUT; config->mouse_warping = WARP_OUTPUT;
config->focus_wrapping = WRAP_YES; config->focus_wrapping = WRAP_YES;
config->validating = false; config->validating = false;

View file

@ -500,14 +500,22 @@ static void handle_key_event(struct sway_keyboard *keyboard,
// Compositor bindings // Compositor bindings
if (!handled && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) { if (!handled && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
if (config->ttyaccess) {
return;
} else {
handled = keyboard_execute_compositor_binding( handled = keyboard_execute_compositor_binding(
keyboard, keyinfo.translated_keysyms, keyboard, keyinfo.translated_keysyms,
keyinfo.translated_modifiers, keyinfo.translated_keysyms_len); keyinfo.translated_modifiers, keyinfo.translated_keysyms_len);
}
} }
if (!handled && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) { if (!handled && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
if (config->ttyaccess) {
return;
} else {
handled = keyboard_execute_compositor_binding( handled = keyboard_execute_compositor_binding(
keyboard, keyinfo.raw_keysyms, keyinfo.raw_modifiers, keyboard, keyinfo.raw_keysyms, keyinfo.raw_modifiers,
keyinfo.raw_keysyms_len); keyinfo.raw_keysyms_len);
}
} }
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) { if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
@ -970,10 +978,10 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) {
wl_signal_add(&sway_group->wlr_group->keyboard.events.modifiers, wl_signal_add(&sway_group->wlr_group->keyboard.events.modifiers,
&sway_group->keyboard_modifiers); &sway_group->keyboard_modifiers);
sway_group->keyboard_modifiers.notify = handle_keyboard_group_modifiers; sway_group->keyboard_modifiers.notify = handle_keyboard_group_modifiers;
wl_signal_add(&sway_group->wlr_group->events.enter, &sway_group->enter); wl_signal_add(&sway_group->wlr_group->events.enter, &sway_group->enter);
sway_group->enter.notify = handle_keyboard_group_enter; sway_group->enter.notify = handle_keyboard_group_enter;
wl_signal_add(&sway_group->wlr_group->events.leave, &sway_group->leave); wl_signal_add(&sway_group->wlr_group->events.leave, &sway_group->leave);
sway_group->leave.notify = handle_keyboard_group_leave; sway_group->leave.notify = handle_keyboard_group_leave;
return; return;

View file

@ -41,6 +41,7 @@ sway_sources = files(
'config/input.c', 'config/input.c',
'commands/assign.c', 'commands/assign.c',
'commands/ttyaccess.c',
'commands/bar.c', 'commands/bar.c',
'commands/bind.c', 'commands/bind.c',
'commands/border.c', 'commands/border.c',

View file

@ -154,6 +154,9 @@ They are expected to be used with *bindsym* or at runtime through *swaymsg*(1).
is now. If no argument is given, it does the same as _toggle_. If _global_ is now. If no argument is given, it does the same as _toggle_. If _global_
is specified, the view will be fullscreen across all outputs. is specified, the view will be fullscreen across all outputs.
*ttyaccess* enable|disable
Do not switch VTs, block tty access.
*gaps* inner|outer|horizontal|vertical|top|right|bottom|left all|current *gaps* inner|outer|horizontal|vertical|top|right|bottom|left all|current
set|plus|minus <amount> set|plus|minus <amount>
Changes the _inner_ or _outer_ gaps for either _all_ workspaces or the Changes the _inner_ or _outer_ gaps for either _all_ workspaces or the