diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h index 053615a210..9361b72977 100644 --- a/gdk/mir/gdkmir-private.h +++ b/gdk/mir/gdkmir-private.h @@ -131,4 +131,11 @@ void _gdk_mir_print_resize_event (const MirResizeEvent *event); void _gdk_mir_print_event (const MirEvent *event); +/* TODO: Remove once we have proper transient window support. */ +GdkWindow * _gdk_mir_window_get_transient_child (GdkWindow *window, + gint x, + gint y, + gint *out_x, + gint *out_y); + #endif /* __GDK_PRIVATE_MIR_H__ */ diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c index cfe36e8df5..20b7972171 100644 --- a/gdk/mir/gdkmireventsource.c +++ b/gdk/mir/gdkmireventsource.c @@ -459,7 +459,31 @@ gdk_mir_event_source_convert_events (GdkMirEventSource *source) * event was being dispatched... */ if (window != NULL) - gdk_mir_event_source_queue_event (source->display, window, &event->event); + { + /* TODO: Remove once we have proper transient window support. */ + if (event->event.type == mir_event_type_motion) + { + GdkWindow *child; + gint x; + gint y; + + x = event->event.motion.pointer_coordinates[0].x; + y = event->event.motion.pointer_coordinates[0].y; + + child = _gdk_mir_window_get_transient_child (window, x, y, &x, &y); + + if (child && child != window) + { + window = child; + + event->event.motion.pointer_count = MAX (event->event.motion.pointer_count, 1); + event->event.motion.pointer_coordinates[0].x = x; + event->event.motion.pointer_coordinates[0].y = y; + } + } + + gdk_mir_event_source_queue_event (source->display, window, &event->event); + } else g_warning ("window was destroyed before event arrived..."); diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c index 6431ed4f0f..78c51118ee 100644 --- a/gdk/mir/gdkmirwindowimpl.c +++ b/gdk/mir/gdkmirwindowimpl.c @@ -910,6 +910,37 @@ gdk_mir_window_impl_set_transient_for (GdkWindow *window, ensure_no_surface (window); } +/* TODO: Remove once we have proper transient window support. */ +GdkWindow * +_gdk_mir_window_get_transient_child (GdkWindow *window, + gint x, + gint y, + gint *out_x, + gint *out_y) +{ + GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); + GdkWindow *child = NULL; + GList *i; + + if (x < window->x || x >= window->x + window->width || + y < window->y || y >= window->y + window->height) + return NULL; + + x -= window->x; + y -= window->y; + + for (i = impl->transient_children; i && !child; i = i->next) + child = _gdk_mir_window_get_transient_child (i->data, x, y, out_x, out_y); + + if (child) + return child; + + *out_x = x; + *out_y = y; + + return window; +} + static void gdk_mir_window_impl_get_frame_extents (GdkWindow *window, GdkRectangle *rect)