Skip to content

Commit 8611705

Browse files
committed
#164 revert to original info deltas
1 parent bd5de3e commit 8611705

10 files changed

+102
-70
lines changed

src/info.c

Lines changed: 42 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ void print_cfg_commands(enum LogThreshold t, struct Cfg *cfg) {
306306
}
307307
}
308308

309-
void print_head_current(enum LogThreshold t, enum InfoEvent event, struct Head *head) {
309+
void print_head_current(enum LogThreshold t, struct Head *head) {
310310
static const struct Output *output = NULL;
311311

312312
if (!head)
@@ -324,11 +324,9 @@ void print_head_current(enum LogThreshold t, enum InfoEvent event, struct Head *
324324
if (head->current.transform) {
325325
log_(t, " transform: %s", transform_name(head->current.transform));
326326
}
327-
}
328327

329-
print_mode(t, head->current.mode);
328+
print_mode(t, head->current.mode);
330329

331-
if (head->current.enabled) {
332330
log_(t, " VRR: %s", head->current.adaptive_sync == ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED ? "on" : "off");
333331
} else {
334332
log_(t, " (disabled)");
@@ -339,61 +337,45 @@ void print_head_current(enum LogThreshold t, enum InfoEvent event, struct Head *
339337
}
340338
}
341339

342-
void print_head_deltas(enum LogThreshold t, struct Head *head) {
340+
void print_head_desired(enum LogThreshold t, struct Head *head) {
343341
if (!head)
344342
return;
345343

346-
if (head->current.enabled && !head->desired.enabled) {
347-
log_(t, " (enabled) -> (disabled)");
348-
return;
349-
}
350-
351-
if (!head->current.enabled == head->desired.enabled) {
352-
log_(t, " (disabled) -> (enabled)");
353-
}
354-
355-
// mode changes happen in their own operation
356-
if (head_current_mode_not_desired(head)) {
357-
if (head->current.mode != head->desired.mode) {
358-
static char buf_current[2048];
359-
static char buf_desired[2048];
360-
361-
info_mode_string(head->current.mode, buf_current, sizeof(buf_current));
362-
info_mode_string(head->desired.mode, buf_desired, sizeof(buf_desired));
363-
364-
log_(t, " mode: %s -> %s", buf_current, buf_desired);
344+
if (head->desired.enabled) {
345+
if (head_current_mode_not_desired(head)) {
346+
// mode changes happen in their own operation
347+
if (!head->current.enabled || head->current.mode != head->desired.mode) {
348+
print_mode(t, head->desired.mode);
349+
}
350+
} else if (head_current_adaptive_sync_not_desired(head)) {
351+
// adaptive sync changes happen in their own operation
352+
log_(t, " VRR: %s", head->desired.adaptive_sync == ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED ? "on" : "off");
353+
} else {
354+
if (!head->current.enabled || head->current.scale != head->desired.scale) {
355+
log_(t, " scale: %.3f%s",
356+
wl_fixed_to_double(head->desired.scale),
357+
(!head->width_mm || !head->height_mm) ? " (default, size not specified)" : ""
358+
);
359+
}
360+
if (!head->current.enabled || head->current.x != head->desired.x || head->current.y != head->desired.y) {
361+
log_(t, " position: %d,%d",
362+
head->desired.x,
363+
head->desired.y
364+
);
365+
}
366+
if (!head->current.enabled || head->current.transform != head->desired.transform) {
367+
if (head->desired.transform) {
368+
log_(t, " transform: %s", transform_name(head->desired.transform));
369+
} else {
370+
log_(t, " transform: none");
371+
}
372+
}
365373
}
366-
return;
367-
}
368-
369-
// adaptive sync changes happen in their own operation
370-
if (head_current_adaptive_sync_not_desired(head)) {
371-
log_(t, " VRR: %s -> %s",
372-
head->current.adaptive_sync == ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED ? "on" : "off",
373-
head->desired.adaptive_sync == ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED ? "on" : "off"
374-
);
375-
return;
376-
}
377-
378-
if (head->current.scale != head->desired.scale) {
379-
log_(t, " scale: %.3f -> %.3f",
380-
wl_fixed_to_double(head->current.scale),
381-
wl_fixed_to_double(head->desired.scale)
382-
);
383-
}
384-
385-
if (head->current.x != head->desired.x || head->current.y != head->desired.y) {
386-
log_(t, " position: %d,%d -> %d,%d",
387-
head->current.x, head->current.y,
388-
head->desired.x, head->desired.y
389-
);
390-
}
391-
392-
if (head->current.transform != head->desired.transform) {
393-
log_(t, " transform: %s -> %s",
394-
head->current.transform ? transform_name(head->current.transform) : "none",
395-
head->desired.transform ? transform_name(head->desired.transform) : "none"
396-
);
374+
if (!head->current.enabled) {
375+
log_(t, " (enabled)");
376+
}
377+
} else {
378+
log_(t, " (disabled)");
397379
}
398380
}
399381

@@ -431,7 +413,7 @@ void print_head(enum LogThreshold t, enum InfoEvent event, struct Head *head) {
431413
print_modes_res_refresh(t, head);
432414
print_modes_failed(t, head);
433415
log_(t, " current:");
434-
print_head_current(t, event, head);
416+
print_head_current(t, head);
435417
break;
436418
case DEPARTED:
437419
log_(t, "\n%s Departed:", head->name);
@@ -443,7 +425,10 @@ void print_head(enum LogThreshold t, enum InfoEvent event, struct Head *head) {
443425
case DELTA:
444426
if (head_current_not_desired(head)) {
445427
log_(t, "\n%s Changing:", head->name);
446-
print_head_deltas(t, head);
428+
log_(t, " from:");
429+
print_head_current(t, head);
430+
log_(t, " to:");
431+
print_head_desired(t, head);
447432
}
448433
break;
449434
default:

src/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void pid_file_create(void) {
107107
void spawn_sh_cmd(const char * const command, char * const message) {
108108

109109
// experiments show that environment variable length tops out at 128k: variable itself plus contents
110-
message[1024 * 120] = '\0';
110+
// message[1024 * 120] = '\0';
111111

112112
pid_t pid = fork();
113113
if (pid < 0) {

tst/info/print-head-arrived-min.log

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
width: (not specified)
55
height: (not specified)
66
current:
7-
(no mode)
87
(disabled)
98

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

22
name Changing:
3-
(enabled) -> (disabled)
3+
from:
4+
scale: 2.000 (26.458)
5+
position: 700,800
6+
transform: 180
7+
mode: 100x200@30Hz (30,000mHz) (preferred)
8+
VRR: off
9+
to:
10+
(disabled)
411

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
name Changing:
3+
from:
4+
(disabled)
5+
to:
6+
mode: 400x500@60Hz (60,000mHz)
7+
(enabled)
8+
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

22
name Changing:
3-
mode: 100x200@30Hz (30,000mHz) (preferred) -> 400x500@60Hz (60,000mHz)
3+
from:
4+
scale: 2.000 (26.458)
5+
position: 700,800
6+
transform: 180
7+
mode: 100x200@30Hz (30,000mHz) (preferred)
8+
VRR: off
9+
to:
10+
mode: 400x500@60Hz (60,000mHz)
411

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11

22
name Changing:
3-
(disabled) -> (enabled)
4-
scale: 2.000 -> 4.000
5-
position: 700,800 -> 900,1000
6-
transform: 180 -> 90
3+
from:
4+
scale: 2.000 (26.458)
5+
position: 700,800
6+
transform: 180
7+
mode: 100x200@30Hz (30,000mHz) (preferred)
8+
VRR: off
9+
to:
10+
scale: 4.000
11+
position: 900,1000
12+
transform: 90
713

tst/info/print-head-deltas-vrr.log

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

22
name Changing:
3-
VRR: off -> on
3+
from:
4+
scale: 2.000 (26.458)
5+
position: 700,800
6+
transform: 180
7+
mode: 100x200@30Hz (30,000mHz) (preferred)
8+
VRR: off
9+
to:
10+
VRR: on
411

File renamed without changes.

tst/tst-info.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ void print_head_arrived__min(void **state) {
138138
free(expected_log);
139139
}
140140

141-
void print_head_departed(void **state) {
141+
void print_head_departed__ok(void **state) {
142142
print_head(INFO, DEPARTED, head);
143143

144-
char *expected_log = read_file("tst/info/print-head-departed.log");
144+
char *expected_log = read_file("tst/info/print-head-departed-ok.log");
145145
assert_log(INFO, expected_log);
146146
free(expected_log);
147147
}
@@ -171,7 +171,7 @@ void print_head_deltas__vrr(void **state) {
171171
}
172172

173173
void print_head_deltas__other(void **state) {
174-
head->current.enabled = false;
174+
head->current.enabled = true;
175175
head->desired.enabled = true;
176176
head->desired.mode = head->current.mode;
177177

@@ -193,18 +193,31 @@ void print_head_deltas__disable(void **state) {
193193
free(expected_log);
194194
}
195195

196+
void print_head_deltas__enable(void **state) {
197+
head->current.enabled = false;
198+
head->desired.enabled = true;
199+
200+
print_head(INFO, DELTA, head);
201+
202+
char *expected_log = read_file("tst/info/print-head-deltas-enable.log");
203+
assert_log(INFO, expected_log);
204+
free(expected_log);
205+
}
206+
196207
int main(void) {
197208
const struct CMUnitTest tests[] = {
198209
TEST(print_cfg_commands__empty),
199210
TEST(print_cfg_commands__ok),
200211

201212
TEST(print_head_arrived__all),
202213
TEST(print_head_arrived__min),
203-
TEST(print_head_departed),
214+
TEST(print_head_departed__ok),
215+
204216
TEST(print_head_deltas__mode),
205217
TEST(print_head_deltas__vrr),
206218
TEST(print_head_deltas__other),
207219
TEST(print_head_deltas__disable),
220+
TEST(print_head_deltas__enable),
208221
};
209222

210223
return RUN(tests);

0 commit comments

Comments
 (0)