From bd4ca0dd291280dd28ba3a94dce778b2f39ffb2b Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Mon, 10 Jan 2011 04:24:16 +0100 Subject: Simulate motion events when needed. --- src/ld-canvas.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ld-canvas.c b/src/ld-canvas.c index 1c48325..e41d014 100644 --- a/src/ld-canvas.c +++ b/src/ld-canvas.c @@ -9,6 +9,8 @@ */ #include +#include + #include #include @@ -187,6 +189,7 @@ static void diagram_disconnect_signals (LdCanvas *self); static gdouble ld_canvas_get_base_unit_in_px (GtkWidget *self); static gdouble ld_canvas_get_scale_in_px (LdCanvas *self); +static void simulate_motion (LdCanvas *self); static gboolean on_motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); static gboolean on_leave_notify (GtkWidget *widget, GdkEventCrossing *event, @@ -799,10 +802,7 @@ ld_canvas_set_zoom (LdCanvas *self, gdouble zoom) self->priv->zoom = clamped_zoom; - /* TODO: Retrieve the position of the mouse and call - * check_terminals() instead of just hiding the terminals. - */ - hide_terminals (self); + simulate_motion (self); update_adjustments (self); gtk_widget_queue_draw (GTK_WIDGET (self)); @@ -1108,6 +1108,30 @@ queue_terminal_draw (LdCanvas *self, LdPoint *terminal) queue_draw (self, &rect); } +static void +simulate_motion (LdCanvas *self) +{ + GdkEventMotion event; + GtkWidget *widget; + gint x, y; + GdkModifierType state; + + widget = GTK_WIDGET (self); + + if (gdk_window_get_pointer (widget->window, &x, &y, &state) + != widget->window) + return; + + memset (&event, 0, sizeof (event)); + event.type = GDK_MOTION_NOTIFY; + event.window = widget->window; + event.x = x; + event.y = y; + event.state = state; + + on_motion_notify (widget, &event, NULL); +} + static gboolean on_motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { -- cgit v1.2.3-70-g09d2