Skip to content

Commit

Permalink
Merge pull request #3381 from atlas-engineer/electron-input-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aadcg committed May 20, 2024
2 parents 5b2fac6 + b3ff6da commit 63fa20d
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 126 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable

- name: Compile ${{matrix.renderer}} port on ${{matrix.os}}
run: nix-shell build-scripts/shell-${{matrix.renderer}}.nix --run 'make all NYXT_RENDERER=${{matrix.renderer}}'
run: nix-shell build-scripts/shell.nix --run 'make all NYXT_RENDERER=${{matrix.renderer}}'

- name: Test ${{matrix.renderer}} port on ${{matrix.os}}
env:
NASDF_NON_INTERACTIVE_TESTS: true
# It runs the tests for system nyxt, not nyxt/${{matrix.renderer}}.
run: nix-shell build-scripts/shell-${{matrix.renderer}}.nix --run 'make check'
run: nix-shell build-scripts/shell.nix --run 'make check'
2 changes: 0 additions & 2 deletions build-scripts/nyxt.scm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

(use-modules (guix packages)
(guix gexp)
(nongnu packages lisp)
(gnu packages gstreamer)
(gnu packages web-browsers)
(gnu packages glib)
Expand Down Expand Up @@ -61,7 +60,6 @@
cl-custom-hash-table
cl-dexador
cl-dissect
cl-electron
cl-enchant
cl-flexi-streams
cl-gobject-introspection ; WebKitGTK
Expand Down
35 changes: 0 additions & 35 deletions build-scripts/shell-electron.nix

This file was deleted.

68 changes: 0 additions & 68 deletions build-scripts/shell-gi-gtk.nix

This file was deleted.

82 changes: 82 additions & 0 deletions build-scripts/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# SPDX-FileCopyrightText: Atlas Engineer LLC
# SPDX-License-Identifier: BSD-3-Clause

# To start the CL REPL:

# nix-shell /path/to/shell.nix --run 'sbcl --dynamic-space-size 3072'

{ pkgs ? import <nixpkgs> {} } :
with builtins;
let inherit (pkgs) stdenv; in
with pkgs;
stdenv.mkDerivation {
name = "nyxt-dev";

nativeBuildInputs = [
pkgs.libressl.out
pkgs.libfixposix.out
pkgs.sqlite.out
pkgs.pkg-config.out
pkgs.sbcl
]
++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [
pkgs.webkitgtk
];

buildInputs = [
pkgs.sqlite
pkgs.pkg-config
pkgs.enchant.out
pkgs.libfixposix.out
]
++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [
pkgs.gobject-introspection
pkgs.gsettings-desktop-schemas.out
pkgs.glib-networking.out
pkgs.pango.out
pkgs.cairo.out
pkgs.gdk-pixbuf.out
pkgs.gtk3.out
pkgs.glib.out
pkgs.webkitgtk
]
++ (with gst_all_1; [
gst-plugins-base
gst-plugins-good
gst-plugins-bad
gst-plugins-ugly
gst-libav
]);

LD_LIBRARY_PATH = with lib;
makeLibraryPath (
[
pkgs.enchant.out
pkgs.sqlite.out
pkgs.pkg-config.out
pkgs.libfixposix.out
pkgs.libressl.out
]
++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [
pkgs.gobject-introspection
pkgs.gsettings-desktop-schemas.out
pkgs.glib-networking.out
pkgs.pango.out
pkgs.cairo.out
pkgs.gdk-pixbuf.out
pkgs.gtk3.out
pkgs.glib.out
pkgs.webkitgtk
]
);

GIO_MODULE_DIR = "${pkgs.glib-networking.out}/lib/gio/modules/";
GIO_EXTRA_MODULES = "${pkgs.glib-networking.out}/lib/gio/modules/";

shellHook =
''
NYXT_ROOT=`dirname ${toString ../README.org}`;
export CL_SOURCE_REGISTRY=$HOME/common-lisp//:$NYXT_ROOT/_build//:$CL_SOURCE_REGISTRY;
'';

}
25 changes: 7 additions & 18 deletions source/input.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ Return nil to forward to renderer or non-nil otherwise."
(when (input-buffer-p buffer)
(setf (last-event buffer) event))
(when (prompt-buffer-p buffer)
;; Prompt buffer updating must happen on a separate thread.
(run-thread "update-prompt-buffer"
(update-prompt-input buffer
(ps-eval :buffer buffer
Expand All @@ -141,34 +140,24 @@ Return nil to forward to renderer or non-nil otherwise."
(declare (ignore matching-keymap))
(cond
((keymaps:keymap-p bound-function)
(echo "Pressed keys: ~a" (keyspecs-without-keycode key-stack))
(log:debug "Prefix binding ~a" (keyspecs key-stack translated-key))
(log:debug "Prefix binding ~a." (keyspecs key-stack translated-key))
t)

((typep bound-function '(and (not null) (or symbol command)))
(let ((command (typecase bound-function
(symbol (symbol-function (resolve-user-symbol bound-function :command)))
(command bound-function))))
(check-type command command)
(log:debug "Found key binding ~a to ~a" (keyspecs key-stack translated-key) bound-function)
;; We save the last key separately to keep it available to the
;; command even after key-stack has been reset in the other
;; thread.
(log:debug "Found key binding ~a to ~a." (keyspecs key-stack translated-key) bound-function)
(setf (last-key buffer) (first key-stack))
(unwind-protect
(funcall (command-dispatcher *browser*) command)
;; We must reset the key-stack on errors or else all subsequent
;; keypresses will keep triggering the same erroring command.
(setf key-stack nil))
(run-thread "run-command"
(unwind-protect (funcall (command-dispatcher *browser*) command)
(setf key-stack nil)))
t))

((or (and (input-buffer-p buffer) (forward-input-events-p buffer))
(pointer-event-p (first (last key-stack))))
(log:debug "Forward key ~s" (keyspecs key-stack))
(log:debug "Forward key ~s." (keyspecs key-stack))
(setf key-stack nil)
nil)

(t
(log:debug "Fallback forward key ~s" (keyspecs key-stack))
(log:debug "Fallback forward key ~s." (keyspecs key-stack))
(setf key-stack nil)
nil))))))

0 comments on commit 63fa20d

Please sign in to comment.