[gtk+] mir: generate leave events for transient children
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] mir: generate leave events for transient children
- Date: Thu, 5 Feb 2015 16:28:30 +0000 (UTC)
commit 901bc2957de45c06457746374e1e33883d28d1dc
Author: William Hua <william attente ca>
Date: Wed Dec 17 12:37:28 2014 -0500
mir: generate leave events for transient children
gdk/mir/gdkmir-private.h | 5 ++++
gdk/mir/gdkmireventsource.c | 50 +++++++++++++++++++++++++++++++++++++++++++
gdk/mir/gdkmirwindowimpl.c | 10 ++++++++
3 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h
index ca8d239..635d575 100644
--- a/gdk/mir/gdkmir-private.h
+++ b/gdk/mir/gdkmir-private.h
@@ -140,4 +140,9 @@ GdkWindow * _gdk_mir_window_get_visible_transient_child (GdkWindow *window,
gint *out_x,
gint *out_y);
+/* TODO: Remove once we have proper transient window support. */
+void _gdk_mir_window_transient_children_foreach (GdkWindow *window,
+ GFunc func,
+ gpointer user_data);
+
#endif /* __GDK_PRIVATE_MIR_H__ */
diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c
index 8a16528..7188303 100644
--- a/gdk/mir/gdkmireventsource.c
+++ b/gdk/mir/gdkmireventsource.c
@@ -292,6 +292,44 @@ handle_key_event (GdkWindow *window, const MirKeyEvent *event)
}
}
+/* TODO: Remove once we have proper transient window support. */
+typedef struct
+{
+ gdouble x;
+ gdouble y;
+ guint32 event_time;
+ gboolean cursor_inside;
+} LeaveInfo;
+
+/* TODO: Remove once we have proper transient window support. */
+static void
+generate_leave_events (GdkWindow *window,
+ LeaveInfo *user_data)
+{
+ GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
+ LeaveInfo info = *user_data;
+ gdouble x;
+ gdouble y;
+ gboolean cursor_inside;
+ MirMotionButton button_state;
+
+ info.x -= window->x;
+ info.y -= window->y;
+
+ if (info.cursor_inside)
+ info.cursor_inside = 0 <= info.x && info.x < window->width && 0 <= info.y && info.y < window->height;
+
+ _gdk_mir_window_impl_get_cursor_state (impl, &x, &y, &cursor_inside, &button_state);
+
+ if (cursor_inside && !info.cursor_inside)
+ {
+ _gdk_mir_window_impl_set_cursor_state (impl, x, y, FALSE, button_state);
+ generate_crossing_event (window, GDK_LEAVE_NOTIFY, info.x, info.y, info.event_time);
+ }
+
+ _gdk_mir_window_transient_children_foreach (window, (GFunc) generate_leave_events, &info);
+}
+
static void
handle_motion_event (GdkWindow *window, const MirMotionEvent *event)
{
@@ -313,6 +351,18 @@ handle_motion_event (GdkWindow *window, const MirMotionEvent *event)
modifier_state = get_modifier_state (event->modifiers, event->button_state);
event_time = NANO_TO_MILLI (event->event_time);
+ /* TODO: Remove once we have proper transient window support. */
+ {
+ LeaveInfo info;
+
+ info.x = x;
+ info.y = y;
+ info.event_time = event_time;
+ info.cursor_inside = TRUE;
+
+ _gdk_mir_window_transient_children_foreach (window, (GFunc) generate_leave_events, &info);
+ }
+
/* The Mir events generate hover-exits even while inside the window so
counteract this by always generating an enter notify on all other events */
if (!cursor_inside && event->action != mir_motion_action_hover_exit)
diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c
index fccba87..b866868 100644
--- a/gdk/mir/gdkmirwindowimpl.c
+++ b/gdk/mir/gdkmirwindowimpl.c
@@ -958,6 +958,16 @@ _gdk_mir_window_get_visible_transient_child (GdkWindow *window,
return window;
}
+/* TODO: Remove once we have proper transient window support. */
+void
+_gdk_mir_window_transient_children_foreach (GdkWindow *window,
+ GFunc func,
+ gpointer user_data)
+{
+ GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
+ g_list_foreach (impl->transient_children, func, user_data);
+}
+
static void
gdk_mir_window_impl_get_frame_extents (GdkWindow *window,
GdkRectangle *rect)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]