[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Show modeline when super key is pressed
From: |
Toby Worland |
Subject: |
Re: Show modeline when super key is pressed |
Date: |
Sun, 1 Dec 2024 02:30:35 +0000 |
Honestly I have little experience with xlib, but I’ll chuck my 2c in.
> each type of event is only bound to one single event-handler.
Sadly this is not the case, stump handles these events in other places
too. Go have a look in input.lisp and search for `xlib:process-event`.
I think the only real option is to add more hooks in so you can listen
for this key in a clean way. This is also why you’re not seeing your
key-release handler fire, as once a key that is mapped(1) has been
pressed, its release event gets handled somewhere else.
You will also need to grab the key so that stump will listen out for
it, see the `sync-keys` function.
I’ve attached my initial attempt at this, though it is not very clean.
It will only toggle the modeline outside of input boxes, and if you
also use super/meta as part of your prefix key, the mode line may get
stuck on until you hit it again. I’m assuming that adding the hooks to
check for this key in the other event handlers will fix these problems
though.
(1) non mapped keys like super & meta aren’t being listened for
init.lisp:
(in-package :stumpwm-user)
(defparameter *super-key* xlib::left-super-keysym)
(defparameter *meta-key* xlib::left-meta-keysym)
(defun mode-line-hidden-p ()
"Return T if the mode-line is hidden, else NIL."
(not (stumpwm::head-mode-line (current-head))))
(setq stumpwm::*custom-key-event-handler*
(lambda (code state)
(declare (ignore state))
(let ((keysym (xlib::keycode->keysym stumpwm::*display* code 0)))
(when (or (eql *super-key* keysym)
(eql *meta-key* keysym))
(when (mode-line-hidden-p)
(mode-line))))))
(stumpwm::define-stump-event-handler :key-release (code state)
(declare (ignore state))
(let ((keysym (xlib::keycode->keysym stumpwm::*display* code 0)))
(when (or (eql *super-key* keysym)
(eql *meta-key* keysym))
(unless (mode-line-hidden-p)
(mode-line)))))
(defun stumpwm::xwin-grab-keys (win group) ; Patched function from window.lisp
;; These two lines have been added
(stumpwm::xwin-grab-key win (stumpwm::make-key :keysym *super-key*))
(stumpwm::xwin-grab-key win (stumpwm::make-key :keysym *meta-key*))
;; Rest of this is original
(dolist (map (stumpwm::dereference-kmaps (stumpwm::top-maps group)))
(dolist (i (stumpwm::kmap-bindings map))
(stumpwm::xwin-grab-key win (stumpwm::binding-key i)))))
(stumpwm::sync-keys)
- Re: Show modeline when super key is pressed,
Toby Worland <=
- Re: Show modeline when super key is pressed, Daniel Radetsky, 2024/12/02
- Message not available
- Re: Show modeline when super key is pressed, Daniel Radetsky, 2024/12/10
- Re: Show modeline when super key is pressed, szos, 2024/12/15
- Re: Show modeline when super key is pressed, szos, 2024/12/31
- Re: Show modeline when super key is pressed, Lillia, 2024/12/31
- Re: Show modeline when super key is pressed, Daniel Radetsky, 2024/12/31
- Re: Show modeline when super key is pressed, Lillia, 2024/12/31
- Re: Show modeline when super key is pressed, szos, 2024/12/31
- Re: Show modeline when super key is pressed, szos, 2024/12/31