From: Po Lu Date: Tue, 18 Jan 2022 11:52:51 +0000 (+0800) Subject: Intern virtual modifier atoms the smart way on X X-Git-Tag: emacs-29.0.90~2966 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4f23dbaa67183097f2aba1b93ace3646466faca9;p=emacs.git 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. --- 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) int syms_per_code; XModifierKeymap *mods; #ifdef HAVE_XKB - Atom meta; - Atom super; - Atom hyper; - Atom shiftlock; - Atom alt; int i; int found_meta_p = false; #endif @@ -5454,28 +5449,22 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo) #ifdef HAVE_XKB if (dpyinfo->xkb_desc) { - meta = XInternAtom (dpyinfo->display, "Meta", False); - super = XInternAtom (dpyinfo->display, "Super", False); - hyper = XInternAtom (dpyinfo->display, "Hyper", False); - shiftlock = XInternAtom (dpyinfo->display, "ShiftLock", False); - alt = XInternAtom (dpyinfo->display, "Alt", False); - for (i = 0; i < XkbNumVirtualMods; i++) { uint vmodmask = dpyinfo->xkb_desc->server->vmods[i]; - if (dpyinfo->xkb_desc->names->vmods[i] == meta) + if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_Meta) { dpyinfo->meta_mod_mask |= vmodmask; found_meta_p = vmodmask; } - else if (dpyinfo->xkb_desc->names->vmods[i] == alt) + else if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_Alt) dpyinfo->alt_mod_mask |= vmodmask; - else if (dpyinfo->xkb_desc->names->vmods[i] == super) + else if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_Super) dpyinfo->super_mod_mask |= vmodmask; - else if (dpyinfo->xkb_desc->names->vmods[i] == hyper) + else if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_Hyper) dpyinfo->hyper_mod_mask |= vmodmask; - else if (dpyinfo->xkb_desc->names->vmods[i] == shiftlock) + else if (dpyinfo->xkb_desc->names->vmods[i] == dpyinfo->Xatom_ShiftLock) dpyinfo->shift_lock_mask |= vmodmask; } @@ -15337,9 +15326,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) XkbNewKeyboardNotifyMask | XkbMapNotifyMask, XkbNewKeyboardNotifyMask | XkbMapNotifyMask); } - - /* Figure out which modifier bits mean what. */ - x_find_modifier_meanings (dpyinfo); #endif #if defined USE_CAIRO || defined HAVE_XFT @@ -15455,6 +15441,13 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) ATOM_REFS_INIT ("_NET_WM_STATE_SKIP_TASKBAR", Xatom_net_wm_state_skip_taskbar) ATOM_REFS_INIT ("_NET_WM_STATE_ABOVE", Xatom_net_wm_state_above) ATOM_REFS_INIT ("_NET_WM_STATE_BELOW", Xatom_net_wm_state_below) +#ifdef HAVE_XKB + ATOM_REFS_INIT ("Meta", Xatom_Meta) + ATOM_REFS_INIT ("Super", Xatom_Super) + ATOM_REFS_INIT ("Hyper", Xatom_Hyper) + ATOM_REFS_INIT ("ShiftLock", Xatom_ShiftLock) + ATOM_REFS_INIT ("Alt", Xatom_Alt) +#endif }; int i; @@ -15485,6 +15478,11 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) dpyinfo->Xatom_xsettings_sel = atoms_return[i]; } +#ifdef HAVE_XKB + /* Figure out which modifier bits mean what. */ + x_find_modifier_meanings (dpyinfo); +#endif + dpyinfo->x_dnd_atoms_size = 8; dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms * 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 /* SM */ Atom Xatom_SM_CLIENT_ID; +#ifdef HAVE_XKB + /* Virtual modifiers */ + Atom Xatom_Meta, Xatom_Super, Xatom_Hyper, Xatom_ShiftLock, Xatom_Alt; +#endif + #ifdef HAVE_XRANDR int xrandr_major_version; int xrandr_minor_version;