GNU bug report logs - #79806
Fixing the keyboard behavior in haiku

Previous Next

Package: emacs;

Reported by: "Vincent Filou" <vincent.filou <at> gmail.com>

Date: Mon, 10 Nov 2025 06:02:03 UTC

Severity: normal

To reply to this bug, email your comments to 79806 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#79806; Package emacs. (Mon, 10 Nov 2025 06:02:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Vincent Filou" <vincent.filou <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 10 Nov 2025 06:02:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Vincent Filou" <vincent.filou <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Fixing the keyboard behavior in haiku
Date: Sun, 09 Nov 2025 22:30:04 +0000
[Message part 1 (text/plain, inline)]
To quote https://www.gnu.org/software/emacs/manual/html_node/emacs/Haiku-Basics.html

"Emacs is incapable of receiving unusual modifier keys such as Hyper under Haiku, or to 
receive accented characters produced from the system Super key map."

The following patch corrects this behavior under Haiku OS, by distiguishing
between left and right option keys. The left option key is used for the super
modifier, the right option key is used for accented caracters. It is
expected that if there is only one option key, it will be the left,
thus the behavior should be the same as before the patch. 


In GNU Emacs 31.0.50 (build 1, x86_64-unknown-haiku, Haiku R1/beta5) of
 2025-11-09 built on shredder
Repository revision: d2bc774ec9c7bcdd47d3f893a690ca5683ce9a08
Repository branch: master
Windowing system distributor 'Haiku, Inc.', version 5.1.1
Configured using:
 'configure --prefix=/boot/home/config/non-packaged/ --with-be-app
 'CFLAGS=-O0 -g3''

[emacs_alt_patch_haiku.patch (text/x-patch, BMailAttachment)]
diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 8669e2f49e7..88892cdd3bf 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -427,6 +427,40 @@ map_caps (uint32_t kc, uint32_t *ch)
   key_map_lock.Unlock ();
 }
 
