diff options
author | Vincent Sanders <vince@kyllikki.org> | 2017-04-23 21:03:32 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2017-04-23 21:03:32 +0100 |
commit | ab53f74788ece5121667bf69375fd3394d984fc9 (patch) | |
tree | b37a17537ac8eb86835edf7961052b9641b88835 /frontends | |
parent | ff20edbfbe35ce2be631456ffbe8ae6ca9fd05f5 (diff) | |
parent | 6e0f5bee5587db14f7c5755f50a7a17d665d0b99 (diff) | |
download | netsurf-ab53f74788ece5121667bf69375fd3394d984fc9.tar.gz netsurf-ab53f74788ece5121667bf69375fd3394d984fc9.tar.bz2 |
Merge branch 'vince/invalidate-api'
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/amiga/gui.c | 83 | ||||
-rw-r--r-- | frontends/atari/gui.c | 52 | ||||
-rw-r--r-- | frontends/beos/window.cpp | 54 | ||||
-rw-r--r-- | frontends/framebuffer/gui.c | 39 | ||||
-rw-r--r-- | frontends/gtk/window.c | 40 | ||||
-rw-r--r-- | frontends/monkey/browser.c | 36 | ||||
-rw-r--r-- | frontends/riscos/print.c | 4 | ||||
-rw-r--r-- | frontends/riscos/window.c | 89 | ||||
-rw-r--r-- | frontends/riscos/window.h | 14 | ||||
-rw-r--r-- | frontends/windows/window.c | 63 |
10 files changed, 262 insertions, 212 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index 657227459..3e66259eb 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -245,7 +245,7 @@ static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *r static void gui_window_set_scroll(struct gui_window *g, int sx, int sy); static void gui_window_remove_caret(struct gui_window *g); static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip); -static void gui_window_update_box(struct gui_window *g, const struct rect *restrict rect); +//static void amiga_window_invalidate_area(struct gui_window *g, const struct rect *restrict rect); /* accessors for default options - user option is updated if it is set as per default */ @@ -3667,6 +3667,44 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw return; } + +/** + * Invalidates an area of an amiga browser window + * + * \param g gui_window + * \param rect area to redraw or NULL for the entire window area + * \return NSERROR_OK on success or appropriate error code + */ +static nserror amiga_window_invalidate_area(struct gui_window *g, + const struct rect *restrict rect) +{ + struct nsObject *nsobj; + struct rect *restrict deferred_rect; + + if(!g) return NSERROR_BAD_PARAMETER; + + if (rect == NULL) { + if (g != g->shared->gw) { + return NSERROR_OK; + } + } else { + if (ami_gui_window_update_box_deferred_check(g->deferred_rects, rect, + g->deferred_rects_pool)) { + deferred_rect = ami_memory_itempool_alloc(g->deferred_rects_pool, + sizeof(struct rect)); + CopyMem(rect, deferred_rect, sizeof(struct rect)); + nsobj = AddObject(g->deferred_rects, AMINS_RECT); + nsobj->objstruct = deferred_rect; + } else { + LOG("Ignoring duplicate or subset of queued box redraw"); + } + } + ami_schedule_redraw(g->shared, false); + + return NSERROR_OK; +} + + static void ami_refresh_window(struct gui_window_2 *gwin) { /* simplerefresh only */ @@ -3699,7 +3737,7 @@ static void ami_refresh_window(struct gui_window_2 *gwin) regrect = gwin->win->RPort->Layer->DamageList->RegionRectangle; - gui_window_update_box(gwin->gw, &r); + amiga_window_invalidate_area(gwin->gw, &r); while(regrect) { @@ -3714,7 +3752,7 @@ static void ami_refresh_window(struct gui_window_2 *gwin) regrect = regrect->Next; - gui_window_update_box(gwin->gw, &r); + amiga_window_invalidate_area(gwin->gw, &r); } EndRefresh(gwin->win, TRUE); @@ -4706,7 +4744,7 @@ static void ami_redraw_callback(void *p) * * \param gwin a struct gui_window_2 * \param full_redraw set to true to schedule a full redraw, - should only be set to false when called from gui_window_update_box() + should only be set to false when called from amiga_window_invalidate_area() */ void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw) { @@ -4721,14 +4759,6 @@ static void ami_schedule_redraw_remove(struct gui_window_2 *gwin) ami_schedule(-1, ami_redraw_callback, gwin); } -static void gui_window_redraw_window(struct gui_window *g) -{ - if(!g) return; - - if(g == g->shared->gw) - ami_schedule_redraw(g->shared, true); -} - static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw) { struct nsObject *node; @@ -4796,23 +4826,6 @@ bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects, return true; } -static void gui_window_update_box(struct gui_window *g, const struct rect *restrict rect) -{ - struct nsObject *nsobj; - struct rect *restrict deferred_rect; - if(!g) return; - - if(ami_gui_window_update_box_deferred_check(g->deferred_rects, rect, - g->deferred_rects_pool)) { - deferred_rect = ami_memory_itempool_alloc(g->deferred_rects_pool, sizeof(struct rect)); - CopyMem(rect, deferred_rect, sizeof(struct rect)); - nsobj = AddObject(g->deferred_rects, AMINS_RECT); - nsobj->objstruct = deferred_rect; - } else { - LOG("Ignoring duplicate or subset of queued box redraw"); - } - ami_schedule_redraw(g->shared, false); -} /** * callback from core to reformat a window. @@ -4883,26 +4896,26 @@ static void ami_do_redraw(struct gui_window_2 *gwin) { ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, 0, height - (vcurrent - oldv) - 1); ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, width + 1, height + 1); - gui_window_update_box(gwin->gw, &rect); + amiga_window_invalidate_area(gwin->gw, &rect); } else if(vcurrent<oldv) /* Going up */ { ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, 0, 0); ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, width + 1, oldv - vcurrent + 1); - gui_window_update_box(gwin->gw, &rect); + amiga_window_invalidate_area(gwin->gw, &rect); } if(hcurrent>oldh) /* Going right */ { ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, width - (hcurrent - oldh), 0); ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, width + 1, height + 1); - gui_window_update_box(gwin->gw, &rect); + amiga_window_invalidate_area(gwin->gw, &rect); } else if(hcurrent<oldh) /* Going left */ { ami_spacebox_to_ns_coords(gwin, &rect.x0, &rect.y0, 0, 0); ami_spacebox_to_ns_coords(gwin, &rect.x1, &rect.y1, oldh - hcurrent + 1, height + 1); - gui_window_update_box(gwin->gw, &rect); + amiga_window_invalidate_area(gwin->gw, &rect); } } else @@ -4932,6 +4945,7 @@ static void ami_do_redraw(struct gui_window_2 *gwin) ami_gui_free_space_box(bbox); } + void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs) { if(gwin->objects[GID_HSCROLL]) @@ -5556,8 +5570,7 @@ static char *ami_gui_get_user_dir(STRPTR current_user) static struct gui_window_table amiga_window_table = { .create = gui_window_create, .destroy = gui_window_destroy, - .redraw = gui_window_redraw_window, - .update = gui_window_update_box, + .invalidate = amiga_window_invalidate_area, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c index 1287b4715..ad568b761 100644 --- a/frontends/atari/gui.c +++ b/frontends/atari/gui.c @@ -385,34 +385,41 @@ static void atari_window_reformat(struct gui_window *gw) } } -static void gui_window_redraw_window(struct gui_window *gw) -{ - //CMP_BROWSER b; - GRECT rect; - if (gw == NULL) - return; - //b = gw->browser; - window_get_grect(gw->root, BROWSER_AREA_CONTENT, &rect); - window_schedule_redraw_grect(gw->root, &rect); -} -static void gui_window_update_box(struct gui_window *gw, const struct rect *rect) +/** + * Invalidates an area of an atari browser window + * + * \param gw gui_window + * \param rect area to redraw or NULL for the entire window area + * \return NSERROR_OK on success or appropriate error code + */ +static nserror +atari_window_invalidate_area(struct gui_window *gw, + const struct rect *rect) { GRECT area; - struct gemtk_wm_scroll_info_s *slid; - if (gw == NULL) - return; - - slid = gemtk_wm_get_scroll_info(gw->root->win); + if (gw == NULL) { + return NSERROR_BAD_PARAMETER; + } window_get_grect(gw->root, BROWSER_AREA_CONTENT, &area); - area.g_x += rect->x0 - (slid->x_pos * slid->x_unit_px); - area.g_y += rect->y0 - (slid->y_pos * slid->y_unit_px); - area.g_w = rect->x1 - rect->x0; - area.g_h = rect->y1 - rect->y0; + + if (rect != NULL) { + struct gemtk_wm_scroll_info_s *slid; + + slid = gemtk_wm_get_scroll_info(gw->root->win); + + area.g_x += rect->x0 - (slid->x_pos * slid->x_unit_px); + area.g_y += rect->y0 - (slid->y_pos * slid->y_unit_px); + area.g_w = rect->x1 - rect->x0; + area.g_h = rect->y1 - rect->y0; + } + //dbg_grect("update box", &area); window_schedule_redraw_grect(gw->root, &area); + + return NSERROR_OK; } bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy) @@ -680,7 +687,7 @@ static void gui_window_new_content(struct gui_window *w) slid->x_pos = 0; slid->y_pos = 0; gemtk_wm_update_slider(w->root->win, GEMTK_WM_VH_SLIDER); - gui_window_redraw_window(w); + atari_window_invalidate_area(w, NULL); } @@ -1051,8 +1058,7 @@ static void gui_init(int argc, char** argv) static struct gui_window_table atari_window_table = { .create = gui_window_create, .destroy = gui_window_destroy, - .redraw = gui_window_redraw_window, - .update = gui_window_update_box, + .invalidate = atari_window_invalidate_area, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp index fbf7b1652..4db7b3ca6 100644 --- a/frontends/beos/window.cpp +++ b/frontends/beos/window.cpp @@ -1000,39 +1000,42 @@ void nsbeos_redraw_caret(struct gui_window *g) g->view->UnlockLooper(); } -static void gui_window_redraw_window(struct gui_window *g) +/** + * Invalidate an area of a beos browser window + * + * \param gw The netsurf window being invalidated. + * \param rect area to redraw or NULL for entrire window area. + * \return NSERROR_OK or appropriate error code. + */ +static nserror +beos_window_invalidate_area(struct gui_window *g, const struct rect *rect) { - if (g->view == NULL) - return; - if (!g->view->LockLooper()) - return; - - nsbeos_current_gc_set(g->view); - - g->view->Invalidate(); - - nsbeos_current_gc_set(NULL); - g->view->UnlockLooper(); -} + if (browser_window_has_content(g->bw) == false) { + return NSERROR_OK; + } -static void gui_window_update_box(struct gui_window *g, const struct rect *rect) -{ - if (browser_window_has_content(g->bw) == false) - return; + if (g->view == NULL) { + return NSERROR_OK; + } - if (g->view == NULL) - return; - if (!g->view->LockLooper()) - return; + if (!g->view->LockLooper()) { + return NSERROR_OK; + } nsbeos_current_gc_set(g->view); -//XXX +1 ?? - g->view->Invalidate(BRect(rect->x0, rect->y0, - rect->x1 - 1, rect->y1 - 1)); + if (rect != NULL) { + //XXX +1 ?? + g->view->Invalidate(BRect(rect->x0, rect->y0, + rect->x1 - 1, rect->y1 - 1)); + } else { + g->view->Invalidate(); + } nsbeos_current_gc_set(NULL); g->view->UnlockLooper(); + + return NSERROR_OK; } static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) @@ -1349,8 +1352,7 @@ static void gui_window_get_dimensions(struct gui_window *g, int *width, int *hei static struct gui_window_table window_table = { gui_window_create, gui_window_destroy, - gui_window_redraw_window, - gui_window_update_box, + beos_window_invalidate_area, gui_window_get_scroll, gui_window_set_scroll, gui_window_get_dimensions, diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c index 4d4c7334f..3de228a38 100644 --- a/frontends/framebuffer/gui.c +++ b/frontends/framebuffer/gui.c @@ -1803,21 +1803,33 @@ gui_window_destroy(struct gui_window *gw) free(gw); } -static void -gui_window_redraw_window(struct gui_window *g) -{ - fb_queue_redraw(g->browser, 0, 0, fbtk_get_width(g->browser), fbtk_get_height(g->browser) ); -} -static void -gui_window_update_box(struct gui_window *g, const struct rect *rect) +/** + * Invalidates an area of a framebuffer browser window + * + * \param gw The netsurf window being invalidated. + * \param rect area to redraw or NULL for the entire window area + * \return NSERROR_OK on success or appropriate error code + */ +static nserror +fb_window_invalidate_area(struct gui_window *g, const struct rect *rect) { struct browser_widget_s *bwidget = fbtk_get_userpw(g->browser); - fb_queue_redraw(g->browser, - rect->x0 - bwidget->scrollx, - rect->y0 - bwidget->scrolly, - rect->x1 - bwidget->scrollx, - rect->y1 - bwidget->scrolly); + + if (rect != NULL) { + fb_queue_redraw(g->browser, + rect->x0 - bwidget->scrollx, + rect->y0 - bwidget->scrolly, + rect->x1 - bwidget->scrollx, + rect->y1 - bwidget->scrolly); + } else { + fb_queue_redraw(g->browser, + 0, + 0, + fbtk_get_width(g->browser), + fbtk_get_height(g->browser)); + } + return NSERROR_OK; } static bool @@ -2051,8 +2063,7 @@ static void framebuffer_window_reformat(struct gui_window *gw) static struct gui_window_table framebuffer_window_table = { .create = gui_window_create, .destroy = gui_window_destroy, - .redraw = gui_window_redraw_window, - .update = gui_window_update_box, + .invalidate = fb_window_invalidate_area, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c index 40e5580b5..25b975e7d 100644 --- a/frontends/gtk/window.c +++ b/frontends/gtk/window.c @@ -1014,27 +1014,38 @@ static void gui_window_remove_caret(struct gui_window *g) } -static void gui_window_redraw_window(struct gui_window *g) -{ - gtk_widget_queue_draw(GTK_WIDGET(g->layout)); -} - -static void gui_window_update_box(struct gui_window *g, const struct rect *rect) +/** + * Invalidates an area of a GTK browser window + * + * \param g gui_window + * \param rect area to redraw or NULL for the entire window area + * \return NSERROR_OK on success or appropriate error code + */ +static nserror +nsgtk_window_invalidate_area(struct gui_window *g, const struct rect *rect) { int sx, sy; float scale; - if (!browser_window_has_content(g->bw)) - return; + if (rect == NULL) { + gtk_widget_queue_draw(GTK_WIDGET(g->layout)); + return NSERROR_OK; + } + + if (!browser_window_has_content(g->bw)) { + return NSERROR_OK; + } gui_window_get_scroll(g, &sx, &sy); scale = browser_window_get_scale(g->bw); gtk_widget_queue_draw_area(GTK_WIDGET(g->layout), - rect->x0 * scale - sx, - rect->y0 * scale - sy, - (rect->x1 - rect->x0) * scale, - (rect->y1 - rect->y0) * scale); + rect->x0 * scale - sx, + rect->y0 * scale - sy, + (rect->x1 - rect->x0) * scale, + (rect->y1 - rect->y0) * scale); + + return NSERROR_OK; } static void gui_window_set_status(struct gui_window *g, const char *text) @@ -1295,7 +1306,7 @@ gui_window_file_gadget_open(struct gui_window *g, GTK_FILE_CHOOSER(dialog)); browser_window_set_gadget_filename(g->bw, gadget, filename); - + g_free(filename); } @@ -1305,8 +1316,7 @@ gui_window_file_gadget_open(struct gui_window *g, static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, - .redraw = gui_window_redraw_window, - .update = gui_window_update_box, + .invalidate = nsgtk_window_invalidate_area, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c index 3bf0dd036..7cd3d077b 100644 --- a/frontends/monkey/browser.c +++ b/frontends/monkey/browser.c @@ -119,12 +119,6 @@ gui_window_set_title(struct gui_window *g, const char *title) } static void -gui_window_redraw_window(struct gui_window *g) -{ - fprintf(stdout, "WINDOW REDRAW WIN %u\n", g->win_num); -} - -static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { @@ -166,13 +160,28 @@ gui_window_set_scroll(struct gui_window *g, int sx, int sy) fprintf(stdout, "WINDOW SET_SCROLL WIN %u X %d Y %d\n", g->win_num, sx, sy); } -static void -gui_window_update_box(struct gui_window *g, const struct rect *rect) +/** + * Invalidates an area of a monkey browser window + * + * \param gw gui_window + * \param rect area to redraw or NULL for the entire window area + * \return NSERROR_OK on success or appropriate error code + */ +static nserror +monkey_window_invalidate_area(struct gui_window *gw, const struct rect *rect) { - fprintf(stdout, "WINDOW UPDATE_BOX WIN %u X %d Y %d WIDTH %d HEIGHT %d\n", - g->win_num, rect->x0, rect->y0, - (rect->x1 - rect->x0), (rect->y1 - rect->y0)); - + fprintf(stdout, "WINDOW INVALIDATE_AREA WIN %u", gw->win_num); + + if (rect != NULL) { + fprintf(stdout, + " X %d Y %d WIDTH %d HEIGHT %d\n", + rect->x0, rect->y0, + (rect->x1 - rect->x0), (rect->y1 - rect->y0)); + } else { + fprintf(stdout," ALL\n"); + } + + return NSERROR_OK; } static void @@ -501,8 +510,7 @@ monkey_window_handle_command(int argc, char **argv) static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, - .redraw = gui_window_redraw_window, - .update = gui_window_update_box, + .invalidate = monkey_window_invalidate_area, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, diff --git a/frontends/riscos/print.c b/frontends/riscos/print.c index 1ccfc7f74..b7ddd4e53 100644 --- a/frontends/riscos/print.c +++ b/frontends/riscos/print.c @@ -41,6 +41,7 @@ #include "content/content.h" #include "riscos/gui.h" +#include "riscos/window.h" #include "riscos/dialog.h" #include "riscos/menus.h" #include "riscos/print.h" @@ -95,7 +96,6 @@ static unsigned int print_fonts_count; /** Error in print_fonts_plot_text() or print_fonts_callback(). */ static const char *print_fonts_error; -void gui_window_redraw_window(struct gui_window *g); static bool ro_gui_print_click(wimp_pointer *pointer); static bool ro_gui_print_apply(wimp_w w); @@ -729,7 +729,7 @@ bool print_document(struct gui_window *g, const char *filename) if (content_get_type(h) == CONTENT_HTML) content_reformat(h, false, saved_width, saved_height); - gui_window_redraw_window(g); + ro_gui_window_invalidate_area(g, NULL); return true; diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c index b1ea58ae1..6b5089ca9 100644 --- a/frontends/riscos/window.c +++ b/frontends/riscos/window.c @@ -90,8 +90,6 @@ #include "riscos/ucstables.h" #include "riscos/filetype.h" -void gui_window_redraw_window(struct gui_window *g); - static void gui_window_set_extent(struct gui_window *g, int width, int height); static void ro_gui_window_redraw(wimp_draw *redraw); @@ -696,46 +694,39 @@ static void gui_window_set_title(struct gui_window *g, const char *title) ro_gui_set_window_title(g->window, g->title); } - -/** - * Force a redraw of the entire contents of a browser window. - * - * \param g gui_window to redraw - */ -void gui_window_redraw_window(struct gui_window *g) +/* exported interface documented in riscos/window.h */ +nserror ro_gui_window_invalidate_area(struct gui_window *g, + const struct rect *rect) { + bool use_buffer; + int x0, y0, x1, y1; + struct update_box *cur; 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); - ro_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); - ro_warn_user("WimpError", error->errmess); - } -} - -/** - * Redraw an area of a window. - * - * \param g The window to update - * \param rect The area of the window to update. - */ + if (rect == NULL) { + 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); + ro_warn_user("WimpError", error->errmess); + return NSERROR_INVALID; + } -static void gui_window_update_box(struct gui_window *g, const struct rect *rect) -{ - bool use_buffer; - int x0, y0, x1, y1; - struct update_box *cur; + 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); + ro_warn_user("WimpError", error->errmess); + return NSERROR_INVALID; + } + return NSERROR_OK; + } x0 = floorf(rect->x0 * 2 * g->scale); y0 = -ceilf(rect->y1 * 2 * g->scale); @@ -747,25 +738,27 @@ static void gui_window_update_box(struct gui_window *g, const struct rect *rect) /* try to optimise buffered redraws */ if (use_buffer) { for (cur = pending_updates; cur != NULL; cur = cur->next) { - if ((cur->g != g) || (!cur->use_buffer)) + if ((cur->g != g) || (!cur->use_buffer)) { continue; - if ((((cur->x0 - x1) < MARGIN) || ((cur->x1 - x0) < MARGIN)) && - (((cur->y0 - y1) < MARGIN) || ((cur->y1 - y0) < MARGIN))) { + } + if ((((cur->x0 - x1) < MARGIN) || + ((cur->x1 - x0) < MARGIN)) && + (((cur->y0 - y1) < MARGIN) || + ((cur->y1 - y0) < MARGIN))) { cur->x0 = min(cur->x0, x0); cur->y0 = min(cur->y0, y0); cur->x1 = max(cur->x1, x1); cur->y1 = max(cur->y1, y1); - return; + return NSERROR_OK; } - } } cur = malloc(sizeof(struct update_box)); if (!cur) { LOG("No memory for malloc."); - ro_warn_user("NoMemory", 0); - return; + return NSERROR_NOMEM; } + cur->x0 = x0; cur->y0 = y0; cur->x1 = x1; @@ -774,6 +767,8 @@ static void gui_window_update_box(struct gui_window *g, const struct rect *rect) pending_updates = cur; cur->g = g; cur->use_buffer = use_buffer; + + return NSERROR_OK; } @@ -1983,7 +1978,7 @@ bool ro_gui_window_handle_local_keypress(struct gui_window *g, wimp_key *key, /* Toggle display of box outlines. */ browser_window_debug(g->bw, CONTENT_DEBUG_REDRAW); - gui_window_redraw_window(g); + ro_gui_window_invalidate_area(g, NULL); return true; case wimp_KEY_RETURN: @@ -4104,8 +4099,9 @@ void ro_gui_window_action_page_info(struct gui_window *g) void ro_gui_window_redraw_all(void) { struct gui_window *g; - for (g = window_list; g; g = g->next) - gui_window_redraw_window(g); + for (g = window_list; g; g = g->next) { + ro_gui_window_invalidate_area(g, NULL); + } } @@ -4985,8 +4981,7 @@ bool ro_gui_alt_pressed(void) static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, - .redraw = gui_window_redraw_window, - .update = gui_window_update_box, + .invalidate = ro_gui_window_invalidate_area, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, diff --git a/frontends/riscos/window.h b/frontends/riscos/window.h index 2e6f6e9aa..30b096580 100644 --- a/frontends/riscos/window.h +++ b/frontends/riscos/window.h @@ -42,5 +42,19 @@ bool ro_gui_window_check_menu(wimp_menu *menu); */ nserror ro_gui_window_set_url(struct gui_window *g, struct nsurl *url); +/** + * Cause an area of a window to be invalidated + * + * The specified area of the window should now be considered out of + * date. If the entire window is invalidated this simply calls + * wimp_force_redraw() otherwise the area is added to a queue of + * pending updates which will be processed from a wimp poll allowing + * multiple invalidation requests to be agregated. + * + * \param g The window to update + * \param rect The area of the window to update or NULL to redraw entire contents. + */ +nserror ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect); + #endif diff --git a/frontends/windows/window.c b/frontends/windows/window.c index c9022026b..c0af46f8f 100644 --- a/frontends/windows/window.c +++ b/frontends/windows/window.c @@ -883,17 +883,35 @@ static void nsws_window_update_forward_back(struct gui_window *w) /** - * redraw the whole window + * Invalidate an area of a win32 browser window * - * \param gw win32 frontends graphical window. + * \param gw The netsurf window being invalidated. + * \param rect area to redraw or NULL for entrire window area. + * \return NSERROR_OK or appropriate error code. */ -static void win32_window_redraw_window(struct gui_window *gw) +static nserror +win32_window_invalidate_area(struct gui_window *gw, const struct rect *rect) { - /* LOG("gw:%p", gw); */ - if (gw != NULL) { - RedrawWindow(gw->drawingarea, NULL, NULL, - RDW_INVALIDATE | RDW_NOERASE); + RECT *redrawrectp = NULL; + RECT redrawrect; + + assert(gw != NULL); + + if (rect != NULL) { + redrawrectp = &redrawrect; + + redrawrect.left = (long)rect->x0 - (gw->scrollx / gw->scale); + redrawrect.top = (long)rect->y0 - (gw->scrolly / gw->scale); + redrawrect.right =(long)rect->x1; + redrawrect.bottom = (long)rect->y1; + } + RedrawWindow(gw->drawingarea, + redrawrectp, + NULL, + RDW_INVALIDATE | RDW_NOERASE); + + return NSERROR_OK; } @@ -922,7 +940,7 @@ static void nsws_set_scale(struct gui_window *gw, float scale) browser_window_set_scale(gw->bw, scale, true); } - win32_window_redraw_window(gw); + win32_window_invalidate_area(gw, NULL); win32_window_set_scroll(gw, x, y); } @@ -1523,32 +1541,6 @@ static void win32_window_destroy(struct gui_window *w) /** - * Cause redraw of part of a win32 window. - * - * \param gw win32 gui window - * \param rect area to redraw - */ -static void -win32_window_update(struct gui_window *gw, const struct rect *rect) -{ - if (gw == NULL) - return; - - RECT redrawrect; - - redrawrect.left = (long)rect->x0 - (gw->scrollx / gw->scale); - redrawrect.top = (long)rect->y0 - (gw->scrolly / gw->scale); - redrawrect.right =(long)rect->x1; - redrawrect.bottom = (long)rect->y1; - - RedrawWindow(gw->drawingarea, - &redrawrect, - NULL, - RDW_INVALIDATE | RDW_NOERASE); -} - - -/** * Find the current dimensions of a win32 browser window's content area. * * \param gw gui_window to measure @@ -1776,8 +1768,7 @@ static void win32_window_stop_throbber(struct gui_window *w) static struct gui_window_table window_table = { .create = win32_window_create, .destroy = win32_window_destroy, - .redraw = win32_window_redraw_window, - .update = win32_window_update, + .invalidate = win32_window_invalidate_area, .get_scroll = win32_window_get_scroll, .set_scroll = win32_window_set_scroll, .get_dimensions = win32_window_get_dimensions, |