diff options
author | Richard Wilson <rjw@netsurf-browser.org> | 2006-01-01 13:58:31 +0000 |
---|---|---|
committer | Richard Wilson <rjw@netsurf-browser.org> | 2006-01-01 13:58:31 +0000 |
commit | 5dff5b7a3cff736fbe77f0ce25d66ab111f7fcf8 (patch) | |
tree | 1c6851749ea016b6f7c2a711f2979fde7f06b034 /riscos | |
parent | 6916d94356c03fbfc44293ba824519f5deed52cb (diff) | |
download | netsurf-5dff5b7a3cff736fbe77f0ce25d66ab111f7fcf8.tar.gz netsurf-5dff5b7a3cff736fbe77f0ce25d66ab111f7fcf8.tar.bz2 |
[project @ 2006-01-01 13:58:31 by rjw]
Re-introduce clicking in URL completion window
svn path=/import/netsurf/; revision=1925
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/dialog.c | 2 | ||||
-rw-r--r-- | riscos/gui.c | 5 | ||||
-rw-r--r-- | riscos/url_complete.c | 72 | ||||
-rw-r--r-- | riscos/url_complete.h | 5 |
4 files changed, 38 insertions, 46 deletions
diff --git a/riscos/dialog.c b/riscos/dialog.c index 009398ef5..1e44b5719 100644 --- a/riscos/dialog.c +++ b/riscos/dialog.c @@ -151,6 +151,8 @@ void ro_gui_dialog_init(void) /* url suggestion */ dialog_url_complete = ro_gui_dialog_create("url_suggest"); + ro_gui_wimp_event_register_mouse_click(dialog_url_complete, + ro_gui_url_complete_click); ro_gui_wimp_event_register_redraw_window(dialog_url_complete, ro_gui_url_complete_redraw); ro_gui_wimp_event_set_help_prefix(dialog_url_complete, "HelpAutoURL"); diff --git a/riscos/gui.c b/riscos/gui.c index 791e25d3b..c463e8f36 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -820,7 +820,7 @@ void ro_gui_null_reason_code(void) if (gui_track_wimp_w == history_window) ro_gui_history_mouse_at(&pointer); if (gui_track_wimp_w == dialog_url_complete) - ro_gui_url_complete_mouse_at(&pointer, false); + ro_gui_url_complete_mouse_at(&pointer); else if (gui_track_gui_window) ro_gui_window_mouse_at(gui_track_gui_window, &pointer); break; @@ -955,9 +955,6 @@ void ro_gui_mouse_click(wimp_pointer *pointer) if (ro_gui_wimp_event_mouse_click(pointer)) return; - - if (pointer->w == dialog_url_complete) - ro_gui_url_complete_mouse_at(pointer, true); else if ((g = ro_gui_window_lookup(pointer->w)) != NULL) ro_gui_window_click(g, pointer); else if ((dw = ro_gui_download_window_lookup(pointer->w)) != NULL) diff --git a/riscos/url_complete.c b/riscos/url_complete.c index 2926cbcc4..0e0e360ce 100644 --- a/riscos/url_complete.c +++ b/riscos/url_complete.c @@ -508,12 +508,27 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) { /** - * Handle mouse movements/clicks over the URL completion window. + * Handle mouse movement over the URL completion window. * * \param pointer the pointer state - * \param buttons whether to react to mouse buttons */ -void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, bool buttons) { +void ro_gui_url_complete_mouse_at(wimp_pointer *pointer) { + wimp_mouse_state current; + + current = pointer->buttons; + pointer->buttons = 0; + ro_gui_url_complete_click(pointer); + pointer->buttons = current; +} + + +/** + * Handle mouse clicks in the URL completion window. + * + * \param pointer the pointer state + * \return whether the click was handled + */ +bool ro_gui_url_complete_click(wimp_pointer *pointer) { wimp_window_state state; os_error *error; int selection, old_selection; @@ -521,8 +536,8 @@ void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, bool buttons) { char *url; if ((mouse_x == pointer->pos.x) && (mouse_y == pointer->pos.y) && - (pointer->buttons == 0)) - return; + (!pointer->buttons)) + return false; mouse_x = pointer->pos.x; mouse_y = pointer->pos.y; @@ -532,20 +547,20 @@ void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, bool buttons) { LOG(("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess)); warn_user("WimpError", error->errmess); - return; + return false; } selection = (state.visible.y1 - pointer->pos.y - state.yscroll) / 44; if (selection != url_complete_matches_selection) { if (url_complete_matches_selection == -1) { g = ro_gui_window_lookup(url_complete_parent); if (!g) - return; + return false; url = ro_gui_get_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL); free(url_complete_original_url); url_complete_original_url = malloc(strlen(url) + 1); if (!url_complete_original_url) - return; + return false; strcpy(url_complete_original_url, url); } old_selection = url_complete_matches_selection; @@ -566,12 +581,16 @@ void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, bool buttons) { warn_user("WimpError", error->errmess); } } + if (!pointer->buttons) + return true; + /* find owning window */ + g = ro_gui_window_lookup(url_complete_parent); + if (!g) + return false; + /* Select sets the text and launches */ - if ((pointer->buttons == wimp_CLICK_SELECT) && (buttons)) { - g = ro_gui_window_lookup(url_complete_parent); - if (!g) - return; + if (pointer->buttons == wimp_CLICK_SELECT) { ro_gui_set_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL, url_complete_matches[url_complete_matches_selection]); @@ -582,36 +601,11 @@ void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, bool buttons) { ro_gui_url_complete_close(NULL, 0); /* Adjust just sets the text */ - } else if ((pointer->buttons == wimp_CLICK_ADJUST) && (buttons)) { - g = ro_gui_window_lookup(url_complete_parent); - if (!g) - return; + } else if (pointer->buttons == wimp_CLICK_ADJUST) { ro_gui_set_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL, url_complete_matches[url_complete_matches_selection]); ro_gui_url_complete_keypress(g, 0); } -} - - -/** - * Dumps all matching URLs to stderr. - */ -void url_complete_dump_matches(const char *url) { - char *match_url; - struct url_data *reference = NULL; - char *output; - - match_url = url_store_match_string(url); - if (!match_url) - return; - - fprintf(stderr, "\nDumping matches for '%s' ('%s'):\n", url, match_url); - while ((output = url_store_match(match_url, &reference))) { - fprintf(stderr, " - "); - fprintf(stderr, output); - fprintf(stderr, "\n"); - } - fprintf(stderr, "\nEnd of matches.\n\n"); - free(match_url); + return true; } diff --git a/riscos/url_complete.h b/riscos/url_complete.h index 9a192de2b..8c5233919 100644 --- a/riscos/url_complete.h +++ b/riscos/url_complete.h @@ -20,8 +20,7 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key); void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open); bool ro_gui_url_complete_close(struct gui_window *g, wimp_i i); void ro_gui_url_complete_redraw(wimp_draw *redraw); -void ro_gui_url_complete_mouse_at(wimp_pointer *pointer, bool buttons); - -void url_complete_dump_matches(const char *url); +void ro_gui_url_complete_mouse_at(wimp_pointer *pointer); +bool ro_gui_url_complete_click(wimp_pointer *pointer); #endif |