diff options
| author | Po Lu | 2022-01-18 19:52:51 +0800 |
|---|---|---|
| committer | Po Lu | 2022-01-18 19:54:22 +0800 |
| commit | 4f23dbaa67183097f2aba1b93ace3646466faca9 (patch) | |
| tree | 0d8874d8ab53e18d8ca29267ad5a114972d5069b /src | |
| parent | 9f25c41ad45eaa34c8b7aa88a8c75d5dd4bd7ba7 (diff) | |
| download | emacs-4f23dbaa67183097f2aba1b93ace3646466faca9.tar.gz emacs-4f23dbaa67183097f2aba1b93ace3646466faca9.zip | |
Intern virtual modifier atoms the smart way on X
* src/xterm.c (x_find_modifier_meanings): Get rid of calls to
XInternAtom.
(x_term_init): Initialize atom refs for virtual modifiers and
make sure to only call `x_find_modifier_meanings' after they
are interned.
* src/xterm.h (struct x_display_info): New fields for virtual
modifier atoms.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 36 | ||||
| -rw-r--r-- | src/xterm.h | 5 |
2 files changed, 22 insertions, 19 deletions
diff --git a/src/xterm.c b/src/xterm.c index 9bf4404c9cf..54d10e01c30 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -5436,11 +5436,6 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo) | |||
| 5436 | int syms_per_code; | 5436 | int syms_per_code; |
| 5437 | XModifierKeymap *mods; | 5437 | XModifierKeymap *mods; |
| 5438 | #ifdef HAVE_XKB | 5438 | #ifdef HAVE_XKB |
| 5439 | Atom meta; | ||
| 5440 | Atom super; | ||
| 5441 | Atom hyper; | ||
| 5442 | Atom shiftlock; | ||
| 5443 | Atom alt; | ||
| 5444 | int i; | 5439 | int i; |
| 5445 | int found_meta_p = false; | 5440 | int found_meta_p = false; |
| 5446 | #endif | 5441 | #endif |
| @@ -5454,28 +5449,22 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo) | |||
| 5454 | #ifdef HAVE_XKB | 5449 | #ifdef HAVE_XKB |
| 5455 | if (dpyinfo->xkb_desc) | 5450 | if (dpyinfo->xkb_desc) |
| 5456 | { | 5451 | { |
| 5457 | meta = XInternAtom (dpyinfo->display, "Meta", False); | ||
| 5458 | super = XInternAtom (dpyinfo->display, "Super", False); | ||
| 5459 | hyper = XInternAtom (dpyinfo->display, "Hyper", False); | ||
| 5460 | shiftlock = XInternAtom (dpyinfo->display, "ShiftLock", False); | ||
| 5461 | alt = XInternAtom (dpyinfo->display, "Alt", False); | ||
| 5462 | |||
| 5463 | for (i = 0; i < XkbNumVirtualMods; i++) | 5452 | for (i = 0; i < XkbNumVirtualMods; i++) |
| 5464 | { | 5453 | { |
| 5465 | uint vmodmask = dpyinfo->xkb_desc->server->vmods[i]; | 5454 | uint vmodmask = dpyinfo->xkb_desc->server->vmods[i]; |
| 5466 | 5455 | ||
| 5467 | if (dpyinfo->xkb_desc->names->vmods[i] == meta) | 5456 | if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_Meta) |
| 5468 | { | 5457 | { |
| 5469 | dpyinfo->meta_mod_mask |= vmodmask; | 5458 | dpyinfo->meta_mod_mask |= vmodmask; |
| 5470 | found_meta_p = vmodmask; | 5459 | found_meta_p = vmodmask; |
| 5471 | } | 5460 | } |
| 5472 | else if (dpyinfo->xkb_desc->names->vmods[i] == alt) | 5461 | else if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_Alt) |
| 5473 | dpyinfo->alt_mod_mask |= vmodmask; | 5462 | dpyinfo->alt_mod_mask |= vmodmask; |
| 5474 | else if (dpyinfo->xkb_desc->names->vmods[i] == super) | 5463 | else if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_Super) |
| 5475 | dpyinfo->super_mod_mask |= vmodmask; | 5464 | dpyinfo->super_mod_mask |= vmodmask; |
| 5476 | else if (dpyinfo->xkb_desc->names->vmods[i] == hyper) | 5465 | else if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_Hyper) |
| 5477 | dpyinfo->hyper_mod_mask |= vmodmask; | 5466 | dpyinfo->hyper_mod_mask |= vmodmask; |
| 5478 | else if (dpyinfo->xkb_desc->names->vmods[i] == shiftlock) | 5467 | else if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_ShiftLock) |
| 5479 | dpyinfo->shift_lock_mask |= vmodmask; | 5468 | dpyinfo->shift_lock_mask |= vmodmask; |
| 5480 | } | 5469 | } |
| 5481 | 5470 | ||
| @@ -15337,9 +15326,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 15337 | XkbNewKeyboardNotifyMask | XkbMapNotifyMask, | 15326 | XkbNewKeyboardNotifyMask | XkbMapNotifyMask, |
| 15338 | XkbNewKeyboardNotifyMask | XkbMapNotifyMask); | 15327 | XkbNewKeyboardNotifyMask | XkbMapNotifyMask); |
| 15339 | } | 15328 | } |
| 15340 | |||
| 15341 | /* Figure out which modifier bits mean what. */ | ||
| 15342 | x_find_modifier_meanings (dpyinfo); | ||
| 15343 | #endif | 15329 | #endif |
| 15344 | 15330 | ||
| 15345 | #if defined USE_CAIRO || defined HAVE_XFT | 15331 | #if defined USE_CAIRO || defined HAVE_XFT |
| @@ -15455,6 +15441,13 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 15455 | ATOM_REFS_INIT ("_NET_WM_STATE_SKIP_TASKBAR", Xatom_net_wm_state_skip_taskbar) | 15441 | ATOM_REFS_INIT ("_NET_WM_STATE_SKIP_TASKBAR", Xatom_net_wm_state_skip_taskbar) |
| 15456 | ATOM_REFS_INIT ("_NET_WM_STATE_ABOVE", Xatom_net_wm_state_above) | 15442 | ATOM_REFS_INIT ("_NET_WM_STATE_ABOVE", Xatom_net_wm_state_above) |
| 15457 | ATOM_REFS_INIT ("_NET_WM_STATE_BELOW", Xatom_net_wm_state_below) | 15443 | ATOM_REFS_INIT ("_NET_WM_STATE_BELOW", Xatom_net_wm_state_below) |
| 15444 | #ifdef HAVE_XKB | ||
| 15445 | ATOM_REFS_INIT ("Meta", Xatom_Meta) | ||
| 15446 | ATOM_REFS_INIT ("Super", Xatom_Super) | ||
| 15447 | ATOM_REFS_INIT ("Hyper", Xatom_Hyper) | ||
| 15448 | ATOM_REFS_INIT ("ShiftLock", Xatom_ShiftLock) | ||
| 15449 | ATOM_REFS_INIT ("Alt", Xatom_Alt) | ||
| 15450 | #endif | ||
| 15458 | }; | 15451 | }; |
| 15459 | 15452 | ||
| 15460 | int i; | 15453 | int i; |
| @@ -15485,6 +15478,11 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 15485 | dpyinfo->Xatom_xsettings_sel = atoms_return[i]; | 15478 | dpyinfo->Xatom_xsettings_sel = atoms_return[i]; |
| 15486 | } | 15479 | } |
| 15487 | 15480 | ||
| 15481 | #ifdef HAVE_XKB | ||
| 15482 | /* Figure out which modifier bits mean what. */ | ||
| 15483 | x_find_modifier_meanings (dpyinfo); | ||
| 15484 | #endif | ||
| 15485 | |||
| 15488 | dpyinfo->x_dnd_atoms_size = 8; | 15486 | dpyinfo->x_dnd_atoms_size = 8; |
| 15489 | dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms | 15487 | dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms |
| 15490 | * dpyinfo->x_dnd_atoms_size); | 15488 | * dpyinfo->x_dnd_atoms_size); |
diff --git a/src/xterm.h b/src/xterm.h index 664db48392d..696f9db3d0a 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -496,6 +496,11 @@ struct x_display_info | |||
| 496 | /* SM */ | 496 | /* SM */ |
| 497 | Atom Xatom_SM_CLIENT_ID; | 497 | Atom Xatom_SM_CLIENT_ID; |
| 498 | 498 | ||
| 499 | #ifdef HAVE_XKB | ||
| 500 | /* Virtual modifiers */ | ||
| 501 | Atom Xatom_Meta, Xatom_Super, Xatom_Hyper, Xatom_ShiftLock, Xatom_Alt; | ||
| 502 | #endif | ||
| 503 | |||
| 499 | #ifdef HAVE_XRANDR | 504 | #ifdef HAVE_XRANDR |
| 500 | int xrandr_major_version; | 505 | int xrandr_major_version; |
| 501 | int xrandr_minor_version; | 506 | int xrandr_minor_version; |