Why OmaSnap's Crosshair Feels Instant
I press the screenshot key in OmaSnap and the crosshair is already there. Not a fade, not a flicker, just there. Then I press the same key in ShareX-Rust, the rewrite we're building, and I can feel the gap. It is small, but once you notice it you can't stop noticing it.
So we read both codebases side by side to find out where the time goes. We expected one big mistake. We found something more interesting: OmaSnap is fast because of a long list of decisions that each cost it something, and most cross-platform apps can't make those decisions at all.
We haven't profiled either app on Hyprland yet, so the Linux section comes from reading the code and its numbers are estimates. The Windows numbers further down were measured.
What OmaSnap does when you press the key
OmaSnap is a Wayland screenshot and annotation overlay for Omarchy on Hyprland. Its path from key to crosshair is short:
- Ask
hyprctlwhich monitor has focus. - Grab that one monitor with
ext-image-copy-captureinto a shared memory buffer. - Wrap that buffer as a
QImagein the compositor's own pixel format. No copy, no conversion. - While the grab runs, fetch the window list from
hyprctl clientsin a second process. - Map one layer-shell surface and let Qt paint it on the CPU.
That is the whole list. The pixels the compositor wrote are the pixels Qt paints. Nothing on the way touches them.
What ShareX-Rust does on Hyprland
ShareX-Rust is built with GPUI and has to run on Windows, macOS, X11 and every Wayland desktop, and match the C# ShareX feature for feature. On Hyprland, the same key press does this, all in series on the UI thread:
- List the windows through X11. The capture library, xcap, opens a new connection to XWayland for every property it reads. A window's title, PID, position, size and state together take ten or more connections, so twenty open windows add up to a few hundred handshakes before the first pixel is grabbed. And because XWayland only knows X11 windows, native Wayland windows don't even appear in the list.
- List the monitors through X11, the same way.
- Grab every monitor, one after another, each waiting on its own round trip to the compositor. OmaSnap grabs only the one you're looking at.
- Convert the pixels several times. Each 4K monitor is about 33 MB. It is swizzled from the compositor's BGRx to RGBA, has its alpha set to 255 in another pass, is copied into one virtual-screen image when there are several monitors, and is then cut into tiles and swizzled back to BGRA for the GPU. That is four or five full passes over the image. OmaSnap makes none.
- Start the GPU. Each monitor gets a layer-shell window with its own swapchain, and the tiles are uploaded as textures before the first frame.
- Sometimes wait for the mouse. The pointer position comes from Hyprland's socket on the fast path only. If the capture falls back to the slow path, there is no pointer on Linux, and the crosshair appears only when you move the mouse.
Each step on that list has a reason. Together they are the delay I can feel.
What ShareX-Rust does on Windows
Windows doesn't have the XWayland problems, so we measured it instead of guessing. We turned on ShareX-Rust's startup profiler (SHAREX_PROFILE_STARTUP=1) and ran Region Capture three times on a Snapdragon X Elite laptop with two monitors. The clock starts when the running app receives the command:
| Step | Time (3 runs) |
|---|---|
| List windows and monitors | 2 to 3 ms |
Grab both monitors with GDI BitBlt |
61 to 77 ms |
| Join them into one image | 11 to 19 ms |
| Cut the image into GPU tiles | 6 to 9 ms |
| Open the two overlay windows | about 35 ms |
| First frame drawn on both | 200 to 237 ms in total |
Listing windows, which we worried about, costs almost nothing here. The grab is the biggest single step, and the pixel work around it (convert to RGBA, join, convert back to BGRA for the GPU) adds 25 to 35 ms more. The rest is GPUI opening two windows and drawing their first frames, and the monitor under the pointer is not always drawn first.
The profiler also stops before something you can see: Windows plays its window-open animation on the overlay. The C# ShareX turns that animation off for its Region Capture window; the Rust overlay doesn't yet.
Why that speed is hard to copy
Reading OmaSnap's AGENTS.md, the speed isn't a trick in one function. It's the product's rules:
- One compositor. OmaSnap supports Hyprland only, on purpose. A pull request for another compositor is welcome "only if it adds zero complexity to the Hyprland path". That rule lets it ask Hyprland directly for windows and monitors instead of going through a layer that works everywhere and is fast nowhere.
- One monitor. It captures the focused monitor, not the whole desktop. That halves or thirds the work on a multi-monitor desk before anything else happens.
- No conversions. It keeps the pixels in the compositor's format all the way to the screen. That only works because it never has to hand them to another platform's API.
- No GPU at startup. Qt paints into shared memory on the CPU. There is no device, swapchain or shader to set up while you wait.
- The main thread never blocks. Its threading notes say the UI thread does "capture, paint, and input handling, and nothing else". Anything slower runs on a worker, and the notes list the two times they broke that rule themselves and fixed it.
- No backwards compatibility and almost no settings. Fewer options means fewer branches between the key and the first frame.
Every one of those is a trade. ShareX can't drop Windows or macOS, can't capture only one monitor when the C# app captures all of them, and can't skip the GPU, because GPUI is the toolkit the whole app is built on. A project with four people, a feature-parity goal and three operating systems pays for portability on every key press.
What ShareX-Rust can still take from it
Not all of the gap is portability. Some of it is just work done in the wrong place, and that can change without giving up any platform.
Linux (Hyprland)
- Ask Hyprland, not XWayland. The code already talks to Hyprland's socket for the pointer. Asking it for clients and monitors too, on a separate thread during the grab, removes the X11 connections and fixes the missing Wayland windows.
- Grab the monitor under the pointer first. Grab it, open its overlay, then grab the rest.
- Convert once. Go from the compositor's buffer straight to GPU tiles in one pass.
- Always read the pointer, so the crosshair never waits for a mouse move.
Windows
- Turn off the window-open animation. Set
DWMWA_TRANSITIONS_FORCEDISABLEDon each overlay before it is shown, as the C# app already does. It costs one call and removes a delay the profiler can't even see. - Grab faster. The 61 to 77 ms GDI grab is the largest measured step. Grab the monitors in parallel instead of one after another, starting with the one under the pointer, and try DXGI Desktop Duplication or Windows Graphics Capture against
BitBlt. - Stay in BGRA. GDI already returns the byte order the GPU wants. Skipping the RGBA round trip and the joined image, and building each monitor's tiles straight from its own grab, should save most of the 25 to 35 ms of pixel work.
- Draw the pointer's monitor first. Open and paint its overlay before the others, so the crosshair you are looking at appears first.
Both
- Start the GPU early. Create the overlay windows when the app starts, hidden, and reuse them, so the key press doesn't pay for opening windows and setting up swapchains.
None of that will make a GPUI app paint like a Qt raster surface on its first frame. But it should move ShareX from "I can feel it" to "I have to measure it", which is the right goal for a tool you trigger dozens of times a day.
The lesson
Speed like OmaSnap's isn't an optimisation you add at the end. It comes from what the tool refuses to be: one compositor, one monitor, one job, no settings screen. Most of us can't refuse that much, but we can at least know what each feature costs between the key and the crosshair, and stop paying for the ones we don't need.
~ Mike