Commit 5235bd3e authored by Paul Eggert's avatar Paul Eggert
Browse files

* xterm.c: Use EMACS_INT for Emacs modifiers, and int for X modifiers.

Before, the code was not consistent.  These values cannot exceed
2**31 - 1 so there's no need to make them unsigned.
(x_x_to_emacs_modifiers): Accept int and return EMACS_INT.
(x_emacs_to_x_modifiers): Accept EMACS_INT and return int.
(x_x_to_emacs_modifiers, x_emacs_to_x_modifiers): Reject non-integers
as modifiers.
* xterm.h (x_x_to_emacs_modifiers): Adjust to signature change.
parent bc827e23
2011-05-11 Paul Eggert <eggert@cs.ucla.edu>
* xterm.c: Use EMACS_INT for Emacs modifiers, and int for X modifiers.
Before, the code was not consistent. These values cannot exceed
2**31 - 1 so there's no need to make them unsigned.
(x_x_to_emacs_modifiers): Accept int and return EMACS_INT.
(x_emacs_to_x_modifiers): Accept EMACS_INT and return int.
(x_x_to_emacs_modifiers, x_emacs_to_x_modifiers): Reject non-integers
as modifiers.
* xterm.h (x_x_to_emacs_modifiers): Adjust to signature change.
* lisp.h (XINT) [USE_LISP_UNION_TYPE]: Cast to EMACS_INT.
(XUINT) [USE_LISP_UNION_TYPE]: Cast to EMACS_UINT.
Otherwise, GCC 4.6.0 warns about printf (pI, XINT (...)),
......
......@@ -3609,23 +3609,23 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo)
/* Convert between the modifier bits X uses and the modifier bits
Emacs uses. */
unsigned int
x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, unsigned int state)
EMACS_INT
x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state)
{
EMACS_UINT mod_meta = meta_modifier;
EMACS_UINT mod_alt = alt_modifier;
EMACS_UINT mod_hyper = hyper_modifier;
EMACS_UINT mod_super = super_modifier;
EMACS_INT mod_meta = meta_modifier;
EMACS_INT mod_alt = alt_modifier;
EMACS_INT mod_hyper = hyper_modifier;
EMACS_INT mod_super = super_modifier;
Lisp_Object tem;
tem = Fget (Vx_alt_keysym, Qmodifier_value);
if (! EQ (tem, Qnil)) mod_alt = XUINT (tem);
if (INTEGERP (tem)) mod_alt = XINT (tem);
tem = Fget (Vx_meta_keysym, Qmodifier_value);
if (! EQ (tem, Qnil)) mod_meta = XUINT (tem);
if (INTEGERP (tem)) mod_meta = XINT (tem);
tem = Fget (Vx_hyper_keysym, Qmodifier_value);
if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem);
if (INTEGERP (tem)) mod_hyper = XINT (tem);
tem = Fget (Vx_super_keysym, Qmodifier_value);
if (! EQ (tem, Qnil)) mod_super = XUINT (tem);
if (INTEGERP (tem)) mod_super = XINT (tem);
return ( ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? shift_modifier : 0)
......@@ -3636,24 +3636,24 @@ x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, unsigned int state)
| ((state & dpyinfo->hyper_mod_mask) ? mod_hyper : 0));
}
static unsigned int
x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, unsigned int state)
static int
x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state)
{
EMACS_UINT mod_meta = meta_modifier;
EMACS_UINT mod_alt = alt_modifier;
EMACS_UINT mod_hyper = hyper_modifier;
EMACS_UINT mod_super = super_modifier;
int mod_meta = meta_modifier;
int mod_alt = alt_modifier;
int mod_hyper = hyper_modifier;
int mod_super = super_modifier;
Lisp_Object tem;
tem = Fget (Vx_alt_keysym, Qmodifier_value);
if (! EQ (tem, Qnil)) mod_alt = XUINT (tem);
if (INTEGERP (tem)) mod_alt = XINT (tem);
tem = Fget (Vx_meta_keysym, Qmodifier_value);
if (! EQ (tem, Qnil)) mod_meta = XUINT (tem);
if (INTEGERP (tem)) mod_meta = XINT (tem);
tem = Fget (Vx_hyper_keysym, Qmodifier_value);
if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem);
if (INTEGERP (tem)) mod_hyper = XINT (tem);
tem = Fget (Vx_super_keysym, Qmodifier_value);
if (! EQ (tem, Qnil)) mod_super = XUINT (tem);
if (INTEGERP (tem)) mod_super = XINT (tem);
return ( ((state & mod_alt) ? dpyinfo->alt_mod_mask : 0)
......
......@@ -989,8 +989,7 @@ extern void x_mouse_leave (struct x_display_info *);
#ifdef USE_X_TOOLKIT
extern int x_dispatch_event (XEvent *, Display *);
#endif
extern unsigned int x_x_to_emacs_modifiers (struct x_display_info *,
unsigned);
extern EMACS_INT x_x_to_emacs_modifiers (struct x_display_info *, int);
extern int x_display_pixel_height (struct x_display_info *);
extern int x_display_pixel_width (struct x_display_info *);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment