summaryrefslogtreecommitdiff
path: root/src/core/display.c
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2013-05-03 18:51:22 +0100
committerNeil Roberts <neil@linux.intel.com>2013-05-07 18:11:33 +0100
commitbfe4a73d361c6553e3f6adfe449fbab635ecb545 (patch)
tree387c7ac2bdfa527476943fb3d0fde7e3183f6440 /src/core/display.c
parent542bba57a84447f1545c9779995c5b62dd5813ae (diff)
downloadmutter-wip/wayland-input.tar.gz
wayland: Add basic input supportwip/wayland-input
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.
Diffstat (limited to 'src/core/display.c')
-rw-r--r--src/core/display.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/src/core/display.c b/src/core/display.c
index 6f111825d..1aec6eec9 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1868,10 +1868,9 @@ get_input_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.
@@ -1881,21 +1880,18 @@ get_input_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);
@@ -2392,6 +2388,14 @@ event_callback (XEvent *event,
}
break;
case XI_FocusIn:
+#ifdef HAVE_WAYLAND
+ {
+ MetaWaylandCompositor *compositor =
+ meta_wayland_compositor_get_default ();
+ meta_wayland_compositor_set_input_focus (compositor, window);
+ }
+#endif
+ /* fall through */
case XI_FocusOut:
if (window)
{
@@ -2967,6 +2971,30 @@ 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 (event->type == MotionNotify)
+ 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