Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

656 B
Raw Blame
import { usePlatform } from "./platformInfo";
import { useProject } from "./project";
import { clampZoom } from "./zoom";

interface Point {
  x: number;
  y: number;
}

/** Wry Cocoa/GTK supply logical points; Win32 supplies physical client pixels.
 * WebView2's DPR includes zoom; WKWebView's does not. All consumers need CSS pixels.
 */
export function nativeDropPoint(
  point: Point,
  os = usePlatform.getState().os,
  dpr = window.devicePixelRatio || 1,
  zoom = clampZoom(useProject.getState().settings?.appearance?.zoom) / 100,
): Point {
  const divisor = os === "windows" ? dpr : zoom;
  return { x: point.x / divisor, y: point.y / divisor };
}