-
-
Notifications
You must be signed in to change notification settings - Fork 17
refactor: The whole project #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: The whole project #6
Conversation
|
Checking in with this from time to time and it's really impressive stuff, thank you so much for your work on this! |
db4b31f to
865b158
Compare
|
You can merge now. FYI, I had to apply this workaround across multiple parts of the code, so it’s not fully idiomatic yet. type App struct {
app *models.App
}
func New(app *models.App) *App {
return &App{app: app}
}Instead of defining methods on the struct like this: func (a *App) foo() {}I prefer using standalone functions that take the struct as an argument: func foo(a *App) {}This avoids mutating structs from other packages, which is generally discouraged in Go. It keeps your API simpler and avoids unintentional side effects. Also, check the TODO comments I added for future refactoring. Currently, shaders are embedded in the binary, but we could also load them from disk or combine both approaches. Embedding works fine for now and keeps things self-contained. |
|
Very curious to test out this copilot review feature. Don't worry, will be reviewing manually too (hence the slow merge - sorry!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Major refactor to modularize the project, move Wayland/C interop into a dedicated package, externalize shaders, and introduce a proper cmd entrypoint.
- Extracted Wayland integration into pkg/wayland with xkbcommon-based key handling.
- Split application into internal packages (models, draw, update, spawn, stroke, gesture, execute, opengl) and moved main to cmd/hexecute.
- Externalized GLSL shaders to files (with go:embed) and added shader compilation helpers.
- Updated module path to GitHub and adjusted project structure.
Reviewed Changes
Copilot reviewed 31 out of 35 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| wayland.go | Removed legacy monolithic Wayland/C interop (replaced by pkg/wayland). |
| pkg/wayland/wlr-layer-shell-client.h | Formatting/consistency tweaks to autogenerated header. |
| pkg/wayland/wayland.h | New C header: Wayland/XKB declarations and exported functions. |
| pkg/wayland/wayland.go | New Go wrapper for Wayland/EGL window lifecycle and input. |
| pkg/wayland/wayland.c | New C implementation for Wayland glue, XKB, and input tracking. |
| pkg/wayland/keyboard-shortcuts-inhibit-client.h | Formatting/consistency tweaks to autogenerated header. |
| pkg/wayland/.clangd | Added editor config for C/C++ completions (non-functional change). |
| main.go | Removed monolithic main (replaced by cmd/hexecute). |
| internal/update/update.go | New package for cursor/particle update logic. |
| internal/stroke/stroke.go | Ported stroke/gesture logic into internal package. |
| internal/spawn/spawn.go | Particle spawning helpers split out. |
| internal/shaders/shader.go | Shader compilation helpers (from file and from source). |
| internal/shaders/paths.go | Shader paths and embedded shader sources. |
| internal/shaders/*.glsl | GLSL shaders extracted to files. |
| internal/opengl/opengl.go | OpenGL init and VAO/VBO/program setup. |
| internal/models/models.go | Centralized data structures (App, Point, Particle, GestureConfig). |
| internal/gesture/gesture.go | Gesture config load/save helpers. |
| internal/fornow/fornow.go | Transitional logic: point accumulation and gesture execution. |
| internal/execute/execute.go | Command execution helper. |
| internal/draw/draw.go | Rendering logic (background, glow, lines, particles). |
| internal/config/config.go | Config path helper. |
| go.mod | Module path updated; go version directive changed. |
| cmd/hexecute/main.go | New entrypoint wiring packages together and event loop. |
| README.md | Updated demo asset path. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| struct xkb_context *xkb_context; | ||
| struct xkb_keymap *xkb_keymap; | ||
| struct xkb_state *xkb_state; |
Copilot
AI
Oct 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xkb_context, xkb_keymap, and xkb_state are allocated but never released, causing a memory leak. Add a cleanup function (xkb_state_unref, xkb_keymap_unref, xkb_context_unref) and call it from WaylandWindow.Destroy.
| if *listGestures { | ||
| gestures, err := gestures.LoadGestures() | ||
| if err != nil { | ||
| log.Fatal("Failed to load gestures:", err) | ||
| } | ||
| if len(gestures) == 0 { |
Copilot
AI
Oct 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The local variable gestures shadows the imported package name 'gestures', which reduces readability and can lead to subtle mistakes. Consider renaming the variable to 'gs' or 'loadedGestures'.
| spawn := spawn.New(app) | ||
| spawn.SpawnExitWisps(float32(x), float32(y)) | ||
| } |
Copilot
AI
Oct 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The local variable spawn shadows the imported package 'spawn'. Rename the variable (e.g., 'spawner') to avoid confusion; the same pattern appears again when spawning cursor sparkles.
| spawn := spawn.New(app) | ||
| spawn.SpawnCursorSparkles(float32(x), float32(y)) |
Copilot
AI
Oct 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Same shadowing as above; rename the local variable to avoid masking the package import.
| logMsg := make([]byte, logLength) | ||
| gl.GetProgramInfoLog(a.app.Program, logLength, nil, &logMsg[0]) | ||
| log.Fatalf("Failed to link program: %s", logMsg) |
Copilot
AI
Oct 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Avoid calling log.Fatalf in a library/init function; prefer returning an error so the caller can decide how to handle failures. This pattern repeats for other program links in this file.
| type App struct { | ||
| *models.App | ||
| } | ||
|
|
Copilot
AI
Oct 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This wrapper type is declared but not used in the file; consider removing it to keep the entrypoint lean.
| type App struct { | |
| *models.App | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, accurate information from AI! The issue has been resolved in this PR, though it currently doesn’t affect the project.
|
if i had a penny for every hallucination here then i wouldn't need employment |
|
@cilginc what's with the |
Oh, I forgot to refactor that package before committing. Working on it. |
061bb59 to
f47aba9
Compare
ThatOtherAndrew
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally got through all this! And still with 1h20m of overnight sleep remaining 😅
Thanks again for the refactor!
|
Ready to merge, I believe! What command is it that you've been using to build the project outside of Nix? Is it something similar to the form |
I use |
|
Didn't know that ellipsis was a syntax, thanks! I'll update the README accordingly. |
No description provided.