Code

patch 168780
authorbuliabyak <buliabyak@users.sourceforge.net>
Tue, 11 Aug 2009 01:40:49 +0000 (01:40 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Tue, 11 Aug 2009 01:40:49 +0000 (01:40 +0000)
src/dropper-context.cpp
src/dropper-context.h
src/node-context.cpp
src/node-context.h
src/zoom-context.cpp
src/zoom-context.h

index 985e3ac5153cecf1194f03502a2d4db8bacbdbc5..aa17ea8597a960a570aad2767670bdbdd17a0ada 100644 (file)
@@ -129,6 +129,11 @@ static void sp_dropper_context_finish(SPEventContext *ec)
     SPDropperContext *dc = SP_DROPPER_CONTEXT(ec);
 
     ec->enableGrDrag(false);
+       
+    if (dc->grabbed) {
+        sp_canvas_item_ungrab(dc->grabbed, GDK_CURRENT_TIME);
+        dc->grabbed = NULL;
+    }
 
     if (dc->area) {
         gtk_object_destroy(GTK_OBJECT(dc->area));
@@ -171,6 +176,12 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
                 dc->dragging = TRUE;
                 ret = TRUE;
             }
+                       
+                       sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+                                                               GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
+                                                               NULL, event->button.time);
+                       dc->grabbed = SP_CANVAS_ITEM(desktop->acetate);
+                       
             break;
        case GDK_MOTION_NOTIFY:
             if (event->motion.state & GDK_BUTTON2_MASK) {
@@ -311,6 +322,11 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
             {
                 sp_canvas_item_hide(dc->area);
                 dc->dragging = FALSE;
+                               
+                               if (dc->grabbed) {
+                                       sp_canvas_item_ungrab(dc->grabbed, event->button.time);
+                                       dc->grabbed = NULL;
+                               }
 
                 double alpha_to_set = setalpha? dc->alpha : 1.0;
 
index 678ab6b47f875abe861cbec70545bee93c37e36e..64181e3c8764860e4d438cfdbecc5ea7ca1d04e4 100644 (file)
@@ -32,6 +32,7 @@ struct SPDropperContext {
 
     unsigned int dragging : 1;
 
+       SPCanvasItem *grabbed;
     SPCanvasItem *area;
     Geom::Point centre;
 
index a0fb78ba19cd737a7e1c273d79de5b86b37bbc78..3535ae9e0c7be19a73b74b40897db22a00047c55 100644 (file)
@@ -117,6 +117,11 @@ sp_node_context_dispose(GObject *object)
     SPEventContext *ec = SP_EVENT_CONTEXT(object);
 
     ec->enableGrDrag(false);
+       
+    if (nc->grabbed) {
+        sp_canvas_item_ungrab(nc->grabbed, GDK_CURRENT_TIME);
+        nc->grabbed = NULL;
+    }
 
     nc->sel_changed_connection.disconnect();
     nc->sel_changed_connection.~connection();
@@ -327,6 +332,12 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                                          event->button.y);
                 Geom::Point const button_dt(desktop->w2d(button_w));
                 Inkscape::Rubberband::get(desktop)->start(desktop, button_dt);
+                               
+                sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+                                    GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
+                                    NULL, event->button.time);
+                               nc->grabbed = SP_CANVAS_ITEM(desktop->acetate);
+                               
                 nc->current_state = SP_NODE_CONTEXT_INACTIVE;
                 desktop->updateNow();
                 ret = TRUE;
@@ -483,6 +494,12 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     }
                     ret = TRUE;
                     Inkscape::Rubberband::get(desktop)->stop();
+                                       
+                                       if (nc->grabbed) {
+                                               sp_canvas_item_ungrab(nc->grabbed, event->button.time);
+                                               nc->grabbed = NULL;
+                                       }
+                                       
                     desktop->updateNow();
                     nc->rb_escaped = false;
                     nc->drag = FALSE;
index 0e141274f635c96b8623888faa73aa09458e509a..2345ffc7e798d7359aab7bc8eed6b3f8e37979b7 100644 (file)
@@ -57,6 +57,7 @@ struct SPNodeContext {
     unsigned int current_state;
  
     SPItem * flashed_item;
+       SPCanvasItem *grabbed;
     Inkscape::Display::TemporaryItem * flash_tempitem;
     int remove_flash_counter;
 };
index 2f0185731073dbb6dd0c94304bb6525fc6beaf22..f8212069e11e4398b160ccad45c51c6887307620 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "macros.h"
 #include "rubberband.h"
+#include "display/sp-canvas-util.h"
 #include "desktop.h"
 #include "pixmaps/cursor-zoom.xpm"
 #include "pixmaps/cursor-zoom-out.xpm"
@@ -86,7 +87,14 @@ static void sp_zoom_context_init (SPZoomContext *zoom_context)
 static void
 sp_zoom_context_finish (SPEventContext *ec)
 {
+       SPZoomContext *zc = SP_ZOOM_CONTEXT(ec);
+       
        ec->enableGrDrag(false);
+       
+    if (zc->grabbed) {
+        sp_canvas_item_ungrab(zc->grabbed, GDK_CURRENT_TIME);
+        zc->grabbed = NULL;
+    }
 }
 
 static void sp_zoom_context_setup(SPEventContext *ec)
@@ -119,6 +127,8 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent
 {
     SPDesktop *desktop = event_context->desktop;
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+       
+       SPZoomContext *zc = SP_ZOOM_CONTEXT(event_context);
     tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
     double const zoom_inc = prefs->getDoubleLimited("/options/zoomincrement/value", M_SQRT2, 1.01, 10);
 
@@ -147,6 +157,12 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent
                 desktop->zoom_relative_keep_point(button_dt, zoom_rel);
                 ret = TRUE;
             }
+                       
+                       sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+                                                               GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
+                                                               NULL, event->button.time);
+                       zc->grabbed = SP_CANVAS_ITEM(desktop->acetate);
+                               
             break;
         }
 
@@ -188,6 +204,12 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent
                 ret = TRUE;
             } 
             Inkscape::Rubberband::get(desktop)->stop();
+                       
+                       if (zc->grabbed) {
+                               sp_canvas_item_ungrab(zc->grabbed, event->button.time);
+                               zc->grabbed = NULL;
+                       }
+                       
             xp = yp = 0;
             escaped = false;
             break;
index aadba9551cbe544b11535768f7bb7f6678750b76..133267135a6f39acb19d40e814074eab3431d1de 100644 (file)
@@ -24,6 +24,7 @@ class SPZoomContextClass;
 
 struct SPZoomContext {
        SPEventContext event_context;
+       SPCanvasItem *grabbed;
 };
 
 struct SPZoomContextClass {