RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
Merge upstream master into integration/neumorphism
Petar Margetića729a94f2622
diff --cc src/control_center/sections/appearance.zigindex e8d8c3b,3fec82f..95faadc--- a/src/control_center/sections/appearance.zig+++ b/src/control_center/sections/appearance.zig@@@ -611,8 -620,9 +625,9 @@@ pub const groups = [_]struct { title: ?.{ .title = i18n.msg("Themes & colours"), .rows = &.{ .theme, .taskbar_theme, .theme_pack, .icon_theme, .dark_mode, .app_colors } },.{ .title = i18n.msg("Wallpaper"), .rows = &.{.wallpaper} },.{ .title = i18n.msg("Fonts & cursor"), .rows = &.{ .font_family, .font_size, .cursor } },- .{ .title = i18n.msg("Windows"), .rows = &.{ .radius, .shadow, .edge_glow, .chrome_opacity, .window_tabs, .inactive_dim, .inactive_opacity, .terminal_opacity, .window_gap, .scrollbar_width } },+ .{ .title = i18n.msg("Windows"), .rows = &.{ .radius, .shadow, .edge_glow, .button_hover_glow, .chrome_opacity, .window_tabs, .inactive_dim, .inactive_opacity, .terminal_opacity, .window_gap, .scrollbar_width } },- .{ .title = i18n.msg("Motion & feedback"), .rows = &.{ .animations, .animation_speed, .reduced_motion, .focus_zoom, .drag_feedback, .drag_scale, .dodge_file_drags, .launch_splash } },+ .{ .title = i18n.msg("Motion & feedback"), .rows = &.{ .animations, .animation_speed, .reduced_motion, .focus_zoom, .switcher_style, .drag_feedback, .drag_scale, .dodge_file_drags, .launch_splash } },+ .{ .title = i18n.msg("Effects"), .rows = &.{ .effect_window_move, .effect_window_resize, .effect_window_minimize } },.{ .title = null, .rows = &.{.dock} },.{ .title = null, .rows = &.{.taskbar} },.{ .title = null, .rows = &.{.start_menu} },diff --cc src/control_center/sections/appearance_rows.zigindex fb217db,5d0cb47..b06561f--- a/src/control_center/sections/appearance_rows.zig+++ b/src/control_center/sections/appearance_rows.zig@@@ -233,7 -242,28 +243,28 @@@ pub fn buildBehaviorRows(out: *Section};}- /// The UI font, cursor theme, font size, radius, shadow and glow rows.+ /// Optional flame effects: three independent toggles, off by default. They+ /// only run while Animations are on (and Reduced motion is not).+ pub fn buildEffectRows(out: *Section, pal: theme.Theme) void {+ const effects = out.cc.server.config.effects;+ const rows = .{+ .{ "effect_window_move", i18n.msg("Flames while moving windows"), effects.window_move.enabled, &EffectToggle(.window_move).changed },+ .{ "effect_window_resize", i18n.msg("Flames while resizing windows"), effects.resize().enabled, &EffectToggle(.window_resize).changed },+ .{ "effect_window_minimize", i18n.msg("Flames when minimizing windows"), effects.minimize().enabled, &EffectToggle(.window_minimize).changed },+ };+ inline for (rows, 0..) |row, i| {+ out.effect_label_children[i] = .{+ .{ .kind = .{ .text = .{ .content = row[1].get(), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },+ .{ .kind = .{ .text = .{ .content = i18n.tr("Needs Animations to be on"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },+ };+ out.effect_row_children[i] = .{+ .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.effect_label_children[i] },+ .{ .name = row[0], .kind = .{ .toggle = .{ .on = row[2], .owner = out, .on_change = row[3] } } },+ };+ }+ }+-/// The UI font, cursor theme, font size, radius, shadow and edge glow rows.++/// The UI font, cursor theme, font size, radius, shadow, edge glow and button hover glow rows.pub fn buildFontRows(out: *Section, arena: std.mem.Allocator, t: theme.Theme, pal: theme.Theme) void {if (out.font_families == null) {out.font_families = @import("ui").font_fallback.listFamilies(out.font_arena.allocator()) catch null;diff --cc src/editor/app_controls.zigindex a872dfc,9022d6f..6865483--- a/src/editor/app_controls.zig+++ b/src/editor/app_controls.zig@@@ -8,91 -8,60 +8,143 @@@ const Rect = @import("ui").context_menuconst app = @import("app.zig");const App = app.App;const SearchControl = @import("app_search.zig").Control;+const ui_theme = @import("ui").theme;++pub fn buttonProximity(self: *const App, box: Rect) button.ProximitySample {+ return button.sampleProximity(+ .{ .x = @floatCast(box.x), .y = @floatCast(box.y), .w = @floatCast(box.w), .h = @floatCast(box.h) },+ @floatCast(self.px),+ @floatCast(self.py),+ .{ .x = 0, .y = 0, .w = @floatFromInt(self.w), .h = @floatFromInt(self.h) },+ );+}++fn nearestButton(self: *App, x: f64, y: f64) f32 {+ if (self.menu_open) return std.math.inf(f32);+ var nearest = std.math.inf(f32);+ if (self.close_tab != null) {+ if (self.operation == null) {+ const dx = (@as(f64, @floatFromInt(self.w)) - 420) / 2;+ const dy = (@as(f64, @floatFromInt(self.h)) - 170) / 2;+ for ([_]Rect{+ .{ .x = dx + 20, .y = dy + 112, .w = 115, .h = 38 },+ .{ .x = dx + 145, .y = dy + 112, .w = 125, .h = 38 },+ .{ .x = dx + 280, .y = dy + 112, .w = 120, .h = 38 },+ }) |box| {+ const sample = button.sampleProximity(+ .{ .x = @floatCast(box.x), .y = @floatCast(box.y), .w = @floatCast(box.w), .h = @floatCast(box.h) },+ @floatCast(x), @floatCast(y),+ .{ .x = 0, .y = 0, .w = @floatFromInt(self.w), .h = @floatFromInt(self.h) },+ );+ nearest = @min(nearest, sample.distance);+ }+ }+ return nearest;+ }- for (self.first_tab..self.tabs.items.len) |i| {- const index = i - self.first_tab;- if (@as(f64, @floatFromInt(index + 1)) * app.tab_w > self.tabRight()) break;++ for (0..self.tabs.items.len) |index| {++ const tab_x = self.tabX(index);++ if (tab_x >= self.tabRight()) break;++ if (tab_x + self.tabWidth() <= 0) continue;+ const box = self.tabCloseBox(index);+ const sample = button.sampleProximity(+ .{ .x = @floatCast(box.x), .y = @floatCast(box.y), .w = @floatCast(box.w), .h = @floatCast(box.h) },+ @floatCast(x), @floatCast(y),- .{ .x = 0, .y = 0, .w = @floatFromInt(self.w), .h = @floatFromInt(self.h) },++ .{ .x = 0, .y = 0, .w = @floatCast(self.tabRight()), .h = 38 },+ );+ nearest = @min(nearest, sample.distance);+ }+ for ([_]Rect{ self.newButtonBox() }) |box| {+ const sample = button.sampleProximity(+ .{ .x = @floatCast(box.x), .y = @floatCast(box.y), .w = @floatCast(box.w), .h = @floatCast(box.h) },+ @floatCast(x), @floatCast(y),+ .{ .x = 0, .y = 0, .w = @floatFromInt(self.w), .h = @floatFromInt(self.h) },+ );+ nearest = @min(nearest, sample.distance);+ }+ if (!self.has_titlebar) {+ const box = self.menuButtonBox();+ const sample = button.sampleProximity(+ .{ .x = @floatCast(box.x), .y = @floatCast(box.y), .w = @floatCast(box.w), .h = @floatCast(box.h) },+ @floatCast(x), @floatCast(y),+ .{ .x = 0, .y = 0, .w = @floatFromInt(self.w), .h = @floatFromInt(self.h) },+ );+ nearest = @min(nearest, sample.distance);+ }+ if (self.find_open) {+ const controls = [_]SearchControl{ .next, .toggle, .close, .replace, .replace_all };+ for (controls) |control| {+ if (!self.replace_open and (control == .replace or control == .replace_all)) continue;+ const box = self.searchBox(control);+ const sample = button.sampleProximity(+ .{ .x = @floatCast(box.x), .y = @floatCast(box.y), .w = @floatCast(box.w), .h = @floatCast(box.h) },+ @floatCast(x), @floatCast(y),+ .{ .x = 0, .y = 0, .w = @floatFromInt(self.w), .h = @floatFromInt(self.h) },+ );+ nearest = @min(nearest, sample.distance);+ }+ }+ return nearest;+}++pub fn proximityChanged(self: *App, old_x: f64, old_y: f64, new_x: f64, new_y: f64) bool {+ const reach = ui_theme.global.border_glow_reach;+ if (!ui_theme.global.button_hover_glow_enabled or reach <= 0) return false;+ return @min(nearestButton(self, old_x, old_y), nearestButton(self, new_x, new_y)) <= reach;+}- pub fn tabCloseBox(_: *const App, index: usize) Rect {- return .{ .x = @as(f64, @floatFromInt(index)) * app.tab_w + app.tab_w - 36, .y = 2, .w = 34, .h = 34 };+ /// The strip is the width left of the new-tab button. Tabs share it, none+ /// wider than `tab_max` or narrower than `tab_min`; a strip holding more than+ /// fit at `tab_min` scrolls by pixels, so the tab cut off at its edge shows+ /// that there is more.+ pub fn tabWidth(self: *const App) f64 {+ const count: f64 = @floatFromInt(@max(1, self.tabs.items.len));+ return std.math.clamp(self.tabRight() / count, app.tab_min, app.tab_max);+ }++ /// Where tab `index` starts on screen.+ pub fn tabX(self: *const App, index: usize) f64 {+ return @as(f64, @floatFromInt(index)) * self.tabWidth() - self.tab_scroll;+ }++ /// The tab under an x position of the strip.+ pub fn tabAt(self: *const App, x: f64) ?usize {+ if (x < 0 or x >= self.tabRight()) return null;+ const index: usize = @intFromFloat((x + self.tab_scroll) / self.tabWidth());+ return if (index < self.tabs.items.len) index else null;+ }++ pub fn tabScrollMax(self: *const App) f64 {+ const count: f64 = @floatFromInt(self.tabs.items.len);+ return @max(0, count * self.tabWidth() - self.tabRight());+ }++ pub fn scrollTabs(self: *App, delta: f64) void {+ const before = self.tab_scroll;+ self.tab_scroll = std.math.clamp(before + delta, 0, self.tabScrollMax());+ if (self.tab_scroll != before) self.dirty = true;+ }++ /// What decides whether the selected tab needs bringing into view.+ pub const Strip = struct { selected: usize = std.math.maxInt(usize), count: usize = 0, right: f64 = 0 };++ /// Scrolls the selected tab into view when it, the number of tabs or the+ /// width changed, and keeps the scroll in range. Other changes (typing)+ /// leave a strip the user scrolled away alone.+ pub fn revealTab(self: *App) void {+ const seen: Strip = .{ .selected = self.selected, .count = self.tabs.items.len, .right = self.tabRight() };+ if (!std.meta.eql(seen, self.strip_seen)) {+ self.strip_seen = seen;+ const width = self.tabWidth();+ const left = @as(f64, @floatFromInt(self.selected)) * width;+ if (left < self.tab_scroll) {+ self.tab_scroll = left;+ } else if (left + width > self.tab_scroll + seen.right) self.tab_scroll = left + width - seen.right;+ }+ self.tab_scroll = std.math.clamp(self.tab_scroll, 0, self.tabScrollMax());+ }++ pub fn tabCloseBox(self: *const App, index: usize) Rect {+ return .{ .x = self.tabX(index) + self.tabWidth() - 36, .y = 2, .w = 34, .h = 34 };}pub fn newButtonBox(self: *const App) Rect {diff --cc src/images/main.zigindex 6a79514,3f5daa6..52d66e4--- a/src/images/main.zig+++ b/src/images/main.zig@@@ -370,8 -372,8 +372,9 @@@ pub const Client = struct},.leave => {self.inside = false;+ self.finger_navigation.reset();self.app.cancelDrag();+ self.app.handleMotion(-1, -1);},.motion => |ev| {self.handlePointerMotion(ev.surface_x.toDouble(), ev.surface_y.toDouble());diff --cc src/input/motion.zigindex 8a7873e,eaac7a9..2a512d0--- a/src/input/motion.zig+++ b/src/input/motion.zig@@@ -180,47 -180,12 +180,51 @@@ pub fn updateDockReveal(input: *Input)while (it.next()) |output| output.dock.pointerAt(input.cursor.x, input.cursor.y, engaged);}+fn updateWidgetProximity(input: *Input) void {+ if (input.open_start_menu) |menu| {+ const local = scene_data.toNodeLocal(&menu.buffer_node.node, input.cursor.x, input.cursor.y);+ if (ui_input.updateButtonProximity(&menu.root, @floatCast(local.x), @floatCast(local.y), .{+ .x = 0,+ .y = 0,+ .w = @floatFromInt(menu.panel_box.width),+ .h = @floatFromInt(menu.panel_box.height),+ })) {+ menu.requestWidgetRepaint();+ }+ }++ if (input.open_control_center) |cc| {+ const local = cc.localPoint(input.cursor.x, input.cursor.y);+ if (ui_input.updateButtonProximity(&cc.root, @floatCast(local.x), @floatCast(local.y), .{+ .x = 0,+ .y = 0,+ .w = @floatFromInt(cc.panel_box.width),+ .h = @floatFromInt(cc.panel_box.height),+ })) {+ cc.requestWidgetRepaint();+ }+ }++ if (input.open_power_menu) |menu| {+ const local = scene_data.toNodeLocal(&menu.buffer_node.node, input.cursor.x, input.cursor.y);+ if (ui_input.updateButtonProximity(&menu.root, @floatCast(local.x), @floatCast(local.y), .{+ .x = 0,+ .y = 0,+ .w = @floatFromInt(menu.panel_box.width),+ .h = @floatFromInt(menu.panel_box.height),+ })) {+ menu.requestWidgetRepaint();+ }+ }+}+pub fn processCursorMotion(input: *Input, time_msec: u32) void {- if (input.server.locker != null or input.server.polkit_dialog != null or input.server.switcher.active()) return;+ if (input.server.locker != null or input.server.polkit_dialog != null) return;+ if (input.server.switcher.active()) {+ input.server.switcher.motion(input.cursor.x, input.cursor.y);+ return;+ }+ updateWidgetProximity(input);defer input.updateGrabBorderGlow();input.positionDragIcon();input.drag_dodge.motion();diff --cc src/pdf/client_input.zigindex c3fd56b,6560719..1724793--- a/src/pdf/client_input.zig+++ b/src/pdf/client_input.zig@@@ -20,9 -20,8 +20,10 @@@ pub fn pointerEvent(_: *wl.Pointer, eve},.leave => {self.inside = false;+ self.finger_navigation.reset();self.app.cancelDrag();+ self.app.handleMotion(-1, -1);+ self.app.dirty = true;},.motion => |ev| {self.handlePointerMotion(ev.surface_x.toDouble(), ev.surface_y.toDouble());diff --cc src/pdf_tests.zigindex b424cfa,da726e8..3cee7df--- a/src/pdf_tests.zig+++ b/src/pdf_tests.zig@@@ -7,7 -7,7 +7,8 @@@ const cache = @import("pdf/cache.zig")const worker = @import("pdf/worker.zig");test {+ _ = @import("pdf/app_pointer.zig");+ _ = @import("pdf/syscall_policy.zig");}const testing = std.testing;diff --cc src/ui/mod.zigindex 99d2c07,b07c2ae..d399a2b--- a/src/ui/mod.zig+++ b/src/ui/mod.zig@@@ -5,9 -5,8 +5,10 @@@ pub const arrange = @import("arrange.zipub const paint = @import("paint.zig");pub const window_chrome = @import("window_chrome.zig");pub const theme = @import("theme.zig");+pub const border_glow = @import("border_glow");pub const input = @import("input.zig");+pub const interaction_surface = @import("interaction_surface.zig");+ pub const trackpad_navigation = @import("trackpad_navigation.zig");pub const widgets = struct {pub const scrollbar = @import("widgets/scrollbar.zig");