mirror of
https://github.com/brl/mutter.git
synced 2025-06-13 16:59:30 +00:00
wayland: Add basic input support
This copies the basic input support from the Clayland demo compositor. It adds a basic wl_seat implementation which can convert Clutter mouse events to Wayland events. For this to work all of the wayland surface actors need to be made reactive. The wayland keyboard input focus surface is updated whenever Mutter sees a FocusIn event so that it will stay in synch with whatever surface Mutter wants as the focus. Wayland surfaces don't get this event so for now it will just give them focus whenever they are clicked as a hack to test the code. Authored-by: Neil Roberts <neil@linux.intel.com> Authored-by: Giovanni Campagna <gcampagna@src.gnome.org>
This commit is contained in:

committed by
Jasper St. Pierre

parent
40e820f551
commit
268ebb1b18
@ -467,6 +467,9 @@ gboolean meta_display_modifiers_accelerator_activate (MetaDisplay *display);
|
||||
/* In above-tab-keycode.c */
|
||||
guint meta_display_get_above_tab_keycode (MetaDisplay *display);
|
||||
|
||||
gboolean meta_display_handle_event (MetaDisplay *display,
|
||||
XEvent *event);
|
||||
|
||||
#ifdef HAVE_XI23
|
||||
gboolean meta_display_process_barrier_event (MetaDisplay *display,
|
||||
XIBarrierEvent *event);
|
||||
|
@ -2137,10 +2137,9 @@ handle_window_focus_event (MetaDisplay *display,
|
||||
}
|
||||
|
||||
/**
|
||||
* event_callback:
|
||||
* meta_display_handle_event:
|
||||
* @display: The MetaDisplay that events are coming from
|
||||
* @event: The event that just happened
|
||||
* @data: The #MetaDisplay that events are coming from, cast to a gpointer
|
||||
* so that it can be sent to a callback
|
||||
*
|
||||
* This is the most important function in the whole program. It is the heart,
|
||||
* it is the nexus, it is the Grand Central Station of Mutter's world.
|
||||
@ -2150,21 +2149,18 @@ handle_window_focus_event (MetaDisplay *display,
|
||||
* busy around here. Most of this function is a ginormous switch statement
|
||||
* dealing with all the kinds of events that might turn up.
|
||||
*/
|
||||
static gboolean
|
||||
event_callback (XEvent *event,
|
||||
gpointer data)
|
||||
gboolean
|
||||
meta_display_handle_event (MetaDisplay *display,
|
||||
XEvent *event)
|
||||
{
|
||||
MetaWindow *window;
|
||||
MetaWindow *property_for_window;
|
||||
MetaDisplay *display;
|
||||
Window modified;
|
||||
gboolean frame_was_receiver;
|
||||
gboolean bypass_compositor;
|
||||
gboolean filter_out_event;
|
||||
XIEvent *input_event;
|
||||
|
||||
display = data;
|
||||
|
||||
#ifdef WITH_VERBOSE_MODE
|
||||
if (dump_events)
|
||||
meta_spew_event (display, event);
|
||||
@ -2655,6 +2651,15 @@ event_callback (XEvent *event,
|
||||
}
|
||||
break;
|
||||
case XI_FocusIn:
|
||||
#ifdef HAVE_WAYLAND
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
MetaWaylandCompositor *compositor =
|
||||
meta_wayland_compositor_get_default ();
|
||||
meta_wayland_compositor_set_input_focus (compositor, window);
|
||||
}
|
||||
#endif
|
||||
/* fall through */
|
||||
case XI_FocusOut:
|
||||
/* libXi does not properly copy the serial to the XIEnterEvent, so pull it
|
||||
* from the parent XAnyEvent.
|
||||
@ -3202,6 +3207,32 @@ event_callback (XEvent *event,
|
||||
return filter_out_event;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_callback (XEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
MetaDisplay *display = data;
|
||||
|
||||
/* Under Wayland we want to filter out mouse motion events so we can
|
||||
synthesize them from the Clutter events instead. This is
|
||||
necessary because the position in the mouse events is passed to
|
||||
the X server relative to the position of the surface. The X
|
||||
server then translates these back to screen coordinates based on
|
||||
the window position. If we rely on this translatation when
|
||||
dragging a window around then the window will jump around
|
||||
erratically because of the lag between updating the window
|
||||
position from the surface position. Instead we bypass the
|
||||
translation altogether by directly using the Clutter events */
|
||||
#ifdef HAVE_WAYLAND
|
||||
if (meta_is_wayland_compositor () &&
|
||||
event->type == GenericEvent &&
|
||||
event->xcookie.evtype == XI_Motion)
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
return meta_display_handle_event (display, event);
|
||||
}
|
||||
|
||||
/* Return the window this has to do with, if any, rather
|
||||
* than the frame or root window that was selecting
|
||||
* for substructure
|
||||
|
Reference in New Issue
Block a user