惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Palo Alto Networks Blog
C
Cisco Blogs
The Hacker News
The Hacker News
T
Threatpost
S
Schneier on Security
K
Kaspersky official blog
Spread Privacy
Spread Privacy
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
NISL@THU
NISL@THU
量子位
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
Security Latest
Security Latest
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
News and Events Feed by Topic
爱范儿
爱范儿
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Project Zero
Project Zero
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cisco Talos Blog
Cisco Talos Blog
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
T
Tenable Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
Forbes - Security
Forbes - Security
博客园 - 三生石上(FineUI控件)
C
Cyber Attacks, Cyber Crime and Cyber Security
N
News and Events Feed by Topic
V
V2EX
Webroot Blog
Webroot Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Blog — PlanetScale
Blog — PlanetScale
M
MIT News - Artificial intelligence
Scott Helme
Scott Helme
Simon Willison's Weblog
Simon Willison's Weblog
L
LangChain Blog
W
WeLiveSecurity
Cloudbric
Cloudbric

Martin Owens activity

Martin Owens deleted project branch average-color-divide at Inkscape / inkscape Fix divide-by-zero crash when using calligraphy tool (!7923) · Merge requests · Inkscape / inkscape · GitLab Add selection file to bypass Windows command length limits (correction) (865df7a5) · Commits · Inkscape / inkscape · GitLab Draft: Fix AppImage crashing during save on older distros (!7922) · Merge requests · Inkscape / inkscape · GitLab e71fa7f8e0858aab87b7fc0814a30a8c88da9b43 to fe225a6b9e1042c7221d95173be22a02b3725337 · Martin Owens / inkscape · GitLab 403 Forbidden on Inkscape web server (#693) · Issues · Inkscape / inkscape-web · GitLab 403 Forbidden on Inkscape web server (#13509) · Issues · Inkscape / Inbox · GitLab Add selection file to bypass Windows command length limits (correction) (!7917) · 合并请求 · Inkscape / inkscape · GitLab Non-vertical axonometric axis implementation (!7912) · Merge requests · Inkscape / inkscape · GitLab Update split mode on tab switch (!7915) · Merge requests · Inkscape / inkscape · GitLab inset/offset as app functions so they can be used from CLI (!7914) · Merge requests · Inkscape / inkscape · GitLab Performace regresion in last month (#5879) · Issues · Inkscape / inkscape · GitLab [Regression] Right-aligned text has a new gap in 1.4.4 (#6130) · Issues · Inkscape / inkscape · GitLab [Regression] Right-aligned text has a new gap in 1.4.4 (#13498) · Issues · Inkscape / Inbox · GitLab c503804e014994d611de1b225bee8158c06448a8 to a4588d8ead1e7049b90c5a126962746ed286ab17 · Inkscape / inkscape-web · GitLab Validate the extensions of signature file uploads (a4588d8e) · 提交 · Inkscape / inkscape-web · GitLab Allow color conversions using static arrays instead of just vectors (e71fa7f8) · 提交 · Martin Owens / inkscape · GitLab Speed up ungroup on thousands of items (!7908) · Merge requests · Inkscape / inkscape · GitLab Incorrect handling of FontMatrix and transformation matrices with internal PDF import (#4845) · Issues · Inkscape / inkscape · GitLab Handling edge case of negative fonts in PDF (59040229) · 提交 · Inkscape / inkscape · GitLab Handling edge case of negative fonts in PDF (!7911) · 合并请求 · Inkscape / inkscape · GitLab Allow color conversions using static arrays instead of just vectors (33e65d1b) · Commits · Martin Owens / inkscape · GitLab Allow color conversions using static arrays instead of just vectors (9be5f867) · Commits · Martin Owens / inkscape · GitLab a9672ea1dff483b5b3aa8c6b5d88cd223001bef5 to 512a5e57602ac52e1d35782a7dcebae04262b2b8 · Martin Owens / inkscape · GitLab Add selection file to bypass Windows command length limits (!7905) · 合并请求 · Inkscape / inkscape · GitLab Revert Pango label changes (1.4.x) (!7907) · 合并请求 · Inkscape / inkscape · GitLab Crash on selecting a `<text>` object without a `<tspan>` inside (#5462) · Issues · Inkscape / inkscape · GitLab Fix breakage with Ubuntu 26.04 CI (!7904) · 合并请求 · Inkscape / inkscape · GitLab c673fdd5148253276826d4eda3951daaefb82607 to 356b31383ba324396a225686613236484305533d · Martin Owens / inkscape · GitLab Revert Text tool cursor changes (1.4.x) (!7903) · 合并请求 · Inkscape / inkscape · GitLab Add selection file to bypass Windows command length limits (c8da6484) · 提交 · Inkscape / inkscape · GitLab Add new simplifyInvisible path manipulator function (e15296e3) · 提交 · Martin Owens / inkscape · GitLab Add new simplifyInvisible path manipulator function (!7902) · 合并请求 · Inkscape / inkscape · GitLab 提交 · weld-nodes-if-tiny · Martin Owens / inkscape · GitLab Update PDF version string to 2.0 (!7901) · 合并请求 · Inkscape / inkscape · GitLab Fix TypeError in replace_font.py (!726) · 合并请求 · Inkscape / extensions · GitLab Remove "using namespace Inkscape" in style-internal.h (!7731) · 合并请求 · Inkscape / inkscape · GitLab Fix color_negative.py for HSL colors (!725) · 合并请求 · Inkscape / extensions · GitLab Add selection file to bypass Windows command length limits (2626d26b) · 提交 · Inkscape / extensions · GitLab Extensions fail with too many items selected in Windows (#2627) · Issues · Inkscape / inkscape · GitLab Joining points not working (#5540) · Issues · Inkscape / Inbox · GitLab Add argument file to bypass Windows command length limits (!7899) · 合并请求 · Inkscape / inkscape · GitLab Add selection file to bypass Windows command length limits (!724) · 合并请求 · Inkscape / extensions · GitLab 4f05fa82847e7798338aa8db1aab21acfe0f7455 to 3bbc78baaee71371d7e6e3a14c59f554b1d9929b · Inkscape / Inbox · GitLab Fix PlantUML syntax (!7) · 合并请求 · Inkscape / Inbox · GitLab Apply 1 suggestion(s) to 1 file(s) (ccd43fd7) · 提交 · Inkscape / Inbox · GitLab Add editing issues advice (!8) · 合并请求 · Inkscape / Inbox · GitLab 提交 · doctormo-master-patch-44578 · Inkscape / Inbox · GitLab New UX for text in shape and text in path (c673fdd5) · Commits · Martin Owens / inkscape · GitLab Converge canvas item text rendering to one place (!7895) · 合并请求 · Inkscape / inkscape · GitLab New UX for text in shape and text in path (20ad9dae) · 提交 · Martin Owens / inkscape · GitLab 1.5-dev: Page labels overflow on Windows (#13460) · Issues · Inkscape / Inbox · GitLab 1.5-dev: Page labels overflow on Windows (#6121) · Issues · Inkscape / inkscape · GitLab Stop cursor from blinking when defocused, take 3 (1.4.x) (!7896) · 合并请求 · Inkscape / inkscape · GitLab New UX for text in shape and text in path (dabd763c) · Commits · Martin Owens / inkscape · GitLab e93c9eb034a1b744ef1a16889e588965057f13a1 to cc89121ffe961f34351888f9dcaacd8b68fc2f1f · Martin Owens / inkscape · GitLab Update Color API preparing for new Rendering Engine (!7894) · Merge requests · Inkscape / inkscape · GitLab Commits · color-api-rendering-changes · Martin Owens / inkscape · GitLab 4fad4dca7c8c63a60f68bf796b4cf1abdebb5f90 to dd1cf0272f1efc11aaf062f39be46227fac972d8 · Martin Owens / inkscape · GitLab Stop cursor from blinking when defocused, take 2 (1.4.x) (!7893) · Merge requests · Inkscape / inkscape · GitLab Switch PangoCairo rendering backend to Fontconfig (1.4.x) (!7891) · Merge requests · Inkscape / inkscape · GitLab Speed up drawing cache insert (1.4.x) (!7889) · Merge requests · Inkscape / inkscape · GitLab Cherry-pick | Fix crash while using maximum scans in trace dialog (!7888) · Merge requests · Inkscape / inkscape · GitLab Display Mode: Toggle Preview (Instead of Quick Preview) does not work (#5650) · Issues · Inkscape / inkscape · GitLab Imported file contains invisible objects that prevent boolean operations when selected. (#5036) · Issues · Inkscape / inkscape · GitLab Fix Memory Leak when reading paper sizes (!7885) · Merge requests · Inkscape / inkscape · GitLab Rounded concave triangle marker (!7884) · Merge requests · Inkscape / inkscape · GitLab Switch PangoCairo rendering backend to Fontconfig (!7882) · Merge requests · Inkscape / inkscape · GitLab New UX for text in shape and text in path (e93c9eb0) · Commits · Martin Owens / inkscape · GitLab New UX for text in shape and text in path (!7827) · Merge requests · Inkscape / inkscape · GitLab 8f9cb2784a5c5714448c030e83f3f2ac36a2ae28 to 26f5129e7cb3fbe32f9fe41df6673df8e72619a1 · Martin Owens / inkscape · GitLab Fix tests in debian packaging (!7838) · Merge requests · Inkscape / inkscape · GitLab Draft: Upgrade to Ubuntu 26.04 (!64) · Merge requests · Inkscape / inkscape-ci-docker · GitLab Draft: Fix breakage with Ubuntu 26.04 CI (!148) · Merge requests · Inkscape / lib2geom · GitLab Speed up drawing cache insert (!7876) · Merge requests · Inkscape / inkscape · GitLab Cleanup SPIFloat and default values in styles (b233c4c0) · Commits · Inkscape / inkscape · GitLab Add nullptr guards to text actions (!7879) · Merge requests · Inkscape / inkscape · GitLab Fix crash while using maximum scans in trace dialog (!7880) · Merge requests · Inkscape / inkscape · GitLab 06fae2b82103418a6f8639b75fed8b89b37fc59f to 16ddfaedd6e6611888945de84907665d78cd9abf · Martin Owens / inkscape · GitLab Refactor paint server data so the renderer works from data (c821845d) · Commits · Inkscape / inkscape · GitLab 1.4.x backports for 1.4.4 (!7840) · 合并请求 · Inkscape / inkscape · GitLab Cleanup SPIFloat and default values in styles (!7874) · Merge requests · Inkscape / inkscape · GitLab Commits · cleanup-spifloat-values · Martin Owens / inkscape · GitLab f6fdc326437935b01a7846bfcee7785ce4d3e7bd to 4fad4dca7c8c63a60f68bf796b4cf1abdebb5f90 · Martin Owens / inkscape · GitLab Page tool on-canvas selection and modification (#353) · Issues · Inkscape / Inkscape UX · GitLab Canvas rect pixel alignment improvements (!7849) · Merge requests · Inkscape / inkscape · GitLab 1.4.x backports for 1.4.4 (with strings) (!7867) · Merge requests · Inkscape / inkscape · GitLab Inconsistent selection validation across extensions (#624) · Issues · Inkscape / extensions · GitLab Refactor paint server data so the renderer works from data (!7859) · Merge requests · Inkscape / inkscape · GitLab Rename star turn upright for clarity (!7863) · Merge requests · Inkscape / inkscape · GitLab Add desktop check to StyleSubject (!7864) · Merge requests · Inkscape / inkscape · GitLab Crash on Selection::_emitChanged() (#13432) · Issues · Inkscape / Inbox · GitLab Clone image in pdf not reused (#6105) · Issues · Inkscape / inkscape · GitLab Add custom color palette support to bitmap tracing with novel color quantization algorithm (!7862) · Merge requests · Inkscape / inkscape · GitLab Add a rasterize-fills extension (!723) · Merge requests · Inkscape / extensions · GitLab Node snapping causes stall when many paths/nodes present (#5055) · Issues · Inkscape / inkscape · GitLab Martin Owens pushed new project branch refactor-paint-server-data at Martin Owens / inkscape Policy Discussion: Generative AI (#5) · Issues · Inkscape / Inkscape Board · GitLab Use epsilon in isChord function for EllipticalArc (!145) · Merge requests · Inkscape / lib2geom · GitLab Backport "Handle text with different lang across tspans" to 1.4.x (!7692) · Merge requests · Inkscape / inkscape · GitLab
Remove use of DrawingItemCanvas for area_world geometry (3de40411) · Commits · Martin Owens / inkscape · GitLab
Martin Owens · 2026-06-27 · via Martin Owens activity
Commit 3de40411 authored by Martin Owens's avatar Martin Owens 🕘
Browse files

Remove use of DrawingItemCanvas for area_world geometry

The area_world geometry used for some shape picking calculations should
be an argument on the pick rather than a bit of data that the Drawing
system requests from the DrawingItemCanvas

Along with this we pull out the remaining SPDocument single point pickers
and move them into SPDesktop. The area pickers need to also be moved and
a future refactoring to create a PickManager to seperate the code and it's
item cache functionality.
Original line number Diff line number Diff line
@@ -346,45 +346,204 @@ Inkscape::UI::Dialog::DialogContainer *SPDesktop::getContainer()
    return _widget->getDialogContainer();
}

