[project @ 2006-01-01 13:58:31 by rjw]

Re-introduce clicking in URL completion window

svn path=/import/netsurf/; revision=1925
This commit is contained in:
Richard Wilson 2006-01-01 13:58:31 +00:00
parent 6916d94356
commit 5dff5b7a3c
4 changed files with 38 additions and 46 deletions

View File

@ -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");

View File

@ -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)

View File

@ -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;
}

View File

@ -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