Hello Vasi.

Yes, I know but... I already found a solution and it works, so I will continue 
the fight (even that I admit that Wayland is not wow)!

See screenshot:
https://github.com/fredvs/wayland-pascal/assets/3421249/e8053dbc-a7e7-4c8a-a206-bbd7ded16a84

The trick was to create a library-for-work with the declared functions and use 
that library for linking.
That library is only need for linking, users dont need it.
So now I think I get great keys.

Hum, yes, sorry but once again ChatGPT helped me a lot.
Here his answer:

--------------------------------------

If the `wl_display_get_registry` and `wl_registry_add_listener` functions are 
inlined in the C/C++ headers and you cannot directly access them from Pascal 
due to the inlining, you may need to use a workaround.

One approach is to create C/C++ wrapper functions that encapsulate the inlined 
Wayland functions and then call those wrapper functions from your Pascal code. 
Here's an example of how you can create such wrappers:

1. Create a C/C++ file, e.g., `wayland_wrapper.c`, and define wrapper functions 
for the inlined functions:

```c
// wayland_wrapper.c
#include <wayland-client.h>

// Wrapper for wl_display_get_registry
struct wl_registry* my_wl_display_get_registry(struct wl_display* display) {
    return wl_display_get_registry(display);
}

// Wrapper for wl_registry_add_listener
int my_wl_registry_add_listener(struct wl_registry* registry,
                                const struct wl_registry_listener* listener,
                                void* data) {
    return wl_registry_add_listener(registry, listener, data);
}
```

2. Compile `wayland_wrapper.c` into a shared library (e.g., 
`libwayland_wrapper.so`):

```bash
gcc -fPIC -shared -o libwayland_wrapper.so wayland_wrapper.c -lwayland-client
```

3. In your Pascal code, use the `external` keyword to declare the wrapper 
functions:

```pascal
function my_wl_display_get_registry(display: pwl_display): pwl_registry; cdecl; 
external 'libwayland_wrapper';
function my_wl_registry_add_listener(registry: pwl_registry; listener: 
Pwl_registry_listener; data: pointer): cint; cdecl; external 
'libwayland_wrapper';
```

4. Use these wrapper functions in your Pascal code as needed.

By creating C/C++ wrappers, you can access the inlined Wayland functions 
indirectly from your Pascal code. Make sure to link your Pascal program with 
the `libwayland_wrapper.so` shared library when building your Pascal project.

This approach allows you to work around the issue of inlined functions in the 
Wayland headers and use them in your Pascal code effectively.



________________________________
De : vasi vasi <funl...@gmail.com>
Envoyé : vendredi 22 septembre 2023 19:10
À : General list for MSEide+MSEgui <mseide-msegui-talk@lists.sourceforge.net>
Objet : Re: [MSEide-MSEgui-talk] MSEgui and Wayland.

Fred,

let the Wayland team to solve the problems they created in forcing the move 
from X-Window with a half baked solution. We (me and my family) use X server 
because is the only one that correctly manages the Wacom tablet.

For now we don't care about Wayland is not useful for us and is really their 
problem.

Wait for when things are usable. Not worth the effort at the expense of your 
health.

On Fri, Sep 22, 2023 at 6:40 PM Fred vS 
<fi...@hotmail.com<mailto:fi...@hotmail.com>> wrote:
Hello everybody.

I am already blocked because some methods in wayland-client.so are inlined and 
not accessible for fpc.

I have asked it to the maintainer of the Wayland book with the demos:
https://github.com/bugaevc/writing-wayland-clients/issues/2

But I dont understand his solution.

Do you have a idea what should be done to access those methods?

Fre;D

________________________________
De : Fred vS <fi...@hotmail.com<mailto:fi...@hotmail.com>>
Envoyé : vendredi 22 septembre 2023 01:21
À : General list for MSEide+MSEgui 
<mseide-msegui-talk@lists.sourceforge.net<mailto:mseide-msegui-talk@lists.sourceforge.net>>
Objet : Re: [MSEide-MSEgui-talk] MSEgui and Wayland.

Hello everybody.

For the fun, I started a new Github project: 
https://github.com/fredvs/wayland-pascal

It takes inspiration of the demos from:
https://bugaevc.gitbooks.io/writing-wayland-clients/content/black-square/first-steps.html
(Yes, I confess, I was helped by ChatGPT for the translation of the C demos to 
Pascal.)

It uses the excellent fpc-wayland Bindings Generator for freepascal from 
Andrews Haines.
https://github.com/andrewd207/fpc-wayland

The goal is to discover step by step, with code, how to make Wayland work with 
fpc.
And maybe one day adapt this for msegui.

The first step is a Pascal program that connect to a Wayland Client (of course 
you need a Wayland session):

https://github.com/fredvs/wayland-pascal/assets/3421249/1a29cd1b-5af0-4fd4-9b70-d87a9a4e9148

Fre;D
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net<mailto:mseide-msegui-talk@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


--
Vasi
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to