<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
Hello.
<div dir="ltr">
<div class="x_elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="x_elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<p dir="auto" data-sourcepos="3:1-4:52" class="x_ContentPasted0" style="margin-top: 0px; margin-bottom: 0px;">
I try to make work the "Keyboard event" step from the Wayland-book but the C demo crash at loading. </p>
<p dir="auto" data-sourcepos="3:1-4:52" class="x_ContentPasted0 elementToProof" style="margin-top: 0px; margin-bottom: 0px;">
The problem comes from the mapping: with that error:</p>
<p dir="auto" data-sourcepos="7:1-7:72" style="margin-top: 0px; margin-bottom: 0px;">
<code class="x_ContentPasted0"><br>
</code></p>
<p dir="auto" data-sourcepos="7:1-7:72" style="margin-top: 0px; margin-bottom: 0px;">
<code class="x_ContentPasted0">Line 301: wl_keyboard_keymap: Assertion map_shm != MAP_FAILED' failed.</code></p>
<p dir="auto" data-sourcepos="9:1-9:21" class="x_ContentPasted0 elementToProof" style="margin-top: 0px; margin-bottom: 0px;">
<br>
</p>
<p dir="auto" data-sourcepos="9:1-9:21" class="x_ContentPasted0" style="margin-top: 0px; margin-bottom: 0px;">
Here is the function:</p>
</div>
<div class="x_elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<pre class="x_code x_highlight x_ContentPasted1" lang="plaintext"><span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC1">static void</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC2">wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC3"> uint32_t format, int32_t fd, uint32_t size)</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC4">{</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC5"> struct client_state *client_state = data;</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC6"> assert(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1);</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC7"> </span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC8"> // Line 301: Here problem with mapping</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC9"> char *map_shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC10"> assert(map_shm != MAP_FAILED);</span>
<span lang="plaintext" class="x_line" id="x_LC11"></span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC12"> struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_string(</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC13"> client_state->xkb_context, map_shm,</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC14"> XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC15"> munmap(map_shm, size);</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC16"> close(fd);</span>
<span lang="plaintext" class="x_line" id="x_LC17"></span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC18"> struct xkb_state *xkb_state = xkb_state_new(xkb_keymap);</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC19"> xkb_keymap_unref(client_state->xkb_keymap);</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC20"> xkb_state_unref(client_state->xkb_state);</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC21"> client_state->xkb_keymap = xkb_keymap;</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC22"> client_state->xkb_state = xkb_state;</span>
<span lang="plaintext" class="x_line x_ContentPasted1" id="x_LC23">}</span>
</pre>
</div>
<div class="x_elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="x_elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<p dir="auto" data-sourcepos="36:1-36:88" class="x_ContentPasted2" style="margin-top: 0px; margin-bottom: 0px;">
Why does the mapping fails, I did check <em class="x_ContentPasted2">fd</em> and <em class="x_ContentPasted2">
size</em> and they are correctly assigned?</p>
<p dir="auto" data-sourcepos="38:1-38:7" class="x_ContentPasted2" style="margin-top: 0px; margin-bottom: 0px;">
<br>
</p>
<p dir="auto" data-sourcepos="38:1-38:7" class="x_ContentPasted2" style="margin-top: 0px; margin-bottom: 0px;">
Thanks.</p>
<br>
</div>
</div>
</body>
</html>