aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config/output.c
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2017-12-06 12:57:13 +0100
committerLibravatar emersion <contact@emersion.fr>2017-12-06 12:57:13 +0100
commit68ae989ceef0a144988c0a55b13aaacf514b957d (patch)
tree1b15d250117736185d287b65c4841163eaecff48 /sway/config/output.c
parentAdd output config (diff)
downloadsway-68ae989ceef0a144988c0a55b13aaacf514b957d.tar.gz
sway-68ae989ceef0a144988c0a55b13aaacf514b957d.tar.zst
sway-68ae989ceef0a144988c0a55b13aaacf514b957d.zip
Init, merge output config params, use wlr_output_layout
Diffstat (limited to 'sway/config/output.c')
-rw-r--r--sway/config/output.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 02e18e59..4ed2c531 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -2,6 +2,7 @@
2#include <string.h> 2#include <string.h>
3#include <assert.h> 3#include <assert.h>
4#include <wlr/types/wlr_output.h> 4#include <wlr/types/wlr_output.h>
5#include <wlr/types/wlr_output_layout.h>
5#include "sway/config.h" 6#include "sway/config.h"
6#include "sway/output.h" 7#include "sway/output.h"
7#include "log.h" 8#include "log.h"
@@ -13,6 +14,15 @@ int output_name_cmp(const void *item, const void *data) {
13 return strcmp(output->name, name); 14 return strcmp(output->name, name);
14} 15}
15 16
17void output_config_defaults(struct output_config *oc) {
18 oc->enabled = -1;
19 oc->width = oc->height -1;
20 oc->refresh_rate = -1;
21 oc->x = oc->y = -1;
22 oc->scale = -1;
23 oc->transform = -1;
24}
25
16void merge_output_config(struct output_config *dst, struct output_config *src) { 26void merge_output_config(struct output_config *dst, struct output_config *src) {
17 if (src->name) { 27 if (src->name) {
18 if (dst->name) { 28 if (dst->name) {
@@ -38,6 +48,12 @@ void merge_output_config(struct output_config *dst, struct output_config *src) {
38 if (src->scale != -1) { 48 if (src->scale != -1) {
39 dst->scale = src->scale; 49 dst->scale = src->scale;
40 } 50 }
51 if (src->refresh_rate != -1) {
52 dst->refresh_rate = src->refresh_rate;
53 }
54 if (src->transform != -1) {
55 dst->transform = src->transform;
56 }
41 if (src->background) { 57 if (src->background) {
42 if (dst->background) { 58 if (dst->background) {
43 free(dst->background); 59 free(dst->background);
@@ -86,29 +102,28 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
86 set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate); 102 set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate);
87 } 103 }
88 if (oc && oc->scale > 0) { 104 if (oc && oc->scale > 0) {
105 sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale);
89 wlr_output->scale = oc->scale; 106 wlr_output->scale = oc->scale;
90 } 107 }
91 if (oc && oc->transform != WL_OUTPUT_TRANSFORM_NORMAL) { 108 if (oc && oc->transform >= 0) {
109 sway_log(L_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
92 wlr_output_transform(wlr_output, oc->transform); 110 wlr_output_transform(wlr_output, oc->transform);
93 } 111 }
94 112
95 // Find position for it 113 // Find position for it
96 if (oc && oc->x != -1 && oc->y != -1) { 114 if (oc && (oc->x != -1 || oc->y != -1)) {
97 sway_log(L_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y); 115 sway_log(L_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y);
98 output->x = oc->x; 116 wlr_output_layout_add(root_container.output_layout, wlr_output, oc->x,
99 output->y = oc->y; 117 oc->y);
100 } else { 118 } else {
101 int x = 0; 119 wlr_output_layout_add_auto(root_container.output_layout, wlr_output);
102 for (int i = 0; i < root_container.children->length; ++i) {
103 swayc_t *c = root_container.children->items[i];
104 if (c->type == C_OUTPUT) {
105 if (c->width + c->x > x) {
106 x = c->width + c->x;
107 }
108 }
109 }
110 output->x = x;
111 } 120 }
121 struct wlr_box *output_layout_box =
122 wlr_output_layout_get_box(root_container.output_layout, wlr_output);
123 output->x = output_layout_box->x;
124 output->y = output_layout_box->y;
125 output->width = output_layout_box->width;
126 output->height = output_layout_box->height;
112 127
113 if (!oc || !oc->background) { 128 if (!oc || !oc->background) {
114 // Look for a * config for background 129 // Look for a * config for background
@@ -128,7 +143,7 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
128 } 143 }
129 144
130 if (oc && oc->background) { 145 if (oc && oc->background) {
131 // TODO: swaybg 146 // TODO swaybg
132 /*if (output->bg_pid != 0) { 147 /*if (output->bg_pid != 0) {
133 terminate_swaybg(output->bg_pid); 148 terminate_swaybg(output->bg_pid);
134 } 149 }