mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	add cursor configuration
This commit is contained in:
		
							parent
							
								
									b3a43e2261
								
							
						
					
					
						commit
						699d489f93
					
				
					 4 changed files with 29 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -67,6 +67,12 @@ static int config_ini_handler(void *user, const char *section, const char *name,
 | 
			
		|||
				wlr_log(L_ERROR, "got unknown transform value: %s", value);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	} else if (strcmp(section, "cursor") == 0) {
 | 
			
		||||
		if (strcmp(name, "map-to-output") == 0) {
 | 
			
		||||
			config->cursor.mapped_output = strdup(value);
 | 
			
		||||
		} else {
 | 
			
		||||
			wlr_log(L_ERROR, "got unknown cursor config: %s", name);
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		wlr_log(L_ERROR, "got unknown config section: %s", section);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -128,6 +134,9 @@ void example_config_destroy(struct example_config *config) {
 | 
			
		|||
	if (config->config_path) {
 | 
			
		||||
		free(config->config_path);
 | 
			
		||||
	}
 | 
			
		||||
	if (config->cursor.mapped_output) {
 | 
			
		||||
		free(config->cursor.mapped_output);
 | 
			
		||||
	}
 | 
			
		||||
	free(config);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,10 @@ struct output_config {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
struct example_config {
 | 
			
		||||
	struct {
 | 
			
		||||
		char *mapped_output;
 | 
			
		||||
	} cursor;
 | 
			
		||||
 | 
			
		||||
	struct wl_list outputs;
 | 
			
		||||
	char *config_path;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,6 +70,11 @@ static void handle_output_add(struct output_state *ostate) {
 | 
			
		|||
	sample->layout = configure_layout(sample->config, &ostate->compositor->outputs);
 | 
			
		||||
	wlr_cursor_attach_output_layout(sample->cursor, sample->layout);
 | 
			
		||||
 | 
			
		||||
	char *mapped_output = sample->config->cursor.mapped_output;
 | 
			
		||||
	if (mapped_output && strcmp(mapped_output, wlr_output->name) == 0) {
 | 
			
		||||
		wlr_cursor_map_to_output(sample->cursor, wlr_output);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	// TODO configuration
 | 
			
		||||
	if (strcmp("DP-1", ostate->output->name) == 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -95,6 +100,10 @@ static void handle_output_remove(struct output_state *ostate) {
 | 
			
		|||
	wlr_output_layout_destroy(sample->layout);
 | 
			
		||||
	sample->layout = configure_layout(sample->config, &ostate->compositor->outputs);
 | 
			
		||||
	wlr_cursor_attach_output_layout(sample->cursor, sample->layout);
 | 
			
		||||
 | 
			
		||||
	if (strcmp(sample->config->cursor.mapped_output, ostate->output->name) == 0) {
 | 
			
		||||
		wlr_cursor_map_to_output(sample->cursor, NULL);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_output_resolution(struct compositor_state *state,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,4 +30,11 @@ rotate=270
 | 
			
		|||
x=1080
 | 
			
		||||
y=232
 | 
			
		||||
 | 
			
		||||
# Cursor Configuration
 | 
			
		||||
# ~~~~~~~~~~~~~~~~~~~~
 | 
			
		||||
# Value "map-to-output" specifies the output to which the cursor is
 | 
			
		||||
# constrained.
 | 
			
		||||
[cursor]
 | 
			
		||||
map-to-output=HDMI-A-1
 | 
			
		||||
 | 
			
		||||
# vim:filetype=dosini
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue