unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* numpad doesnt seem to send kp events in wayland
@ 2024-10-21 23:17 joakim
  2024-10-22 21:55 ` Arsen Arsenović
  0 siblings, 1 reply; 9+ messages in thread
From: joakim @ 2024-10-21 23:17 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I used to use a numpad to bind to do things in emacs.

This used to work really well on the i3wm window manager and a gtk emacs
build.

Then I bought a nice new framework laptop which has a hidpi screen, so I
switched to using the sway wm, and emacs-pgtk.

Now the numpad no longer sends keypad events in a way that emacs
recognizes, instead just plain numbers are received.

for some reason i3 wont work anymore so I dont have anything to compare
with.

Is this just me or is this a well known problem?

below is an example of the code I use, but normally I just test with c-h
k to see which key emacs receives.

I also tried xev, and there it seems I get kp events, at least under
xwayland I guess.

(define-key cider-mode-map (kbd "<kp-enter>") 'sylt-stop)
(define-key cider-mode-map (kbd "<kp-separator>") 'sylt-play-metro)

(defmacro sylt-song-event-map-key (key num)
  `(define-key cider-mode-map (kbd ,key)
               (lambda  () (interactive)   (cider-nrepl-sync-request:eval  ,(concat "(sylt.core/song-event \"" num "\")")))))



(sylt-song-event-map-key "<kp-0>" "init")
(sylt-song-event-map-key "<kp-1>" "1")


-- 
Joakim Verona
joakim@verona.se



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: numpad doesnt seem to send kp events in wayland
  2024-10-21 23:17 numpad doesnt seem to send kp events in wayland joakim
@ 2024-10-22 21:55 ` Arsen Arsenović
  2024-10-23  7:11   ` joakim
  0 siblings, 1 reply; 9+ messages in thread
From: Arsen Arsenović @ 2024-10-22 21:55 UTC (permalink / raw)
  To: joakim; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1567 bytes --]

joakim@verona.se writes:

