Event processing issue
Hi all,
Someone surely must see an easy fix for this annoying bug I ran into the other day. ~suv reported that scrolling the canvas using the scroll wheel is prohibited when the pointer is hovering above the snap indicator (see the last paragraph of this comment: https://bugs.launchpad.net/inkscape/+bug/522335/comments/8). This becomes very reproducible and annoying when using a dense grid, together the pre-snap indicator, in for example the rectangle context. Through debugging I learned that the scroll events reach sp_canvas_scroll() (just as they should), and from which they should be dispatched via emit_event() (in sp-canvas.cpp). But this only works if the canvas->current_item has been set, but in this situation the current-item is null.
Now my question is: what should the current-item be set to in this case, and how do I control this?
Thanks,
Diederik
PS: This is a stack trace of how things should work, in this case there was no grid and therefore no snap-indicator was drawn:
Thread [1] (Suspended: Breakpoint hit.) 31 sp_canvas_scroll_to() /home/diedenrezi/InkscapeBZR/inkscape/src/display/sp-canvas.cpp:2179 0x00000000006161fa 30 SPDesktop::scroll_world() /home/diedenrezi/InkscapeBZR/inkscape/src/desktop.cpp:1110 0x0000000000a744f6 29 sp_event_context_private_root_handler() /home/diedenrezi/InkscapeBZR/inkscape/src/event-context.cpp:707 0x000000000046279f 28 sp_rect_context_root_handler() /home/diedenrezi/InkscapeBZR/inkscape/src/rect-context.cpp:448 0x0000000000af5f6d 27 sp_event_context_virtual_root_handler() /home/diedenrezi/InkscapeBZR/inkscape/src/event-context.cpp:941 0x0000000000463222 26 sp_event_context_root_handler() /home/diedenrezi/InkscapeBZR/inkscape/src/event-context.cpp:937 0x00000000004631ed 25 sp_desktop_root_handler() /home/diedenrezi/InkscapeBZR/inkscape/src/desktop-events.cpp:67 0x0000000000a7a682 24 sp_marshal_BOOLEAN__POINTER() /home/diedenrezi/InkscapeBZR/inkscape/src/helper/sp-marshal.cpp:352 0x00000000006cf763 23 g_closure_invoke() 0x0000003e9180ba8e 22 <symbol is not available> 0x0000003e91820ec3 21 g_signal_emit_valist() 0x0000003e918220ec 20 gtk_signal_emit() 0x00000031668e3bd2 19 emit_event() /home/diedenrezi/InkscapeBZR/inkscape/src/display/sp-canvas.cpp:1348 0x0000000000613f57 18 sp_canvas_scroll() /home/diedenrezi/InkscapeBZR/inkscape/src/display/sp-canvas.cpp:1581 0x0000000000614928 17 <symbol is not available> 0x0000003166753a33 16 g_closure_invoke() 0x0000003e9180ba8e 15 <symbol is not available> 0x0000003e91820b8d 14 g_signal_emit_valist() 0x0000003e918220ec 13 g_signal_emit() 0x0000003e918227a3 12 <symbol is not available> 0x000000316687620f 11 gtk_propagate_event() 0x000000316674a794 10 gtk_main_do_event() 0x000000316674b8d3 9 snooper() /home/diedenrezi/InkscapeBZR/inkscape/src/main.cpp:896 0x000000000044d569 8 <symbol is not available> 0x0000003166e5fe9c 7 g_main_context_dispatch() 0x0000003e9143920e 6 <symbol is not available> 0x0000003e9143cbf8 5 g_main_loop_run() 0x0000003e9143d045 4 gtk_main() 0x000000316674be07 3 sp_main_gui() /home/diedenrezi/InkscapeBZR/inkscape/src/main.cpp:962 0x000000000044db86 2 Inkscape::NSApplication::Application::run() /home/diedenrezi/InkscapeBZR/inkscape/src/application/application.cpp:114 0x00000000005acada
1 main() /home/diedenrezi/InkscapeBZR/inkscape/src/main.cpp:698 0x000000000044cf9e
On Wed, Mar 3, 2010 at 6:25 PM, Diederik van Lierop <mail@...1689...> wrote:
Now my question is: what should the current-item be set to in this case, and how do I control this?
pick_current_item is the place where new current_item is picked; it calls sp_canvas_item_invoke_point with the root canvas item, and that recurses down into descendants, checking each one through its point method if it is under cursor and on top. You may try to check this machinery to see why your snapping item is not picked.
On 03/17/2010 10:56 PM, bulia byak wrote:
pick_current_item is the place where new current_item is picked; it calls sp_canvas_item_invoke_point with the root canvas item, and that recurses down into descendants, checking each one through its point method if it is under cursor and on top. You may try to check this machinery to see why your snapping item is not picked.
I did ;-) and found out that after the snap indicator was deleted, the current_item was no longer valid (null). Events get lost in such a case because we don't know where to send them to. Although canvas->need_repick was flagged, a repick hadn't occured yet. I fixed this (rev. 9158) by explicitely calling pick_current_item() in emit_event() in such a case, which fixed scrolling when hovering above a snap indicator. I'm still not sure though if this is a proper fix, but I haven't heard of any regressions or side effects yet.
Regards,
Diederik
On Wed, Mar 17, 2010 at 7:07 PM, Diederik van Lierop <mail@...1689...> wrote:
I did ;-) and found out that after the snap indicator was deleted, the current_item was no longer valid (null). Events get lost in such a case because we don't know where to send them to. Although canvas->need_repick was flagged, a repick hadn't occured yet. I fixed this (rev. 9158) by explicitely calling pick_current_item() in emit_event() in such a case, which fixed scrolling when hovering above a snap indicator. I'm still not sure though if this is a proper fix, but I haven't heard of any regressions or side effects yet.
Ah, sorry for belated advice :) I think your fix is OK, but I will have it in mind if I notice any regressions.
participants (2)
-
bulia byak
-
Diederik van Lierop