the artifacts were caused because we tried to set the gamma right after receiving the event, this resulted in two pending page-flips, which not always play well together.
This also seems to fix a screen freeze when turning on a monitor that has gamma.
Additionally the current method won't work once 0 is merged
OZ6EU4ESUN5IPI6LR6W3AFJYSENWH63M33AZCLX7CAHD3EERD7RAC
SIRA464UEQQBTBSW2UZMJWVXZEQ6RO2MM2N2R7YAOEBYCPSJJVVAC
OHQMPQ67TSE2LEGDVQ6X5FTSOO632DODDVDCFQBS3KDVZ52NR7XAC
7L3TU7JVWPBPHN7WF4TJ263BZ6BC3AYRRW6PULFUP5JZUGWWNUSAC
7B74AT3BXYB7PVW4F6SGQNPMHOU5TEV5TZ54CG6VSQI46XSEKWXQC
EQRGODLKSVSPFSUZU7BV5ER72U4QS4ATSBKV544XXQVKKTOSC7EAC
M3UB6SYALD67PTQ24D6HXFL7YEOT7WILE7UMTIS22KQNW5BQD6KAC
2K5G3BS3VK2VPZ25ZVWPSZSEB5MGMQZVHV4I7RAGDVUOSXP5LVMAC
OVLCSHYEKV3OPPZ3GC7KEAMF7YOWHFWE5J6KYGE3OXWQAS62S4XAC
L22THA22ACZI3EH4QX3NRHN6K6JMT5VQX6EG2JECURQQUGL5OSSQC
BTMOWGN7DBF5DUUXCBC3APRRX3U27KLD2MVJ6L4FXTCLMWV3C4MQC
XAPDQAZQOCBOUSLUKRXNICOGCNSLKRGKVLU5JYWZLRMZI6ONG22QC
/*
* HACK: The "correct" way to set the gamma is to commit it together with
* the rest of the state in one go, but to do that we would need to rewrite
* wlr_scene_output_commit() in order to add the gamma to the pending
* state before committing, instead try to commit the gamma in one frame,
* and commit the rest of the state in the next one (or in the same frame if
* the gamma can not be committed).
*/
if (m->gamma_lut_changed) {
gamma_control = wlr_gamma_control_manager_v1_get_control(gamma_control_mgr, m->wlr_output);
m->gamma_lut_changed = 0;
if (!wlr_gamma_control_v1_apply(gamma_control, &pending))
goto commit;
if (!wlr_output_test_state(m->wlr_output, &pending)) {
wlr_gamma_control_v1_send_failed_and_destroy(gamma_control);
goto commit;
}
wlr_output_commit_state(m->wlr_output, &pending);
wlr_output_schedule_frame(m->wlr_output);
} else {
commit:
struct wlr_output_state state;
wlr_output_state_init(&state);
if (!wlr_gamma_control_v1_apply(event->control, &state)) {
wlr_output_state_finish(&state);
return;
}
if (!wlr_output_test_state(event->output, &state)) {
wlr_gamma_control_v1_send_failed_and_destroy(event->control);
wlr_output_state_finish(&state);
return;
}
wlr_output_commit_state(event->output, &state);
wlr_output_schedule_frame(event->output);
Monitor *m = event->output->data;
m->gamma_lut_changed = 1;
wlr_output_schedule_frame(m->wlr_output);