~ubuntu-branches/ubuntu/natty/inkscape/natty

« back to all changes in this revision

Viewing changes to src/display/sp-canvas.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
/* SPCanvasItem */
104
104
 
105
105
enum {ITEM_EVENT, ITEM_LAST_SIGNAL};
 
106
enum {PROP_0, PROP_VISIBLE};
106
107
 
107
108
 
108
109
static void sp_canvas_request_update (SPCanvas *canvas);
114
115
static void sp_canvas_item_construct (SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args);
115
116
 
116
117
static int emit_event (SPCanvas *canvas, GdkEvent *event);
 
118
static int pick_current_item (SPCanvas *canvas, GdkEvent *event);
117
119
 
118
120
static guint item_signals[ITEM_LAST_SIGNAL] = { 0 };
119
121
 
120
 
static GtkObjectClass *item_parent_class;
121
 
 
122
122
/**
123
123
 * Registers the SPCanvasItem class with Glib and returns its type number.
124
124
 */
151
151
{
152
152
    GObjectClass *object_class = (GObjectClass *) klass;
153
153
 
154
 
    /* fixme: Derive from GObject */
155
 
    item_parent_class = (GtkObjectClass*)gtk_type_class (GTK_TYPE_OBJECT);
156
 
 
157
154
    item_signals[ITEM_EVENT] = g_signal_new ("event",
158
155
                                             G_TYPE_FROM_CLASS (klass),
159
156
                                             G_SIGNAL_RUN_LAST,
172
169
static void
173
170
sp_canvas_item_init (SPCanvasItem *item)
174
171
{
 
172
    // TODO items should not be visible on creation - this causes kludges with items
 
173
    // that should be initially invisible; examples of such items: node handles, the CtrlRect
 
174
    // used for rubberbanding, path outline, etc.
175
175
    item->flags |= SP_CANVAS_ITEM_VISIBLE;
176
176
    item->xform = Geom::Matrix(Geom::identity());
177
177
}
277
277
        group_remove (SP_CANVAS_GROUP (item->parent), item);
278
278
    }
279
279
 
280
 
    G_OBJECT_CLASS (item_parent_class)->dispose (object);
 
280
    G_OBJECT_CLASS (g_type_class_peek(g_type_parent(sp_canvas_item_get_type())))->dispose (object);
281
281
}
282
282
 
283
283
/**
477
477
    item->canvas->need_repick = TRUE;
478
478
}
479
479
 
 
480
bool
 
481
sp_canvas_item_is_visible (SPCanvasItem *item)
 
482
{
 
483
    return item->flags & SP_CANVAS_ITEM_VISIBLE;
 
484
}
 
485
 
 
486
 
480
487
/**
481
488
 * Sets visible flag on item and requests a redraw.
482
489
 */
542
549
    if (item->canvas->grabbed_item)
543
550
        return -1;
544
551
 
545
 
    if (!(item->flags & SP_CANVAS_ITEM_VISIBLE))
546
 
        return -1;
 
552
    // This test disallows grabbing events by an invisible item, which may be useful
 
553
    // sometimes. An example is the hidden control point used for the selector component,
 
554
    // where it is used for object selection and rubberbanding. There seems to be nothing
 
555
    // preventing this except this test, so I removed it.
 
556
    // -- Krzysztof Kosiński, 2009.08.12
 
557
    //if (!(item->flags & SP_CANVAS_ITEM_VISIBLE))
 
558
    //    return -1;
547
559
 
548
560
    if (HAS_BROKEN_MOTION_HINTS) {
549
561
        event_mask &= ~GDK_POINTER_MOTION_HINT_MASK;
1314
1326
    if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item)) {
1315
1327
        item = canvas->grabbed_item;
1316
1328
    } else {
 
1329
        // Make sure that current_item is up-to-date. If a snap indicator was just deleted, then
 
1330
        // sp_canvas_item_dispose has been called and there is no current_item specified. We need
 
1331
        // that though because otherwise we don't know where to send this event to, leading to a
 
1332
        // lost event. We can't wait for idle events to have current_item updated, we need it now!
 
1333
        // Otherwise, scrolling when hovering above a pre-snap indicator won't work (for example)
 
1334
        // See this bug report: https://bugs.launchpad.net/inkscape/+bug/522335/comments/8
 
1335
        if (canvas->need_repick && !canvas->in_repick && event->type == GDK_SCROLL) {
 
1336
            // To avoid side effects, we'll only do this for scroll events, because this is the
 
1337
            // only thing we want to fix here. An example of a reported side effect is that
 
1338
            // otherwise selection of nodes in the node editor by dragging a rectangle using a
 
1339
            // tablet will break
 
1340
            canvas->need_repick = FALSE;
 
1341
            pick_current_item (canvas, (GdkEvent *) event);
 
1342
        }
1317
1343
        item = canvas->current_item;
1318
1344
    }
1319
1345
 
1479
1505
        retval = emit_event (canvas, &new_event);
1480
1506
    }
1481
1507
 
 
1508
 
 
1509
 
1482
1510
    return retval;
1483
1511
}
1484
1512
 
1576
1604
static int
1577
1605
sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
1578
1606
{
1579
 
        int status;
 
1607
    int status;
1580
1608
    SPCanvas *canvas = SP_CANVAS (widget);
1581
1609
 
1582
1610
    track_latency((GdkEvent *)event);
1588
1616
        return FALSE;
1589
1617
 
1590
1618
    canvas->state = event->state;
1591
 
        pick_current_item (canvas, (GdkEvent *) event);
1592
 
        status = emit_event (canvas, (GdkEvent *) event);
1593
 
        if (event->is_hint) {
1594
 
                request_motions(widget->window, event);
1595
 
        }
 
1619
    pick_current_item (canvas, (GdkEvent *) event);
 
1620
    status = emit_event (canvas, (GdkEvent *) event);
 
1621
    if (event->is_hint) {
 
1622
        request_motions(widget->window, event);
 
1623
    }
1596
1624
 
1597
1625
    return status;
1598
1626
}
2083
2111
static int
2084
2112
do_update (SPCanvas *canvas)
2085
2113
{
2086
 
    if (!canvas->root || !canvas->pixmap_gc) // canvas may have already be destroyed by closing desktop durring interrupted display!
 
2114
    if (!canvas->root || !canvas->pixmap_gc) // canvas may have already be destroyed by closing desktop during interrupted display!
2087
2115
        return TRUE;
2088
2116
 
2089
2117
    /* Cause the update if necessary */
2184
2212
    } else {
2185
2213
        // scrolling as part of zoom; do nothing here - the next do_update will perform full redraw
2186
2214
    }
 
2215
 
2187
2216
}
2188
2217
 
2189
2218
/**