static void _build_flat_item_list(std::deque<SPItem*> &cache, SPGroup *group, unsigned int dkey, bool into_groups, bool active_only)
{
    for (auto& o: group->children) {
        if (!is<SPItem>(&o)) {
            continue;
        }

        if (is<SPGroup>(&o) && (cast<SPGroup>(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) {
            _build_flat_item_list(cache, cast<SPGroup>(&o), dkey, into_groups, active_only);
        } else {
            auto child = cast<SPItem>(&o);
            if (!active_only || child->isVisibleAndUnlocked(dkey)) {
                cache.push_front(child);
            }
        }
    }
}

/**
 * \see SPDocument::getItemFromListAtPointBottom()
Turn the SVG DOM into a cached flat list of nodes that can be searched from top-down.
The list can be persisted, which improves "find at multiple points" speed.
*/
SPItem *SPDesktop::getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const
std::deque<SPItem*> const &SPDesktop::get_flat_item_list(bool into_groups, bool active_only) const
{
    g_return_val_if_fail (doc() != nullptr, NULL);
    // Build a caching key from our inputs
    using key_t = decltype(_node_cache)::key_type;
    auto const key = (key_t{dkey} << 2) | (into_groups << 1) | active_only;

    auto const [it, inserted] = _node_cache.try_emplace(key);
    if (inserted) {
        _build_flat_item_list(it->second, doc()->getRoot(), dkey, into_groups, active_only);
    }
    return it->second;
}

SPItem *SPDesktop::_getItemFromListAtPointBottom(SPGroup *group, std::vector<SPItem*> const &list, Geom::Point const &p) const
{
    if (!group) {
        return nullptr;
    }

    auto area_world = canvas->get_area_world();
    bool outline = canvas->canvas_point_in_outline_zone(p - canvas->get_pos());
    return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p, outline);
    double const delta = Inkscape::Preferences::get()->getDouble("/options/cursortolerance/value", 1.0);

    for (auto &c: group->children) {
        if (auto item = cast<SPItem>(&c)) {
            if (auto di = item->get_arenaitem(dkey)) {
                if (di->pick(p, delta, area_world, Inkscape::DrawingItem::PICK_STICKY | outline * Inkscape::DrawingItem::PICK_OUTLINE) && item->isVisibleAndUnlocked(dkey)) {
                    if (std::find(list.begin(), list.end(), item) != list.end()) {
                        return item;
                    }
                }
            }

            if (auto group = cast<SPGroup>(item)) {
                if (auto ret = _getItemFromListAtPointBottom(group, list, p)) {
                    return ret;
                }
            }
        }
    }

    return nullptr;
}

/**
 * \see SPDocument::getItemAtPoint()
Returns the items from the descendants of group (recursively) which are at the
point p, or NULL if none. Honors into_groups on whether to recurse into non-layer
groups or not. Honors take_insensitive on whether to return insensitive items.
If upto != NULL, then if item upto is encountered (at any level), stops searching
upwards in z-order and returns what it has found so far (i.e. the found items are
guaranteed to be lower than upto). Requires a list of nodes built by build_flat_item_list.
If items_count > 0, it'll return the topmost (in z-order) items_count items.
 */
SPItem *SPDesktop::getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto) const
std::vector<SPItem*> SPDesktop::find_items_at_point(std::deque<SPItem*> const &nodes, Geom::Point const &p, int items_count, SPItem *upto) const
{
    g_return_val_if_fail (doc() != nullptr, NULL);
    double const delta = Inkscape::Preferences::get()->getDouble("/options/cursortolerance/value", 1.0);

    std::vector<SPItem*> result;

    auto area_world = canvas->get_area_world();
    bool outline = canvas->canvas_point_in_outline_zone(p - canvas->get_pos());
    return doc()->getItemAtPoint( dkey, p, into_groups, upto, outline);

    bool seen_upto = !upto;
    for (auto node : nodes) {
        if (!seen_upto) {
            if (node == upto) {
                seen_upto = true;
            }
            continue;
        }
        if (auto di = node->get_arenaitem(dkey)) {
            if (di->pick(p, delta, area_world, Inkscape::DrawingItem::PICK_STICKY | outline * Inkscape::DrawingItem::PICK_OUTLINE)) {
                result.emplace_back(node);
                if (--items_count == 0) {
                    break;
                }
            }
        }
    }

std::vector<SPItem*> SPDesktop::getItemsAtPoints(std::vector<Geom::Point> points, bool all_layers, bool topmost_only, size_t limit, bool active_only) const
    return result;
}

