From e60613d7a38926fa323094ad96f6fe2bdeb535d2 Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 20 May 2024 23:05:11 +0300 Subject: [PATCH 1/6] gitmodules: Bump cl-electron. --- _build/cl-electron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_build/cl-electron b/_build/cl-electron index e647943dac3..270856b4984 160000 --- a/_build/cl-electron +++ b/_build/cl-electron @@ -1 +1 @@ -Subproject commit e647943dac358f97f3a27ab4a49dad3625c5c471 +Subproject commit 270856b49849a6f48c8d96cc2b6a05ac89a2b997 From 39ddbb52758f2817b31aa4a08bb16cb2f72a9a81 Mon Sep 17 00:00:00 2001 From: John Mercouris Date: Mon, 20 May 2024 22:31:52 +0300 Subject: [PATCH 2/6] input: Do not block on input dispatch. Otherwise, it wouldn't be possible to execute JavaScript when handling input from the renderer (Electron port). In more detail: - JavaScript waits for a synchronous response from Nyxt as to whether it should prevent an event from bubbling, or consume it. In other words, JavaScript needs to know whether it needs to run event.preventDefault(). - In our input handling on the Lisp side, if we try to execute some JavaScript before we return t/nil we'll send a request to a blocked JavaScript program (the one waiting for synchronous input), asking it to do something. - Our Lisp program will not continue until the JavaScript we tried to execute runs. - Our Lisp program will be unable to return t/nil. - We have deadlocked our program. --- source/input.lisp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/input.lisp b/source/input.lisp index 6acccf00003..49b9c3c5805 100644 --- a/source/input.lisp +++ b/source/input.lisp @@ -155,11 +155,11 @@ Return nil to forward to renderer or non-nil otherwise." ;; command even after key-stack has been reset in the other ;; thread. (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) + ;; We must reset the key-stack on errors or else all subsequent + ;; keypresses will keep triggering the same erroring command. + (setf key-stack nil))) t)) ((or (and (input-buffer-p buffer) (forward-input-events-p buffer)) From 742e9a9510c8251f6853dd8caec7c815f7368c56 Mon Sep 17 00:00:00 2001 From: John Mercouris Date: Mon, 20 May 2024 22:36:19 +0300 Subject: [PATCH 3/6] input(dispatch-input-event): Minor review. --- source/input.lisp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/source/input.lisp b/source/input.lisp index 49b9c3c5805..4d8a2ce487b 100644 --- a/source/input.lisp +++ b/source/input.lisp @@ -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 @@ -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)) (run-thread "run-command" (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))) 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)))))) From 4f32655f4f448b3406e909e6c688092e6f73ae49 Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 20 May 2024 18:37:44 +0300 Subject: [PATCH 4/6] build-scripts/nyxt.scm: Remove electron dependency. cl-electron must be located in a path where ASDF sees it. Note that the all non-lisp dependencies are now handled by Node.js. Reverts commit a39942d6540df93931a9682fa8723f1574fb4e43. --- build-scripts/nyxt.scm | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-scripts/nyxt.scm b/build-scripts/nyxt.scm index 656947c985a..e1cefa723c6 100644 --- a/build-scripts/nyxt.scm +++ b/build-scripts/nyxt.scm @@ -23,7 +23,6 @@ (use-modules (guix packages) (guix gexp) - (nongnu packages lisp) (gnu packages gstreamer) (gnu packages web-browsers) (gnu packages glib) @@ -61,7 +60,6 @@ cl-custom-hash-table cl-dexador cl-dissect - cl-electron cl-enchant cl-flexi-streams cl-gobject-introspection ; WebKitGTK From 3abca5870c481ee23868b28305707026d201cc63 Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 20 May 2024 18:41:56 +0300 Subject: [PATCH 5/6] build-scripts/shell.nix: Unify and refactor. Handles both the WebKitGTK and Electron ports. --- build-scripts/shell-electron.nix | 35 -------------- build-scripts/shell-gi-gtk.nix | 68 -------------------------- build-scripts/shell.nix | 82 ++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 103 deletions(-) delete mode 100644 build-scripts/shell-electron.nix delete mode 100644 build-scripts/shell-gi-gtk.nix create mode 100644 build-scripts/shell.nix diff --git a/build-scripts/shell-electron.nix b/build-scripts/shell-electron.nix deleted file mode 100644 index 0b2b30cc769..00000000000 --- a/build-scripts/shell-electron.nix +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-FileCopyrightText: Atlas Engineer LLC -# SPDX-License-Identifier: BSD-3-Clause - -# This file is meant to be used with the nyxt/electron system. Use this -# file to open a nix shell with the required dependencies to run SBCL -# and load nyxt/electron. - -{ pkgs ? import {} } : -with builtins; -let inherit (pkgs) stdenv; in -with pkgs; -stdenv.mkDerivation { - name = "nyxt-dev"; - - nativeBuildInputs = [ - pkgs.libressl.out - pkgs.libfixposix.out - pkgs.sbcl - pkgs.sqlite.out - pkgs.pkg-config.out - ]; - - buildInputs = [ electron_29-bin ]; - - LD_LIBRARY_PATH = with lib; "${makeLibraryPath [ pkgs.libfixposix.out - pkgs.sqlite.out - pkgs.libressl.out ]};"; - - shellHook = - '' - NYXT_ROOT=`dirname ${toString ../README.org}`; - export CL_SOURCE_REGISTRY=$HOME/common-lisp//:$NYXT_ROOT/_build//:$CL_SOURCE_REGISTRY; - ''; - -} diff --git a/build-scripts/shell-gi-gtk.nix b/build-scripts/shell-gi-gtk.nix deleted file mode 100644 index 79a92020b40..00000000000 --- a/build-scripts/shell-gi-gtk.nix +++ /dev/null @@ -1,68 +0,0 @@ -# SPDX-FileCopyrightText: Atlas Engineer LLC -# SPDX-License-Identifier: BSD-3-Clause - -# This file is meant to be used with the nyxt/gi-gtk system. Use this -# file to open a nix shell with the required dependencies to run SBCL -# and load nyxt/gi-gtk. - -{ pkgs ? import {} } : -with builtins; -let inherit (pkgs) stdenv; in -with pkgs; -stdenv.mkDerivation { - name = "nyxt-dev"; - - nativeBuildInputs = [ - pkgs.libressl.out - pkgs.webkitgtk - pkgs.sbcl - ]; - - buildInputs = [ - pkgs.sqlite - pkgs.gobject-introspection - pkgs.pkg-config - pkgs.enchant.out - 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.libfixposix.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.gsettings-desktop-schemas.out - pkgs.enchant.out - pkgs.sqlite.out - pkgs.glib-networking.out - pkgs.webkitgtk - pkgs.gobject-introspection - pkgs.pkg-config.out - pkgs.gtk3 - pkgs.pango.out - pkgs.cairo.out - pkgs.gdk-pixbuf.out - pkgs.glib.out - pkgs.libfixposix.out - pkgs.libressl.out ]};"; - - 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; - ''; - -} diff --git a/build-scripts/shell.nix b/build-scripts/shell.nix new file mode 100644 index 00000000000..04c934db41d --- /dev/null +++ b/build-scripts/shell.nix @@ -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 {} } : +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; + ''; + +} From b3ff6da2ca6bd65d90d94ef56779a5ba9986b61f Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 20 May 2024 22:54:49 +0300 Subject: [PATCH 6/6] .github/workflows/tests: Fix filename. --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c16a301a759..d63d93f083f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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'