mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Added in glitchy disabling
This commit is contained in:
		
							parent
							
								
									e232241466
								
							
						
					
					
						commit
						98fad060e2
					
				
					 4 changed files with 21 additions and 0 deletions
				
			
		| 
						 | 
					@ -24,6 +24,7 @@ struct sway_mode {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct output_config {
 | 
					struct output_config {
 | 
				
			||||||
	char *name;
 | 
						char *name;
 | 
				
			||||||
 | 
					    bool enabled;
 | 
				
			||||||
	int width, height;
 | 
						int width, height;
 | 
				
			||||||
	int x, y;
 | 
						int x, y;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -372,9 +372,14 @@ static bool cmd_output(struct sway_config *config, int argc, char **argv) {
 | 
				
			||||||
	struct output_config *output = calloc(1, sizeof(struct output_config));
 | 
						struct output_config *output = calloc(1, sizeof(struct output_config));
 | 
				
			||||||
	output->x = output->y = output->width = output->height = -1;
 | 
						output->x = output->y = output->width = output->height = -1;
 | 
				
			||||||
	output->name = strdup(argv[0]);
 | 
						output->name = strdup(argv[0]);
 | 
				
			||||||
 | 
					    output->enabled = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO: atoi doesn't handle invalid numbers
 | 
						// TODO: atoi doesn't handle invalid numbers
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    if (strcmp(argv[1], "disable") == 0) {
 | 
				
			||||||
 | 
					        output->enabled = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	for (i = 1; i < argc; ++i) {
 | 
						for (i = 1; i < argc; ++i) {
 | 
				
			||||||
		if (strcasecmp(argv[i], "resolution") == 0 || strcasecmp(argv[i], "res") == 0) {
 | 
							if (strcasecmp(argv[i], "resolution") == 0 || strcasecmp(argv[i], "res") == 0) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,6 +70,10 @@ swayc_t *new_output(wlc_handle handle) {
 | 
				
			||||||
		oc = NULL;
 | 
							oc = NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (oc && !oc->enabled) {
 | 
				
			||||||
 | 
					        return NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	swayc_t *output = new_swayc(C_OUTPUT);
 | 
						swayc_t *output = new_swayc(C_OUTPUT);
 | 
				
			||||||
	if (oc && oc->width != -1 && oc->height != -1) {
 | 
						if (oc && oc->width != -1 && oc->height != -1) {
 | 
				
			||||||
		output->width = oc->width;
 | 
							output->width = oc->width;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,11 +86,22 @@ swayc_t *container_under_pointer(void) {
 | 
				
			||||||
static bool handle_output_created(wlc_handle output) {
 | 
					static bool handle_output_created(wlc_handle output) {
 | 
				
			||||||
	swayc_t *op = new_output(output);
 | 
						swayc_t *op = new_output(output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!op) {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        wlc_output_focus(output);
 | 
				
			||||||
	// Switch to workspace if we need to
 | 
						// Switch to workspace if we need to
 | 
				
			||||||
	if (swayc_active_workspace() == NULL) {
 | 
						if (swayc_active_workspace() == NULL) {
 | 
				
			||||||
 | 
					        sway_log(L_INFO, "Focus switch");
 | 
				
			||||||
		swayc_t *ws = op->children->items[0];
 | 
							swayc_t *ws = op->children->items[0];
 | 
				
			||||||
		workspace_switch(ws);
 | 
							workspace_switch(ws);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					    if (wlc_output_get_sleep(wlc_get_focused_output())) {
 | 
				
			||||||
 | 
					        wlc_output_focus(output);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue