mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-08 13:29:45 -05:00
implement output layout auto configuration
This commit is contained in:
parent
e91c91d455
commit
40bd6bcc43
6 changed files with 156 additions and 89 deletions
|
|
@ -255,49 +255,14 @@ void example_config_destroy(struct example_config *config) {
|
|||
free(config);
|
||||
}
|
||||
|
||||
struct wlr_output_layout *configure_layout(struct example_config *config,
|
||||
struct wl_list *outputs) {
|
||||
struct wlr_output_layout *layout = wlr_output_layout_init();
|
||||
int max_x = INT_MIN;
|
||||
int max_x_y = INT_MIN; // y value for the max_x output
|
||||
|
||||
// first add all the configured outputs
|
||||
struct output_state *output;
|
||||
wl_list_for_each(output, outputs, link) {
|
||||
struct output_config *conf;
|
||||
wl_list_for_each(conf, &config->outputs, link) {
|
||||
if (strcmp(conf->name, output->output->name) == 0) {
|
||||
wlr_output_layout_add(layout, output->output,
|
||||
conf->x, conf->y);
|
||||
wlr_output_transform(output->output, conf->transform);
|
||||
int width, height;
|
||||
wlr_output_effective_resolution(output->output, &width,
|
||||
&height);
|
||||
if (conf->x + width > max_x) {
|
||||
max_x = conf->x + width;
|
||||
max_x_y = conf->y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
struct output_config *example_config_get_output(struct example_config *config,
|
||||
struct wlr_output *output) {
|
||||
struct output_config *o_config;
|
||||
wl_list_for_each(o_config, &config->outputs, link) {
|
||||
if (strcmp(o_config->name, output->name) == 0) {
|
||||
return o_config;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_x == INT_MIN) {
|
||||
// couldn't find a configured output
|
||||
max_x = 0;
|
||||
max_x_y = 0;
|
||||
}
|
||||
|
||||
// now add all the other configured outputs in a sensible position
|
||||
wl_list_for_each(output, outputs, link) {
|
||||
if (wlr_output_layout_get(layout, output->output)) {
|
||||
continue;
|
||||
}
|
||||
wlr_output_layout_add(layout, output->output, max_x, max_x_y);
|
||||
int width, height;
|
||||
wlr_output_effective_resolution(output->output, &width, &height);
|
||||
max_x += width;
|
||||
}
|
||||
|
||||
return layout;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue