<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">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Hello.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<p dir="auto" data-sourcepos="3:1-4:52" class="ContentPasted0">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="ContentPasted0">The problem comes from the mapping: with that error:</p>
<p dir="auto" data-sourcepos="7:1-7:72"><code class="ContentPasted0"><br>
</code></p>
<p dir="auto" data-sourcepos="7:1-7:72"><code class="ContentPasted0">Line 301: wl_keyboard_keymap: Assertion map_shm != MAP_FAILED' failed.</code></p>
<p dir="auto" data-sourcepos="9:1-9:21" class="ContentPasted0"><br>
</p>
<p dir="auto" data-sourcepos="9:1-9:21" class="ContentPasted0">Here is the function:</p>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<pre class="code highlight ContentPasted1" lang="plaintext"><span lang="plaintext" class="line ContentPasted1" id="LC1">static void</span>
<span lang="plaintext" class="line ContentPasted1" id="LC2">wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,</span>
<span lang="plaintext" class="line ContentPasted1" id="LC3">             uint32_t format, int32_t fd, uint32_t size)</span>
<span lang="plaintext" class="line ContentPasted1" id="LC4">{</span>
<span lang="plaintext" class="line ContentPasted1" id="LC5">     struct client_state *client_state = data;</span>
<span lang="plaintext" class="line ContentPasted1" id="LC6">     assert(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1);</span>
<span lang="plaintext" class="line ContentPasted1" id="LC7">     </span>
<span lang="plaintext" class="line ContentPasted1" id="LC8">     // Line 301: Here problem with mapping</span>
<span lang="plaintext" class="line ContentPasted1" id="LC9">     char *map_shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);</span>
<span lang="plaintext" class="line ContentPasted1" id="LC10">     assert(map_shm != MAP_FAILED);</span>
<span lang="plaintext" class="line" id="LC11"></span>
<span lang="plaintext" class="line ContentPasted1" id="LC12">     struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_string(</span>
<span lang="plaintext" class="line ContentPasted1" id="LC13">                     client_state->xkb_context, map_shm,</span>
<span lang="plaintext" class="line ContentPasted1" id="LC14">                     XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);</span>
<span lang="plaintext" class="line ContentPasted1" id="LC15">     munmap(map_shm, size);</span>
<span lang="plaintext" class="line ContentPasted1" id="LC16">     close(fd);</span>
<span lang="plaintext" class="line" id="LC17"></span>
<span lang="plaintext" class="line ContentPasted1" id="LC18">     struct xkb_state *xkb_state = xkb_state_new(xkb_keymap);</span>
<span lang="plaintext" class="line ContentPasted1" id="LC19">     xkb_keymap_unref(client_state->xkb_keymap);</span>
<span lang="plaintext" class="line ContentPasted1" id="LC20">     xkb_state_unref(client_state->xkb_state);</span>
<span lang="plaintext" class="line ContentPasted1" id="LC21">     client_state->xkb_keymap = xkb_keymap;</span>
<span lang="plaintext" class="line ContentPasted1" id="LC22">     client_state->xkb_state = xkb_state;</span>
<span lang="plaintext" class="line ContentPasted1" id="LC23">}</span>
</pre>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<p dir="auto" data-sourcepos="36:1-36:88" class="ContentPasted2">Why does the mapping fails, I did check
<em class="ContentPasted2">fd</em> and <em class="ContentPasted2">size</em> and they are correctly assigned?</p>
<p dir="auto" data-sourcepos="38:1-38:7" class="ContentPasted2"><br>
</p>
<p dir="auto" data-sourcepos="38:1-38:7" class="ContentPasted2">Thanks.</p>
<br>
</div>
</body>
</html>