+static void
+map_option (uint32_t kc, uint32_t *ch)
+{
+  if (!key_map_lock.Lock ())
+    gui_abort ("Failed to lock keymap");
+  if (!key_map)
+    get_key_map (&key_map, &key_chars);
+  if (!key_map)
+    return;
+  if (kc >= 128)
+    return;
+
+  int32_t m = key_map->option_map[kc];
+  map_key (key_chars, m, ch);
+  key_map_lock.Unlock ();
+}
+
+static void
+map_shift_option (uint32_t kc, uint32_t *ch)
+{
+  if (!key_map_lock.Lock ())
+    gui_abort ("Failed to lock keymap");
+  if (!key_map)
+    get_key_map (&key_map, &key_chars);
+  if (!key_map)
+    return;
+  if (kc >= 128)
+    return;
+
+  int32_t m = key_map->option_shift_map[kc];
+  map_key (key_chars, m, ch);
+  key_map_lock.Unlock ();
+}
+
 static void
 map_caps_shift (uint32_t kc, uint32_t *ch)
 {
@@ -1087,7 +1121,7 @@ my_team_id (void)
 	if (mods & B_COMMAND_KEY)
 	  rq.modifiers |= HAIKU_MODIFIER_ALT;
 
-	if (mods & B_OPTION_KEY)
+	if (mods & B_LEFT_OPTION_KEY)
 	  rq.modifiers |= HAIKU_MODIFIER_SUPER;
 
 	/* mods & B_SHIFT_KEY should be inverted if keycode is
@@ -1137,14 +1171,21 @@ my_team_id (void)
 		if (mods & B_CAPS_LOCK)
 		  map_caps_shift (key, &rq.multibyte_char);
 		else
-		  map_shift (key, &rq.multibyte_char);
+		  if(mods & B_RIGHT_OPTION_KEY)
+			map_shift_option(key, &rq.multibyte_char);
+		  else
+			map_shift (key, &rq.multibyte_char);
 	      }
 	    else
 	      {
-		if (mods & B_CAPS_LOCK)
-		  map_caps (key, &rq.multibyte_char);
-		else
-		  map_normal (key, &rq.multibyte_char);
+			if(mods & B_RIGHT_OPTION_KEY)
+				map_option(key, &rq.multibyte_char);
+			else{
+				if (mods & B_CAPS_LOCK)
+					map_caps (key, &rq.multibyte_char);
+				else
+					map_normal (key, &rq.multibyte_char);
+			}
 	      }
 	  }
 
@@ -1167,7 +1208,7 @@ my_team_id (void)
 	if (mods & B_COMMAND_KEY)
 	  rq.modifiers |= HAIKU_MODIFIER_ALT;
 
-	if (mods & B_OPTION_KEY)
+	if (mods & B_LEFT_OPTION_KEY)
 	  rq.modifiers |= HAIKU_MODIFIER_SUPER;
 
 	float dx, dy;
@@ -2013,7 +2054,7 @@ my_team_id (void)
     if (mods & B_COMMAND_KEY)
       rq.modifiers |= HAIKU_MODIFIER_ALT;
 
-    if (mods & B_OPTION_KEY)
+    if (mods & B_LEFT_OPTION_KEY)
       rq.modifiers |= HAIKU_MODIFIER_SUPER;
 
     if (!scroll_bar)
@@ -2100,7 +2141,7 @@ my_team_id (void)
     if (mods & B_COMMAND_KEY)
       rq.modifiers |= HAIKU_MODIFIER_ALT;
 
-    if (mods & B_OPTION_KEY)
+    if (mods & B_LEFT_OPTION_KEY)
       rq.modifiers |= HAIKU_MODIFIER_SUPER;
 
     rq.time = when;
[BeOS Attributes (application/x-be_attribute, BMailAttachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79806; Package emacs. (Mon, 10 Nov 2025 12:11:02 GMT) Full text and rfc822 format available.

Message #8 received at 79806 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Vincent Filou" <vincent.filou <at> gmail.com>,
 Po Lu <luangruo <at> yahoo.com>
Cc: 79806 <at> debbugs.gnu.org
Subject: Re: bug#79806: Fixing the keyboard behavior in haiku
Date: Mon, 10 Nov 2025 14:09:59 +0200
> From: "Vincent Filou" <vincent.filou <at> gmail.com>
> Date: Sun, 09 Nov 2025 22:30:04 +0000
> 
> To quote https://www.gnu.org/software/emacs/manual/html_node/emacs/Haiku-Basics.html
> 
> "Emacs is incapable of receiving unusual modifier keys such as Hyper under Haiku, or to 
> receive accented characters produced from the system Super key map."
> 
> The following patch corrects this behavior under Haiku OS, by distiguishing
> between left and right option keys. The left option key is used for the super
> modifier, the right option key is used for accented caracters. It is
> expected that if there is only one option key, it will be the left,
> thus the behavior should be the same as before the patch. 

Thanks.  I'm adding Po Lu, who maintains the Haiku port, to the
discussion.

In any case, to accept a contribution of this size, we will need you
to sign a copyright assignment agreement that assigns the copyright
for your contribution to the FSF.  If you agree, I will send you the
form to fill and the instructions to go with it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79806; Package emacs. (Mon, 10 Nov 2025 15:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 79806 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Filou <vincent.filou <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, 79806 <at> debbugs.gnu.org
Subject: Re: bug#79806: Fixing the keyboard behavior in haiku
Date: Mon, 10 Nov 2025 16:19:11 +0100
[Message part 1 (text/plain, inline)]
Le lun. 10 nov. 2025 à 13:10, Eli Zaretskii <eliz <at> gnu.org> a écrit :

> > From: "Vincent Filou" <vincent.filou <at> gmail.com>
> > Date: Sun, 09 Nov 2025 22:30:04 +0000
> >
> > To quote
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Haiku-Basics.html
> >
> > "Emacs is incapable of receiving unusual modifier keys such as Hyper
> under Haiku, or to
> > receive accented characters produced from the system Super key map."
> >
> > The following patch corrects this behavior under Haiku OS, by
> distiguishing
> > between left and right option keys. The left option key is used for the
> super
> > modifier, the right option key is used for accented caracters. It is
> > expected that if there is only one option key, it will be the left,
> > thus the behavior should be the same as before the patch.
>
> Thanks.  I'm adding Po Lu, who maintains the Haiku port, to the
> discussion.
>
> In any case, to accept a contribution of this size, we will need you
> to sign a copyright assignment agreement that assigns the copyright
> for your contribution to the FSF.  If you agree, I will send you the
> form to fill and the instructions to go with it.


It’s just copy past of existing functions with tiny modifications :)  You
can send the form


>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79806; Package emacs. (Mon, 10 Nov 2025 15:47:01 GMT) Full text and rfc822 format available.

Message #14 received at 79806 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Vincent Filou <vincent.filou <at> gmail.com>
Cc: luangruo <at> yahoo.com, 79806 <at> debbugs.gnu.org
Subject: Re: bug#79806: Fixing the keyboard behavior in haiku
Date: Mon, 10 Nov 2025 17:46:14 +0200
> From: Vincent Filou <vincent.filou <at> gmail.com>
> Date: Mon, 10 Nov 2025 16:19:11 +0100
> Cc: Po Lu <luangruo <at> yahoo.com>, 79806 <at> debbugs.gnu.org
> 
> It’s just copy past of existing functions with tiny modifications :)  You can send the form 

Thanks, form sent off-list.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79806; Package emacs. (Tue, 11 Nov 2025 01:22:02 GMT) Full text and rfc822 format available.

Message #17 received at 79806 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: "Vincent Filou" <vincent.filou <at> gmail.com>
Cc: 79806 <at> debbugs.gnu.org
Subject: Re: bug#79806: Fixing the keyboard behavior in haiku
Date: Tue, 11 Nov 2025 09:21:31 +0800
"Vincent Filou" <vincent.filou <at> gmail.com> writes:

> To quote https://www.gnu.org/software/emacs/manual/html_node/emacs/Haiku-Basics.html
>
> "Emacs is incapable of receiving unusual modifier keys such as Hyper
> under Haiku, or to receive accented characters produced from the
> system Super key map."
>
> The following patch corrects this behavior under Haiku OS, by
> distiguishing between left and right option keys. The left option key
> is used for the super modifier, the right option key is used for
> accented caracters. It is expected that if there is only one option
> key, it will be the left, thus the behavior should be the same as
> before the patch.

Thanks.  This, I understand, is a departure from the typical behavior of
GUI programs on Haiku, and as such should be made conditional on a user
option.

Otherwise, the patch appears alright saving stylistic issues that must
be corrected before it is merged (but this can wait till you have
completed the copyright assignment procedure).




This bug report was last modified 1 day ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.