aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYuuki Harano2020-11-26 23:44:29 +0900
committerYuuki Harano2020-11-26 23:44:29 +0900
commitdb169f81346f3a642b645937218dc3d1dae3301f (patch)
treef60239e63868fdb04bbc099ac60d92eb1c12dbea /src
parent68b8acc405f2f7f7cfca6fe88820dfa13161a3c6 (diff)
downloademacs-db169f81346f3a642b645937218dc3d1dae3301f.tar.gz
emacs-db169f81346f3a642b645937218dc3d1dae3301f.zip
Add support for hyper modifier key
* src/pgtkterm.c (x_find_modifier_meanings): Autodetect key mask. (pgtk_gtk_to_emacs_modifiers): Use autodetected mask instead of GDK's. (pgtk_emacs_to_gtk_modifiers): Use autodetected mask instead of GDK's. (key_press_event): Ignore hyper as well as super. * src/pgtkterm.h (struct pgtk_display_info): New member for hyper.
Diffstat (limited to 'src')
-rw-r--r--src/pgtkterm.c27
-rw-r--r--src/pgtkterm.h2
2 files changed, 24 insertions, 5 deletions
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 6f2bb2898b2..0cf9bb84e76 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -5441,6 +5441,25 @@ x_find_modifier_meanings (struct pgtk_display_info *dpyinfo)
5441 { 5441 {
5442 dpyinfo->super_mod_mask = GDK_MOD4_MASK; 5442 dpyinfo->super_mod_mask = GDK_MOD4_MASK;
5443 } 5443 }
5444
5445 state = GDK_HYPER_MASK;
5446 r = gdk_keymap_map_virtual_modifiers (keymap, &state);
5447 if (r)
5448 {
5449 /* Hyper key exists. */
5450 if (state == GDK_HYPER_MASK)
5451 {
5452 dpyinfo->hyper_mod_mask = GDK_MOD3_MASK; /* maybe this is hyper. */
5453 }
5454 else
5455 {
5456 dpyinfo->hyper_mod_mask = state & ~GDK_HYPER_MASK;
5457 }
5458 }
5459 else
5460 {
5461 dpyinfo->hyper_mod_mask = GDK_MOD3_MASK;
5462 }
5444} 5463}
5445 5464
5446static void 5465static void
@@ -5497,7 +5516,7 @@ pgtk_gtk_to_emacs_modifiers (struct pgtk_display_info *dpyinfo, int state)
5497 mod |= mod_alt; 5516 mod |= mod_alt;
5498 if (state & dpyinfo->super_mod_mask) 5517 if (state & dpyinfo->super_mod_mask)
5499 mod |= mod_super; 5518 mod |= mod_super;
5500 if (state & GDK_HYPER_MASK) 5519 if (state & dpyinfo->hyper_mod_mask)
5501 mod |= mod_hyper; 5520 mod |= mod_hyper;
5502 return mod; 5521 return mod;
5503} 5522}
@@ -5521,7 +5540,7 @@ pgtk_emacs_to_gtk_modifiers (struct pgtk_display_info *dpyinfo, int state)
5521 if (state & mod_super) 5540 if (state & mod_super)
5522 mask |= dpyinfo->super_mod_mask; 5541 mask |= dpyinfo->super_mod_mask;
5523 if (state & mod_hyper) 5542 if (state & mod_hyper)
5524 mask |= GDK_HYPER_MASK; 5543 mask |= dpyinfo->hyper_mod_mask;
5525 if (state & shift_modifier) 5544 if (state & shift_modifier)
5526 mask |= GDK_SHIFT_MASK; 5545 mask |= GDK_SHIFT_MASK;
5527 if (state & mod_ctrl) 5546 if (state & mod_ctrl)
@@ -5613,10 +5632,10 @@ key_press_event (GtkWidget * widget, GdkEvent * event, gpointer * user_data)
5613 { 5632 {
5614 /* While super is pressed, gtk_im_context_filter_keypress() always process the 5633 /* While super is pressed, gtk_im_context_filter_keypress() always process the
5615 * key events ignoring super. 5634 * key events ignoring super.
5616 * As a work around, don't call it while super is pressed... 5635 * As a work around, don't call it while super or hyper are pressed...
5617 */ 5636 */
5618 struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); 5637 struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
5619 if (!(event->key.state & dpyinfo->super_mod_mask)) 5638 if (!(event->key.state & (dpyinfo->super_mod_mask | dpyinfo->hyper_mod_mask)))
5620 { 5639 {
5621 if (pgtk_im_filter_keypress (f, &event->key)) 5640 if (pgtk_im_filter_keypress (f, &event->key))
5622 return TRUE; 5641 return TRUE;
diff --git a/src/pgtkterm.h b/src/pgtkterm.h
index a777885518e..09b3b21b170 100644
--- a/src/pgtkterm.h
+++ b/src/pgtkterm.h
@@ -235,7 +235,7 @@ struct pgtk_display_info
235 struct frame *last_mouse_glyph_frame; 235 struct frame *last_mouse_glyph_frame;
236 236
237 /* Modifier masks in gdk */ 237 /* Modifier masks in gdk */
238 int meta_mod_mask, alt_mod_mask, super_mod_mask; 238 int meta_mod_mask, alt_mod_mask, super_mod_mask, hyper_mod_mask;
239 239
240 /* The last click event. */ 240 /* The last click event. */
241 GdkEvent *last_click_event; 241 GdkEvent *last_click_event;