idle-inhibit: fix naming, eliminate "self" naming convention
Also add missing copyright headers
This commit is contained in:
parent
b0d4610999
commit
b65e4f6b17
@ -1,4 +1,20 @@
|
||||
const Self = @This();
|
||||
// This file is part of river, a dynamic tiling wayland compositor.
|
||||
//
|
||||
// Copyright 2022 The River Developers
|
||||
//
|
||||
// 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
|
||||
// the Free Software Foundation, version 3.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
const IdleInhibitManager = @This();
|
||||
|
||||
const std = @import("std");
|
||||
const wlr = @import("wlroots");
|
||||
@ -11,31 +27,31 @@ const IdleInhibitor = @import("IdleInhibitor.zig");
|
||||
const SceneNodeData = @import("SceneNodeData.zig");
|
||||
const View = @import("View.zig");
|
||||
|
||||
idle_inhibit_manager: *wlr.IdleInhibitManagerV1,
|
||||
wlr_manager: *wlr.IdleInhibitManagerV1,
|
||||
new_idle_inhibitor: wl.Listener(*wlr.IdleInhibitorV1) =
|
||||
wl.Listener(*wlr.IdleInhibitorV1).init(handleNewIdleInhibitor),
|
||||
inhibitors: std.TailQueue(IdleInhibitor) = .{},
|
||||
|
||||
pub fn init(self: *Self) !void {
|
||||
self.* = .{
|
||||
.idle_inhibit_manager = try wlr.IdleInhibitManagerV1.create(server.wl_server),
|
||||
pub fn init(inhibit_manager: *IdleInhibitManager) !void {
|
||||
inhibit_manager.* = .{
|
||||
.wlr_manager = try wlr.IdleInhibitManagerV1.create(server.wl_server),
|
||||
};
|
||||
self.idle_inhibit_manager.events.new_inhibitor.add(&self.new_idle_inhibitor);
|
||||
inhibit_manager.wlr_manager.events.new_inhibitor.add(&inhibit_manager.new_idle_inhibitor);
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Self) void {
|
||||
while (self.inhibitors.pop()) |inhibitor| {
|
||||
pub fn deinit(inhibit_manager: *IdleInhibitManager) void {
|
||||
while (inhibit_manager.inhibitors.pop()) |inhibitor| {
|
||||
inhibitor.data.destroy.link.remove();
|
||||
util.gpa.destroy(inhibitor);
|
||||
}
|
||||
self.new_idle_inhibitor.link.remove();
|
||||
inhibit_manager.new_idle_inhibitor.link.remove();
|
||||
}
|
||||
|
||||
pub fn idleInhibitCheckActive(self: *Self) void {
|
||||
pub fn checkActive(inhibit_manager: *IdleInhibitManager) void {
|
||||
var inhibited = false;
|
||||
var it = self.inhibitors.first;
|
||||
var it = inhibit_manager.inhibitors.first;
|
||||
while (it) |node| : (it = node.next) {
|
||||
const node_data = SceneNodeData.fromSurface(node.data.inhibitor.surface) orelse continue;
|
||||
const node_data = SceneNodeData.fromSurface(node.data.wlr_inhibitor.surface) orelse continue;
|
||||
switch (node_data.data) {
|
||||
.view => |view| {
|
||||
if (view.current.output != null and
|
||||
@ -62,14 +78,14 @@ pub fn idleInhibitCheckActive(self: *Self) void {
|
||||
}
|
||||
|
||||
fn handleNewIdleInhibitor(listener: *wl.Listener(*wlr.IdleInhibitorV1), inhibitor: *wlr.IdleInhibitorV1) void {
|
||||
const self = @fieldParentPtr(Self, "new_idle_inhibitor", listener);
|
||||
const inhibit_manager = @fieldParentPtr(IdleInhibitManager, "new_idle_inhibitor", listener);
|
||||
const inhibitor_node = util.gpa.create(std.TailQueue(IdleInhibitor).Node) catch return;
|
||||
inhibitor_node.data.init(inhibitor, self) catch {
|
||||
inhibitor_node.data.init(inhibitor, inhibit_manager) catch {
|
||||
util.gpa.destroy(inhibitor_node);
|
||||
return;
|
||||
};
|
||||
|
||||
self.inhibitors.append(inhibitor_node);
|
||||
inhibit_manager.inhibitors.append(inhibitor_node);
|
||||
|
||||
self.idleInhibitCheckActive();
|
||||
inhibit_manager.checkActive();
|
||||
}
|
@ -1,4 +1,20 @@
|
||||
const Self = @This();
|
||||
// This file is part of river, a dynamic tiling wayland compositor.
|
||||
//
|
||||
// Copyright 2022 The River Developers
|
||||
//
|
||||
// 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
|
||||
// the Free Software Foundation, version 3.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
const IdleInhibitor = @This();
|
||||
|
||||
const std = @import("std");
|
||||
const wlr = @import("wlroots");
|
||||
@ -7,29 +23,36 @@ const wl = @import("wayland").server.wl;
|
||||
const server = &@import("main.zig").server;
|
||||
const util = @import("util.zig");
|
||||
|
||||
const IdleInhibitorManager = @import("IdleInhibitorManager.zig");
|
||||
const IdleInhibitManager = @import("IdleInhibitManager.zig");
|
||||
|
||||
inhibit_manager: *IdleInhibitManager,
|
||||
wlr_inhibitor: *wlr.IdleInhibitorV1,
|
||||
|
||||
inhibitor_manager: *IdleInhibitorManager,
|
||||
inhibitor: *wlr.IdleInhibitorV1,
|
||||
destroy: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleDestroy),
|
||||
|
||||
pub fn init(self: *Self, inhibitor: *wlr.IdleInhibitorV1, inhibitor_manager: *IdleInhibitorManager) !void {
|
||||
self.inhibitor_manager = inhibitor_manager;
|
||||
self.inhibitor = inhibitor;
|
||||
self.destroy.setNotify(handleDestroy);
|
||||
inhibitor.events.destroy.add(&self.destroy);
|
||||
pub fn init(
|
||||
inhibitor: *IdleInhibitor,
|
||||
wlr_inhibitor: *wlr.IdleInhibitorV1,
|
||||
inhibit_manager: *IdleInhibitManager,
|
||||
) !void {
|
||||
inhibitor.* = .{
|
||||
.inhibit_manager = inhibit_manager,
|
||||
.wlr_inhibitor = wlr_inhibitor,
|
||||
};
|
||||
wlr_inhibitor.events.destroy.add(&inhibitor.destroy);
|
||||
|
||||
inhibitor_manager.idleInhibitCheckActive();
|
||||
inhibit_manager.checkActive();
|
||||
}
|
||||
|
||||
fn handleDestroy(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
|
||||
const self = @fieldParentPtr(Self, "destroy", listener);
|
||||
self.destroy.link.remove();
|
||||
const inhibitor = @fieldParentPtr(IdleInhibitor, "destroy", listener);
|
||||
|
||||
const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self);
|
||||
server.idle_inhibitor_manager.inhibitors.remove(node);
|
||||
inhibitor.destroy.link.remove();
|
||||
|
||||
self.inhibitor_manager.idleInhibitCheckActive();
|
||||
const node = @fieldParentPtr(std.TailQueue(IdleInhibitor).Node, "data", inhibitor);
|
||||
server.idle_inhibit_manager.inhibitors.remove(node);
|
||||
|
||||
inhibitor.inhibit_manager.checkActive();
|
||||
|
||||
util.gpa.destroy(node);
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ fn commitTransaction(root: *Root) void {
|
||||
}
|
||||
}
|
||||
|
||||
server.idle_inhibitor_manager.idleInhibitCheckActive();
|
||||
server.idle_inhibit_manager.checkActive();
|
||||
|
||||
if (root.pending_state_dirty) {
|
||||
root.applyPending();
|
||||
|
@ -26,7 +26,7 @@ const util = @import("util.zig");
|
||||
|
||||
const Config = @import("Config.zig");
|
||||
const Control = @import("Control.zig");
|
||||
const IdleInhibitorManager = @import("IdleInhibitorManager.zig");
|
||||
const IdleInhibitManager = @import("IdleInhibitManager.zig");
|
||||
const InputManager = @import("InputManager.zig");
|
||||
const LayerSurface = @import("LayerSurface.zig");
|
||||
const LayoutManager = @import("LayoutManager.zig");
|
||||
@ -88,7 +88,7 @@ config: Config,
|
||||
control: Control,
|
||||
status_manager: StatusManager,
|
||||
layout_manager: LayoutManager,
|
||||
idle_inhibitor_manager: IdleInhibitorManager,
|
||||
idle_inhibit_manager: IdleInhibitManager,
|
||||
lock_manager: LockManager,
|
||||
|
||||
pub fn init(server: *Server, runtime_xwayland: bool) !void {
|
||||
@ -130,7 +130,7 @@ pub fn init(server: *Server, runtime_xwayland: bool) !void {
|
||||
.control = undefined,
|
||||
.status_manager = undefined,
|
||||
.layout_manager = undefined,
|
||||
.idle_inhibitor_manager = undefined,
|
||||
.idle_inhibit_manager = undefined,
|
||||
.lock_manager = undefined,
|
||||
};
|
||||
|
||||
@ -165,7 +165,7 @@ pub fn init(server: *Server, runtime_xwayland: bool) !void {
|
||||
try server.control.init();
|
||||
try server.status_manager.init();
|
||||
try server.layout_manager.init();
|
||||
try server.idle_inhibitor_manager.init();
|
||||
try server.idle_inhibit_manager.init();
|
||||
try server.lock_manager.init();
|
||||
|
||||
server.xdg_shell.events.new_surface.add(&server.new_xdg_surface);
|
||||
@ -207,7 +207,7 @@ pub fn deinit(server: *Server) void {
|
||||
|
||||
server.root.deinit();
|
||||
server.input_manager.deinit();
|
||||
server.idle_inhibitor_manager.deinit();
|
||||
server.idle_inhibit_manager.deinit();
|
||||
server.lock_manager.deinit();
|
||||
|
||||
server.wl_server.destroy();
|
||||
|
Loading…
Reference in New Issue
Block a user