<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div dir="ltr">
<div class="x_elementToProof elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Ho, many thanks Emmanuel.</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);">
I will deeply study your mail.</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);">
By the way, I am busy to translate all the "steps" demos of the Wayland-book into Pascal:</div>
<div class="x_elementToProof x_ContentPasted0" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://github.com/fredvs/wayland-pascal" data-auth="NotApplicable" id="OWA26fd5f1c-e76b-3094-b036-0db5b4d55b68" class="x_OWAAutoLink">https://github.com/fredvs/wayland-pascal</a></div>
<div class="x_elementToProof x_ContentPasted0" 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);">
Now, Free Pascal compiler can create nice and working "Pure Wayland applications".</div>
<div class="x_elementToProof x_ContentPasted1" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Note too that the C demos in Wayland-book have some ommisions in code ( I added the fixes in /src/c).</div>
<div class="x_elementToProof x_ContentPasted1 x_ContentPasted2" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
But for the "Keyboard events" step, I am blocked, the C "Keyboard events" demo in /src/c does not use the key-map, but it works to give the actions of the keys and the number of the keys. The same for the translated Pascal code.</div>
<div class="x_elementToProof x_ContentPasted1" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="x_elementToProof x_ContentPasted1" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
But ok, I will try to make the map-keyboard working thanks to with your advices.</div>
<div class="x_elementToProof x_ContentPasted1" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="x_elementToProof x_ContentPasted1" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Many thanks.</div>
<div class="x_elementToProof x_ContentPasted1" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="x_elementToProof x_ContentPasted1 x_ContentPasted3" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Write you later.<br>
</div>
<div class="x_elementToProof x_ContentPasted1" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="x_elementToProof x_ContentPasted1" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Fre;D<br>
</div>
<div id="x_appendonsend"></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size: 11pt; color: rgb(0, 0, 0);"><b>De :</b> Emmanuel Gil Peyrot <linkmauve@linkmauve.fr><br>
<b>Envoyé :</b> mercredi 4 octobre 2023 20:28<br>
<b>À :</b> Fred vS <fiens@hotmail.com><br>
<b>Cc :</b> wayland-devel@lists.freedesktop.org <wayland-devel@lists.freedesktop.org><br>
<b>Objet :</b> Re: Problem with mmap keyboard.</font>
<div> </div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_PlainText">On Wed, Oct 04, 2023 at 06:19:30PM +0000, Fred vS wrote:<br>
> Hello.<br>
<br>
Hi,<br>
<br>
> <br>
> <br>
> I try to make work the "Keyboard event" step from the Wayland-book but the C demo crash at loading.<br>
> <br>
> The problem comes from the mapping: with that error:<br>
> <br>
> <br>
> Line 301: wl_keyboard_keymap: Assertion map_shm != MAP_FAILED' failed.<br>
> <br>
> <br>
> Here is the function:<br>
> <br>
> static void<br>
> wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,<br>
>              uint32_t format, int32_t fd, uint32_t size)<br>
> {<br>
>      struct client_state *client_state = data;<br>
>      assert(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1);<br>
> <br>
>      // Line 301: Here problem with mapping<br>
>      char *map_shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);<br>
<br>
We can read in the documentation of this protocol:<br>
<a href="https://wayland.app/protocols/wayland#wl_keyboard:event:keymap" data-auth="NotApplicable" id="OWA1f8c55f5-f6b3-aeeb-81f6-8b07dc24dbb5" class="OWAAutoLink">https://wayland.app/protocols/wayland#wl_keyboard:event:keymap</a><br>
<br>
“From version 7 onwards, the fd must be mapped with MAP_PRIVATE by the<br>
recipient, as MAP_SHARED may fail.”<br>
<br>
I don’t know which wl_shell version you are using, but check that maybe.<br>
<br>
>      assert(map_shm != MAP_FAILED);<br>
> <br>
>      struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_string(<br>
>                      client_state->xkb_context, map_shm,<br>
>                      XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);<br>
>      munmap(map_shm, size);<br>
>      close(fd);<br>
> <br>
>      struct xkb_state *xkb_state = xkb_state_new(xkb_keymap);<br>
>      xkb_keymap_unref(client_state->xkb_keymap);<br>
>      xkb_state_unref(client_state->xkb_state);<br>
>      client_state->xkb_keymap = xkb_keymap;<br>
>      client_state->xkb_state = xkb_state;<br>
> }<br>
> <br>
> <br>
> <br>
> Why does the mapping fails, I did check fd and size and they are correctly assigned?<br>
> <br>
> <br>
> Thanks.<br>
> <br>
<br>
-- <br>
Link Mauve<br>
</div>
</span></font></div>
</div>
</body>
</html>