diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | include/sway/commands.h | 2 | ||||
| -rw-r--r-- | include/sway/config.h | 8 | ||||
| -rw-r--r-- | include/swaybar/i3bar.h | 2 | ||||
| -rw-r--r-- | sway/commands.c | 1 | ||||
| -rw-r--r-- | sway/commands/seat.c | 1 | ||||
| -rw-r--r-- | sway/commands/seat/pointer_constraint.c (renamed from sway/commands/pointer_constraint.c) | 23 | ||||
| -rw-r--r-- | sway/config/seat.c | 6 | ||||
| -rw-r--r-- | sway/input/cursor.c | 2 | ||||
| -rw-r--r-- | sway/meson.build | 2 | ||||
| -rw-r--r-- | sway/sway-bar.5.scd | 2 | ||||
| -rw-r--r-- | sway/sway-input.5.scd | 5 | ||||
| -rw-r--r-- | sway/sway.5.scd | 28 | ||||
| -rw-r--r-- | swaybar/i3bar.c | 3 | ||||
| -rw-r--r-- | swaybar/render.c | 6 | 
15 files changed, 65 insertions, 28 deletions
| @@ -40,7 +40,7 @@ Install dependencies:  * pango  * cairo  * gdk-pixbuf2 \*\* -* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) >= 1.8.0 (optional: man pages) \* +* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) >= 1.8.1 (optional: man pages) \*  * git \*  _\*Compile-time dep_ diff --git a/include/sway/commands.h b/include/sway/commands.h index 2877c370..3ed00763 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -153,7 +153,6 @@ sway_cmd cmd_new_window;  sway_cmd cmd_no_focus;  sway_cmd cmd_output;  sway_cmd cmd_permit; -sway_cmd cmd_pointer_constraint;  sway_cmd cmd_popup_during_fullscreen;  sway_cmd cmd_reject;  sway_cmd cmd_reload; @@ -268,6 +267,7 @@ sway_cmd seat_cmd_attach;  sway_cmd seat_cmd_cursor;  sway_cmd seat_cmd_fallback;  sway_cmd seat_cmd_hide_cursor; +sway_cmd seat_cmd_pointer_constraint;  sway_cmd cmd_ipc_cmd;  sway_cmd cmd_ipc_events; diff --git a/include/sway/config.h b/include/sway/config.h index e63b9895..43ea7778 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -135,6 +135,12 @@ struct seat_attachment_config {  	// TODO other things are configured here for some reason  }; +enum seat_config_allow_constrain { +	CONSTRAIN_DEFAULT,  // the default is currently enabled +	CONSTRAIN_ENABLE, +	CONSTRAIN_DISABLE +}; +  /**   * Options for multiseat and other misc device configurations   */ @@ -143,7 +149,7 @@ struct seat_config {  	int fallback; // -1 means not set  	list_t *attachments; // list of seat_attachment configs  	int hide_cursor_timeout; -	bool allow_constrain; +	enum seat_config_allow_constrain allow_constrain;  };  enum config_dpms { diff --git a/include/swaybar/i3bar.h b/include/swaybar/i3bar.h index aa4415ff..5b6001ce 100644 --- a/include/swaybar/i3bar.h +++ b/include/swaybar/i3bar.h @@ -7,7 +7,7 @@  struct i3bar_block {  	struct wl_list link; // status_link::blocks  	int ref_count; -	char *full_text, *short_text, *align; +	char *full_text, *short_text, *align, *min_width_str;  	bool urgent;  	uint32_t *color;  	int min_width; diff --git a/sway/commands.c b/sway/commands.c index 425897fb..dd994fa1 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -81,7 +81,6 @@ static struct cmd_handler handlers[] = {  	{ "no_focus", cmd_no_focus },  	{ "output", cmd_output },  	{ "popup_during_fullscreen", cmd_popup_during_fullscreen }, -	{ "pointer_constraint", cmd_pointer_constraint },  	{ "seat", cmd_seat },  	{ "set", cmd_set },  	{ "show_marks", cmd_show_marks }, diff --git a/sway/commands/seat.c b/sway/commands/seat.c index 69000b57..81bb5f5d 100644 --- a/sway/commands/seat.c +++ b/sway/commands/seat.c @@ -11,6 +11,7 @@ static struct cmd_handler seat_handlers[] = {  	{ "cursor", seat_cmd_cursor },  	{ "fallback", seat_cmd_fallback },  	{ "hide_cursor", seat_cmd_hide_cursor }, +	{ "pointer_constraint", seat_cmd_pointer_constraint },  };  struct cmd_results *cmd_seat(int argc, char **argv) { diff --git a/sway/commands/pointer_constraint.c b/sway/commands/seat/pointer_constraint.c index 2dda0776..3890ebde 100644 --- a/sway/commands/pointer_constraint.c +++ b/sway/commands/seat/pointer_constraint.c @@ -12,11 +12,14 @@ enum operation {  };  // pointer_constraint [enable|disable|escape] -struct cmd_results *cmd_pointer_constraint(int argc, char **argv) { +struct cmd_results *seat_cmd_pointer_constraint(int argc, char **argv) {  	struct cmd_results *error = NULL;  	if ((error = checkarg(argc, "pointer_constraint", EXPECTED_EQUAL_TO, 1))) {  		return error;  	} +	if (!config->handler_context.seat_config) { +		return cmd_results_new(CMD_FAILURE, "No seat defined"); +	}  	enum operation op;  	if (strcmp(argv[0], "enable") == 0) { @@ -33,19 +36,23 @@ struct cmd_results *cmd_pointer_constraint(int argc, char **argv) {  		return cmd_results_new(CMD_FAILURE, "Can only escape at runtime.");  	} -	struct sway_cursor *cursor = config->handler_context.seat->cursor; -	struct seat_config *seat_config = seat_get_config(cursor->seat); +	struct seat_config *seat_config = config->handler_context.seat_config;  	switch (op) {  	case OP_ENABLE: -		seat_config->allow_constrain = true; +		seat_config->allow_constrain = CONSTRAIN_ENABLE;  		break;  	case OP_DISABLE: -		seat_config->allow_constrain = false; +		seat_config->allow_constrain = CONSTRAIN_DISABLE;  		/* fallthrough */ -	case OP_ESCAPE: -		sway_cursor_constrain(cursor, NULL); +	case OP_ESCAPE:; +		bool wildcard = !strcmp(seat_config->name, "*"); +		struct sway_seat *seat = NULL; +		wl_list_for_each(seat, &server.input->seats, link) { +			if (wildcard || !strcmp(seat->wlr_seat->name, seat_config->name)) { +				sway_cursor_constrain(seat->cursor, NULL); +			} +		}  		break;  	} -  	return cmd_results_new(CMD_SUCCESS, NULL);  } diff --git a/sway/config/seat.c b/sway/config/seat.c index 541c4f99..04a44e3a 100644 --- a/sway/config/seat.c +++ b/sway/config/seat.c @@ -26,7 +26,7 @@ struct seat_config *new_seat_config(const char* name) {  		return NULL;  	}  	seat->hide_cursor_timeout = -1; -	seat->allow_constrain = true; +	seat->allow_constrain = CONSTRAIN_DEFAULT;  	return seat;  } @@ -143,6 +143,10 @@ void merge_seat_config(struct seat_config *dest, struct seat_config *source) {  	if (source->hide_cursor_timeout != -1) {  		dest->hide_cursor_timeout = source->hide_cursor_timeout;  	} + +	if (source->allow_constrain != CONSTRAIN_DEFAULT) { +		dest->allow_constrain = source->allow_constrain; +	}  }  struct seat_config *copy_seat_config(struct seat_config *seat) { diff --git a/sway/input/cursor.c b/sway/input/cursor.c index e8674490..c38d8d3a 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -1459,7 +1459,7 @@ void handle_pointer_constraint(struct wl_listener *listener, void *data) {  void sway_cursor_constrain(struct sway_cursor *cursor,  		struct wlr_pointer_constraint_v1 *constraint) {  	struct seat_config *config = seat_get_config(cursor->seat); -	if (!config->allow_constrain) { +	if (config->allow_constrain == CONSTRAIN_DISABLE) {  		return;  	} diff --git a/sway/meson.build b/sway/meson.build index b3837e21..293a4ed2 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -75,7 +75,6 @@ sway_sources = files(  	'commands/nop.c',  	'commands/output.c',  	'commands/popup_during_fullscreen.c', -	'commands/pointer_constraint.c',  	'commands/reload.c',  	'commands/rename.c',  	'commands/resize.c', @@ -85,6 +84,7 @@ sway_sources = files(  	'commands/seat/cursor.c',  	'commands/seat/fallback.c',  	'commands/seat/hide_cursor.c', +	'commands/seat/pointer_constraint.c',  	'commands/set.c',  	'commands/show_marks.c',  	'commands/smart_borders.c', diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd index 5c8b9417..13827e5e 100644 --- a/sway/sway-bar.5.scd +++ b/sway/sway-bar.5.scd @@ -18,7 +18,7 @@ Sway allows configuring swaybar in the sway configuration file.  	https://i3wm.org/docs/i3bar-protocol.html  	If running this command via IPC, you can disable a running status command by -	setting the command to a single dash: _swaybar bar bar-0 status_command -_ +	setting the command to a single dash: _swaybar bar bar-0 status\_command -_  *pango_markup* enabled|disabled  	Enables or disables pango markup for status lines. This has no effect on diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index 4b14ef14..88b4347a 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd @@ -172,6 +172,11 @@ in their own "seat").  	disables hiding the cursor. The minimal timeout is 100 and any value less  	than that (aside from 0), will be increased to 100. +*seat* <name> pointer_constraint enable|disable|escape +	Enables or disables the ability for clients to capture the cursor (enabled +	by default) for the seat. This is primarily useful for video games. The +	"escape" command can be used at runtime to escape from a captured client. +  # SEE ALSO  *sway*(5) *sway-output*(5) diff --git a/sway/sway.5.scd b/sway/sway.5.scd index e04c5fbf..fd0a22dc 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -72,7 +72,7 @@ The following commands may only be used in the configuration file.  	*sway-output*(5) for more information.  	It can be disabled by setting the command to a single dash: -	_swaybg_command -_ +	_swaybg\_command -_  *swaynag_command* <command>  	Executes custom command for _swaynag_. Default is _swaynag_. Additional @@ -82,7 +82,7 @@ The following commands may only be used in the configuration file.  	results.  	It can be disabled by setting the command to a single dash: -	_swaynag_command -_ +	_swaynag\_command -_  *xwayland* enable|disable  	Enables or disables Xwayland support, which allows X11 applications to be @@ -282,7 +282,7 @@ runtime.  		for_window <criteria> move container to output <output> -*bindsym* [--release|--locked] [--input-device=<device>] [--no-warn] <key combo> <command> +*bindsym* [--whole-window] [--border] [--exclude-titlebar] [--release] [--locked] [--input-device=<device>] [--no-warn] <key combo> <command>  	Binds _key combo_ to execute the sway command _command_ when pressed. You  	may use XKB key names here (*xev*(1) is a good tool for discovering these).  	With the flag _--release_, the command is executed when the key combo is @@ -294,11 +294,24 @@ runtime.  	the _--no-warn_ flag.  	Mouse buttons can either be specified in the form _button[1-9]_ or by using -	the name of the event code (ex _BTN_LEFT_ or _BTN_RIGHT_). For the former +	the name of the event code (ex _BTN\_LEFT_ or _BTN\_RIGHT_). For the former  	option, the buttons will be mapped to their values in X11 (1=left, 2=middle,  	3=right, 4=scroll up, 5=scroll down, 6=scroll left, 7=scroll right, 8=back,  	9=forward). For the latter option, you can find the event names using  	_libinput debug-events_. +	 +	_--whole-window_, _--border_, and _--exclude-titlebar_ are mouse-only options +	which affect the region in which the mouse bindings can be triggered.  By +	default, mouse bindings are only triggered when over the title bar. With the +	_--border_ option, the border of the window will be included in this region. +	With the _--whole-window_ option, the cursor can be anywhere over a window +	including the title, border, and content. _--exclude-titlebar_ can be used in +	conjunction with any other option to specify that the titlebar should be +	excluded from the region of consideration. + +	There is currently, however, no way to execute a mouse binding over a layer +	surface (which includes the background of an empty workspace). This behaviour +	is carried over from i3.  	Example:  ``` @@ -306,7 +319,7 @@ runtime.  		bindsym Mod1+Shift+f exec firefox  ``` -	*bindcode* [--release|--locked] [--input-device=<device>] [--no-warn] <code> <command> +	*bindcode* [--whole-window] [--border] [--exclude-titlebar] [--release] [--locked] [--input-device=<device>] [--no-warn] <code> <command>  	is also available for binding with key/button codes instead of key/button names.  *client.<class>* <border> <background> <text> <indicator> <child_border> @@ -539,11 +552,6 @@ The default colors are:  	\* may be used in lieu of a specific output name to configure all outputs.  	A list of output names may be obtained via *swaymsg -t get_outputs*. -*pointer_constraint* enable|disable|escape -	Enables or disables the ability for clients to capture the cursor (enabled -	by default). This is primarily useful for video games. The "escape" command -	can be used at runtime to escape from a captured client. -  *popup_during_fullscreen* smart|ignore|leave_fullscreen  	Determines what to do when a fullscreen view opens a dialog.  	If _smart_ (the default), the dialog will be displayed. If _ignore_, the diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c index da93a132..43e2fe2d 100644 --- a/swaybar/i3bar.c +++ b/swaybar/i3bar.c @@ -21,6 +21,7 @@ void i3bar_block_unref(struct i3bar_block *block) {  		free(block->full_text);  		free(block->short_text);  		free(block->align); +		free(block->min_width_str);  		free(block->name);  		free(block->instance);  		free(block->color); @@ -78,7 +79,7 @@ static void i3bar_parse_json(struct status_line *status,  				block->min_width = json_object_get_int(min_width);  			} else if (type == json_type_string) {  				/* the width will be calculated when rendering */ -				block->min_width = 0; +				block->min_width_str = strdup(json_object_get_string(min_width));  			}  		}  		block->align = strdup(align ? json_object_get_string(align) : "left"); diff --git a/swaybar/render.c b/swaybar/render.c index e27f7d4c..116cc595 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -159,6 +159,12 @@ static uint32_t render_status_block(cairo_t *cairo,  	double ws_vertical_padding = config->status_padding * output->scale;  	int width = text_width; +	if (block->min_width_str) { +		int w; +		get_text_size(cairo, config->font, &w, NULL, NULL, +				output->scale, block->markup, "%s", block->min_width_str); +		block->min_width = w; +	}  	if (width < block->min_width) {  		width = block->min_width;  	} | 
