[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/xelb 9089f9c 08/10: Use numerical keysyms and mod-masks
From: |
Chris Feng |
Subject: |
[elpa] externals/xelb 9089f9c 08/10: Use numerical keysyms and mod-masks |
Date: |
Fri, 29 Jul 2016 09:15:57 +0000 (UTC) |
branch: externals/xelb
commit 9089f9c9c9cd26c241d159700d780022bc50b423
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>
Use numerical keysyms and mod-masks
* xcb-keysyms.el (xcb:keysyms:event->keysym): Always return a cons cell
containing a numerical keysym and a mod-mask.
(xcb:keysyms:keysym->event): Adapt to use numerical mod-masks.
---
xcb-keysyms.el | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/xcb-keysyms.el b/xcb-keysyms.el
index e965683..a32d8b3 100644
--- a/xcb-keysyms.el
+++ b/xcb-keysyms.el
@@ -544,9 +544,9 @@ Return 0 if conversion fails."
"Emacs event representations of XF86keysym (#x1008ff00 - #x1008ffff)")
(cl-defmethod xcb:keysyms:event->keysym ((obj xcb:connection) event)
- "Translate Emacs key event EVENT to X Keysym.
+ "Translate Emacs key event EVENT to (keysym . mod-mask).
-This function returns nil when it fails to convert an event."
+Return (0 . 0) when conversion fails."
(let ((modifiers (event-modifiers event))
(event (event-basic-type event))
keysym)
@@ -575,7 +575,8 @@ This function returns nil when it fails to convert an
event."
(setq keysym event)
(when (<= #x100 event #x10ffff) ;Unicode
(setq keysym (+ #x1000000 event)))))
- (when keysym
+ (if (not keysym)
+ '(0 . 0)
(let ((keycode (xcb:keysyms:keysym->keycode obj keysym))
keysym*)
(when (/= 0 keycode)
@@ -602,14 +603,11 @@ This function returns nil when it fails to convert an
event."
(`hyper xcb:keysyms:hyper-mask)
(`super xcb:keysyms:super-mask)
(`alt xcb:keysyms:alt-mask)
- (`down 0)
- ;; FIXME: more?
- (_ 0)))
+ (_
+ ;; Include but not limit to: down.
+ 0)))
modifiers)))
- (unless (memq nil modifiers)
- `(,keysym
- ;; state for KeyPress event
- ,(apply #'logior modifiers))))))
+ (cons keysym (apply #'logior modifiers)))))
(cl-defmethod xcb:keysyms:keysym->event ((_obj xcb:connection) keysym
&optional mask allow-modifiers)
@@ -617,6 +615,9 @@ This function returns nil when it fails to convert an
event."
One may use MASK to provide modifier keys. If ALLOW-MODIFIERS is non-nil,
this function will also return symbols for pure modifiers keys."
+ ;; Convert nil to 0.
+ (unless mask
+ (setq mask 0))
(let ((event (cond ((<= #x20 keysym #xff)
keysym)
((<= #xff00 keysym #xffff)
@@ -633,7 +634,7 @@ this function will also return symbols for pure modifiers
keys."
mod-alt mod-meta mod-hyper mod-super)
(when event
(if allow-modifiers
- (when mask
+ (when (/= 0 mask)
;; Clear modifier bits for modifier keys.
(pcase event
((or `lmeta* `rmeta*)
@@ -643,13 +644,11 @@ this function will also return symbols for pure modifiers
keys."
((or `lshift* `rshift*)
(setq mask (logand mask (lognot xcb:keysyms:shift-mask))))
((or `lhyper* `rhyper*)
- (when xcb:keysyms:hyper-mask
- (setq mask (logand mask (lognot xcb:keysyms:hyper-mask)))))
+ (setq mask (logand mask (lognot xcb:keysyms:hyper-mask))))
((or `lsuper* `rsuper*)
(setq mask (logand mask (lognot xcb:keysyms:super-mask))))
((or `lalt* `ralt*)
- (when xcb:keysyms:alt-mask
- (setq mask (logand mask (lognot xcb:keysyms:alt-mask)))))))
+ (setq mask (logand mask (lognot xcb:keysyms:alt-mask))))))
(when (memq event
'(lshift*
rshift*
@@ -669,7 +668,7 @@ this function will also return symbols for pure modifiers
keys."
kp-numlock))
(setq event nil))))
(when event
- (if (not mask)
+ (if (= 0 mask)
event
;; Set mod-* if possible.
(when x-alt-keysym
@@ -702,13 +701,11 @@ this function will also return symbols for pure modifiers
keys."
(or (not (<= #x20 keysym #xff)) ;Not a Latin-1 character
(<= ?A keysym ?Z))) ;An uppercase letter
(push 'shift event))
- (when (and xcb:keysyms:hyper-mask
- (/= 0 (logand mask xcb:keysyms:hyper-mask)))
+ (when (/= 0 (logand mask xcb:keysyms:hyper-mask))
(push (or mod-hyper 'hyper) event))
(when (/= 0 (logand mask xcb:keysyms:super-mask))
(push (or mod-super 'super) event))
- (when (and xcb:keysyms:alt-mask
- (/= 0 (logand mask xcb:keysyms:alt-mask)))
+ (when (/= 0 (logand mask xcb:keysyms:alt-mask))
(push (or mod-alt 'alt) event))
(event-convert-list event)))))
- [elpa] externals/xelb updated (e58ac74 -> f5216dc), Chris Feng, 2016/07/29
- [elpa] externals/xelb bddad0e 04/10: Eliminate compile warnings for Emacs 24, Chris Feng, 2016/07/29
- [elpa] externals/xelb b1e83e8 05/10: Fix extension event number, Chris Feng, 2016/07/29
- [elpa] externals/xelb eee1348 03/10: Precompute the size of <union>, Chris Feng, 2016/07/29
- [elpa] externals/xelb 2f9c5e5 01/10: Enable XKB module, Chris Feng, 2016/07/29
- [elpa] externals/xelb 39d4efb 07/10: Set XKB per-client flags, Chris Feng, 2016/07/29
- [elpa] externals/xelb 600b825 09/10: Support system-specific and legacy keysyms, Chris Feng, 2016/07/29
- [elpa] externals/xelb 9089f9c 08/10: Use numerical keysyms and mod-masks,
Chris Feng <=
- [elpa] externals/xelb d7d1115 06/10: Adapt 'xcb-keysyms' library to use XKB, Chris Feng, 2016/07/29
- [elpa] externals/xelb 9a73b79 02/10: Fix issues with <switch>, Chris Feng, 2016/07/29
- [elpa] externals/xelb f5216dc 10/10: Merge branch 'feat/xkb' into externals/xelb, Chris Feng, 2016/07/29