Implement wlr-output-power-management-unstable-v1 protocol
This commit is contained in:
committed by
Isaac Freund
parent
773c5ff687
commit
d821f6b0dc
@ -2,6 +2,7 @@
|
||||
//
|
||||
// Copyright 2020 Isaac Freund
|
||||
// Copyright 2020 Leon Henrik Plickat
|
||||
// Copyright 2020 Marten Ringwelski
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@ -600,6 +601,11 @@ fn handleFrame(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This function is called every time an output is ready to display a frame,
|
||||
// generally at the output's refresh rate (e.g. 60Hz).
|
||||
const self = @fieldParentPtr(Self, "listen_frame", listener.?);
|
||||
|
||||
// TODO(wlroots) Remove this check when we update wlroots 0.11 to 0.12
|
||||
// wlroots fix: https://github.com/swaywm/wlroots/commit/85757665e6e1393773b36282aa244feb10b7a5fe
|
||||
if (!self.wlr_output.enabled) return;
|
||||
|
||||
render.renderOutput(self);
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,9 @@ listen_new_xdg_surface: c.wl_listener,
|
||||
wlr_layer_shell: *c.wlr_layer_shell_v1,
|
||||
listen_new_layer_surface: c.wl_listener,
|
||||
|
||||
wlr_output_power_manager: *c.wlr_output_power_manager_v1,
|
||||
listen_output_power_manager_set_mode: c.wl_listener,
|
||||
|
||||
wlr_xwayland: if (build_options.xwayland) *c.wlr_xwayland else void,
|
||||
listen_new_xwayland_surface: if (build_options.xwayland) c.wl_listener else void,
|
||||
|
||||
@ -100,6 +103,11 @@ pub fn init(self: *Self) !void {
|
||||
const wlr_compositor = c.wlr_compositor_create(self.wl_display, wlr_renderer) orelse
|
||||
return error.OutOfMemory;
|
||||
|
||||
// Set up output power manager
|
||||
self.wlr_output_power_manager = c.wlr_output_power_manager_v1_create(self.wl_display);
|
||||
self.listen_output_power_manager_set_mode.notify = handleOutputPowerManagementSetMode;
|
||||
c.wl_signal_add(&self.wlr_output_power_manager.events.set_mode, &self.listen_output_power_manager_set_mode);
|
||||
|
||||
// Set up xdg shell
|
||||
self.wlr_xdg_shell = c.wlr_xdg_shell_create(self.wl_display) orelse return error.OutOfMemory;
|
||||
self.listen_new_xdg_surface.notify = handleNewXdgSurface;
|
||||
@ -284,3 +292,28 @@ fn handleNewXwaylandSurface(listener: ?*c.wl_listener, data: ?*c_void) callconv(
|
||||
const node = util.gpa.create(ViewStack(View).Node) catch return;
|
||||
node.view.init(output, output.current.tags, wlr_xwayland_surface);
|
||||
}
|
||||
|
||||
fn handleOutputPowerManagementSetMode(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
const self = @fieldParentPtr(Self, "listen_output_power_manager_set_mode", listener.?);
|
||||
const mode_event = util.voidCast(c.wlr_output_power_v1_set_mode_event, data.?);
|
||||
const wlr_output: *c.wlr_output = mode_event.output;
|
||||
|
||||
const enable = mode_event.mode == .ZWLR_OUTPUT_POWER_V1_MODE_ON;
|
||||
|
||||
const log_text = if (enable) "Enabling" else "Disabling";
|
||||
log.debug(
|
||||
.server,
|
||||
"{} dpms for output {}",
|
||||
.{log_text, wlr_output.name},
|
||||
);
|
||||
|
||||
c.wlr_output_enable(wlr_output, enable);
|
||||
if (!c.wlr_output_commit(wlr_output)) {
|
||||
log.err(
|
||||
.server,
|
||||
"wlr_output_commit failed for {}",
|
||||
.{wlr_output.name},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ pub usingnamespace @cImport({
|
||||
@cInclude("wlr/types/wlr_matrix.h");
|
||||
@cInclude("wlr/types/wlr_output.h");
|
||||
@cInclude("wlr/types/wlr_output_layout.h");
|
||||
@cInclude("wlr/types/wlr_output_power_management_v1.h");
|
||||
@cInclude("wlr/types/wlr_pointer.h");
|
||||
@cInclude("wlr/types/wlr_primary_selection.h");
|
||||
@cInclude("wlr/types/wlr_primary_selection_v1.h");
|
||||
|
Reference in New Issue
Block a user