From: buliabyak Date: Sun, 25 Feb 2007 05:46:48 +0000 (+0000) Subject: move a global to a class property; reduce the use of is_scrolling to prevent the... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=04f50952e01e32eef6902cce4cc1df66e9a6f2c2;p=inkscape.git move a global to a class property; reduce the use of is_scrolling to prevent the lack-of-redraw issues --- diff --git a/src/desktop.cpp b/src/desktop.cpp index 5590633b8..e1cc23083 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -897,13 +897,13 @@ SPDesktop::zoom_drawing() * Scroll canvas by specific coordinate amount. */ void -SPDesktop::scroll_world (double dx, double dy) +SPDesktop::scroll_world (double dx, double dy, bool is_scrolling) { g_assert(_widget); NR::Rect const viewbox = canvas->getViewbox(); - sp_canvas_scroll_to(canvas, viewbox.min()[NR::X] - dx, viewbox.min()[NR::Y] - dy, FALSE); + sp_canvas_scroll_to(canvas, viewbox.min()[NR::X] - dx, viewbox.min()[NR::Y] - dy, FALSE, is_scrolling); _widget->updateRulers(); _widget->updateScrollbars(expansion(_d2w)); diff --git a/src/desktop.h b/src/desktop.h index 42e059db2..9f3d77520 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -214,12 +214,12 @@ struct SPDesktop : public Inkscape::UI::View::View void next_zoom(); bool scroll_to_point (NR::Point const *s_dt, gdouble autoscrollspeed = 0); - void scroll_world (double dx, double dy); - void scroll_world (NR::Point const scroll) + void scroll_world (double dx, double dy, bool is_scrolling = false); + void scroll_world (NR::Point const scroll, bool is_scrolling = false) { using NR::X; - using NR::Y; - scroll_world(scroll[X], scroll[Y]); + using NR::Y; + scroll_world(scroll[X], scroll[Y], is_scrolling); } void getWindowGeometry (gint &x, gint &y, gint &w, gint &h); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index b10af7f6a..f716d383a 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -988,6 +988,9 @@ sp_canvas_init (SPCanvas *canvas) canvas->forced_redraw_limit = -1; canvas->slowest_buffer = 0; + + canvas->is_scrolling = false; + } /** @@ -1590,8 +1593,6 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, } } -static int is_scrolling = 0; - /* Paint the given rect, while updating canvas->redraw_aborted and running iterations after each * buffer; make sure canvas->redraw_aborted never goes past aborted_limit (used for 2-rect * optimized repaint) @@ -1707,11 +1708,11 @@ sp_canvas_paint_rect_internal (SPCanvas *canvas, NRRectL *rect, NR::ICoord *x_ab // OPTIMIZATION IDEA: if drawing is really slow (as measured by canvas->slowest // buffer), do the same - process some events even before we paint any buffers - if (is_scrolling) { - is_scrolling = 0; + if (canvas->is_scrolling) { while (Gtk::Main::events_pending()) { // process any events Gtk::Main::iteration(false); } + canvas->is_scrolling = false; if (this_count != canvas->redraw_count) { // if there was redraw, return 1; // interrupt this one } @@ -2154,7 +2155,7 @@ sp_canvas_root (SPCanvas *canvas) * Scrolls canvas to specific position. */ void -sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear) +sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, bool is_scrolling) { g_return_if_fail (canvas != NULL); g_return_if_fail (SP_IS_CANVAS (canvas)); @@ -2174,7 +2175,7 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear) if (!clear) { // scrolling without zoom; redraw only the newly exposed areas if ((dx != 0) || (dy != 0)) { - is_scrolling = 1; + canvas->is_scrolling = is_scrolling; if (GTK_WIDGET_REALIZED (canvas)) { gdk_window_scroll (SP_CANVAS_WINDOW (canvas), -dx, -dy); } diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 39a7ae1f8..bc5f835f1 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -178,6 +178,8 @@ struct SPCanvas { bool gen_all_enter_events; int rendermode; + + bool is_scrolling; NR::Rect getViewbox() const; }; @@ -186,7 +188,7 @@ GtkWidget *sp_canvas_new_aa(); SPCanvasGroup *sp_canvas_root(SPCanvas *canvas); -void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int clear); +void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int clear, bool is_scrolling = false); void sp_canvas_update_now(SPCanvas *canvas); void sp_canvas_request_redraw(SPCanvas *canvas, int x1, int y1, int x2, int y2); diff --git a/src/event-context.cpp b/src/event-context.cpp index f3a402eeb..99dc5ac20 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -405,7 +405,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context, NR::Point const motion_w(event->motion.x, event->motion.y); NR::Point const moved_w( motion_w - button_w ); - event_context->desktop->scroll_world(moved_w); + event_context->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw ret = TRUE; } } else if (zoom_rb) {