SPItem *SPDesktop::find_item_at_point(std::deque<SPItem*> const &nodes, Geom::Point const &p, SPItem *upto) const
{
    if (!doc())
        return {};
    bool outline = false;
    for (auto &p : points) {
        outline = outline || canvas->canvas_point_in_outline_zone(p - canvas->get_pos());
    auto items = find_items_at_point(nodes, p, 1, upto);
    if (items.empty()) {
        return nullptr;
    }
    return doc()->getItemsAtPoints(dkey, points, all_layers, topmost_only, limit, active_only, outline);
    return items.back();
}

/**
 * \see SPDocument::getGroupAtPoint()
 * Returns the topmost non-layer group from the descendants of group which is at point p,
 * or null if none. Recurses into layers but not into groups.
 */
SPItem *SPDesktop::find_group_at_point(SPGroup *group, Geom::Point const &p) const
{
    double const delta = Inkscape::Preferences::get()->getDouble("/options/cursortolerance/value", 1.0);

    auto area_world = canvas->get_area_world();
    bool outline = canvas->canvas_point_in_outline_zone(p - canvas->get_pos());

    for (auto &c : group->children | std::views::reverse) {
        if (auto group = cast<SPGroup>(&c)) {
            if (group->effectiveLayerMode(dkey) == SPGroup::LAYER) {
                if (auto ret = find_group_at_point(group, p)) {
                    return ret;
                }
            } else if (auto di = group->get_arenaitem(dkey)) {
                if (di->pick(p, delta, area_world, Inkscape::DrawingItem::PICK_STICKY | outline * Inkscape::DrawingItem::PICK_OUTLINE)) {
                    return group;
                }
            }
        }
    }

    return nullptr;
}

/**
 * Returns the bottommost item from the list which is at the point, or NULL if none.
 */
SPItem *SPDesktop::getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const
{
    g_return_val_if_fail (doc() != nullptr, NULL);
    return _getItemFromListAtPointBottom(doc()->getRoot(), list, p);
}

SPItem *SPDesktop::getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto) const
{
    return find_item_at_point(get_flat_item_list(into_groups, true), p, upto);
}

