<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On 1 June 2015 at 12:22, 박성진 <span dir="ltr"><<a href="mailto:sj76.park@samsung.com" target="_blank">sj76.park@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<p>Actually, we'd like to provide a key grab protocol to wayland client(s)<br></p>
<p>with which each client can make request to grab a key to wayland compositor.</p>
<p>To use the protocol, we need to provide one or more keycodes associated with a given keysym to the compositor as an argument.</p>
<p>At this moment we would like to call the following API to get keycode(s) from a keysym if exist.</p>
<p>Could you share your opinion ?</p></div></blockquote><div><br></div><div>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.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<p>/**</p>
<p> @param[in] keymap : xkb_keymap pointer</p>
<p> @param[in] keysym : xkb_keysym_t keysym</p>
<p> @param[out] keycodes array : xkb_keycode_t pointer</p>
<p> @return number of keycodes found on success, otherwise -1</p>
<p>*/</p>
<p>XKB_EXPORT int xkb_keycodes_from_keysym(struct xkb_keymap *keymap, xkb_keysym_t keysym, xkb_keycode_t *keycodes);</p>
<p>or XKB_EXPORT int xkb_keymap_keycodes_from_keysym(struct xkb_keymap *keymap, xkb_keysym_t keysym, xkb_keycode_t *keycodes);</p></div></blockquote><div>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:</div><div>xkb_keycode_t *keycodes;</div><div>int num_keycodes;</div><div><br></div><div>num_keycodes = xkb_keymap_keycodes_from_keysym(keymap, keysym, NULL);</div><div>if (num_keycodes == -1)</div><div> return -1;</div><div>else if (num_keycodes == 0)</div><div> return 1; /* still succeeded, just don't have any keycodes */</div><div><br></div><div>keycodes = malloc(num_keycodes * sizeof(*keycodes));</div><div>num_keycodes = xkb_keymap_keycodes_from_keysym(keymap, keysym, keycodes);</div><div><br></div><div>Cheers,</div><div>Daniel</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><span class="">
<p>Thanks and regards,</p>
<p>Sung-Jin Park</p>
<p> </p>
<p>------- <b>Original Message</b> -------</p>
</span><p><b>Sender</b> : Daniel Stone<<a href="mailto:daniel@fooishbar.org" target="_blank">daniel@fooishbar.org</a>></p>
<p><b>Date</b> : 2015-06-01 18:57 (GMT+09:00)</p>
<p><b>Title</b> : Re: [libxkbcommon] Question about how to get xkb_keycode_t from xkb_keysym_t.</p><div><div class="h5">
<p> </p>
<div dir="ltr">Hi Sung-Jin,
<div class="gmail_extra"><br>
<div class="gmail_quote">On 1 June 2015 at 07:16, Sung-Jin Park <span dir="ltr"><<a href="mailto:sj76.park@samsung.com" target="_blank">sj76.park@samsung.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid">
<div>
<p><span style="FONT-SIZE:16px;FONT-FAMILY:'\00b9d1\00c740 \00ace0\00b515';COLOR:rgb(51,51,51);LINE-HEIGHT:25px">I'd like to ask how to get keycode(s) from keysym using libxkbcommon API.</span><br></p>
<div style="WHITE-SPACE:normal;TEXT-TRANSFORM:none;WORD-SPACING:0px;COLOR:rgb(34,34,34);FONT:small arial,sans-serif;LETTER-SPACING:normal;TEXT-INDENT:0px;font-size-adjust:none;font-stretch:normal"><span style="FONT-SIZE:16px;FONT-FAMILY:맑은 고딕;COLOR:rgb(51,51,51);LINE-HEIGHT:25px">Is there any API in libxkbcommon ?</span></div></div></blockquote>
<div><br></div>
<div>The short answer is, no.</div>
<div><br></div>
<div>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.</div>
<div><br></div>
<div>If you can share more details of what you actually want to achieve, that might be helpful.</div>
<div><br></div>
<div>Cheers,</div>
<div>Daniel </div></div></div></div>
<p> </p>
<p> </p>
</div></div><table>
<tbody>
<tr>
<td>
<p><img border="0" src="cid:39MRZQS8QVYH@namo.co.kr"></p></td></tr></tbody></table></div><img src="http://ext.samsung.net/mailcheck/SeenTimeChecker?do=2ca45776e672e14d572869ec7757a5c52acea990db9004c361cedcb6724b56210beae83852bfee8031ac65c790352a7bd5d78d49b87aef04f866eba98cb7300acf878f9a26ce15a0" border="0" width="0" height="0"></blockquote></div><br></div></div>