Code

* Remove unused variables
[inkscape.git] / src / display / sp-canvas.cpp
index d1d7221f00cd39608273fe7a2df95023b287b1f2..edd429f0d10b2a40cd4a2dc7aefef865172eaf68 100644 (file)
@@ -495,7 +495,7 @@ sp_canvas_item_grab (SPCanvasItem *item, guint event_mask, GdkCursor *cursor, gu
     /* fixme: But Canvas actualle does get key events, so all we need is routing these here */
     gdk_pointer_grab (SP_CANVAS_WINDOW (item->canvas), FALSE,
                       (GdkEventMask)(event_mask & (~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK))),
-                      NULL, cursor, etime);   
+                      NULL, cursor, etime);
 
     item->canvas->grabbed_item = item;
     item->canvas->grabbed_event_mask = event_mask;
@@ -587,7 +587,7 @@ sp_canvas_item_grab_focus (SPCanvasItem *item)
         ev.focus_change.window = SP_CANVAS_WINDOW (item->canvas);
         ev.focus_change.send_event = FALSE;
         ev.focus_change.in = TRUE;
-               
+
         emit_event (item->canvas, &ev);
     }
 }
@@ -960,6 +960,9 @@ sp_canvas_init (SPCanvas *canvas)
 
     canvas->need_repick = TRUE;
 
+    // See comment at in sp-canvas.h.
+    canvas->gen_all_enter_events = false;
+
     canvas->tiles=NULL;
     canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
     canvas->tileH=canvas->tileV=0;
@@ -995,7 +998,7 @@ shutdown_transients (SPCanvas *canvas)
     canvas->tiles=NULL;
     canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
     canvas->tileH=canvas->tileV=0;
-  
+
     if (canvas->grabbed_item) {
         canvas->grabbed_item = NULL;
         gdk_pointer_ungrab (GDK_CURRENT_TIME);
@@ -1251,10 +1254,22 @@ emit_event (SPCanvas *canvas, GdkEvent *event)
 static int
 pick_current_item (SPCanvas *canvas, GdkEvent *event)
 {
+    int button_down = 0;
     double x, y;
 
     int retval = FALSE;
 
+    if (canvas->gen_all_enter_events == false) {
+        // If a button is down, we'll perform enter and leave events on the
+        // current item, but not enter on any other item.  This is more or
+        // less like X pointer grabbing for canvas items.
+        //
+        button_down = canvas->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK |
+                GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK);
+
+        if (!button_down) canvas->left_grabbed_item = FALSE;
+    }
+
     /* Save the event in the canvas.  This is used to synthesize enter and
      * leave events in case the current item changes.  It is also used to
      * re-pick the current item if the current one gets deleted.  Also,
@@ -1342,6 +1357,15 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event)
         canvas->in_repick = FALSE;
     }
 
+    if (canvas->gen_all_enter_events == false) {
+        // new_current_item may have been set to NULL during the call to
+        // emit_event() above
+        if ((canvas->new_current_item != canvas->current_item) && button_down) {
+            canvas->left_grabbed_item = TRUE;
+            return retval;
+        }
+    }
+
     /* Handle the rest of cases */
 
     canvas->left_grabbed_item = FALSE;
@@ -1541,6 +1565,10 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
             buf.rect.y0 = y0;
             buf.rect.x1 = x1;
             buf.rect.y1 = y1;
+            buf.visible_rect.x0 = draw_x1;
+            buf.visible_rect.y0 = draw_y1;
+            buf.visible_rect.x1 = draw_x2;
+            buf.visible_rect.y1 = draw_y2;
             GdkColor *color = &widget->style->bg[GTK_STATE_NORMAL];
             buf.bg_color = (((color->red & 0xff00) << 8)
                             | (color->green & 0xff00)
@@ -1825,7 +1853,7 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear)
     canvas->y0 = iy;
 
     sp_canvas_resize_tiles(canvas,canvas->x0,canvas->y0,canvas->x0+canvas->widget.allocation.width,canvas->y0+canvas->widget.allocation.height);
-  
+
     if (!clear) {
         // scrolling without zoom; redraw only the newly exposed areas
         if ((dx != 0) || (dy != 0)) {
@@ -1861,7 +1889,7 @@ sp_canvas_update_now (SPCanvas *canvas)
     g_return_if_fail (canvas != NULL);
     g_return_if_fail (SP_IS_CANVAS (canvas));
 
-    if (!(canvas->need_update || 
+    if (!(canvas->need_update ||
           canvas->need_redraw))
         return;
 
@@ -2051,9 +2079,9 @@ void sp_canvas_dirty_rect(SPCanvas* canvas,int nl,int nt,int nr,int nb)
     if ( tr > canvas->tRight ) tr=canvas->tRight;
     if ( tt < canvas->tTop ) tt=canvas->tTop;
     if ( tb > canvas->tBottom ) tb=canvas->tBottom;
-  
+
     canvas->need_redraw = TRUE;
-  
+
     for (int i=tl;i<tr;i++) {
         for (int j=tt;j<tb;j++) {
             canvas->tiles[(i-canvas->tLeft)+(j-canvas->tTop)*canvas->tileH]=1;