<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ismoil Vakhidov</title>
    <description>The latest articles on DEV Community by Ismoil Vakhidov (@ismoil77).</description>
    <link>https://dev.to/ismoil77</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4257031%2Fe21023f1-b1e2-452c-98c4-4e2003a0b638.jpg</url>
      <title>DEV Community: Ismoil Vakhidov</title>
      <link>https://dev.to/ismoil77</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ismoil77"/>
    <language>en</language>
    <item>
      <title>How Amberflip catches a file drag on Windows, Wayland and macOS</title>
      <dc:creator>Ismoil Vakhidov</dc:creator>
      <pubDate>Sat, 21 Nov 2026 09:28:21 +0000</pubDate>
      <link>https://dev.to/ismoil77/how-amberflip-catches-a-file-drag-on-windows-wayland-and-macos-3n4i</link>
      <guid>https://dev.to/ismoil77/how-amberflip-catches-a-file-drag-on-windows-wayland-and-macos-3n4i</guid>
      <description>&lt;p&gt;I make &lt;a href="https://amberflip.com" rel="noopener noreferrer"&gt;Amberflip&lt;/a&gt;, a small file converter. You drag a file, tap Shift, and a wheel of formats opens under the pointer. Drop the file on "JPG" and the converted copy appears next to the original. Nothing is uploaded: it all runs on your own computer. The app is written in Rust with egui and runs on Windows, Linux and macOS.&lt;/p&gt;

&lt;p&gt;Converting the files turned out to be the easy part. The hard part was noticing that someone is dragging a file at all, while that drag belongs to another app: Explorer, Finder, Nautilus, a browser. This post is about how that works on each system, and about how the same engine became an MCP server for Claude and other AI apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;winit 0.30, which egui runs on, reports hovered and dropped files on Windows and X11, but not on native Wayland. And no toolkit tells you where the pointer is during a drag that started in another application. So every system needed its own sensor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Windows: a low-level mouse hook
&lt;/h2&gt;

&lt;p&gt;A tiny resident process installs a &lt;code&gt;WH_MOUSE_LL&lt;/code&gt; hook. It arms when the left button goes down over an Explorer file view (&lt;code&gt;DirectUIHWND&lt;/code&gt; or &lt;code&gt;SysListView32&lt;/code&gt; inside &lt;code&gt;CabinetWClass&lt;/code&gt;, &lt;code&gt;Progman&lt;/code&gt; or &lt;code&gt;WorkerW&lt;/code&gt;) and fires once the pointer has travelled past the drag threshold.&lt;/p&gt;

&lt;p&gt;Things I learned on the way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Windows silently removes a hook that stalls for about 300 ms.&lt;/strong&gt; The callback does no I/O at all.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The wheel must not steal focus&lt;/strong&gt; from the app you are dragging from. The window uses &lt;code&gt;WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW&lt;/code&gt;. An unfocused window gets no key events, so the keys that switch rings are read with &lt;code&gt;GetAsyncKeyState&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transparency is not guaranteed.&lt;/strong&gt; On a machine without a usable GPU (many VMs), OpenGL is missing and wgpu falls back to Direct3D 12 on WARP, whose swap chain has no per-pixel alpha. The "transparent" window comes out black. The fallback is an opaque wheel with the window cut to a circle by &lt;code&gt;SetWindowRgn&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Elevation matters.&lt;/strong&gt; Windows blocks drag and drop from an elevated window to a normal one, so a drag from an Explorer window running as administrator can't land on the wheel.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wayland: there is no global drag detection
&lt;/h2&gt;

&lt;p&gt;On Wayland this is by design: one client must not see another client's drag. So I looked for the closest legal equivalent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hyprland, Sway, KDE.&lt;/strong&gt; The app puts a 2-pixel &lt;code&gt;wlr-layer-shell&lt;/code&gt; strip on one screen edge, on the overlay layer, with a transparent buffer. When a file drag touches the strip, the compositor sends &lt;code&gt;wl_data_device.enter&lt;/code&gt; with &lt;code&gt;text/uri-list&lt;/code&gt; on offer, and the daemon opens the wheel at the pointer. On Hyprland the pointer position comes from its IPC socket, which keeps answering during a drag. The edge is configurable, because the strip also swallows clicks on the outermost 2 pixels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Receiving the drop.&lt;/strong&gt; winit can't receive a drop on Wayland either, so Amberflip binds a second &lt;code&gt;wl_data_device&lt;/code&gt; on winit's own &lt;code&gt;wl_display&lt;/code&gt; and filters events by the window's &lt;code&gt;wl_surface&lt;/code&gt;. One detail matters a lot here: it accepts only the &lt;em&gt;copy&lt;/em&gt; action, never &lt;em&gt;move&lt;/em&gt;. With &lt;em&gt;move&lt;/em&gt;, the source app deletes the original file after the drop is finished.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GNOME.&lt;/strong&gt; Mutter has no layer-shell, and clients can't choose where their windows go. But Mutter emits &lt;code&gt;dnd-enter&lt;/code&gt; and &lt;code&gt;dnd-position-change(x, y)&lt;/code&gt; for every Wayland drag grab, so a small GNOME Shell extension forwards those signals over D-Bus and centres the wheel on the pointer. The catch: the extension can't tell a file drag from a text or tab drag, so the wheel closes by itself if nothing arrives.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing without a hand on the mouse.&lt;/strong&gt; A small example program owns a &lt;code&gt;text/uri-list&lt;/code&gt; data source and drives a &lt;code&gt;zwlr_virtual_pointer&lt;/code&gt;: press, start the drag, move along a line through the screen edge onto a wheel sector, release. Hyprland accepts virtual-pointer input, so the whole path runs without uinput or manual dragging.&lt;/p&gt;

