Writing a mutter plugin -> problems with getting input events

Hi Community,

I started experimenting with writing a mutter plugin first step was just drawing a simple rectangle via a clutter canvas and actor. This worked very well, the next step would be getting input events like mouse move or mouse click but I am not able to get this sorted out. What I tried so far is setting the actor to be reactive and then connecting to the key-press and motion event.

Here some simplified code how it looks currently:

MetaDisplay *display = meta_plugin_get_display(plugin);

int screen_width, screen_height;
meta_display_get_size(display, &screen_width, &screen_height);

ClutterContent *canvas = clutter_canvas_new();
clutter_canvas_set_size(CLUTTER_CANVAS(canvas), screen_width, screen_height);

ClutterActor *desktop = clutter_actor_new();
clutter_actor_set_request_mode(desktop, CLUTTER_REQUEST_CONTENT_SIZE);
clutter_actor_set_content(desktop, canvas);
clutter_actor_set_reactive(desktop, true);

<connect to signals>
g_object_unref(canvas);

ClutterActor *stage = meta_get_stage_for_display(display);
clutter_actor_insert_child_above(stage, desktop, nullptr);
clutter_actor_show(desktop);

Is there anything special which needs to be done in order to receive input events from within mutter?

Thanks in advance,
Jan

I digged around a the gnome-shell code and found the following functions:

shell_global_set_stage_input_region
sync_input_region

Which explicitly sets the input region for X11, this seems only be needed if mutter is run in an X11 environment. Can someone explain how the input handling is done if wayland is used? Is it pure clutter?

Can’t remember the details, maybe look at StEntry and StButton in gnome-shell to see what they do.

Dealing with “input region” is an X11 relic that you shouldn’t need to bother being Wayland-only.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.