SPItem *SPDesktop::getGroupAtPoint(Geom::Point const &p) const
{
    g_return_val_if_fail (doc() != nullptr, NULL);
    bool outline = canvas->canvas_point_in_outline_zone(p - canvas->get_pos());
    return doc()->getGroupAtPoint(dkey, p, outline);
    return find_group_at_point(doc()->getRoot(), p);
}

std::vector<SPItem*> SPDesktop::getItemsAtPoints(std::vector<Geom::Point> points, bool all_layers, bool topmost_only, size_t limit, bool active_only) const
{
    std::vector<SPItem*> result;
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();

    // When picking along the path, we don't want small objects close together
    // (such as hatching strokes) to obscure each other by their deltas,
    // so we temporarily set delta to a small value
    gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
    prefs->setDouble("/options/cursortolerance/value", 0.25);

    auto &node_cache = get_flat_item_list(true, active_only);

    SPObject *current_layer = nullptr;
    current_layer = layerManager().currentLayer();
    size_t item_counter = 0;
    for(auto point : points) {
        std::vector<SPItem*> items = find_items_at_point(node_cache, point, topmost_only, nullptr);
        for (SPItem *item : items) {
            if (item && result.end()==find(result.begin(), result.end(), item))
                if(all_layers || layerManager().layerForObject(item) == current_layer) {
                    result.push_back(item);
                    item_counter++;
                    //limit 0 = no limit
                    if(item_counter == limit){
                        prefs->setDouble("/options/cursortolerance/value", saved_delta);
                        return result;
                    }
                }
        }
    }

    // and now we restore it back
    prefs->setDouble("/options/cursortolerance/value", saved_delta);

    return result;
}

