an2io29 downloadsFixes Canvas drag-and-drop on Linux when Chromium misclassifies the mouse as a pen device. Common in VMware/VirtualBox guests, ChromeOS Crostini, and some Wayland setups.
An Obsidian plugin that fixes Canvas drag-and-drop on Linux when an ordinary mouse is misclassified as a pen device by Chromium/Electron.
If only drag interactions are broken while clicks work fine, this is almost certainly the bug this plugin fixes.
The bug is reproducible with or without sandboxing (firejail, snap, flatpak, AppImage). It's not specific to any sandbox or distribution.
Open Obsidian DevTools (Ctrl+Shift+I), go to the Console tab, type
allow pasting and Enter, then paste:
(() => {
const log = e => console.log(e.type, 'pointerType:', e.pointerType, 'button:', e.button);
['pointerdown','pointermove','pointerup'].forEach(t =>
document.addEventListener(t, log, true));
setTimeout(() => ['pointerdown','pointermove','pointerup'].forEach(t =>
document.removeEventListener(t, log, true)), 10000);
})();
Try to drag a Canvas card. If the console logs pointerType: pen for an
ordinary mouse, this plugin will fix it.
Obsidian's Canvas drag handler uses a strict equality check on the pointer type:
e.targetNode === this.wrapperEl && "mouse" === e.pointerType && 0 === e.button
Under the affected configurations, Chromium reports pointerType as "pen"
even for a regular mouse, so the handler rejects the event and the drag never
starts. This plugin registers capture-phase listeners on window for every
relevant pointer event type. When a pen event fires, it rewrites
pointerType to "mouse" in place using Object.defineProperty. Because we
mutate the original event rather than dispatch a synthetic clone, the event's
target, currentTarget, view, and propagation path stay correct. By the time
Obsidian's downstream handlers see the event, it looks like a normal mouse
event.
"mouse" check, this plugin becomes unnecessary.main.js and manifest.json from the latest release.<vault>/.obsidian/plugins/canvas-drag-fix/.npm install
npm run build
This produces main.js next to manifest.json. Copy both into your vault's
plugin folder.
For development, use npm run dev which rebuilds on changes.
0BSD. See LICENSE in the repository root.