From 7b1a3591e3083e3de4490046672772b7045918e2 Mon Sep 17 00:00:00 2001 From: Max Schillinger Date: Tue, 14 Nov 2023 22:40:38 +0100 Subject: [PATCH] mode/hint: Set style.right for :left hints Calculate and set style.right instead of setting style.left + style.transform (for :left hints). Limit style.left/right in both directions: Not less than 0, not to close to the window border. --- source/mode/hint.lisp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/source/mode/hint.lisp b/source/mode/hint.lisp index 4bf0a6e8a947..1af6a3bd48d3 100644 --- a/source/mode/hint.lisp +++ b/source/mode/hint.lisp @@ -128,22 +128,34 @@ A positive value shifts to the bottom.") (:left padding-left) (:right (- padding-right)) (otherwise 0))) + (absolute-x-position (+ (ps:@ window page-x-offset) + relative-x-position + padding-x-adjustment + user-x-offset)) + (inner-width (ps:@ window inner-width)) + (max-x-position (- inner-width 25)) (element (ps:chain document (create-element "span")))) (setf (ps:@ element class-name) "nyxt-hint" (ps:@ element style position) "absolute" - (ps:@ element style left) (+ (ps:max (+ (ps:@ window page-x-offset) - relative-x-position - padding-x-adjustment - user-x-offset) - 0) - "px") + (ps:@ element style left) (unless (eq user-x-alignment :left) + (+ (ps:min + max-x-position + (ps:max + 0 + absolute-x-position)) + "px")) + (ps:@ element style right) (when (eq user-x-alignment :left) + (+ (ps:min + max-x-position + (ps:max + 0 + (- inner-width absolute-x-position))) + "px")) (ps:@ element style top) (+ (ps:max (+ (ps:@ window page-y-offset) (ps:@ rect top) user-y-offset) 0) "px") - (ps:@ element style transform) (when (eq user-x-alignment :left) - "translate(-100%, 0)") (ps:@ element id) (+ "nyxt-hint-" hint) (ps:@ element text-content) hint) element))