/**
@@ -1320,6 +1479,12 @@ void SPDesktop::_attachDocument()
    _saved_or_modified_conn = document->connectSavedOrModified([this] {
        _widget->desktopChangedTitle(this);
    });
    _document_modified_conn = document->connectModified([this](int flags) {
        clearNodeCache();
    });
    _document_object_bound_conn = document->connectObjectBound([this]() {
        clearNodeCache();
    });

    // set new document before firing signal, so handlers can see new value if they query desktop
    _document_replaced_signal.emit(this, document);
@@ -1334,6 +1499,8 @@ void SPDesktop::_detachDocument()

    _document_uri_set_connection.disconnect();
    _saved_or_modified_conn.disconnect();
    _document_modified_conn.disconnect();
    _document_object_bound_conn.disconnect();
    _reconstruction_start_connection.disconnect();
    _reconstruction_finish_connection.disconnect();
    _schedule_zoom_from_document_connection.disconnect();
Original line number Diff line number Diff line
@@ -175,6 +175,8 @@ private:
    sigc::scoped_connection _message_idle_connection;
    sigc::connection _document_uri_set_connection;
    sigc::connection _saved_or_modified_conn;
    sigc::connection _document_modified_conn;
    sigc::connection _document_object_bound_conn;

    std::unique_ptr<Inkscape::UI::Tools::ToolBase> _tool;
    std::unique_ptr<Inkscape::Display::TemporaryItemList> _temporary_item_list;
@@ -577,6 +579,18 @@ private:
    void on_zoom_end(Gdk::EventSequence *sequence);

    void onStatusMessage(Inkscape::MessageType type, char const *message);

    std::deque<SPItem*> const &get_flat_item_list(bool into_groups, bool active_only) const;
    SPItem *_getItemFromListAtPointBottom(SPGroup *group, std::vector<SPItem*> const &list, Geom::Point const &p) const;
    std::vector<SPItem*> find_items_at_point(std::deque<SPItem*> const &nodes, Geom::Point const &p, int items_count = 0, SPItem *upto = nullptr) const;
    SPItem *find_item_at_point(std::deque<SPItem*> const &nodes, Geom::Point const &p, SPItem *upto = nullptr) const;
    SPItem *find_group_at_point(SPGroup *group, Geom::Point const &p) const;

    // Find items by geometry --------------------
    mutable std::map<unsigned long, std::deque<SPItem*>> _node_cache; // Used to speed up search.

public:
    void clearNodeCache() { _node_cache.clear(); }
};

#endif // INKSCAPE_DESKTOP_H
Original line number Diff line number Diff line
@@ -56,7 +56,8 @@ bool CanvasItemDrawing::contains(Geom::Point const &p, double tolerance)
        std::cerr << "CanvasItemDrawing::contains: Non-zero tolerance not implemented!" << std::endl;
    }

    _picked_item = _drawing->pick(p, _drawing->cursorTolerance(), _sticky * DrawingItem::PICK_STICKY | _pick_outline * DrawingItem::PICK_OUTLINE);

    _picked_item = _drawing->pick(p, _drawing->cursorTolerance(), get_canvas()->get_area_world(), get_flags());

    if (_picked_item) {
        // This will trigger a signal that is handled by our event handler. Seems a bit of a
@@ -89,7 +90,7 @@ void CanvasItemDrawing::_update(bool)

    if (_cursor) {
        /* Mess with enter/leave notifiers */
        auto new_drawing_item = _drawing->pick(_c, _delta, _sticky * DrawingItem::PICK_STICKY | _pick_outline * DrawingItem::PICK_OUTLINE);
        auto new_drawing_item = _drawing->pick(_c, _delta, get_canvas()->get_area_world(), get_flags());
        if (_active_item != new_drawing_item) {
            // Fixme: These crossing events have no modifier state set.

@@ -137,7 +138,7 @@ bool CanvasItemDrawing::handle_event(CanvasEvent const &event)
                /* TODO ... event -> arena transform? */
                _c = event.pos;

                _active_item = _drawing->pick(_c, _drawing->cursorTolerance(), _sticky * DrawingItem::PICK_STICKY | _pick_outline * DrawingItem::PICK_OUTLINE);
                _active_item = _drawing->pick(_c, _drawing->cursorTolerance(), get_canvas()->get_area_world(), get_flags());
                retval = _drawing_event_signal.emit(event, _active_item);
            }
        },
