command/send-to-output: add -current-tags flag
This commit is contained in:
		
				
					committed by
					
						 Isaac Freund
						Isaac Freund
					
				
			
			
				
	
			
			
			
						parent
						
							e207a0e03a
						
					
				
				
					commit
					b369815070
				
			| @ -50,10 +50,13 @@ over the Wayland protocol. | ||||
| 	Snap the focused view to the specified screen edge. The view will | ||||
| 	be set to floating. | ||||
|  | ||||
| *send-to-output* *next*|*previous*|*up*|*right*|*down*|*left*|_name_ | ||||
| *send-to-output* [*-current-tags*] *next*|*previous*|*up*|*right*|*down*|*left*|_name_ | ||||
| 	Send the focused view to the next or previous output, the closest | ||||
| 	output in any direction or to an output by name. | ||||
|  | ||||
| 	- *-current-tags*: Assign the currently focused tags of the destination | ||||
| 	  output to the view. | ||||
|  | ||||
| *spawn* _shell_command_ | ||||
| 	Run _shell_command_ using `/bin/sh -c _shell_command_`. Note that | ||||
| 	*spawn* only takes a single argument. To spawn a command taking | ||||
|  | ||||
| @ -17,8 +17,8 @@ | ||||
| const std = @import("std"); | ||||
| const assert = std.debug.assert; | ||||
| const mem = std.mem; | ||||
|  | ||||
| const wlr = @import("wlroots"); | ||||
| const flags = @import("flags"); | ||||
|  | ||||
| const server = &@import("../main.zig").server; | ||||
|  | ||||
| @ -52,7 +52,13 @@ pub fn sendToOutput( | ||||
|     _: *?[]const u8, | ||||
| ) Error!void { | ||||
|     if (args.len < 2) return Error.NotEnoughArguments; | ||||
|     if (args.len > 2) return Error.TooManyArguments; | ||||
|     const result = flags.parser([:0]const u8, &.{ | ||||
|         .{ .name = "current-tags", .kind = .boolean }, | ||||
|     }).parse(args[1..]) catch { | ||||
|         return error.InvalidOption; | ||||
|     }; | ||||
|     if (result.args.len < 1) return Error.NotEnoughArguments; | ||||
|     if (result.args.len > 1) return Error.TooManyArguments; | ||||
|  | ||||
|     // If the noop output is focused, there is nowhere to send the view | ||||
|     if (seat.focused_output == null) { | ||||
| @ -61,10 +67,15 @@ pub fn sendToOutput( | ||||
|     } | ||||
|  | ||||
|     if (seat.focused == .view) { | ||||
|         const destination_output = (try getOutput(seat, args[1])) orelse return; | ||||
|         const destination_output = (try getOutput(seat, result.args[0])) orelse return; | ||||
|  | ||||
|         // If the view is already on destination_output, do nothing | ||||
|         if (seat.focused.view.pending.output == destination_output) return; | ||||
|  | ||||
|         if (result.flags.@"current-tags") { | ||||
|             seat.focused.view.pending.tags = destination_output.pending.tags; | ||||
|         } | ||||
|  | ||||
|         seat.focused.view.setPendingOutput(destination_output); | ||||
|  | ||||
|         server.root.applyPending(); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user