@@ -119,7 +119,102 @@ void merge_output_config(struct output_config *dst, struct output_config *src) {
119
119
}
120
120
}
121
121
122
+ enum output_config_changes {
123
+ OUTPUT_CONFIG_ENABLED = 1 << 1 ,
124
+ OUTPUT_CONFIG_WIDTH = 1 << 2 ,
125
+ OUTPUT_CONFIG_HEIGHT = 1 << 3 ,
126
+ OUTPUT_CONFIG_X = 1 << 4 ,
127
+ OUTPUT_CONFIG_Y = 1 << 5 ,
128
+ OUTPUT_CONFIG_SCALE = 1 << 6 ,
129
+ OUTPUT_CONFIG_SCALE_FILTER = 1 << 7 ,
130
+ OUTPUT_CONFIG_SUBPIXEL = 1 << 8 ,
131
+ OUTPUT_CONFIG_REFRESH_RATE = 1 << 9 ,
132
+ OUTPUT_CONFIG_CUSTOM_MODE = 1 << 10 ,
133
+ OUTPUT_CONFIG_TRANSFORM = 1 << 11 ,
134
+ OUTPUT_CONFIG_MAX_RENDER_TIME = 1 << 12 ,
135
+ OUTPUT_CONFIG_ADAPTIVE_SYNC = 1 << 13 ,
136
+ OUTPUT_CONFIG_BACKGROUND = 1 << 14 ,
137
+ OUTPUT_CONFIG_BACKGROUND_OPTION = 1 << 15 ,
138
+ OUTPUT_CONFIG_BACKGROUND_FALLBACK = 1 << 16 ,
139
+ OUTPUT_CONFIG_DPMS_STATE = 1 << 17 ,
140
+ };
141
+
142
+ int output_config_changes (struct output_config * src ) {
143
+ int changes = 0 ;
144
+
145
+ if (src -> enabled != -1 ) {
146
+ changes |= OUTPUT_CONFIG_ENABLED ;
147
+ }
148
+ if (src -> width != -1 ) {
149
+ changes |= OUTPUT_CONFIG_WIDTH ;
150
+ }
151
+ if (src -> height != -1 ) {
152
+ changes |= OUTPUT_CONFIG_HEIGHT ;
153
+ }
154
+ if (src -> x != -1 ) {
155
+ changes |= OUTPUT_CONFIG_X ;
156
+ }
157
+ if (src -> y != -1 ) {
158
+ changes |= OUTPUT_CONFIG_Y ;
159
+ }
160
+ if (src -> scale != -1 ) {
161
+ changes |= OUTPUT_CONFIG_SCALE ;
162
+ }
163
+ if (src -> scale_filter != SCALE_FILTER_DEFAULT ) {
164
+ changes |= OUTPUT_CONFIG_SCALE_FILTER ;
165
+ }
166
+ if (src -> subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN ) {
167
+ changes |= OUTPUT_CONFIG_SUBPIXEL ;
168
+ }
169
+ if (src -> refresh_rate != -1 ) {
170
+ changes |= OUTPUT_CONFIG_REFRESH_RATE ;
171
+ }
172
+ if (src -> custom_mode != -1 ) {
173
+ changes |= OUTPUT_CONFIG_CUSTOM_MODE ;
174
+ }
175
+ if (src -> transform != -1 ) {
176
+ changes |= OUTPUT_CONFIG_TRANSFORM ;
177
+ }
178
+ if (src -> max_render_time != -1 ) {
179
+ changes |= OUTPUT_CONFIG_MAX_RENDER_TIME ;
180
+ }
181
+ if (src -> adaptive_sync != -1 ) {
182
+ changes |= OUTPUT_CONFIG_ADAPTIVE_SYNC ;
183
+ }
184
+ if (src -> background ) {
185
+ changes |= OUTPUT_CONFIG_BACKGROUND ;
186
+ }
187
+ if (src -> background_option ) {
188
+ changes |= OUTPUT_CONFIG_BACKGROUND_OPTION ;
189
+ }
190
+ if (src -> background_fallback ) {
191
+ changes |= OUTPUT_CONFIG_BACKGROUND_FALLBACK ;
192
+ }
193
+ if (src -> dpms_state != 0 ) {
194
+ changes |= OUTPUT_CONFIG_DPMS_STATE ;
195
+ }
196
+
197
+ return changes ;
198
+ }
199
+
122
200
struct output_config * store_output_config (struct output_config * oc ) {
201
+ // Get rid of any previous output config that has the same name and changes
202
+ // the same things, as it has been superseded. This prevents the output
203
+ // config list of commands growing unbounded.
204
+ int existing_pos = -1 ;
205
+ for (int i = 0 ; i < config -> output_configs -> length ; ++ i ) {
206
+ struct output_config * list_oc = config -> output_configs -> items [i ];
207
+ if (!strcmp (oc -> name , list_oc -> name ) &&
208
+ output_config_changes (oc ) == output_config_changes (list_oc )) {
209
+ existing_pos = i ;
210
+ }
211
+ }
212
+ if (existing_pos >= 0 ) {
213
+ list_del (config -> output_configs , existing_pos );
214
+ }
215
+
216
+ // Then simply add the command to the bottom of the list where it will be
217
+ // applied last and thus have the biggest priority.
123
218
list_add (config -> output_configs , oc );
124
219
125
220
sway_log (SWAY_DEBUG , "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
0 commit comments