[libxkbcommon] Question about how to get xkb_keycode_t from xkb_keysym_t.

박성진 sj76.park at samsung.com
Tue Jun 2 04:03:37 PDT 2015


Dear Daniel and Jasper St.Pierre,

thank you for your opinion !

 

There is a key processing module as a plugin module of a wayland compositor and it has data structures tightly coupled with a keycode.

I’m considering to re-write the data structures which contain keysym type variable instead of keycode variable.

 

Thanks and regards,

Sung-Jin Park

 

From: magcius at gmail.com [mailto:magcius at gmail.com] On Behalf Of Jasper St. Pierre
Sent: Tuesday, June 02, 2015 12:41 AM
To: Daniel Stone
Cc: sj76.park at samsung.com; Ran Benita; wayland-devel at lists.freedesktop.org
Subject: Re: Re: [libxkbcommon] Question about how to get xkb_keycode_t from xkb_keysym_t.

 

Note that there are non-obvious consequences to this. The keymap is hierarchical upon layouts and levels. You can either do a depth-first search, or a breadth-first search. This can change behavior. XKeysymToKeycode is documented as doing a breadth-first search. This can have consequences in behavior. See:

https://git.gnome.org/browse/mutter/commit/src/core/keybindings.c?id=60c22b62366d737f7f6eabe7d46fa682c6f400d7

I'd highly recommend doing keygrabs on keysyms if you do want to let your clients do key grabs at all.

 

On Mon, Jun 1, 2015 at 6:02 AM, Daniel Stone <daniel at fooishbar.org> wrote:

Hi,

 

On 1 June 2015 at 12:22, 박성진 <sj76.park at samsung.com> wrote:

Actually, we'd like to provide a key grab protocol to wayland client(s)

with which each client can make request to grab a key to wayland compositor.

To use the protocol, we need to provide one or more keycodes associated with a given keysym to the compositor as an argument.

At this moment we would like to call the following API to get keycode(s) from a keysym if exist.

Could you share your opinion ?

 

You might be better off asking to grab on a particular keysym instead, since the compositor always needs to track the current state so can trivially extract the keysym.

  

/**

 @param[in] keymap : xkb_keymap pointer

 @param[in] keysym : xkb_keysym_t keysym

 @param[out] keycodes array : xkb_keycode_t pointer

 @return number of keycodes found on success, otherwise -1

*/

XKB_EXPORT int xkb_keycodes_from_keysym(struct xkb_keymap *keymap, xkb_keysym_t keysym, xkb_keycode_t *keycodes);

or XKB_EXPORT int xkb_keymap_keycodes_from_keysym(struct xkb_keymap *keymap, xkb_keysym_t keysym, xkb_keycode_t *keycodes);

On the face of it, this seems okay, except you might want to document that 0 is a valid, non-error, return code; presumably in order to deal with keycode allocation, you would have to do something like:

xkb_keycode_t *keycodes;

int num_keycodes;

 

num_keycodes = xkb_keymap_keycodes_from_keysym(keymap, keysym, NULL);

if (num_keycodes == -1)

    return -1;

else if (num_keycodes == 0)

    return 1; /* still succeeded, just don't have any keycodes */

 

keycodes = malloc(num_keycodes * sizeof(*keycodes));

num_keycodes = xkb_keymap_keycodes_from_keysym(keymap, keysym, keycodes);

 

Cheers,

Daniel

 

Thanks and regards,

Sung-Jin Park

 

------- Original Message -------

Sender : Daniel Stone<daniel at fooishbar.org>

Date : 2015-06-01 18:57 (GMT+09:00)

Title : Re: [libxkbcommon] Question about how to get xkb_keycode_t from xkb_keysym_t.

 

Hi Sung-Jin, 

 

On 1 June 2015 at 07:16, Sung-Jin Park <sj76.park at samsung.com> wrote:

I'd like to ask how to get keycode(s) from keysym using libxkbcommon API.

Is there any API in libxkbcommon ?

 

The short answer is, no.

 

The long answer is, look through the keymap and find every keycode which produces that keysym, which may be on various layouts (groups) or shift levels.

 

If you can share more details of what you actually want to achieve, that might be helpful.

 

Cheers,

Daniel 

 

 




  <http://ext.samsung.net/mailcheck/SeenTimeChecker?do=2ca45776e672e14d572869ec7757a5c52acea990db9004c361cedcb6724b56210beae83852bfee8031ac65c790352a7bd5d78d49b87aef04f866eba98cb7300acf878f9a26ce15a0> 

 


_______________________________________________
wayland-devel mailing list
wayland-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel




-- 

  Jasper

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20150602/f4714778/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 13168 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20150602/f4714778/attachment-0001.gif>


More information about the wayland-devel mailing list