aboutsummaryrefslogtreecommitdiff
path: root/examples/config.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-09-01 03:47:25 -0500
committerGitHub <noreply@github.com>2017-09-01 03:47:25 -0500
commit252a1b9c13e21ca6647233c7023251a2050c32bf (patch)
tree8ab4dc5e9a7768723f2cceac8f763ea203aa8a1d /examples/config.c
parente91c91d45544d7bd435e7628dcafaa346c5310b9 (diff)
parent6d26fda57c4b8345e79cda66dc243683b8c1d453 (diff)
Merge pull request #128 from acrisci/feature/layout-autoconfiguration
implement output layout auto configuration
Diffstat (limited to 'examples/config.c')
-rw-r--r--examples/config.c49
1 files changed, 7 insertions, 42 deletions
diff --git a/examples/config.c b/examples/config.c
index 954edb06..6796ea66 100644
--- a/examples/config.c
+++ b/examples/config.c
@@ -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;
- }
- }
- }
-
- 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;
+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;
}
- 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;
}