diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-09-15 17:32:22 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-09-15 17:32:22 +0200 |
commit | 47a341e159a7a8cb785c1f8d2a5201cc704dfe6d (patch) | |
tree | 6f824f1199f347d26324e5c00f32f72c10e1aa5a /org-roam-ui.el | |
parent | 7fe07246ff2facb32fdaa32f4ab71cce4f92dcc7 (diff) |
fix: #82 split windows sensibly in exwm/webkit
Diffstat (limited to 'org-roam-ui.el')
-rw-r--r-- | org-roam-ui.el | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/org-roam-ui.el b/org-roam-ui.el index 85f9e97..45849b7 100644 --- a/org-roam-ui.el +++ b/org-roam-ui.el @@ -133,6 +133,10 @@ Defaults to #'browse-url." (defvar oru-ws nil "The websocket for org-roam-ui.") +(defvar org-roam-ui--window nil + "The window for displaying nodes opened from within ORUI. +This is mostly to prevent issues with EXWM and the Webkit browser.") + ;; (defvar org-roam-ui-ws nil ;; "The websocket server for org-roam-ui.") @@ -175,9 +179,20 @@ This serves the web-build and API over HTTP." (command (alist-get 'command msg)) (data (alist-get 'data msg))) (cond ((string= command "open") - (org-roam-node-visit - (org-roam-populate (org-roam-node-create - :id (alist-get 'id data))) (not (org-roam-buffer-p)))) + (let* ((node (org-roam-populate (org-roam-node-create + :id (alist-get 'id data)))) + (pos (org-roam-node-point node)) + (buf (org-roam-node-find-noselect node))) + (unless (window-live-p org-roam-ui--window) + (if-let ((windows (window-list)) + (or-windows (seq-filter (lambda (window) (org-roam-buffer-p (window-buffer window))) windows)) + (newest-window (car (seq-sort-by #'window-use-time #'> or-windows)))) + (setq org-roam-ui--window newest-window) + (split-window-horizontally) + (setq org-roam-ui--window (frame-selected-window)))) + (set-window-buffer org-roam-ui--window buf) + (select-window org-roam-ui--window) + (goto-char pos))) ((string= command "delete") (progn (message "Deleted %s" (alist-get 'file data)) |