summaryrefslogtreecommitdiff
path: root/src/macos
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 17:35:06 -0300
committerGabriel Schneider <[email protected]>2026-10-30 17:35:06 -0300
commit6d8da8721141284cf33bb901168b26135893eb86 (patch)
tree791d63401d4e85fbca1d597a8ce0326e70efd545 /src/macos
parentefd43a3a2cf03bb741366331158b368abf9ac583 (diff)
parentbf6810a8f9d6cc82050e7d9c0cfb06358301b574 (diff)
downloadpardes-6d8da8721141284cf33bb901168b26135893eb86.tar.gz
pardes-6d8da8721141284cf33bb901168b26135893eb86.zip
Merge latest upstream into the macOS branch for Zig 0.17
Retain the macOS branch history and local Acme selection color while adopting upstream's current core and platform changes. Pin Zig and ZLS to 0.17.0, and fetch the existing zstbi compatibility commit through upstream after its original fork was removed.
Diffstat (limited to 'src/macos')
-rw-r--r--src/macos/Sources/PardesView.swift8
-rw-r--r--src/macos/Sources/ScenePostprocessor.swift48
-rw-r--r--src/macos/pardes.h10
3 files changed, 13 insertions, 53 deletions
diff --git a/src/macos/Sources/PardesView.swift b/src/macos/Sources/PardesView.swift
index 5ad09c38..4ea4475a 100644
--- a/src/macos/Sources/PardesView.swift
+++ b/src/macos/Sources/PardesView.swift
@@ -523,9 +523,8 @@ private struct TaglineMetrics {
/// Where this band sits inside row `row`, measured down from the row's top.
/// The rule belongs to the core (`pardes_tagline_band_offset`) so that this
- /// shell and the SDL one cannot disagree about it: row zero and the first
- /// pane-tag row meet at a shared rule, a Tagbottom band on the last row
- /// faces the window edge, and everything between is centred.
+ /// shell and the SDL one cannot disagree about it: every band is centred,
+ /// except a Tagbottom band on the last row, which faces the window edge.
func top(row: Int, canvasHeight: CGFloat) -> CGFloat {
CGFloat(pardes_tagline_band_offset(
UInt16(clamping: row), Float(canvasHeight * scale), cellPixels, bandPixels)) / scale
@@ -563,6 +562,7 @@ private func modifiers(_ flags: NSEvent.ModifierFlags) -> UInt32 {
if flags.contains(.control) { mods |= UInt32(PARDES_MOD_CTRL) }
if flags.contains(.option) { mods |= UInt32(PARDES_MOD_ALT) }
if flags.contains(.shift) { mods |= UInt32(PARDES_MOD_SHIFT) }
+ if flags.contains(.command) { mods |= UInt32(PARDES_MOD_SUPER) }
return mods
}
@@ -685,7 +685,7 @@ final class PardesView: NSView {
private var latchedButton: pardes_mouse_button_e?
private var latchedCell: GridPoint?
/// Last physical point delivered by AppKit and its mapping through the
- /// accepted scene. Ripple/glitch can move a source cell under a stationary
+ /// accepted scene. The CRT's barrel moves a source cell under a stationary
/// hand, so successful scene presentations reconcile this point again.
private var pointerPoint: CGPoint?
private var pointerCell: GridPoint?
diff --git a/src/macos/Sources/ScenePostprocessor.swift b/src/macos/Sources/ScenePostprocessor.swift
index cf7892b3..41d54e34 100644
--- a/src/macos/Sources/ScenePostprocessor.swift
+++ b/src/macos/Sources/ScenePostprocessor.swift
@@ -205,11 +205,9 @@ final class ScenePostprocessor {
if scene.flags != 0 {
let crt: Float = scene.flags & UInt32(PARDES_SCENE_CRT) != 0 ? 1 : 0
- let ripple: Float = scene.flags & UInt32(PARDES_SCENE_RIPPLE) != 0 ? 1 : 0
- let glitch: Float = scene.flags & UInt32(PARDES_SCENE_GLITCH) != 0 ? 1 : 0
// SDL samples the scene with CLAMP_TO_EDGE. A finite Core Image
// instead supplies transparent black outside its extent, which
- // would make ripple/glitch tear dark seams at the window edge.
+ // would tear dark seams at the window edge.
// Clamp the input only; the kernel still emits true black before
// sampling when a destination lies outside the CRT tube.
let sceneInput = filtered.clampedToExtent()
@@ -218,7 +216,7 @@ final class ScenePostprocessor {
roiCallback: { _, _ in extent },
arguments: [
sceneInput, scene.time_seconds, Float(scene.frame),
- crt, ripple, glitch,
+ crt,
CIVector(x: extent.width, y: extent.height),
CIVector(x: extent.minX, y: extent.minY),
])
@@ -291,7 +289,7 @@ final class ScenePostprocessor {
/// The scene kernel is a destination-to-source mapping. Pointer input must
/// apply that same mapping before the grid and its panel tracks see a cell,
- /// otherwise a visible word under ripple/glitch is not the word Look gets.
+ /// otherwise a visible word under the barrel is not the word Look gets.
static func sourcePoint(
_ point: CGPoint,
size: CGSize,
@@ -311,27 +309,8 @@ final class ScenePostprocessor {
ccY *= barrel
uvX = ccX * 0.5 + 0.5
uvY = ccY * 0.5 + 0.5
- // Only CRT has a black tube. Ripple/glitch without CRT sample through
- // the texture's clamp-to-edge policy and remain clickable there.
+ // The CRT's black tube has no cell under it.
if crt > 0.5 && min(min(uvX, uvY), min(1 - uvX, 1 - uvY)) <= 0 { return nil }
-
- let time = scene.time_seconds
- if scene.flags & UInt32(PARDES_SCENE_RIPPLE) != 0 {
- let centeredX = uvX - 0.5
- let centeredY = uvY - 0.5
- let radius = sqrtf(centeredX * centeredX + centeredY * centeredY)
- let envelope = 1 - smoothstep(0.04, 0.72, radius)
- let wave = sinf(radius * 42 - time * 5.2)
- let travel = wave * envelope * 0.0032 / max(radius, 0.00001)
- uvX += centeredX * travel
- uvY += centeredY * travel
- }
- if scene.flags & UInt32(PARDES_SCENE_GLITCH) != 0 {
- let band = floorf(uvY * 96)
- let seed = noise(band, floorf(time * 13))
- let tear = smoothstep(0.955, 1, seed)
- uvX += (noise(seed, band) - 0.5) * tear * 0.020
- }
uvX = min(max(uvX, 0), max(0, 1 - 1 / Float(size.width)))
uvY = min(max(uvY, 0), max(0, 1 - 1 / Float(size.height)))
return CGPoint(
@@ -339,23 +318,4 @@ final class ScenePostprocessor {
y: CGFloat(1 - uvY) * size.height)
}
- private static func smoothstep(_ edge0: Float, _ edge1: Float, _ x: Float) -> Float {
- let t = min(max((x - edge0) / (edge1 - edge0), 0), 1)
- return t * t * (3 - 2 * t)
- }
-
- /// Scalar spelling of pardesNoise in crt.ci.metal. Float arithmetic is
- /// deliberate: the shader's band decision must not move at a Double round.
- private static func noise(_ x: Float, _ y: Float) -> Float {
- var qx = fract(x * 0.1031)
- var qy = fract(y * 0.1031)
- var qz = fract(x * 0.1031)
- let d = qx * (qy + 33.33) + qy * (qz + 33.33) + qz * (qx + 33.33)
- qx += d
- qy += d
- qz += d
- return fract((qx + qy) * qz)
- }
-
- private static func fract(_ x: Float) -> Float { x - floorf(x) }
}
diff --git a/src/macos/pardes.h b/src/macos/pardes.h
index f74330e5..33db3bb5 100644
--- a/src/macos/pardes.h
+++ b/src/macos/pardes.h
@@ -82,8 +82,7 @@ typedef struct {
// from the background colour, which a real selection shares.
#define PARDES_CELL_HOVER 0x04u
-// One coherent snapshot for the full-window shader pass. The bitmask lets the
-// host run CRT, ripple and glitch in one kernel instead of stacking filters;
+// One coherent snapshot for the full-window shader pass (CRT);
// time/frame advance only on pardes_animation_tick's display clock.
typedef struct {
uint32_t flags;
@@ -92,8 +91,6 @@ typedef struct {
} pardes_scene_s;
#define PARDES_SCENE_CRT 0x01u
-#define PARDES_SCENE_RIPPLE 0x02u
-#define PARDES_SCENE_GLITCH 0x04u
// One backend-neutral pane transition. Boxes are logical cell rectangles;
// the native shader converts them to backing pixels using the same measured
@@ -111,11 +108,12 @@ typedef struct {
uint8_t pane;
uint8_t phase;
uint8_t effect;
- uint8_t reserved0;
+ uint8_t motion;
uint16_t frame;
uint16_t frame_count;
pardes_panel_box_s from;
pardes_panel_box_s to;
+ float launch;
} pardes_panel_track_s;
#define PARDES_PANEL_OPENING 0u
@@ -143,6 +141,8 @@ typedef struct {
#define PARDES_MOD_CTRL 0x0001u
#define PARDES_MOD_ALT 0x0002u
#define PARDES_MOD_SHIFT 0x0004u
+// Command. Only a click reads it (Cmd-click is B3); a Command key chord never reaches the core.
+#define PARDES_MOD_SUPER 0x0008u
// Keys that carry no text. The four editing keys are their ASCII controls;
// everything else lives in a private-use plane so it can never collide with a