&lt;h2&gt;
  
  
  macOS: no permissions at all
&lt;/h2&gt;

&lt;p&gt;I wanted no Accessibility or Input Monitoring prompt, and it worked out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A global &lt;code&gt;NSEvent&lt;/code&gt; monitor watches for the left mouse button going down. While it is held, the app reads the drag pasteboard every 25 ms. A new change count with &lt;code&gt;public.file-url&lt;/code&gt; on it means files are being dragged. macOS 26 doesn't always bump the count, so a window at the drag-image level (seen through &lt;code&gt;CGWindowListCopyWindowInfo&lt;/code&gt;) also counts.&lt;/li&gt;
&lt;li&gt;Modifier keys are polled with &lt;code&gt;CGEventSourceFlagsState&lt;/code&gt;, which needs no permission either.&lt;/li&gt;
&lt;li&gt;The wheel is a borderless transparent window at &lt;code&gt;NSStatusWindowLevel&lt;/code&gt;, on every Space and over full-screen apps, with the &lt;code&gt;Accessory&lt;/code&gt; activation policy so Finder keeps focus.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  One engine, three doors
&lt;/h2&gt;

&lt;p&gt;The conversion engine is a crate with no UI and no OS calls. The same engine sits behind the wheel, behind a command line tool, and behind an MCP server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx amberflip-cli convert photo.heic --to jpg
npx amberflip-cli compress talk.mp4 --target 40% --height 720
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Giving it to AI apps over MCP
&lt;/h2&gt;

&lt;p&gt;The MCP server has 38 tools: convert, compress, trim and join video, fix audio, crop and annotate pictures, merge, split and redact PDFs, strip metadata, zip and unzip. A few rules shaped it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Paths in, paths out.&lt;/strong&gt; The AI app and Amberflip share the disk, not the bytes. Answers contain the paths of the new files, never the contents of your files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never overwrite.&lt;/strong&gt; Results are new files next to the originals, or in a folder you choose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Look before you cut.&lt;/strong&gt; The server's instructions tell the model to call &lt;code&gt;inspect&lt;/code&gt; before an edit that needs numbers (a picture's size, a video's length, a PDF's page count), and &lt;code&gt;list_operations&lt;/code&gt; to see what applies. An operation whose converter is missing (FFmpeg, Ghostscript, LibreOffice) simply isn't listed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No port.&lt;/strong&gt; It talks over stdio only.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Distribution uses the same pattern as esbuild: the &lt;code&gt;amberflip-cli&lt;/code&gt; npm package lists one binary package per platform as &lt;code&gt;optionalDependencies&lt;/code&gt;, so npm fetches only the binary for your system. &lt;code&gt;bunx&lt;/code&gt; works too.&lt;/p&gt;

&lt;p&gt;Claude Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport stdio --scope user amberflip -- npx -y amberflip-cli mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Claude Desktop, Cursor and other clients:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"amberflip"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"amberflip-cli"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"mcp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then ask: "Make these 12 phone photos JPG, remove the GPS location, and put them in one ZIP." The files never leave your computer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;Amberflip is a paid app: free for 3 days, then a one-time licence key, no subscription. The app is at &lt;a href="https://amberflip.com" rel="noopener noreferrer"&gt;amberflip.com&lt;/a&gt;. Install guides for AI apps, the MCP manifests and the skills are on &lt;a href="https://github.com/ismoil77/amberflip-mcp" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. That repository has docs, not the source code.&lt;/p&gt;

&lt;p&gt;If you know a cleaner way to notice a global file drag on KDE or Sway than a 2-pixel edge strip, I'd really like to hear it in the comments.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I wrote this post with help from an AI assistant.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>wayland</category>
      <category>mcp</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