@@ -154,7 +155,7 @@ bool CanvasItemDrawing::handle_event(CanvasEvent const &event)
            /* TODO ... event -> arena transform? */
            _c = event.pos;

            auto new_drawing_item = _drawing->pick(_c, _drawing->cursorTolerance(), _sticky * DrawingItem::PICK_STICKY | _pick_outline * DrawingItem::PICK_OUTLINE);
            auto new_drawing_item = _drawing->pick(_c, _drawing->cursorTolerance(), get_canvas()->get_area_world(), get_flags());
            if (_active_item != new_drawing_item) {

                /* fixme: What is wrong? */
@@ -194,6 +195,11 @@ bool CanvasItemDrawing::handle_event(CanvasEvent const &event)
    return retval;
}

unsigned CanvasItemDrawing::get_flags() const
{
    return _sticky * DrawingItem::PICK_STICKY | _pick_outline * DrawingItem::PICK_OUTLINE;
}

} // namespace Inkscape

/*
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ protected:

    // Signals
    sigc::signal<bool(CanvasEvent const &, Inkscape::DrawingItem *)> _drawing_event_signal;

private:
    unsigned get_flags() const;
};

} // namespace Inkscape
Original line number Diff line number Diff line
@@ -106,10 +106,10 @@ void DrawingGroup::_clipItem(DrawingContext &dc, RenderContext &rc, Geom::IntRec
    }
}

DrawingItem *DrawingGroup::_pickItem(Geom::Point const &p, double delta, unsigned flags)
DrawingItem *DrawingGroup::_pickItem(Geom::Point const &p, double delta, Geom::OptRect area_world, unsigned flags)
{
    for (auto &i : _children) {
        DrawingItem *picked = i.pick(p, delta, flags);
        DrawingItem *picked = i.pick(p, delta, area_world, flags);
        if (picked) {
            return _pick_children ? picked : this;
        }