diff options
-rw-r--r-- | Docs/core-window-interface | 30 | ||||
-rw-r--r-- | desktop/local_history.c | 1 | ||||
-rw-r--r-- | desktop/treeview.c | 40 | ||||
-rw-r--r-- | include/netsurf/core_window.h | 28 |
4 files changed, 59 insertions, 40 deletions
diff --git a/Docs/core-window-interface b/Docs/core-window-interface index 3dfbcaf47..83c5f586b 100644 --- a/Docs/core-window-interface +++ b/Docs/core-window-interface @@ -34,8 +34,8 @@ The header that defines the callback interface is netsurf/core_window.h The callback table contains five function pointer interfaces which the frontend must implement for the core. - - redraw_request - request a redraw an area of a window + - invalidate + invalidate an area of a window - update_size Update the limits of the window @@ -67,27 +67,29 @@ core to provide the necessary interactions with the frontend windowing system. These actions should ideally use the standard frontend window -processing. So for the GTK frontend when the core calls the redraw +processing. So for the GTK frontend when the core calls the invalidate operation it simply marks the area passed as damaged (using gtk_widget_queue_draw_area()) and lets the standard expose event cause -the redraw to occour. +the redraw to occur. If the frontend needs to redraw an area of a window (perhaps an expose -event occoured) it must call the corewindoe API wrappers -implementation e.g in the case of ssl certificate viewer +event occurred or the window has had an area marked as invalid) it +must call the core window API wrappers implementation which will +perform the plot operations required to update an area of the window. + +e.g in the case of ssl certificate viewer void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d, int x, int y, struct rect *clip, const struct redraw_context *ctx); -which will perform the plot operations required to update an area of -the window for that SSL data. +would perform the plot operations for that SSL data window. Usage ----- The usage pattern that is expected is for a frontend to create a core -window impementation that implements the necessary five API in a +window implementation that implements the necessary five API in a generic way and allows the frontend to provide the specific specialisation for each of the user interface elements it wishes to use (cookies, SSL viewer etc). @@ -95,7 +97,7 @@ use (cookies, SSL viewer etc). The GTK frontend for example: has source corewindow.[ch] which implement the five core callbacks -using generic GTK operations (redraw_request calls +using generic GTK operations (invalidate calls gtk_widget_queue_draw_area() etc.) and then provides additional operations on a GTK drawing area object to attach expose event processing, keypress processing etc. @@ -110,7 +112,7 @@ calls sslcert_viewer_init() directly. frontend skeleton ----------------- -An example core window implementation for a frontend ssl certficiate +An example core window implementation for a frontend ssl certificate viewer is presented here. This implements the suggested usage above and provides generic corewindow helpers. @@ -313,8 +315,8 @@ example_cw_draw_event(toolkit_widget *widget, /** * callback from core to request a redraw */ -static void -example_cw_redraw_request(struct core_window *cw, const struct rect *r) +static nserror +example_cw_invalidate(struct core_window *cw, const struct rect *r) { struct example_corewindow *example_cw = (struct example_corewindow *)cw; @@ -362,7 +364,7 @@ example_cw_drag_status(struct core_window *cw, core_window_drag_status ds) struct core_window_callback_table example_cw_cb_table = { - .redraw_request = example_cw_redraw_request, + .invalidate = example_cw_invalidate, .update_size = example_cw_update_size, .scroll_visible = example_cw_scroll_visible, .get_window_dimensions = example_cw_get_window_dimensions, diff --git a/desktop/local_history.c b/desktop/local_history.c index 05e4b5e18..06f300245 100644 --- a/desktop/local_history.c +++ b/desktop/local_history.c @@ -23,6 +23,7 @@ #include <stdlib.h> +#include "utils/errors.h" #include "netsurf/types.h" #include "netsurf/core_window.h" diff --git a/desktop/treeview.c b/desktop/treeview.c index ff13fb0cb..fe3aa94c3 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -315,12 +315,12 @@ static struct treeview_resource treeview_res[TREE_RES_LAST] = { * \param[in] tree The treeview to request redraw on. * \param[in] r rectangle to redraw */ -static inline void treeview__cw_redraw_request( - const struct treeview *tree, - const struct rect *r) +static inline +void cw_invalidate_area(const struct treeview *tree, + const struct rect *r) { if (tree->cw_t != NULL) { - tree->cw_t->redraw_request(tree->cw_h, r); + tree->cw_t->invalidate(tree->cw_h, r); } } @@ -791,7 +791,7 @@ treeview_create_node_folder(treeview *tree, r.y0 = treeview_node_y(tree, n); r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } } @@ -842,7 +842,7 @@ treeview_update_node_folder(treeview *tree, r.y0 = treeview_node_y(tree, folder); r.x1 = REDRAW_MAX; r.y1 = r.y0 + tree_g.line_height; - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } return NSERROR_OK; @@ -914,7 +914,7 @@ treeview_update_node_entry(treeview *tree, r.y0 = treeview_node_y(tree, entry); r.x1 = REDRAW_MAX; r.y1 = r.y0 + entry->height; - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } return NSERROR_OK; @@ -1001,7 +1001,7 @@ treeview_create_node_entry(treeview *tree, r.y0 = treeview_node_y(tree, n); r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } } @@ -1154,7 +1154,7 @@ static void treeview_edit_cancel(treeview *tree, bool redraw) r.y0 = tree->edit.y; r.x1 = tree->edit.x + tree->edit.w; r.y1 = tree->edit.y + tree->edit.h; - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } } @@ -1496,7 +1496,7 @@ treeview_delete_node(treeview *tree, if (visible && !(flags & TREE_OPTION_SUPPRESS_REDRAW)) { r.x0 = 0; r.x1 = REDRAW_MAX; - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } return NSERROR_OK; @@ -1755,7 +1755,7 @@ nserror treeview_node_expand(treeview *tree, treeview_node *node) r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } return res; @@ -1864,7 +1864,7 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node) r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } return res; @@ -1911,7 +1911,7 @@ nserror treeview_contract(treeview *tree, bool all) treeview__cw_update_size(tree, -1, tree->root->height); /* Redraw */ - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); return NSERROR_OK; } @@ -1985,7 +1985,7 @@ nserror treeview_expand(treeview *tree, bool only_folders) r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } return res; } @@ -3182,7 +3182,7 @@ bool treeview_keypress(treeview *tree, uint32_t key) } if (redraw) { - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } return true; @@ -3358,7 +3358,7 @@ static void treeview_textarea_callback(void *data, struct textarea_msg *msg) r->y1 += tree->edit.y; /* Redraw the textarea */ - treeview__cw_redraw_request(tree, r); + cw_invalidate_area(tree, r); break; default: @@ -3536,7 +3536,7 @@ void treeview_edit_selection(treeview *tree) rect.y0 = y; rect.x1 = REDRAW_MAX; rect.y1 = y + tree_g.line_height; - treeview__cw_redraw_request(tree, &rect); + cw_invalidate_area(tree, &rect); } @@ -3816,7 +3816,7 @@ treeview_node_mouse_action_cb(treeview_node *node, } if (redraw) { - treeview__cw_redraw_request(ma->tree, &r); + cw_invalidate_area(ma->tree, &r); } *end = true; /* Reached line with click; stop walking tree */ @@ -3878,7 +3878,7 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) tree->move.target_pos = TV_TARGET_NONE; treeview__cw_drag_status(tree, CORE_WINDOW_DRAG_NONE); - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); return; default: /* No drag to end */ @@ -3953,7 +3953,7 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) } if (redraw) { - treeview__cw_redraw_request(tree, &r); + cw_invalidate_area(tree, &r); } } else { diff --git a/include/netsurf/core_window.h b/include/netsurf/core_window.h index b6b012049..77d220b9c 100644 --- a/include/netsurf/core_window.h +++ b/include/netsurf/core_window.h @@ -20,7 +20,7 @@ * \file * Interface to core window handling. * - * This provides a generallised API for frontends to implement which + * This provides a generalised API for frontends to implement which * allows them to provide a single implementation for general window * operations on their platform. * @@ -35,6 +35,9 @@ struct core_window; struct rect; +/** + * drag status passed to drag_status callback + */ typedef enum { CORE_WINDOW_DRAG_NONE, CORE_WINDOW_DRAG_SELECTION, @@ -42,15 +45,28 @@ typedef enum { CORE_WINDOW_DRAG_MOVE } core_window_drag_status; -/** Callbacks to achieve various core window functionality. */ +/** + * Callbacks to achieve various core window functionality. + */ struct core_window_callback_table { /** - * Request a redraw of the window + * Invalidate an area of a window. * - * \param[in] cw the core window object - * \param[in] r rectangle to redraw + * The specified area of the window should now be considered + * out of date. If the area is NULL the entire window must be + * invalidated. It is expected that the windowing system will + * then subsequently cause redraw/expose operations as + * necessary. + * + * \note the frontend should not attempt to actually start the + * redraw operations as a result of this callback because the + * core redraw functions may already be threaded. + * + * \param[in] cw The core window to invalidate. + * \param[in] rect area to redraw or NULL for the entire window area + * \return NSERROR_OK on success or appropriate error code */ - void (*redraw_request)(struct core_window *cw, const struct rect *r); + nserror (*invalidate)(struct core_window *cw, const struct rect *rect); /** * Update the limits of the window |