Getting Wayland events using gdk_window_add_filter ()

I am trying to get Wayland events in a program’s event handler. I need to use gdk_window_add_filter () to do this because that’s what the program’s existing event handler uses.

Is it possible to get the Wayland events and the objects associated with them from inside a GdkFilterFunc?

For example:

static GdkFilterReturn filter_func (GdkXEvent *xevent, GdkEvent *event, gpointer data)
{
//process my Wayland event here
}

int main ()
{
gdk_window_add_filter (NULL, filter_func, data);
}

I’m using https://github.com/sardemff7/libgwater/blob/master/wayland/libgwater-wayland.c , I believe that this should provide the necessary GSources to integrate the Wayland loop into the GMainLoop.

This is not really possible as libwayland currently doesn’t have any similar concept of “global events”. Maybe it would make more sense to ask for such a filter function to be added there.

But possibly this may be unnecessary, can you explain what you’re trying to do and why you would need this? There might be another way to accomplish it that doesn’t require writing X or Wayland specific code.

The main reason why there’s no equivalent to the GdkX11Display::xevent api is that libwayland has no ‘native event’ struct that we could use there.

On second thoughts it’s possible that the program’s event handler is already quite abstracted, and that most of it is display-server-agnostic, and that all I may need to do is create a Wayland-specific entrypoint to the event handler.