mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 21:16:50 +03:00
[project @ 2005-02-04 03:02:15 by rjw]
Make URL completion less intrusive, fix incorrect horizontal clipping of vertical scrollbar. svn path=/import/netsurf/; revision=1490
This commit is contained in:
parent
8aa96588e1
commit
097b8e5bcd
@ -273,6 +273,7 @@ void ro_gui_theme_install_click(wimp_pointer *pointer);
|
||||
#define ICON_TOOLBAR_SEARCH 10
|
||||
#define ICON_TOOLBAR_URL 11 // Must be after highest toolbar icon
|
||||
#define ICON_TOOLBAR_THROBBER 12
|
||||
#define ICON_TOOLBAR_SUGGEST 13
|
||||
|
||||
/* icon numbers for hotlist toolbars */
|
||||
#define ICON_TOOLBAR_CREATE 0
|
||||
|
@ -41,6 +41,25 @@ static wimp_icon url_complete_icon;
|
||||
static int mouse_x;
|
||||
static int mouse_y;
|
||||
|
||||
/**
|
||||
* Should be called when the caret is placed into a URL completion icon.
|
||||
*
|
||||
* \param g the gui_window to initialise URL completion for
|
||||
*/
|
||||
void ro_gui_url_complete_start(struct gui_window *g) {
|
||||
char *url;
|
||||
|
||||
if ((!g->toolbar) || (!g->toolbar->display_url) ||
|
||||
(g->window == url_complete_parent))
|
||||
return;
|
||||
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
url = ro_gui_get_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL);
|
||||
url_complete_matched_string = url_store_match_string(url);
|
||||
if (url_complete_matched_string)
|
||||
url_complete_parent = g->window;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles a keypress for URL completion
|
||||
@ -69,13 +88,25 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
|
||||
}
|
||||
|
||||
/* if we are currently active elsewhere, remove the previous window */
|
||||
currently_open = g->window == url_complete_parent;
|
||||
if (g->window != url_complete_parent) {
|
||||
currently_open = ((g->window == url_complete_parent) &&
|
||||
(url_complete_matches_available > 0));
|
||||
if (g->window != url_complete_parent)
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
url_complete_parent = g->window;
|
||||
|
||||
/* forcibly open on down keys */
|
||||
if ((!currently_open) && (url_complete_matched_string)) {
|
||||
switch (key) {
|
||||
case wimp_KEY_DOWN:
|
||||
case wimp_KEY_PAGE_DOWN:
|
||||
case wimp_KEY_CONTROL | wimp_KEY_DOWN:
|
||||
free(url_complete_matched_string);
|
||||
url_complete_matched_string = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* get the text to match */
|
||||
url_complete_parent = g->window;
|
||||
url = ro_gui_get_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL);
|
||||
match_url = url_store_match_string(url);
|
||||
if (!match_url) {
|
||||
@ -349,9 +380,9 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
|
||||
state.visible.x1 = open->visible.x0 - 2 + url_state.icon.extent.x1 - scroll_v;
|
||||
state.visible.y1 = open->visible.y1 - url_state.icon.extent.y1 + 2;
|
||||
state.visible.y0 = state.visible.y1 - (lines * 44);
|
||||
if (state.visible.x1 > toolbar_state.visible.x1)
|
||||
state.visible.x1 = toolbar_state.visible.x1;
|
||||
if (state.visible.x1 - state.visible.x0 - scroll_v < 0) {
|
||||
if (state.visible.x1 + scroll_v > toolbar_state.visible.x1)
|
||||
state.visible.x1 = toolbar_state.visible.x1 - scroll_v;
|
||||
if (state.visible.x1 - state.visible.x0 < 0) {
|
||||
error = xwimp_close_window(dialog_url_complete);
|
||||
if (error) {
|
||||
LOG(("xwimp_close_window: 0x%x: %s",
|
||||
@ -380,10 +411,14 @@ 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) {
|
||||
os_error *error;
|
||||
bool currently_open;
|
||||
|
||||
if ((g && (i == ICON_TOOLBAR_URL) && (g->window == url_complete_parent)))
|
||||
return false;
|
||||
|
||||
currently_open = ((url_complete_parent) &&
|
||||
(url_complete_matches_available > 0));
|
||||
|
||||
free(url_complete_matches);
|
||||
free(url_complete_matched_string);
|
||||
free(url_complete_original_url);
|
||||
@ -402,7 +437,7 @@ bool ro_gui_url_complete_close(struct gui_window *g, wimp_i i) {
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
}
|
||||
return true;
|
||||
return currently_open;
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "netsurf/riscos/gui.h"
|
||||
|
||||
void ro_gui_url_complete_start(struct gui_window *g);
|
||||
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);
|
||||
|
@ -257,11 +257,12 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
||||
|
||||
/* Set the caret position to the URL bar
|
||||
*/
|
||||
if (g->toolbar && g->toolbar->display_url)
|
||||
if (g->toolbar && g->toolbar->display_url) {
|
||||
error = xwimp_set_caret_position(
|
||||
g->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL, -1, -1, -1, 0);
|
||||
else
|
||||
ro_gui_url_complete_start(g);
|
||||
} else
|
||||
error = xwimp_set_caret_position(g->window,
|
||||
wimp_ICON_WINDOW, -100, -100, 32, -1);
|
||||
|
||||
@ -791,6 +792,7 @@ void gui_window_set_url(struct gui_window *g, const char *url)
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
}
|
||||
ro_gui_url_complete_start(g);
|
||||
}
|
||||
|
||||
|
||||
@ -1193,6 +1195,8 @@ void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer)
|
||||
current_gui = g;
|
||||
ro_gui_print_open(g, 0, 0, false, false);
|
||||
break;
|
||||
case ICON_TOOLBAR_URL:
|
||||
ro_gui_url_complete_start(g);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1445,6 +1449,7 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
|
||||
ICON_TOOLBAR_URL, "www.");
|
||||
xwimp_set_caret_position(g->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL, 0, 0, -1, 4);
|
||||
ro_gui_url_complete_start(g);
|
||||
return true;
|
||||
|
||||
case wimp_KEY_CONTROL + wimp_KEY_F2: /* Close window. */
|
||||
@ -1543,8 +1548,10 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
|
||||
return true;
|
||||
|
||||
case wimp_KEY_ESCAPE:
|
||||
if (ro_gui_url_complete_close(0, 0))
|
||||
if (ro_gui_url_complete_close(0, 0)) {
|
||||
ro_gui_url_complete_start(g);
|
||||
return true;
|
||||
}
|
||||
browser_window_stop(g->bw);
|
||||
return true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user