treewide: change type names to be title case
Browse files
+7 −7 src/animations.zig
| @@ -17,12 +17,12 @@ pub const Easing = enum { | |||
| 17 | } | 17 | } |
| 18 | }; | 18 | }; |
| 19 | 19 | ||
| 20 | -pub const Animation_Config = struct { | 20 | +pub const AnimationConfig = struct { |
| 21 | duration_ms: u64 = 150, | 21 | duration_ms: u64 = 150, |
| 22 | easing: Easing = .ease_out, | 22 | easing: Easing = .ease_out, |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | -pub const Scroll_Animation = struct { | 25 | +pub const ScrollAnimation = struct { |
| 26 | start_value: i32 = 0, | 26 | start_value: i32 = 0, |
| 27 | end_value: i32 = 0, | 27 | end_value: i32 = 0, |
| 28 | start_time: i64 = 0, | 28 | start_time: i64 = 0, |
| @@ -30,7 +30,7 @@ pub const Scroll_Animation = struct { | |||
| 30 | easing: Easing = .ease_out, | 30 | easing: Easing = .ease_out, |
| 31 | active: bool = false, | 31 | active: bool = false, |
| 32 | 32 | ||
| 33 | - pub fn start(self: *Scroll_Animation, from: i32, to: i32, config: Animation_Config) void { | 33 | + pub fn start(self: *ScrollAnimation, from: i32, to: i32, config: AnimationConfig) void { |
| 34 | if (from == to) { | 34 | if (from == to) { |
| 35 | self.active = false; | 35 | self.active = false; |
| 36 | return; | 36 | return; |
| @@ -43,7 +43,7 @@ pub const Scroll_Animation = struct { | |||
| 43 | self.active = true; | 43 | self.active = true; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | - pub fn update(self: *Scroll_Animation) ?i32 { | 46 | + pub fn update(self: *ScrollAnimation) ?i32 { |
| 47 | if (!self.active) return null; | 47 | if (!self.active) return null; |
| 48 | 48 | ||
| 49 | const now = std.time.milliTimestamp(); | 49 | const now = std.time.milliTimestamp(); |
| @@ -62,15 +62,15 @@ pub const Scroll_Animation = struct { | |||
| 62 | return @intFromFloat(current); | 62 | return @intFromFloat(current); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | - pub fn isActive(self: *const Scroll_Animation) bool { | 65 | + pub fn isActive(self: *const ScrollAnimation) bool { |
| 66 | return self.active; | 66 | return self.active; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | - pub fn target(self: *const Scroll_Animation) i32 { | 69 | + pub fn target(self: *const ScrollAnimation) i32 { |
| 70 | return self.end_value; | 70 | return self.end_value; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | - pub fn stop(self: *Scroll_Animation) void { | 73 | + pub fn stop(self: *ScrollAnimation) void { |
| 74 | self.active = false; | 74 | self.active = false; |
| 75 | } | 75 | } |
| 76 | }; | 76 | }; |
+2 −2 src/bar/blocks/blocks.zig
| @@ -1,11 +1,11 @@ | |||
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const Static = @import("static.zig").Static; | 3 | pub const Static = @import("static.zig").Static; |
| 4 | -pub const Date_Time = @import("datetime.zig").Date_Time; | 4 | +pub const Date_Time = @import("datetime.zig").DateTime; |
| 5 | pub const Ram = @import("ram.zig").Ram; | 5 | pub const Ram = @import("ram.zig").Ram; |
| 6 | pub const Shell = @import("shell.zig").Shell; | 6 | pub const Shell = @import("shell.zig").Shell; |
| 7 | pub const Battery = @import("battery.zig").Battery; | 7 | pub const Battery = @import("battery.zig").Battery; |
| 8 | -pub const Cpu_Temp = @import("cpu_temp.zig").Cpu_Temp; | 8 | +pub const Cpu_Temp = @import("cpu_temp.zig").CpuTemp; |
| 9 | 9 | ||
| 10 | pub const Block = struct { | 10 | pub const Block = struct { |
| 11 | data: Data, | 11 | data: Data, |
+9 −9 src/bar/blocks/cpu_temp.zig
| @@ -1,7 +1,7 @@ | |||
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const format_util = @import("format.zig"); | 2 | const format_util = @import("format.zig"); |
| 3 | 3 | ||
| 4 | -pub const Cpu_Temp = struct { | 4 | +pub const CpuTemp = struct { |
| 5 | format: []const u8, | 5 | format: []const u8, |
| 6 | device: []const u8, | 6 | device: []const u8, |
| 7 | interval_secs: u64, | 7 | interval_secs: u64, |
| @@ -14,8 +14,8 @@ pub const Cpu_Temp = struct { | |||
| 14 | device: []const u8, | 14 | device: []const u8, |
| 15 | interval_secs: u64, | 15 | interval_secs: u64, |
| 16 | color: c_ulong, | 16 | color: c_ulong, |
| 17 | - ) Cpu_Temp { | 17 | + ) CpuTemp { |
| 18 | - var self = Cpu_Temp{ | 18 | + var self = CpuTemp{ |
| 19 | .format = format, | 19 | .format = format, |
| 20 | .device = device, | 20 | .device = device, |
| 21 | .interval_secs = interval_secs, | 21 | .interval_secs = interval_secs, |
| @@ -27,7 +27,7 @@ pub const Cpu_Temp = struct { | |||
| 27 | return self; | 27 | return self; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | - fn detectPath(self: *Cpu_Temp) void { | 30 | + fn detectPath(self: *CpuTemp) void { |
| 31 | if (self.device.len > 0 and self.device[0] == '/') { | 31 | if (self.device.len > 0 and self.device[0] == '/') { |
| 32 | if (self.device.len <= self.cached_path.len) { | 32 | if (self.device.len <= self.cached_path.len) { |
| 33 | @memcpy(self.cached_path[0..self.device.len], self.device); | 33 | @memcpy(self.cached_path[0..self.device.len], self.device); |
| @@ -46,7 +46,7 @@ pub const Cpu_Temp = struct { | |||
| 46 | if (self.tryPath("/sys/class/thermal/{s}/temp", "thermal_zone0")) return; | 46 | if (self.tryPath("/sys/class/thermal/{s}/temp", "thermal_zone0")) return; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | - fn tryPath(self: *Cpu_Temp, comptime fmt: []const u8, device: []const u8) bool { | 49 | + fn tryPath(self: *CpuTemp, comptime fmt: []const u8, device: []const u8) bool { |
| 50 | const path = std.fmt.bufPrint(&self.cached_path, fmt, .{device}) catch return false; | 50 | const path = std.fmt.bufPrint(&self.cached_path, fmt, .{device}) catch return false; |
| 51 | const file = std.fs.openFileAbsolute(path, .{}) catch return false; | 51 | const file = std.fs.openFileAbsolute(path, .{}) catch return false; |
| 52 | file.close(); | 52 | file.close(); |
| @@ -54,7 +54,7 @@ pub const Cpu_Temp = struct { | |||
| 54 | return true; | 54 | return true; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | - fn findHwmonCpu(self: *Cpu_Temp) bool { | 57 | + fn findHwmonCpu(self: *CpuTemp) bool { |
| 58 | var dir = std.fs.openDirAbsolute("/sys/class/hwmon", .{ .iterate = true }) catch return false; | 58 | var dir = std.fs.openDirAbsolute("/sys/class/hwmon", .{ .iterate = true }) catch return false; |
| 59 | defer dir.close(); | 59 | defer dir.close(); |
| 60 | 60 | ||
| @@ -83,7 +83,7 @@ pub const Cpu_Temp = struct { | |||
| 83 | return false; | 83 | return false; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | - pub fn content(self: *Cpu_Temp, buffer: []u8) []const u8 { | 86 | + pub fn content(self: *CpuTemp, buffer: []u8) []const u8 { |
| 87 | if (self.cached_path_len == 0) return buffer[0..0]; | 87 | if (self.cached_path_len == 0) return buffer[0..0]; |
| 88 | 88 | ||
| 89 | const path = self.cached_path[0..self.cached_path_len]; | 89 | const path = self.cached_path[0..self.cached_path_len]; |
| @@ -103,11 +103,11 @@ pub const Cpu_Temp = struct { | |||
| 103 | return format_util.substitute(self.format, deg_str, buffer); | 103 | return format_util.substitute(self.format, deg_str, buffer); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | - pub fn interval(self: *Cpu_Temp) u64 { | 106 | + pub fn interval(self: *CpuTemp) u64 { |
| 107 | return self.interval_secs; | 107 | return self.interval_secs; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | - pub fn getColor(self: *Cpu_Temp) c_ulong { | 110 | + pub fn getColor(self: *CpuTemp) c_ulong { |
| 111 | return self.color; | 111 | return self.color; |
| 112 | } | 112 | } |
| 113 | }; | 113 | }; |
+5 −5 src/bar/blocks/datetime.zig
| @@ -4,13 +4,13 @@ const c = @cImport({ | |||
| 4 | @cInclude("time.h"); | 4 | @cInclude("time.h"); |
| 5 | }); | 5 | }); |
| 6 | 6 | ||
| 7 | -pub const Date_Time = struct { | 7 | +pub const DateTime = struct { |
| 8 | format: []const u8, | 8 | format: []const u8, |
| 9 | datetime_format: []const u8, | 9 | datetime_format: []const u8, |
| 10 | interval_secs: u64, | 10 | interval_secs: u64, |
| 11 | color: c_ulong, | 11 | color: c_ulong, |
| 12 | 12 | ||
| 13 | - pub fn init(format: []const u8, datetime_format: []const u8, interval_secs: u64, color: c_ulong) Date_Time { | 13 | + pub fn init(format: []const u8, datetime_format: []const u8, interval_secs: u64, color: c_ulong) DateTime { |
| 14 | return .{ | 14 | return .{ |
| 15 | .format = format, | 15 | .format = format, |
| 16 | .datetime_format = datetime_format, | 16 | .datetime_format = datetime_format, |
| @@ -19,7 +19,7 @@ pub const Date_Time = struct { | |||
| 19 | }; | 19 | }; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | - pub fn content(self: *Date_Time, buffer: []u8) []const u8 { | 22 | + pub fn content(self: *DateTime, buffer: []u8) []const u8 { |
| 23 | var now: c.time_t = c.time(null); | 23 | var now: c.time_t = c.time(null); |
| 24 | const tm_ptr = c.localtime(&now); | 24 | const tm_ptr = c.localtime(&now); |
| 25 | if (tm_ptr == null) return buffer[0..0]; | 25 | if (tm_ptr == null) return buffer[0..0]; |
| @@ -97,11 +97,11 @@ pub const Date_Time = struct { | |||
| 97 | }; | 97 | }; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | - pub fn interval(self: *Date_Time) u64 { | 100 | + pub fn interval(self: *DateTime) u64 { |
| 101 | return self.interval_secs; | 101 | return self.interval_secs; |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | - pub fn getColor(self: *Date_Time) c_ulong { | 104 | + pub fn getColor(self: *DateTime) c_ulong { |
| 105 | return self.color; | 105 | return self.color; |
| 106 | } | 106 | } |
| 107 | }; | 107 | }; |
+11 −11 src/config/config.zig
| @@ -36,13 +36,13 @@ pub const Action = enum { | |||
| 36 | scroll_right, | 36 | scroll_right, |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | -pub const Key_Press = struct { | 39 | +pub const KeyPress = struct { |
| 40 | mod_mask: u32 = 0, | 40 | mod_mask: u32 = 0, |
| 41 | keysym: u64 = 0, | 41 | keysym: u64 = 0, |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | pub const Keybind = struct { | 44 | pub const Keybind = struct { |
| 45 | - keys: [4]Key_Press = [_]Key_Press{.{}} ** 4, | 45 | + keys: [4]KeyPress = [_]KeyPress{.{}} ** 4, |
| 46 | key_count: u8 = 1, | 46 | key_count: u8 = 1, |
| 47 | action: Action, | 47 | action: Action, |
| 48 | int_arg: i32 = 0, | 48 | int_arg: i32 = 0, |
| @@ -59,7 +59,7 @@ pub const Rule = struct { | |||
| 59 | focus: bool, | 59 | focus: bool, |
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | -pub const Block_Type = enum { | 62 | +pub const BlockType = enum { |
| 63 | static, | 63 | static, |
| 64 | datetime, | 64 | datetime, |
| 65 | ram, | 65 | ram, |
| @@ -68,27 +68,27 @@ pub const Block_Type = enum { | |||
| 68 | cpu_temp, | 68 | cpu_temp, |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | -pub const Click_Target = enum { | 71 | +pub const ClickTarget = enum { |
| 72 | client_win, | 72 | client_win, |
| 73 | root_win, | 73 | root_win, |
| 74 | tag_bar, | 74 | tag_bar, |
| 75 | }; | 75 | }; |
| 76 | 76 | ||
| 77 | -pub const Mouse_Action = enum { | 77 | +pub const MouseAction = enum { |
| 78 | move_mouse, | 78 | move_mouse, |
| 79 | resize_mouse, | 79 | resize_mouse, |
| 80 | toggle_floating, | 80 | toggle_floating, |
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | -pub const Mouse_Button = struct { | 83 | +pub const MouseButton = struct { |
| 84 | - click: Click_Target, | 84 | + click: ClickTarget, |
| 85 | mod_mask: u32, | 85 | mod_mask: u32, |
| 86 | button: u32, | 86 | button: u32, |
| 87 | - action: Mouse_Action, | 87 | + action: MouseAction, |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | pub const Block = struct { | 90 | pub const Block = struct { |
| 91 | - block_type: Block_Type, | 91 | + block_type: BlockType, |
| 92 | format: []const u8, | 92 | format: []const u8, |
| 93 | command: ?[]const u8 = null, | 93 | command: ?[]const u8 = null, |
| 94 | interval: u32, | 94 | interval: u32, |
| @@ -145,7 +145,7 @@ pub const Config = struct { | |||
| 145 | keybinds: std.ArrayListUnmanaged(Keybind) = .{}, | 145 | keybinds: std.ArrayListUnmanaged(Keybind) = .{}, |
| 146 | rules: std.ArrayListUnmanaged(Rule) = .{}, | 146 | rules: std.ArrayListUnmanaged(Rule) = .{}, |
| 147 | blocks: std.ArrayListUnmanaged(Block) = .{}, | 147 | blocks: std.ArrayListUnmanaged(Block) = .{}, |
| 148 | - buttons: std.ArrayListUnmanaged(Mouse_Button) = .{}, | 148 | + buttons: std.ArrayListUnmanaged(MouseButton) = .{}, |
| 149 | autostart: std.ArrayListUnmanaged([]const u8) = .{}, | 149 | autostart: std.ArrayListUnmanaged([]const u8) = .{}, |
| 150 | 150 | ||
| 151 | pub fn init(allocator: std.mem.Allocator) Config { | 151 | pub fn init(allocator: std.mem.Allocator) Config { |
| @@ -176,7 +176,7 @@ pub const Config = struct { | |||
| 176 | try self.blocks.append(self.allocator, block); | 176 | try self.blocks.append(self.allocator, block); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | - pub fn addButton(self: *Config, button: Mouse_Button) !void { | 179 | + pub fn addButton(self: *Config, button: MouseButton) !void { |
| 180 | try self.buttons.append(self.allocator, button); | 180 | try self.buttons.append(self.allocator, button); |
| 181 | } | 181 | } |
| 182 | 182 | ||
+4 −4 src/config/lua.zig
| @@ -5,10 +5,10 @@ const Keybind = config_mod.Keybind; | |||
| 5 | const Action = config_mod.Action; | 5 | const Action = config_mod.Action; |
| 6 | const Rule = config_mod.Rule; | 6 | const Rule = config_mod.Rule; |
| 7 | const Block = config_mod.Block; | 7 | const Block = config_mod.Block; |
| 8 | -const Block_Type = config_mod.Block_Type; | 8 | +const Block_Type = config_mod.BlockType; |
| 9 | -const Mouse_Button = config_mod.Mouse_Button; | 9 | +const Mouse_Button = config_mod.MouseButton; |
| 10 | -const Click_Target = config_mod.Click_Target; | 10 | +const Click_Target = config_mod.ClickTarget; |
| 11 | -const Mouse_Action = config_mod.Mouse_Action; | 11 | +const Mouse_Action = config_mod.MouseAction; |
| 12 | const ColorScheme = config_mod.ColorScheme; | 12 | const ColorScheme = config_mod.ColorScheme; |
| 13 | 13 | ||
| 14 | const c = @cImport({ | 14 | const c = @cImport({ |
+3 −3 src/keyboard/chord.zig
| @@ -13,7 +13,7 @@ pub const timeout_ms: i64 = 1000; | |||
| 13 | /// whether the sequence is still live. Call `reset` to abandon the | 13 | /// whether the sequence is still live. Call `reset` to abandon the |
| 14 | /// current sequence and release the keyboard grab if one is held. | 14 | /// current sequence and release the keyboard grab if one is held. |
| 15 | pub const ChordState = struct { | 15 | pub const ChordState = struct { |
| 16 | - keys: [max_chord_len]config.Key_Press = .{config.Key_Press{}} ** max_chord_len, | 16 | + keys: [max_chord_len]config.KeyPress = .{config.KeyPress{}} ** max_chord_len, |
| 17 | index: u8 = 0, | 17 | index: u8 = 0, |
| 18 | last_timestamp: i64 = 0, | 18 | last_timestamp: i64 = 0, |
| 19 | keyboard_grabbed: bool = false, | 19 | keyboard_grabbed: bool = false, |
| @@ -22,7 +22,7 @@ pub const ChordState = struct { | |||
| 22 | /// | 22 | /// |
| 23 | /// Returns `false` if the sequence is already at maximum length, in which | 23 | /// Returns `false` if the sequence is already at maximum length, in which |
| 24 | /// case the caller should call `reset` before retrying. | 24 | /// case the caller should call `reset` before retrying. |
| 25 | - pub fn push(self: *ChordState, key: config.Key_Press) bool { | 25 | + pub fn push(self: *ChordState, key: config.KeyPress) bool { |
| 26 | if (self.index >= max_chord_len) return false; | 26 | if (self.index >= max_chord_len) return false; |
| 27 | self.keys[self.index] = key; | 27 | self.keys[self.index] = key; |
| 28 | self.index += 1; | 28 | self.index += 1; |
| @@ -42,7 +42,7 @@ pub const ChordState = struct { | |||
| 42 | /// `display` may be null only during early startup before the connection | 42 | /// `display` may be null only during early startup before the connection |
| 43 | /// is open, in normal operation it should always be provided. | 43 | /// is open, in normal operation it should always be provided. |
| 44 | pub fn reset(self: *ChordState, display: ?*xlib.Display) void { | 44 | pub fn reset(self: *ChordState, display: ?*xlib.Display) void { |
| 45 | - self.keys = .{config.Key_Press{}} ** max_chord_len; | 45 | + self.keys = .{config.KeyPress{}} ** max_chord_len; |
| 46 | self.index = 0; | 46 | self.index = 0; |
| 47 | self.last_timestamp = 0; | 47 | self.last_timestamp = 0; |
| 48 | 48 | ||
+16 −16 src/overlay.zig
| @@ -13,7 +13,7 @@ const key_bg_color: c_ulong = 0x2a2a2a; | |||
| 13 | 13 | ||
| 14 | const max_lines: usize = 12; | 14 | const max_lines: usize = 12; |
| 15 | 15 | ||
| 16 | -pub const Keybind_Overlay = struct { | 16 | +pub const KeybindOverlay = struct { |
| 17 | window: xlib.Window = 0, | 17 | window: xlib.Window = 0, |
| 18 | pixmap: xlib.Pixmap = 0, | 18 | pixmap: xlib.Pixmap = 0, |
| 19 | gc: xlib.GC = null, | 19 | gc: xlib.GC = null, |
| @@ -32,8 +32,8 @@ pub const Keybind_Overlay = struct { | |||
| 32 | descs: [max_lines][]const u8 = undefined, | 32 | descs: [max_lines][]const u8 = undefined, |
| 33 | line_count: usize = 0, | 33 | line_count: usize = 0, |
| 34 | 34 | ||
| 35 | - pub fn init(display: *xlib.Display, screen: c_int, root: xlib.Window, font_name: []const u8, allocator: std.mem.Allocator) ?*Keybind_Overlay { | 35 | + pub fn init(display: *xlib.Display, screen: c_int, root: xlib.Window, font_name: []const u8, allocator: std.mem.Allocator) ?*KeybindOverlay { |
| 36 | - const overlay = allocator.create(Keybind_Overlay) catch return null; | 36 | + const overlay = allocator.create(KeybindOverlay) catch return null; |
| 37 | 37 | ||
| 38 | const font_name_z = allocator.dupeZ(u8, font_name) catch { | 38 | const font_name_z = allocator.dupeZ(u8, font_name) catch { |
| 39 | allocator.destroy(overlay); | 39 | allocator.destroy(overlay); |
| @@ -60,7 +60,7 @@ pub const Keybind_Overlay = struct { | |||
| 60 | return overlay; | 60 | return overlay; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | - pub fn deinit(self: *Keybind_Overlay, allocator: std.mem.Allocator) void { | 63 | + pub fn deinit(self: *KeybindOverlay, allocator: std.mem.Allocator) void { |
| 64 | if (self.display) |display| { | 64 | if (self.display) |display| { |
| 65 | self.destroyWindow(display); | 65 | self.destroyWindow(display); |
| 66 | if (self.font) |font| { | 66 | if (self.font) |font| { |
| @@ -70,7 +70,7 @@ pub const Keybind_Overlay = struct { | |||
| 70 | allocator.destroy(self); | 70 | allocator.destroy(self); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | - fn destroyWindow(self: *Keybind_Overlay, display: *xlib.Display) void { | 73 | + fn destroyWindow(self: *KeybindOverlay, display: *xlib.Display) void { |
| 74 | if (self.xft_draw) |xft_draw| { | 74 | if (self.xft_draw) |xft_draw| { |
| 75 | xlib.XftDrawDestroy(xft_draw); | 75 | xlib.XftDrawDestroy(xft_draw); |
| 76 | self.xft_draw = null; | 76 | self.xft_draw = null; |
| @@ -89,7 +89,7 @@ pub const Keybind_Overlay = struct { | |||
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | - pub fn toggle(self: *Keybind_Overlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void { | 92 | + pub fn toggle(self: *KeybindOverlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void { |
| 93 | if (self.visible) { | 93 | if (self.visible) { |
| 94 | self.hide(); | 94 | self.hide(); |
| 95 | } else { | 95 | } else { |
| @@ -97,7 +97,7 @@ pub const Keybind_Overlay = struct { | |||
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | - pub fn show(self: *Keybind_Overlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void { | 100 | + pub fn show(self: *KeybindOverlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void { |
| 101 | const display = self.display orelse return; | 101 | const display = self.display orelse return; |
| 102 | 102 | ||
| 103 | self.collectKeybinds(config); | 103 | self.collectKeybinds(config); |
| @@ -167,7 +167,7 @@ pub const Keybind_Overlay = struct { | |||
| 167 | self.visible = true; | 167 | self.visible = true; |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | - pub fn hide(self: *Keybind_Overlay) void { | 170 | + pub fn hide(self: *KeybindOverlay) void { |
| 171 | if (!self.visible) return; | 171 | if (!self.visible) return; |
| 172 | if (self.display) |display| { | 172 | if (self.display) |display| { |
| 173 | _ = xlib.XUngrabKeyboard(display, xlib.CurrentTime); | 173 | _ = xlib.XUngrabKeyboard(display, xlib.CurrentTime); |
| @@ -178,7 +178,7 @@ pub const Keybind_Overlay = struct { | |||
| 178 | self.visible = false; | 178 | self.visible = false; |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | - pub fn handleKey(self: *Keybind_Overlay, keysym: u64) bool { | 181 | + pub fn handleKey(self: *KeybindOverlay, keysym: u64) bool { |
| 182 | if (!self.visible) return false; | 182 | if (!self.visible) return false; |
| 183 | if (keysym == 0xff1b or keysym == 'q' or keysym == 'Q') { | 183 | if (keysym == 0xff1b or keysym == 'q' or keysym == 'Q') { |
| 184 | self.hide(); | 184 | self.hide(); |
| @@ -187,11 +187,11 @@ pub const Keybind_Overlay = struct { | |||
| 187 | return false; | 187 | return false; |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | - pub fn isOverlayWindow(self: *Keybind_Overlay, win: xlib.Window) bool { | 190 | + pub fn isOverlayWindow(self: *KeybindOverlay, win: xlib.Window) bool { |
| 191 | return self.visible and self.window != 0 and self.window == win; | 191 | return self.visible and self.window != 0 and self.window == win; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | - fn draw(self: *Keybind_Overlay, display: *xlib.Display, max_key_width: i32, title: []const u8) void { | 194 | + fn draw(self: *KeybindOverlay, display: *xlib.Display, max_key_width: i32, title: []const u8) void { |
| 195 | self.fillRect(display, 0, 0, self.width, self.height, bg_color); | 195 | self.fillRect(display, 0, 0, self.width, self.height, bg_color); |
| 196 | 196 | ||
| 197 | const title_x = @divTrunc(self.width - self.textWidth(display, title), 2); | 197 | const title_x = @divTrunc(self.width - self.textWidth(display, title), 2); |
| @@ -217,12 +217,12 @@ pub const Keybind_Overlay = struct { | |||
| 217 | _ = xlib.c.XFlush(display); | 217 | _ = xlib.c.XFlush(display); |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | - fn fillRect(self: *Keybind_Overlay, display: *xlib.Display, x: i32, y: i32, w: i32, h: i32, color: c_ulong) void { | 220 | + fn fillRect(self: *KeybindOverlay, display: *xlib.Display, x: i32, y: i32, w: i32, h: i32, color: c_ulong) void { |
| 221 | _ = xlib.XSetForeground(display, self.gc, color); | 221 | _ = xlib.XSetForeground(display, self.gc, color); |
| 222 | _ = xlib.XFillRectangle(display, self.pixmap, self.gc, x, y, @intCast(w), @intCast(h)); | 222 | _ = xlib.XFillRectangle(display, self.pixmap, self.gc, x, y, @intCast(w), @intCast(h)); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | - fn drawText(self: *Keybind_Overlay, display: *xlib.Display, x: i32, y: i32, text: []const u8, color: c_ulong) void { | 225 | + fn drawText(self: *KeybindOverlay, display: *xlib.Display, x: i32, y: i32, text: []const u8, color: c_ulong) void { |
| 226 | if (self.xft_draw == null or self.font == null) return; | 226 | if (self.xft_draw == null or self.font == null) return; |
| 227 | if (text.len == 0) return; | 227 | if (text.len == 0) return; |
| 228 | 228 | ||
| @@ -241,14 +241,14 @@ pub const Keybind_Overlay = struct { | |||
| 241 | xlib.XftColorFree(display, visual, colormap, &xft_color); | 241 | xlib.XftColorFree(display, visual, colormap, &xft_color); |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | - fn textWidth(self: *Keybind_Overlay, display: *xlib.Display, text: []const u8) i32 { | 244 | + fn textWidth(self: *KeybindOverlay, display: *xlib.Display, text: []const u8) i32 { |
| 245 | if (self.font == null or text.len == 0) return 0; | 245 | if (self.font == null or text.len == 0) return 0; |
| 246 | var extents: xlib.XGlyphInfo = undefined; | 246 | var extents: xlib.XGlyphInfo = undefined; |
| 247 | xlib.XftTextExtentsUtf8(display, self.font, text.ptr, @intCast(text.len), &extents); | 247 | xlib.XftTextExtentsUtf8(display, self.font, text.ptr, @intCast(text.len), &extents); |
| 248 | return extents.xOff; | 248 | return extents.xOff; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | - fn collectKeybinds(self: *Keybind_Overlay, cfg: *config_mod.Config) void { | 251 | + fn collectKeybinds(self: *KeybindOverlay, cfg: *config_mod.Config) void { |
| 252 | const priority_actions = [_]config_mod.Action{ | 252 | const priority_actions = [_]config_mod.Action{ |
| 253 | .show_keybinds, | 253 | .show_keybinds, |
| 254 | .quit, | 254 | .quit, |
| @@ -280,7 +280,7 @@ pub const Keybind_Overlay = struct { | |||
| 280 | } | 280 | } |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | - fn formatKeyToBuf(self: *Keybind_Overlay, idx: usize, key: *const config_mod.Key_Press) void { | 283 | + fn formatKeyToBuf(self: *KeybindOverlay, idx: usize, key: *const config_mod.KeyPress) void { |
| 284 | var len: usize = 0; | 284 | var len: usize = 0; |
| 285 | var buf = &self.key_bufs[idx]; | 285 | var buf = &self.key_bufs[idx]; |
| 286 | 286 | ||
+4 −4 src/wm/wm.zig
| @@ -78,10 +78,10 @@ pub const WindowManager = struct { | |||
| 78 | 78 | ||
| 79 | chord: ChordState, | 79 | chord: ChordState, |
| 80 | 80 | ||
| 81 | - overlay: ?*overlay_mod.Keybind_Overlay, | 81 | + overlay: ?*overlay_mod.KeybindOverlay, |
| 82 | 82 | ||
| 83 | - scroll_animation: animations.Scroll_Animation, | 83 | + scroll_animation: animations.ScrollAnimation, |
| 84 | - animation_config: animations.Animation_Config, | 84 | + animation_config: animations.AnimationConfig, |
| 85 | 85 | ||
| 86 | running: bool, | 86 | running: bool, |
| 87 | last_motion_monitor: ?*Monitor, | 87 | last_motion_monitor: ?*Monitor, |
| @@ -306,7 +306,7 @@ pub const WindowManager = struct { | |||
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | fn setupOverlay(self: *WindowManager) void { | 308 | fn setupOverlay(self: *WindowManager) void { |
| 309 | - self.overlay = overlay_mod.Keybind_Overlay.init( | 309 | + self.overlay = overlay_mod.KeybindOverlay.init( |
| 310 | self.display.handle, | 310 | self.display.handle, |
| 311 | self.display.screen, | 311 | self.display.screen, |
| 312 | self.display.root, | 312 | self.display.root, |