From 06ddcbb495e31a450b36bd7a90b7760d5ca9553a Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Wed, 25 Apr 2007 22:59:05 +0000 Subject: [PATCH] 2007-04-25 Jim Evins * src/view.h: * src/view.c: (gl_view_update), (expose_cb), (motion_notify_event_cb), (button_press_event_cb), (button_release_event_cb): - Try not to let updates get backed up. - Grab pointer when doing any drag operations. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@652 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 9 +++++++++ glabels2/src/view.c | 39 +++++++++++++++++++++++++++++++++++---- glabels2/src/view.h | 2 ++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index c3fab5cd..b2747c50 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,12 @@ +2007-04-25 Jim Evins + + * src/view.h: + * src/view.c: (gl_view_update), (expose_cb), + (motion_notify_event_cb), (button_press_event_cb), + (button_release_event_cb): + - Try not to let updates get backed up. + - Grab pointer when doing any drag operations. + 2007-04-11 Jim Evins * src/cairo-label-path.c: (gl_cairo_label_path), diff --git a/glabels2/src/view.c b/glabels2/src/view.c index 9cc6243c..79e768f5 100644 --- a/glabels2/src/view.c +++ b/glabels2/src/view.c @@ -553,11 +553,15 @@ gl_view_update (glView *view) if (!widget->window) return; - region = gdk_drawable_get_clip_region (widget->window); - /* redraw the cairo canvas completely by exposing it */ - gdk_window_invalidate_region (widget->window, region, TRUE); + if ( !view->update_scheduled_flag ) + { + view->update_scheduled_flag = TRUE; - gdk_region_destroy (region); + region = gdk_drawable_get_clip_region (widget->window); + /* redraw the cairo canvas completely by exposing it */ + gdk_window_invalidate_region (widget->window, region, TRUE); + gdk_region_destroy (region); + } gl_debug (DEBUG_VIEW, "END"); } @@ -573,6 +577,8 @@ expose_cb (glView *view, gl_debug (DEBUG_VIEW, "START"); + view->update_scheduled_flag = FALSE; + /* get a cairo_t */ cr = gdk_cairo_create (GTK_LAYOUT (view->canvas)->bin_window); @@ -3213,6 +3219,21 @@ motion_notify_event_cb (glView *view, cairo_destroy (cr); + /* + * FIXME: we re-establish grabs here if the grab has been lost. We seem to be + * losing grabs when we emit signals that lead to the manipulation of + * the GtkUIManager. Needs more investigation + */ + if (view->grabbed_flag && !gdk_pointer_is_grabbed ()) + { + gdk_pointer_grab (GTK_LAYOUT (view->canvas)->bin_window, + FALSE, + (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), + NULL, + NULL, + event->time); + } + return return_value; } @@ -3341,6 +3362,14 @@ button_press_event_cb (glView *view, default: g_message ("Invalid view mode."); /*Should not happen!*/ } + + view->grabbed_flag = TRUE; + gdk_pointer_grab (GTK_LAYOUT (view->canvas)->bin_window, + FALSE, + (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), + NULL, + NULL, + event->time); break; case 3: @@ -3387,6 +3416,8 @@ button_release_event_cb (glView *view, { case 1: + view->grabbed_flag = FALSE; + gdk_pointer_ungrab (event->time); /* * Handle event as appropriate for mode */ diff --git a/glabels2/src/view.h b/glabels2/src/view.h index 6d927aac..67a344c8 100644 --- a/glabels2/src/view.h +++ b/glabels2/src/view.h @@ -66,6 +66,7 @@ struct _glView { gdouble x0, y0; gdouble w, h; + gboolean update_scheduled_flag; gboolean grid_visible; gdouble grid_spacing; @@ -74,6 +75,7 @@ struct _glView { glViewMode mode; glLabelObjectType create_type; glViewState state; + gboolean grabbed_flag; /* GL_VIEW_ARROW_MOVE state */ gdouble move_last_x; -- 2.39.5