OutputManager: get rid of output_config_pending
This commit is contained in:
parent
20d804cdb5
commit
6cf01f3624
@ -49,9 +49,6 @@ layout_change: wl.Listener(*wlr.OutputLayout) = undefined,
|
|||||||
power_manager: *wlr.OutputPowerManagerV1,
|
power_manager: *wlr.OutputPowerManagerV1,
|
||||||
power_manager_set_mode: wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode) = undefined,
|
power_manager_set_mode: wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode) = undefined,
|
||||||
|
|
||||||
/// True if and only if we are currently applying an output config
|
|
||||||
output_config_pending: bool = false,
|
|
||||||
|
|
||||||
pub fn init(self: *Self, server: *Server) !void {
|
pub fn init(self: *Self, server: *Server) !void {
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.root = &server.root,
|
.root = &server.root,
|
||||||
@ -107,8 +104,6 @@ fn handleOutputLayoutChange(
|
|||||||
output_layout: *wlr.OutputLayout,
|
output_layout: *wlr.OutputLayout,
|
||||||
) void {
|
) void {
|
||||||
const self = @fieldParentPtr(Self, "layout_change", listener);
|
const self = @fieldParentPtr(Self, "layout_change", listener);
|
||||||
// Ignore if the layout change is from applying a config
|
|
||||||
if (self.output_config_pending) return;
|
|
||||||
|
|
||||||
const config = self.ouputConfigFromCurrent() catch {
|
const config = self.ouputConfigFromCurrent() catch {
|
||||||
log.crit(.output_manager, "out of memory", .{});
|
log.crit(.output_manager, "out of memory", .{});
|
||||||
@ -174,10 +169,9 @@ fn handleOutputPowerManagementSetMode(
|
|||||||
|
|
||||||
/// Apply the given config, return false on faliure
|
/// Apply the given config, return false on faliure
|
||||||
fn applyOutputConfig(self: *Self, config: *wlr.OutputConfigurationV1) bool {
|
fn applyOutputConfig(self: *Self, config: *wlr.OutputConfigurationV1) bool {
|
||||||
// Store whether a config is pending so we can tell if the
|
// Ignore layout change events while applying the config
|
||||||
// wlr_output_layout.change event was triggered by applying the config
|
self.layout_change.link.remove();
|
||||||
self.output_config_pending = true;
|
defer self.root.output_layout.events.change.add(&self.layout_change);
|
||||||
defer self.output_config_pending = false;
|
|
||||||
|
|
||||||
// Test if the config should apply cleanly
|
// Test if the config should apply cleanly
|
||||||
if (!testOutputConfig(config, false)) return false;
|
if (!testOutputConfig(config, false)) return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user