> Hello,
>
> I used to use a numpad to bind to do things in emacs.
>
> This used to work really well on the i3wm window manager and a gtk emacs
> build.
>
> Then I bought a nice new framework laptop which has a hidpi screen, so I
> switched to using the sway wm, and emacs-pgtk.
>
> Now the numpad no longer sends keypad events in a way that emacs
> recognizes, instead just plain numbers are received.
>
> for some reason i3 wont work anymore so I dont have anything to compare
> with.
>
> Is this just me or is this a well known problem?
>
> below is an example of the code I use, but normally I just test with c-h
> k to see which key emacs receives.
>
> I also tried xev, and there it seems I get kp events, at least under
> xwayland I guess.
>
> (define-key cider-mode-map (kbd "<kp-enter>") 'sylt-stop)
> (define-key cider-mode-map (kbd "<kp-separator>") 'sylt-play-metro)
>
> (defmacro sylt-song-event-map-key (key num)
>   `(define-key cider-mode-map (kbd ,key)
>                (lambda  () (interactive)   (cider-nrepl-sync-request:eval  ,(concat "(sylt.core/song-event \"" num "\")")))))
>
>
>
> (sylt-song-event-map-key "<kp-0>" "init")
> (sylt-song-event-map-key "<kp-1>" "1")

FWIW, you can try checking against https://git.sr.ht/~sircmpwn/wev and
WAYLAND_DEBUG=1 instead of xev to check whether there's matching
keycodes.

I don't have a keypad to test with right now but I suspect something can
be arranged for your case.  Consider (read-key) also as a test.
-- 
Arsen Arsenović

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: numpad doesnt seem to send kp events in wayland
  2024-10-22 21:55 ` Arsen Arsenović
@ 2024-10-23  7:11   ` joakim
  2024-10-23 13:06     ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 9+ messages in thread
From: joakim @ 2024-10-23  7:11 UTC (permalink / raw)
  To: Arsen Arsenović; +Cc: help-gnu-emacs

Arsen Arsenović <arsen@aarsen.me> writes:

> joakim@verona.se writes:
>
>> Hello,
>>
>> I used to use a numpad to bind to do things in emacs.
>>
>> This used to work really well on the i3wm window manager and a gtk emacs
>> build.
>>
>> Then I bought a nice new framework laptop which has a hidpi screen, so I
>> switched to using the sway wm, and emacs-pgtk.
>>
>> Now the numpad no longer sends keypad events in a way that emacs
>> recognizes, instead just plain numbers are received.
>>
>> for some reason i3 wont work anymore so I dont have anything to compare
>> with.
>>
>> Is this just me or is this a well known problem?
>>
>> below is an example of the code I use, but normally I just test with c-h
>> k to see which key emacs receives.
>>
>> I also tried xev, and there it seems I get kp events, at least under
>> xwayland I guess.
>>
>> (define-key cider-mode-map (kbd "<kp-enter>") 'sylt-stop)
>> (define-key cider-mode-map (kbd "<kp-separator>") 'sylt-play-metro)
>>
>> (defmacro sylt-song-event-map-key (key num)
>>   `(define-key cider-mode-map (kbd ,key)
>>                (lambda  () (interactive)   (cider-nrepl-sync-request:eval  ,(concat "(sylt.core/song-event \"" num "\")")))))
>>
>>
>>
>> (sylt-song-event-map-key "<kp-0>" "init")
>> (sylt-song-event-map-key "<kp-1>" "1")
>
> FWIW, you can try checking against https://git.sr.ht/~sircmpwn/wev and
> WAYLAND_DEBUG=1 instead of xev to check whether there's matching
> keycodes.
>
> I don't have a keypad to test with right now but I suspect something can
> be arranged for your case.  Consider (read-key) also as a test.

Thanks for the reply!

Using wev, installed from Fedora repos I get, for numpad 4, and normal 4:

[14:     wl_keyboard] key: serial: 60293; time: 61646320; key: 83; state: 0 (released)
                      sym: KP_4         (65460), utf8: ''
[14:     wl_keyboard] key: serial: 60294; time: 61651642; key: 13; state: 1 (pressed)
                      sym: 4            (52), utf8: '4'

That is, the numpad and the number pad sends distinct events that are
received by wev.

using (read-key) in emacs-pgtk, both the numpad and the number row are
received as the same event:

52 (#o64, #x34, ?4) [2 times]

I get the same in a emacs gtk session.

Maybe gtk is doing something weird?

I will need to compile some other type of emacs toolkit next I guess.


-- 
Joakim Verona
joakim@verona.se



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: numpad doesnt seem to send kp events in wayland
  2024-10-23  7:11   ` joakim
@ 2024-10-23 13:06     ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-10-24 18:17       ` joakim
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-10-23 13:06 UTC (permalink / raw)
  To: help-gnu-emacs

> using (read-key) in emacs-pgtk, both the numpad and the number row are
> received as the same event:

Lower-level is `read-event`: `read-key` has code to specifically
"decode" key events.  [ But I doubt it'll make a difference based on
what you posted earlier.  ]

> I get the same in a emacs gtk session.

Hmm... so what was the other session?

> Maybe gtk is doing something weird?

No comment 🙂

> I will need to compile some other type of emacs toolkit next I guess.

I'd actually suggest a bug report.


        Stefan


PS: You can rewrite your macro into a function.  I.e.

    (defmacro sylt-song-event-map-key (key num)
      `(define-key cider-mode-map (kbd ,key)
                   (lambda  ()
                     (interactive)
                     (cider-nrepl-sync-request:eval
                      ,(concat "(sylt.core/song-event \"" num "\")")))))

to

    (defun sylt-song-event-map-key (key num)
      (define-key cider-mode-map (kbd key)
                  (lambda  ()
                    (interactive)
                    (cider-nrepl-sync-request:eval
                     (concat "(sylt.core/song-event \"" num "\")")))))

[ This needs your file to start with the `-*- lexical-binding:t -*-`
  thingy, of course.  ]




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: numpad doesnt seem to send kp events in wayland
  2024-10-23 13:06     ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2024-10-24 18:17       ` joakim
  2024-10-24 20:05         ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: joakim @ 2024-10-24 18:17 UTC (permalink / raw)
  To: Stefan Monnier via Users list for the GNU Emacs text editor
  Cc: Stefan Monnier

Stefan Monnier via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

>> using (read-key) in emacs-pgtk, both the numpad and the number row are
>> received as the same event:
>
> Lower-level is `read-event`: `read-key` has code to specifically
> "decode" key events.  [ But I doubt it'll make a difference based on
> what you posted earlier.  ]

(read-event) returns 4, for numpad 4, as you expected.

>
>> I get the same in a emacs gtk session.
>
> Hmm... so what was the other session?

I   thought emacs-pgtk and emacs was distinct on fedora, maybe I'm
misunderstanding something.

yes, both are compiled --with-pgtk lol!

so now I tried emacs-29.4-gtk+x11 -Q

and then I get "4 (translated from <kp-4>)"
on c-h k, numpad 4, so xwayland is doing something correctly in this
case, which pgtk isnt doing in the same way(imho incorrectly but what do
I know)

(and as a reminder, I run emacs-pgtk because it looks super nice on
wayland, with the scaling hints I use on my framework hidpi screen, but
emacs-29.4-gtk+x11 doesnt look good.)


>
>> Maybe gtk is doing something weird?
>
> No comment 🙂
>
>> I will need to compile some other type of emacs toolkit next I guess.
>
> I'd actually suggest a bug report.

Alright, I'll try that thanks.


>
>         Stefan
>
>
> PS: You can rewrite your macro into a function.  I.e.
>
>     (defmacro sylt-song-event-map-key (key num)
>       `(define-key cider-mode-map (kbd ,key)
>                    (lambda  ()
>                      (interactive)
>                      (cider-nrepl-sync-request:eval
>                       ,(concat "(sylt.core/song-event \"" num "\")")))))
>
> to
>
>     (defun sylt-song-event-map-key (key num)
>       (define-key cider-mode-map (kbd key)
>                   (lambda  ()
>                     (interactive)
>                     (cider-nrepl-sync-request:eval
>                      (concat "(sylt.core/song-event \"" num "\")")))))
>
> [ This needs your file to start with the `-*- lexical-binding:t -*-`
>   thingy, of course.  ]

Thanks, I'll remember to add this when I get the numpad working again :)

Regards
/Joakim
>
>
-- 
Joakim Verona
joakim@verona.se



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: numpad doesnt seem to send kp events in wayland
  2024-10-24 18:17       ` joakim
@ 2024-10-24 20:05         ` Stefan Monnier
  2024-10-25 18:21           ` joakim
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2024-10-24 20:05 UTC (permalink / raw)
  To: joakim; +Cc: Stefan Monnier via Users list for the GNU Emacs text editor

> (and as a reminder, I run emacs-pgtk because it looks super nice on
> wayland, with the scaling hints I use on my framework hidpi screen, but
> emacs-29.4-gtk+x11 doesnt look good.)

IIUC, XWayland currently does a poor job of handling HiDPI, and there's
nothing the X11 clients can do about it.  You might want to report this
part as a bug against XWayland.

I think if they really want everyone to move to Wayland, they'll need
to improve XWayland to the point where there's no good reason to prefer
Xorg over Wayland+XWayland, except for very niche circumstances.
And HiDPI screens aren't niche any more.


        Stefan




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: numpad doesnt seem to send kp events in wayland
  2024-10-24 20:05         ` Stefan Monnier
@ 2024-10-25 18:21           ` joakim
  2024-10-25 20:18             ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: joakim @ 2024-10-25 18:21 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: Stefan Monnier via Users list for the GNU Emacs text editor

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> (and as a reminder, I run emacs-pgtk because it looks super nice on
>> wayland, with the scaling hints I use on my framework hidpi screen, but
>> emacs-29.4-gtk+x11 doesnt look good.)
>
> IIUC, XWayland currently does a poor job of handling HiDPI, and there's
> nothing the X11 clients can do about it.  You might want to report this
> part as a bug against XWayland.

Alright.

>
> I think if they really want everyone to move to Wayland, they'll need
> to improve XWayland to the point where there's no good reason to prefer
> Xorg over Wayland+XWayland, except for very niche circumstances.
> And HiDPI screens aren't niche any more.

For reference, this works nicely in sway but not xwayland:

output eDP-1 scale 1.25

in emacs-pgtk tis is somehow interpreted by the toolkit and the scaling
looks nice.

xwayland also scales but with terribly ugly bitmap scaling, or so i
assume.

Anyway, thanks for the help!

/joakim



>
>
>         Stefan
>
-- 
Joakim Verona
joakim@verona.se



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: numpad doesnt seem to send kp events in wayland
  2024-10-25 18:21           ` joakim
@ 2024-10-25 20:18             ` Stefan Monnier
  2024-10-29 21:13               ` joakim
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2024-10-25 20:18 UTC (permalink / raw)
  To: joakim; +Cc: Stefan Monnier via Users list for the GNU Emacs text editor

> xwayland also scales but with terribly ugly bitmap scaling, or so
> I assume.

I'm staying on Xorg for now (which also saves me from having to choose
and configure a new window manager) so I don't know the details, but while
watching the drama unfold I came across discussions about possible ways
out, see for example https://github.com/hyprwm/Hyprland/issues/6281.


        Stefan




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: numpad doesnt seem to send kp events in wayland
  2024-10-25 20:18             ` Stefan Monnier
@ 2024-10-29 21:13               ` joakim
  0 siblings, 0 replies; 9+ messages in thread
From: joakim @ 2024-10-29 21:13 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: Stefan Monnier via Users list for the GNU Emacs text editor

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> xwayland also scales but with terribly ugly bitmap scaling, or so
>> I assume.
>
> I'm staying on Xorg for now (which also saves me from having to choose
> and configure a new window manager) so I don't know the details, but while
> watching the drama unfold I came across discussions about possible ways
> out, see for example https://github.com/hyprwm/Hyprland/issues/6281.

Alright, thats promising! Thanks for the info!

As for me, I like trying new wm:s now and then, as long as theyre kind
of hackable it can be fun. I did try Hyprland, but I got motion sickness
from all the bling so I had to revert :)

>
>
>         Stefan
>
-- 
Joakim Verona
joakim@verona.se



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-10-29 21:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 23:17 numpad doesnt seem to send kp events in wayland joakim
2024-10-22 21:55 ` Arsen Arsenović
2024-10-23  7:11   ` joakim
2024-10-23 13:06     ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-10-24 18:17       ` joakim
2024-10-24 20:05         ` Stefan Monnier
2024-10-25 18:21           ` joakim
2024-10-25 20:18             ` Stefan Monnier
2024-10-29 21:13               ` joakim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).