From 423f0f1e7068ba4874435c02e31b054e62ae7966 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sun, 21 Mar 2004 13:55:51 +0000 Subject: [project @ 2004-03-21 13:55:51 by bursa] Implement gui_window_update_box() and use in response to CONTENT_MSG_REDRAW. svn path=/import/netsurf/; revision=644 --- desktop/browser.c | 12 +++++++++++- desktop/gui.h | 1 + render/html.c | 3 +-- riscos/window.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/desktop/browser.c b/desktop/browser.c index 64edaf728..337d6f0df 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -199,6 +199,7 @@ void browser_window_callback(content_msg msg, struct content *c, void *p1, void *p2, const char *error) { struct browser_window *bw = p1; + struct box *box; char status[40]; if (c->type == CONTENT_OTHER) { @@ -277,7 +278,16 @@ void browser_window_callback(content_msg msg, struct content *c, break; case CONTENT_MSG_REDRAW: - gui_window_redraw_window(bw->window); + /* error actually holds the box */ + box = (struct box *) error; + if (box) { + int x, y; + box_coords(box, &x, &y); + gui_window_update_box(bw->window, x, y, + x + box->width, + y + box->height); + } else + gui_window_redraw_window(bw->window); break; #ifdef WITH_AUTH diff --git a/desktop/gui.h b/desktop/gui.h index 3554a87ee..62dcf27a7 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -28,6 +28,7 @@ void gui_window_hide(gui_window* g); void gui_window_redraw(gui_window* g, unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1); void gui_window_redraw_window(gui_window* g); +void gui_window_update_box(gui_window *g, int x0, int y0, int x1, int y1); void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy); unsigned long gui_window_get_width(gui_window* g); void gui_window_set_extent(gui_window* g, unsigned long width, unsigned long height); diff --git a/render/html.c b/render/html.c index 4e095d408..e028e523d 100644 --- a/render/html.c +++ b/render/html.c @@ -642,8 +642,7 @@ void html_object_callback(content_msg msg, struct content *object, break; case CONTENT_MSG_REDRAW: - /** \todo send up box coordinates */ - content_broadcast(c, CONTENT_MSG_REDRAW, 0); + content_broadcast(c, CONTENT_MSG_REDRAW, box); break; #ifdef WITH_AUTH diff --git a/riscos/window.c b/riscos/window.c index 2196fa054..a10114d6c 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -254,6 +254,55 @@ void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw) } } + +/** + * Redraw an area of a window. + * + * \param g gui_window + * \param x0 minimum x + * \param y0 minimum y + * \param x1 maximum x + * \param y1 maximum y + */ + +void gui_window_update_box(gui_window *g, int x0, int y0, int x1, int y1) +{ + struct content *c = g->data.browser.bw->current_content; + osbool more; + os_error *error; + wimp_draw update; + + update.w = g->window; + update.box.x0 = x0 * 2; + update.box.y0 = -y1 * 2; + update.box.x1 = x1 * 2; + update.box.y1 = -y0 * 2; + error = xwimp_update_window(&update, &more); + if (error) { + LOG(("xwimp_update_window: 0x%x: %s", + error->errnum, error->errmess)); + return; + } + + while (more) { + content_redraw(c, + update.box.x0 - update.xscroll, + update.box.y1 - update.yscroll, + c->width * 2, c->height * 2, + update.clip.x0, update.clip.y0, + update.clip.x1 - 1, update.clip.y1 - 1, + g->scale); + + error = xwimp_get_rectangle(&update, &more); + if (error) { + LOG(("xwimp_get_rectangle: 0x%x: %s", + error->errnum, error->errmess)); + return; + } + } +} + + void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy) { wimp_window_state state; -- cgit v1.2.3