Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderer/electron: draft. #3549

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions source/renderer/electron.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,18 @@ Note that by changing the default value, modifier keys can be remapped."))
"Return string representation of a keyval.
Return nil when key must be discarded, e.g. for modifiers."
(match key-string
((or "Alt" "Shift" "Control" "Meta") nil)
;; Compatibility layer between GDK keycode names and those of Browsers.
;; https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkkeysyms.h
;; https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
("ControlLeft" nil)
("ControlRight" nil)
("ShiftLeft" nil)
("ShiftRight" nil)
("MetaLeft" nil)
("MetaRight" nil)
("AltLeft" nil)
("AltRight" nil)
;; Key<CHAR>
((vector _ _ _ key) (cl-change-case:lower-case (string key)))
("-" "hyphen")
(" " "space")
("Space" "space")
("Enter" "return")
("Escape" "escape")
("Tab" "tab")
Expand Down Expand Up @@ -419,20 +425,26 @@ Return nil when key must be discarded, e.g. for modifiers."
(_ key-string)))

(defmethod on-signal-key-press-event ((sender electron-buffer) event)
(let ((modifiers (delete nil (list (when (assoc-value event :shift) :shift)
(when (string= "keyDown" (assoc-value event :type))
(let ((modifiers (delete nil (list (when (assoc-value event :shift) :shift)
(when (assoc-value event :control) :control)
(when (assoc-value event :alt) :alt)
(when (assoc-value event :meta) :meta))))
(key-string (translate-key-string (assoc-value event :key))))
(flet ((key () (keymaps:make-key :value key-string
:modifiers (input-modifier-translator sender modifiers)
:status :pressed)))
(when key-string
(alex:appendf (key-stack sender)
(list (key)))
(run-thread "on-signal-key-press" (on-signal-key-press sender (key)))
(dispatch-input-event event sender)))))

(when (assoc-value event :meta) :meta)))
;; (remove-if (lambda (item) (or (string= item "right")
;; (string= item "left")))
;; (assoc-value event :modifiers))
)
(key-string (translate-key-string (assoc-value event :code))))
(flet ((key () (keymaps:make-key :value key-string
:modifiers (input-modifier-translator sender modifiers)
:status :pressed)))
(when key-string
(alex:appendf (key-stack sender)
(list (key)))
(run-thread "on-signal-key-press" (on-signal-key-press sender (key)))
(dispatch-input-event event sender))))))

;; delete?
(defmethod on-signal-key-release-event ((sender electron-window) event)
(declare (ignore sender event)))

Expand Down