From 73686886420f9588efc21befeb061c62545bfde9 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Sat, 3 Mar 2007 19:46:20 +0000 Subject: Dynamically update scale view (implement 1556975) and prevent double redraws. svn path=/trunk/netsurf/; revision=3191 --- content/content.c | 11 +++++++++++ content/content.h | 1 + riscos/dialog.c | 10 ++++++++++ riscos/dialog.h | 1 + riscos/window.c | 34 ++++++++-------------------------- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/content/content.c b/content/content.c index 7503e9d28..446f326db 100644 --- a/content/content.c +++ b/content/content.c @@ -488,6 +488,17 @@ struct content * content_get_ready(const char *url) } +/** + * Get whether a content can reformat + * + * \param c content to check + * \return whether the content can reformat + */ +bool content_get_reformat(struct content *c) { + return (handler_map[c->type].reformat != NULL); +} + + /** * Initialise the content for the specified type. * diff --git a/content/content.h b/content/content.h index 43f9243d3..0eb7c3e4c 100644 --- a/content/content.h +++ b/content/content.h @@ -225,6 +225,7 @@ content_type content_lookup(const char *mime_type); struct content * content_create(const char *url); struct content * content_get(const char *url); struct content * content_get_ready(const char *url); +bool content_get_reformat(struct content *c); bool content_set_type(struct content *c, content_type type, const char *mime_type, const char *params[]); void content_set_status(struct content *c, const char *status_message, ...); diff --git a/riscos/dialog.c b/riscos/dialog.c index 6359c63f3..5352f2a68 100644 --- a/riscos/dialog.c +++ b/riscos/dialog.c @@ -684,6 +684,16 @@ void ro_gui_dialog_prepare_zoom(struct gui_window *g) ro_gui_wimp_event_memorise(dialog_zoom); } +/** + * Update the Scale View dialog to reflect the current window settings + * + * \param g the gui_window to update for + */ +void ro_gui_dialog_update_zoom(struct gui_window *g) { + if (g == ro_gui_current_zoom_gui) + ro_gui_dialog_prepare_zoom(g); +} + bool ro_gui_dialog_openurl_apply(wimp_w w) { url_func_result res; diff --git a/riscos/dialog.h b/riscos/dialog.h index 2fcc206c2..d1963565a 100644 --- a/riscos/dialog.h +++ b/riscos/dialog.h @@ -39,6 +39,7 @@ void ro_gui_dialog_close_persistent(wimp_w parent); void ro_gui_dialog_click(wimp_pointer *pointer); void ro_gui_dialog_prepare_zoom(struct gui_window *g); +void ro_gui_dialog_update_zoom(struct gui_window *g); void ro_gui_dialog_prepare_open_url(void); void ro_gui_save_options(void); void ro_gui_dialog_open_config(void); diff --git a/riscos/window.c b/riscos/window.c index 753c7ca56..620b61b62 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -518,27 +518,7 @@ void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1) */ void gui_window_redraw_window(struct gui_window *g) { - wimp_window_info info; - os_error *error; - - assert(g); - - info.w = g->window; - error = xwimp_get_window_info_header_only(&info); - if (error) { - LOG(("xwimp_get_window_info_header_only: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - return; - } - - error = xwimp_force_redraw(g->window, info.extent.x0, info.extent.y0, - info.extent.x1, info.extent.y1); - if (error) { - LOG(("xwimp_force_redraw: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - } + gui_window_redraw(g, 0, -8192, 8192, 8192); } @@ -1394,11 +1374,13 @@ void gui_window_set_scale(struct gui_window *g, float scale) g->option.scale = scale; c = g->bw->current_content; if (c) { - /* todo: we should only call _update for contents that don't have a - * reformat function and thus don't redraw themselves */ - browser_window_update(g->bw, false); - g->reformat_pending = true; - gui_reformat_pending = true; + ro_gui_dialog_update_zoom(g); + if (!content_get_reformat(c)) { + browser_window_update(g->bw, false); + } else { + g->reformat_pending = true; + gui_reformat_pending = true; + } } } -- cgit v1.2.3