<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">
Sorry for that double post.</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 ContentPasted0">
It was already solved by Emmanuel.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
Fre;D<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>De :</b> wayland-devel <wayland-devel-bounces@lists.freedesktop.org> de la part de Fred vS <fiens@hotmail.com><br>
<b>Envoyé :</b> mercredi 4 octobre 2023 20:14<br>
<b>À :</b> wayland-devel@lists.freedesktop.org <wayland-devel@lists.freedesktop.org><br>
<b>Objet :</b> Problem with mmap keyboard.</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div class="x_elementToProof" style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hello.</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="3:1-4:52" class="x_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="x_ContentPasted0">The problem comes from the mapping: with that error:</p>
<p dir="auto" data-sourcepos="7:1-7:72"><code class="x_ContentPasted0"><br>
</code></p>
<p dir="auto" data-sourcepos="7:1-7:72"><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"><br>
</p>
<p dir="auto" data-sourcepos="9:1-9:21" class="x_ContentPasted0">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">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"><br>
</p>
<p dir="auto" data-sourcepos="38:1-38:7" class="x_ContentPasted2">Thanks.</p>
<br>
</div>
</div>
</body>
</html>