mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 16:05:59 +01:00
output: introduce wlr_output_event_commit
This event contains a `committed` bitfield, which allows callers to know which output fields changed during the commit. This allows users to setup a single atomic commit listener, instead of setting up one listener for each event (mode, scale, transform, and so on). References: https://github.com/swaywm/wlroots/issues/2098
This commit is contained in:
parent
6949d0fd38
commit
c674241ec0
2 changed files with 13 additions and 4 deletions
|
@ -163,7 +163,7 @@ struct wlr_output {
|
||||||
// Emitted right before commit
|
// Emitted right before commit
|
||||||
struct wl_signal precommit; // wlr_output_event_precommit
|
struct wl_signal precommit; // wlr_output_event_precommit
|
||||||
// Emitted right after commit
|
// Emitted right after commit
|
||||||
struct wl_signal commit;
|
struct wl_signal commit; // wlr_output_event_commit
|
||||||
// Emitted right after the buffer has been presented to the user
|
// Emitted right after the buffer has been presented to the user
|
||||||
struct wl_signal present; // wlr_output_event_present
|
struct wl_signal present; // wlr_output_event_present
|
||||||
struct wl_signal enable;
|
struct wl_signal enable;
|
||||||
|
@ -198,6 +198,11 @@ struct wlr_output_event_precommit {
|
||||||
struct timespec *when;
|
struct timespec *when;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wlr_output_event_commit {
|
||||||
|
struct wlr_output *output;
|
||||||
|
uint32_t committed; // bitmask of enum wlr_output_state_field
|
||||||
|
};
|
||||||
|
|
||||||
enum wlr_output_present_flag {
|
enum wlr_output_present_flag {
|
||||||
// The presentation was synchronized to the "vertical retrace" by the
|
// The presentation was synchronized to the "vertical retrace" by the
|
||||||
// display hardware such that tearing does not happen.
|
// display hardware such that tearing does not happen.
|
||||||
|
|
|
@ -581,11 +581,11 @@ bool wlr_output_commit(struct wlr_output *output) {
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
struct wlr_output_event_precommit event = {
|
struct wlr_output_event_precommit pre_event = {
|
||||||
.output = output,
|
.output = output,
|
||||||
.when = &now,
|
.when = &now,
|
||||||
};
|
};
|
||||||
wlr_signal_emit_safe(&output->events.precommit, &event);
|
wlr_signal_emit_safe(&output->events.precommit, &pre_event);
|
||||||
|
|
||||||
if (!output->impl->commit(output)) {
|
if (!output->impl->commit(output)) {
|
||||||
output_state_clear(&output->pending);
|
output_state_clear(&output->pending);
|
||||||
|
@ -604,7 +604,11 @@ bool wlr_output_commit(struct wlr_output *output) {
|
||||||
|
|
||||||
output->commit_seq++;
|
output->commit_seq++;
|
||||||
|
|
||||||
wlr_signal_emit_safe(&output->events.commit, output);
|
struct wlr_output_event_commit event = {
|
||||||
|
.output = output,
|
||||||
|
.committed = output->pending.committed,
|
||||||
|
};
|
||||||
|
wlr_signal_emit_safe(&output->events.commit, &event);
|
||||||
|
|
||||||
bool scale_updated = output->pending.committed & WLR_OUTPUT_STATE_SCALE;
|
bool scale_updated = output->pending.committed & WLR_OUTPUT_STATE_SCALE;
|
||||||
if (scale_updated) {
|
if (scale_updated) {
|
||||||
|
|
Loading…
Reference in a new issue