From 4dc4d8b318c9bee25ca9b2982495b2906cc76287 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 20 Aug 2019 00:16:52 +0100 Subject: add miscellaneous event to browser window callback table extend the browser window callback table with a miscallaneous event entry. This is used to replace all browser window callbacks which take no parameters. This reduces the API surface from seven separate calls to a single call with an enumeration which may be readily extended. The initial implementation in the frontends simply calls the original implementations to reduce scope for errors. --- desktop/browser_window.c | 17 ++++--- desktop/gui_factory.c | 46 +---------------- desktop/selection.c | 4 +- desktop/textinput.c | 7 +-- frontends/amiga/gui.c | 49 +++++++++++++++--- frontends/atari/gui.c | 45 ++++++++++++++-- frontends/beos/window.cpp | 52 ++++++++++++++++--- frontends/framebuffer/gui.c | 37 ++++++++++++-- frontends/gtk/window.c | 52 +++++++++++++++---- frontends/monkey/browser.c | 48 +++++++++++++++--- frontends/riscos/window.c | 57 +++++++++++++++++---- frontends/windows/window.c | 38 ++++++++++++-- include/netsurf/window.h | 121 ++++++++++++++++++++++++-------------------- 13 files changed, 410 insertions(+), 163 deletions(-) diff --git a/desktop/browser_window.c b/desktop/browser_window.c index cf5ba6800..e44b928be 100644 --- a/desktop/browser_window.c +++ b/desktop/browser_window.c @@ -410,14 +410,14 @@ static bool browser_window_check_throbber(struct browser_window *bw) * * \param bw browser window */ -static void browser_window_start_throbber(struct browser_window *bw) +static nserror browser_window_start_throbber(struct browser_window *bw) { bw->throbbing = true; while (bw->parent) bw = bw->parent; - guit->window->start_throbber(bw->window); + return guit->window->event(bw->window, GW_EVENT_START_THROBBER); } @@ -426,16 +426,19 @@ static void browser_window_start_throbber(struct browser_window *bw) * * \param bw browser window */ -static void browser_window_stop_throbber(struct browser_window *bw) +static nserror browser_window_stop_throbber(struct browser_window *bw) { + nserror res = NSERROR_OK; + bw->throbbing = false; while (bw->parent) bw = bw->parent; if (!browser_window_check_throbber(bw)) { - guit->window->stop_throbber(bw->window); + res = guit->window->event(bw->window, GW_EVENT_STOP_THROBBER); } + return res; } @@ -765,7 +768,7 @@ static nserror browser_window_content_ready(struct browser_window *bw) browser_window_remove_caret(bw, false); if (bw->window != NULL) { - guit->window->new_content(bw->window); + guit->window->event(bw->window, GW_EVENT_NEW_CONTENT); browser_window_refresh_url_bar(bw); } @@ -2580,7 +2583,7 @@ void browser_window_update_extent(struct browser_window *bw) { if (bw->window != NULL) { /* Front end window */ - guit->window->update_extent(bw->window); + guit->window->event(bw->window, GW_EVENT_UPDATE_EXTENT); } else { /* Core-managed browser window */ browser_window_handle_scrollbars(bw); @@ -4260,7 +4263,7 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y) &bw->drag.start_scroll_x, &bw->drag.start_scroll_y); - guit->window->scroll_start(bw->window); + guit->window->event(bw->window, GW_EVENT_SCROLL_START); } else { /* Core managed browser window */ bw->drag.start_scroll_x = scrollbar_get_offset(bw->scroll_x); diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index bd8d35bc5..fdb15ef8c 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -55,14 +55,6 @@ static nserror gui_default_window_set_url(struct gui_window *g, struct nsurl *ur return NSERROR_OK; } -static void gui_default_window_start_throbber(struct gui_window *g) -{ -} - -static void gui_default_window_stop_throbber(struct gui_window *g) -{ -} - static bool gui_default_window_drag_start(struct gui_window *g, gui_drag_type type, const struct rect *rect) @@ -82,17 +74,6 @@ static void gui_default_window_set_icon(struct gui_window *g, { } - -static void gui_default_window_new_content(struct gui_window *g) -{ -} - - -static bool gui_default_window_scroll_start(struct gui_window *g) -{ - return true; -} - static void gui_default_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) { @@ -109,10 +90,6 @@ static void gui_default_window_place_caret(struct gui_window *g, { } -static void gui_default_window_remove_caret(struct gui_window *g) -{ -} - static void gui_default_window_create_form_select_menu(struct gui_window *g, struct form_control *control) { @@ -135,9 +112,6 @@ static void gui_default_window_drag_save_selection(struct gui_window *g, { } -static void gui_default_window_start_selection(struct gui_window *g) -{ -} static void gui_default_console_log(struct gui_window *gw, @@ -176,7 +150,7 @@ static nserror verify_window_register(struct gui_window_table *gwt) if (gwt->get_dimensions == NULL) { return NSERROR_BAD_PARAMETER; } - if (gwt->update_extent == NULL) { + if (gwt->event == NULL) { return NSERROR_BAD_PARAMETER; } @@ -200,27 +174,12 @@ static nserror verify_window_register(struct gui_window_table *gwt) if (gwt->place_caret == NULL) { gwt->place_caret = gui_default_window_place_caret; } - if (gwt->remove_caret == NULL) { - gwt->remove_caret = gui_default_window_remove_caret; - } - if (gwt->start_throbber == NULL) { - gwt->start_throbber = gui_default_window_start_throbber; - } - if (gwt->stop_throbber == NULL) { - gwt->stop_throbber = gui_default_window_stop_throbber; - } if (gwt->drag_start == NULL) { gwt->drag_start = gui_default_window_drag_start; } if (gwt->save_link == NULL) { gwt->save_link = gui_default_window_save_link; } - if (gwt->new_content == NULL) { - gwt->new_content = gui_default_window_new_content; - } - if (gwt->scroll_start == NULL) { - gwt->scroll_start = gui_default_window_scroll_start; - } if (gwt->create_form_select_menu == NULL) { gwt->create_form_select_menu = gui_default_window_create_form_select_menu; @@ -234,9 +193,6 @@ static nserror verify_window_register(struct gui_window_table *gwt) if (gwt->drag_save_selection == NULL) { gwt->drag_save_selection = gui_default_window_drag_save_selection; } - if (gwt->start_selection == NULL) { - gwt->start_selection = gui_default_window_start_selection; - } if (gwt->console_log == NULL) { gwt->console_log = gui_default_console_log; } diff --git a/desktop/selection.c b/desktop/selection.c index 10aa4c7dd..c8edda7b1 100644 --- a/desktop/selection.c +++ b/desktop/selection.c @@ -307,7 +307,7 @@ bool selection_click(struct selection *s, browser_mouse_state mouse, s->drag_state = DRAG_END; - guit->window->start_selection(top->window); + guit->window->event(top->window, GW_EVENT_START_SELECTION); } else if (mouse & BROWSER_MOUSE_DRAG_2) { @@ -326,7 +326,7 @@ bool selection_click(struct selection *s, browser_mouse_state mouse, s->drag_state = DRAG_START; } - guit->window->start_selection(top->window); + guit->window->event(top->window, GW_EVENT_START_SELECTION); } else if (mouse & BROWSER_MOUSE_CLICK_2) { diff --git a/desktop/textinput.c b/desktop/textinput.c index 660f01a4a..f8da3d86b 100644 --- a/desktop/textinput.c +++ b/desktop/textinput.c @@ -93,13 +93,14 @@ void browser_window_remove_caret(struct browser_window *bw, bool only_hide) root_bw = browser_window_get_root(bw); assert(root_bw != NULL); - if (only_hide) + if (only_hide) { root_bw->can_edit = true; - else + } else { root_bw->can_edit = false; + } if (root_bw->window) { - guit->window->remove_caret(root_bw->window); + guit->window->event(root_bw->window, GW_EVENT_REMOVE_CARET); } } diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index c2fec1b83..995ec4c4d 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -6284,6 +6284,48 @@ static char *ami_gui_get_user_dir(STRPTR current_user) } +/** + * process miscellaneous window events + * + * \param gw The window receiving the event. + * \param event The event code. + * \return NSERROR_OK when processed ok + */ +static nserror +gui_window_event(struct gui_window *gw, enum gui_window_event event) +{ + switch (event) { + case GW_EVENT_UPDATE_EXTENT: + gui_window_update_extent(gw); + break; + + case GW_EVENT_REMOVE_CARET: + gui_window_remove_caret(gw); + break; + + case GW_EVENT_NEW_CONTENT: + gui_window_new_content(gw); + break; + + case GW_EVENT_START_SELECTION: + gui_start_selection(gw); + break; + + case GW_EVENT_START_THROBBER: + gui_window_start_throbber(gw); + break; + + case GW_EVENT_STOP_THROBBER: + gui_window_stop_throbber(gw); + break; + + default: + break; + } + return NSERROR_OK; +} + + static struct gui_window_table amiga_window_table = { .create = gui_window_create, .destroy = gui_window_destroy, @@ -6291,28 +6333,23 @@ static struct gui_window_table amiga_window_table = { .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, - .update_extent = gui_window_update_extent, + .event = gui_window_event, .set_icon = gui_window_set_icon, .set_title = gui_window_set_title, .set_url = gui_window_set_url, .set_status = gui_window_set_status, .place_caret = gui_window_place_caret, - .remove_caret = gui_window_remove_caret, .drag_start = gui_window_drag_start, - .new_content = gui_window_new_content, .create_form_select_menu = gui_create_form_select_menu, .file_gadget_open = gui_file_gadget_open, .drag_save_object = gui_drag_save_object, .drag_save_selection = gui_drag_save_selection, - .start_selection = gui_start_selection, .console_log = gui_window_console_log, /* from theme */ .set_pointer = gui_window_set_pointer, - .start_throbber = gui_window_start_throbber, - .stop_throbber = gui_window_stop_throbber, /* from download */ .save_link = gui_window_save_link, diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c index 64e83fc8f..e55271c10 100644 --- a/frontends/atari/gui.c +++ b/frontends/atari/gui.c @@ -1040,6 +1040,45 @@ static void gui_init(int argc, char** argv) toolbar_init(); } + +/** + * process miscellaneous window events + * + * \param gw The window receiving the event. + * \param event The event code. + * \return NSERROR_OK when processed ok + */ +static nserror +gui_window_event(struct gui_window *gw, enum gui_window_event event) +{ + switch (event) { + case GW_EVENT_UPDATE_EXTENT: + gui_window_update_extent(gw); + break; + + case GW_EVENT_REMOVE_CARET: + gui_window_remove_caret(gw); + break; + + case GW_EVENT_NEW_CONTENT: + gui_window_new_content(gw); + break; + + case GW_EVENT_START_THROBBER: + gui_window_start_throbber(gw); + break; + + case GW_EVENT_STOP_THROBBER: + gui_window_stop_throbber(gw); + break; + + default: + break; + } + return NSERROR_OK; +} + + static struct gui_window_table atari_window_table = { .create = gui_window_create, .destroy = gui_window_destroy, @@ -1047,7 +1086,7 @@ static struct gui_window_table atari_window_table = { .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, - .update_extent = gui_window_update_extent, + .event = gui_window_event, .set_title = gui_window_set_title, .set_url = gui_window_set_url, @@ -1055,10 +1094,6 @@ static struct gui_window_table atari_window_table = { .set_status = atari_window_set_status, .set_pointer = gui_window_set_pointer, .place_caret = gui_window_place_caret, - .remove_caret = gui_window_remove_caret, - .new_content = gui_window_new_content, - .start_throbber = gui_window_start_throbber, - .stop_throbber = gui_window_stop_throbber, }; static struct gui_clipboard_table atari_clipboard_table = { diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp index e330a825a..93555ee8e 100644 --- a/frontends/beos/window.cpp +++ b/frontends/beos/window.cpp @@ -1348,6 +1348,49 @@ gui_window_get_dimensions(struct gui_window *g, int *width, int *height) return NSERROR_OK; } + +/** + * process miscellaneous window events + * + * \param gw The window receiving the event. + * \param event The event code. + * \return NSERROR_OK when processed ok + */ +static nserror +gui_window_event(struct gui_window *gw, enum gui_window_event event) +{ + switch (event) { + case GW_EVENT_UPDATE_EXTENT: + gui_window_update_extent(gw); + break; + + case GW_EVENT_REMOVE_CARET: + gui_window_remove_caret(gw); + break; + + case GW_EVENT_NEW_CONTENT: + gui_window_new_content(gw); + break; + + case GW_EVENT_START_SELECTION: + gui_start_selection(gw); + break; + + case GW_EVENT_START_THROBBER: + gui_window_start_throbber(gw); + break; + + case GW_EVENT_STOP_THROBBER: + gui_window_stop_throbber(gw); + break; + + default: + break; + } + return NSERROR_OK; +} + + static struct gui_window_table window_table = { gui_window_create, gui_window_destroy, @@ -1355,7 +1398,7 @@ static struct gui_window_table window_table = { gui_window_get_scroll, gui_window_set_scroll, gui_window_get_dimensions, - gui_window_update_extent, + gui_window_event, /* from scaffold */ gui_window_set_title, @@ -1364,18 +1407,13 @@ static struct gui_window_table window_table = { gui_window_set_status, gui_window_set_pointer, gui_window_place_caret, - gui_window_remove_caret, - gui_window_start_throbber, - gui_window_stop_throbber, NULL, //drag_start NULL, //save_link - NULL, //scroll_start - gui_window_new_content, NULL, //create_form_select_menu NULL, //file_gadget_open NULL, //drag_save_object NULL, //drag_save_selection - gui_start_selection + NULL //console_log }; struct gui_window_table *beos_window_table = &window_table; diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c index 914187ba6..74d8b4c5a 100644 --- a/frontends/framebuffer/gui.c +++ b/frontends/framebuffer/gui.c @@ -2085,6 +2085,38 @@ gui_window_remove_caret(struct gui_window *g) } } +/** + * process miscellaneous window events + * + * \param gw The window receiving the event. + * \param event The event code. + * \return NSERROR_OK when processed ok + */ +static nserror +gui_window_event(struct gui_window *gw, enum gui_window_event event) +{ + switch (event) { + case GW_EVENT_UPDATE_EXTENT: + gui_window_update_extent(gw); + break; + + case GW_EVENT_REMOVE_CARET: + gui_window_remove_caret(gw); + break; + + case GW_EVENT_START_THROBBER: + gui_window_start_throbber(gw); + break; + + case GW_EVENT_STOP_THROBBER: + gui_window_stop_throbber(gw); + break; + + default: + break; + } + return NSERROR_OK; +} static struct gui_window_table framebuffer_window_table = { .create = gui_window_create, @@ -2093,15 +2125,12 @@ static struct gui_window_table framebuffer_window_table = { .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, - .update_extent = gui_window_update_extent, + .event = gui_window_event, .set_url = gui_window_set_url, .set_status = gui_window_set_status, .set_pointer = gui_window_set_pointer, .place_caret = gui_window_place_caret, - .remove_caret = gui_window_remove_caret, - .start_throbber = gui_window_start_throbber, - .stop_throbber = gui_window_stop_throbber, }; diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c index 766ae4173..6bf777cbe 100644 --- a/frontends/gtk/window.c +++ b/frontends/gtk/window.c @@ -501,7 +501,7 @@ static gboolean nsgtk_window_keypress_event(GtkWidget *widget, { struct gui_window *g = data; uint32_t nskey; - + if (gtk_im_context_filter_keypress(g->input_method, event)) return TRUE; @@ -617,7 +617,7 @@ static gboolean nsgtk_window_keyrelease_event(GtkWidget *widget, GdkEventKey *event, gpointer data) { struct gui_window *g = data; - + return gtk_im_context_filter_keypress(g->input_method, event); } @@ -1288,7 +1288,7 @@ gui_window_file_gadget_open(struct gui_window *g, NULL); NSLOG(netsurf, INFO, "*** open dialog: %p", dialog); - + int ret = gtk_dialog_run(GTK_DIALOG(dialog)); NSLOG(netsurf, INFO, "*** return value: %d", ret); if (ret == GTK_RESPONSE_ACCEPT) { @@ -1296,7 +1296,7 @@ gui_window_file_gadget_open(struct gui_window *g, filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog)); - + browser_window_set_gadget_filename(g->bw, gadget, filename); g_free(filename); @@ -1305,6 +1305,44 @@ gui_window_file_gadget_open(struct gui_window *g, gtk_widget_destroy(dialog); } + +/** + * process miscellaneous window events + * + * \param gw The window receiving the event. + * \param event The event code. + * \return NSERROR_OK when processed ok + */ +static nserror +gui_window_event(struct gui_window *gw, enum gui_window_event event) +{ + switch (event) { + case GW_EVENT_UPDATE_EXTENT: + gui_window_update_extent(gw); + break; + + case GW_EVENT_REMOVE_CARET: + gui_window_remove_caret(gw); + break; + + case GW_EVENT_START_SELECTION: + gui_window_start_selection(gw); + break; + + case GW_EVENT_START_THROBBER: + gui_window_start_throbber(gw); + break; + + case GW_EVENT_STOP_THROBBER: + gui_window_stop_throbber(gw); + break; + + default: + break; + } + return NSERROR_OK; +} + static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, @@ -1312,22 +1350,18 @@ static struct gui_window_table window_table = { .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, - .update_extent = gui_window_update_extent, + .event = gui_window_event, .set_icon = gui_window_set_icon, .set_status = gui_window_set_status, .set_pointer = gui_window_set_pointer, .place_caret = gui_window_place_caret, - .remove_caret = gui_window_remove_caret, .create_form_select_menu = gui_window_create_form_select_menu, .file_gadget_open = gui_window_file_gadget_open, - .start_selection = gui_window_start_selection, /* from scaffold */ .set_title = nsgtk_window_set_title, .set_url = gui_window_set_url, - .start_throbber = gui_window_start_throbber, - .stop_throbber = gui_window_stop_throbber, }; struct gui_window_table *nsgtk_window_table = &window_table; diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c index b6919940b..26ae09028 100644 --- a/frontends/monkey/browser.c +++ b/frontends/monkey/browser.c @@ -683,6 +683,47 @@ monkey_window_handle_command(int argc, char **argv) } +/** + * process miscellaneous window events + * + * \param gw The window receiving the event. + * \param event The event code. + * \return NSERROR_OK when processed ok + */ +static nserror +gui_window_event(struct gui_window *gw, enum gui_window_event event) +{ + switch (event) { + case GW_EVENT_UPDATE_EXTENT: + gui_window_update_extent(gw); + break; + + case GW_EVENT_REMOVE_CARET: + gui_window_remove_caret(gw); + break; + + case GW_EVENT_SCROLL_START: + gui_window_scroll_start(gw); + break; + + case GW_EVENT_NEW_CONTENT: + gui_window_new_content(gw); + break; + + case GW_EVENT_START_THROBBER: + gui_window_start_throbber(gw); + break; + + case GW_EVENT_STOP_THROBBER: + gui_window_stop_throbber(gw); + break; + + default: + break; + } + return NSERROR_OK; +} + static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, @@ -690,7 +731,7 @@ static struct gui_window_table window_table = { .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, - .update_extent = gui_window_update_extent, + .event = gui_window_event, .set_title = gui_window_set_title, .set_url = gui_window_set_url, @@ -698,13 +739,8 @@ static struct gui_window_table window_table = { .set_status = gui_window_set_status, .set_pointer = gui_window_set_pointer, .place_caret = gui_window_place_caret, - .remove_caret = gui_window_remove_caret, .drag_start = gui_window_drag_start, .save_link = gui_window_save_link, - .scroll_start = gui_window_scroll_start, - .new_content = gui_window_new_content, - .start_throbber = gui_window_start_throbber, - .stop_throbber = gui_window_stop_throbber, .console_log = gui_window_console_log, }; diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c index e2238ac5b..96346f800 100644 --- a/frontends/riscos/window.c +++ b/frontends/riscos/window.c @@ -4134,6 +4134,53 @@ ro_gui_window_import_text(struct gui_window *g, const char *filename) } +/** + * process miscellaneous window events + * + * \param gw The window receiving the event. + * \param event The event code. + * \return NSERROR_OK when processed ok + */ +static nserror +ro_gui_window_event(struct gui_window *gw, enum gui_window_event event) +{ + switch (event) { + case GW_EVENT_UPDATE_EXTENT: + gui_window_update_extent(gw); + break; + + case GW_EVENT_REMOVE_CARET: + gui_window_remove_caret(gw); + break; + + case GW_EVENT_SCROLL_START: + gui_window_scroll_start(gw); + break; + + case GW_EVENT_NEW_CONTENT: + gui_window_new_content(gw); + break; + + case GW_EVENT_START_THROBBER: + gui_window_start_throbber(gw); + break; + + case GW_EVENT_STOP_THROBBER: + gui_window_stop_throbber(gw); + break; + + case GW_EVENT_START_SELECTION: + /* from textselection */ + gui_start_selection(gw); + break; + + default: + break; + } + return NSERROR_OK; +} + + /** * RISC OS browser window operation table */ @@ -4144,7 +4191,7 @@ static struct gui_window_table window_table = { .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, - .update_extent = gui_window_update_extent, + .event = ro_gui_window_event, .set_title = gui_window_set_title, .set_url = ro_gui_window_set_url, @@ -4152,21 +4199,13 @@ static struct gui_window_table window_table = { .set_status = riscos_window_set_status, .set_pointer = gui_window_set_pointer, .place_caret = gui_window_place_caret, - .remove_caret = gui_window_remove_caret, .save_link = gui_window_save_link, .drag_start = gui_window_drag_start, - .scroll_start = gui_window_scroll_start, - .new_content = gui_window_new_content, - .start_throbber = gui_window_start_throbber, - .stop_throbber = gui_window_stop_throbber, .create_form_select_menu = gui_window_create_form_select_menu, /* from save */ .drag_save_object = gui_drag_save_object, .drag_save_selection =gui_drag_save_selection, - - /* from textselection */ - .start_selection = gui_start_selection, }; struct gui_window_table *riscos_window_table = &window_table; diff --git a/frontends/windows/window.c b/frontends/windows/window.c index e1254d8f2..05d7a54d9 100644 --- a/frontends/windows/window.c +++ b/frontends/windows/window.c @@ -1693,6 +1693,39 @@ static void win32_window_stop_throbber(struct gui_window *w) } +/** + * process miscellaneous window events + * + * \param gw The window receiving the event. + * \param event The event code. + * \return NSERROR_OK when processed ok + */ +static nserror +win32_window_event(struct gui_window *gw, enum gui_window_event event) +{ + switch (event) { + case GW_EVENT_UPDATE_EXTENT: + win32_window_update_extent(gw); + break; + + case GW_EVENT_REMOVE_CARET: + win32_window_remove_caret(gw); + break; + + case GW_EVENT_START_THROBBER: + win32_window_start_throbber(gw); + break; + + case GW_EVENT_STOP_THROBBER: + win32_window_stop_throbber(gw); + break; + + default: + break; + } + return NSERROR_OK; +} + /** * win32 frontend browser window handling operation table */ @@ -1703,16 +1736,13 @@ static struct gui_window_table window_table = { .get_scroll = win32_window_get_scroll, .set_scroll = win32_window_set_scroll, .get_dimensions = win32_window_get_dimensions, - .update_extent = win32_window_update_extent, + .event = win32_window_event, .set_title = win32_window_set_title, .set_url = win32_window_set_url, .set_status = win32_window_set_status, .set_pointer = win32_window_set_pointer, .place_caret = win32_window_place_caret, - .remove_caret = win32_window_remove_caret, - .start_throbber = win32_window_start_throbber, - .stop_throbber = win32_window_stop_throbber, }; struct gui_window_table *win32_window_table = &window_table; diff --git a/include/netsurf/window.h b/include/netsurf/window.h index 9f5371e97..e396f7820 100644 --- a/include/netsurf/window.h +++ b/include/netsurf/window.h @@ -28,6 +28,14 @@ #include "netsurf/console.h" +struct browser_window; +struct form_control; +struct rect; +struct hlcache_handle; +struct nsurl; + +enum gui_pointer_shape; + typedef enum gui_save_type { GUI_SAVE_SOURCE, GUI_SAVE_DRAW, @@ -61,13 +69,57 @@ typedef enum { GW_CREATE_TAB = (1 << 1) /**< Create tab in same window as existing */ } gui_window_create_flags; -struct browser_window; -struct form_control; -struct rect; -struct hlcache_handle; -struct nsurl; +/** + * Window events + * + * these are events delivered to a gui window which have no additional + * parameters and hence do not require separate callbacks. + */ +enum gui_window_event { + /** + * An empty event should never occour + */ + GW_EVENT_NONE = 0, -enum gui_pointer_shape; + /** + * Update the extent of the inside of a browser window to that of the + * current content. + * + * @todo this is used to update scroll bars does it need + * renaming? some frontends (windows) do not even implement it. + */ + GW_EVENT_UPDATE_EXTENT, + + /** + * Remove the caret, if present. + */ + GW_EVENT_REMOVE_CARET, + + /** + * start the navigation throbber. + */ + GW_EVENT_START_THROBBER, + + /** + * stop the navigation throbber. + */ + GW_EVENT_STOP_THROBBER, + + /** + * Starts drag scrolling of a browser window + */ + GW_EVENT_SCROLL_START, + + /** + * Called when the gui_window has new content. + */ + GW_EVENT_NEW_CONTENT, + + /** + * selection started + */ + GW_EVENT_START_SELECTION, +}; /** * Graphical user interface window function table. @@ -182,16 +234,16 @@ struct gui_window_table { /** - * Update the extent of the inside of a browser window to that of the - * current content. + * Miscelaneous event occoured for a window * - * @todo this is used to update scroll bars does it need - * renaming? some frontends (windows) do not even implement it. + * This is used to inform the frontend of window events which + * require no additional parameters. * - * \param gw The gui window to update the extent of. + * \param gw The gui window the event occoured for + * \param event Which event has occoured. + * \return NSERROR_OK if teh event was processed else error code. */ - void (*update_extent)(struct gui_window *gw); - + nserror (*event)(struct gui_window *gw, enum gui_window_event event); /* Optional entries */ @@ -246,27 +298,6 @@ struct gui_window_table { */ void (*place_caret)(struct gui_window *g, int x, int y, int height, const struct rect *clip); - /** - * Remove the caret, if present. - * - * \param g window with caret - */ - void (*remove_caret)(struct gui_window *g); - - /** - * start the navigation throbber. - * - * \param g window in which to start throbber. - */ - void (*start_throbber)(struct gui_window *g); - - /** - * stop the navigation throbber. - * - * \param g window with throbber to stop - */ - void (*stop_throbber)(struct gui_window *g); - /** * start a drag operation within a window * @@ -287,21 +318,6 @@ struct gui_window_table { */ nserror (*save_link)(struct gui_window *g, struct nsurl *url, const char *title); - - /** - * Starts drag scrolling of a browser window - * - * \param g the window to scroll - */ - bool (*scroll_start)(struct gui_window *g); - - /** - * Called when the gui_window has new content. - * - * \param gw The gui window that has new content - */ - void (*new_content)(struct gui_window *gw); - /** * create a form select menu * @@ -336,13 +352,6 @@ struct gui_window_table { */ void (*drag_save_selection)(struct gui_window *gw, const char *selection); - /** - * selection started - * - * \param gw The gui window to start selection in. - */ - void (*start_selection)(struct gui_window *gw); - /** * console logging happening. * -- cgit v1.2.3