Improve caret handling.

svn path=/trunk/netsurf/; revision=2917
This commit is contained in:
Richard Wilson 2006-09-05 17:34:30 +00:00
parent 610a31dd97
commit 4994441579

View File

@ -339,25 +339,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
} }
ro_gui_window_open(g, (wimp_open*)&state); ro_gui_window_open(g, (wimp_open*)&state);
/* Set the caret position to the URL bar /* Register event handlers */
*/
if (g->toolbar && g->toolbar->display_url) {
error = xwimp_set_caret_position(
g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL, -1, -1, -1, 0);
ro_gui_url_complete_start(g);
} else
error = xwimp_set_caret_position(g->window,
wimp_ICON_WINDOW, -100, -100, 32, -1);
if (error) {
LOG(("xwimp_set_caret_position: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
return g;
}
/* and register event handlers */
ro_gui_wimp_event_register_keypress(g->window, ro_gui_wimp_event_register_keypress(g->window,
ro_gui_window_keypress); ro_gui_window_keypress);
if (g->toolbar) if (g->toolbar)
@ -366,6 +348,21 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
ro_gui_wimp_event_register_mouse_click(g->window, ro_gui_wimp_event_register_mouse_click(g->window,
ro_gui_window_click); ro_gui_window_click);
/* Claim the caret position for top-level windows */
if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
if (g->toolbar && g->toolbar->display_url) {
error = xwimp_set_caret_position(
g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL, -1, -1, -1, 0);
ro_gui_url_complete_start(g);
if (error) {
LOG(("xwimp_set_caret_position: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
} else
gui_window_place_caret(g, -100, -100, 0);
}
return g; return g;
} }
@ -1878,16 +1875,8 @@ bool ro_gui_window_click(wimp_pointer *pointer)
/* set input focus */ /* set input focus */
if (pointer->buttons == wimp_CLICK_SELECT || if (pointer->buttons == wimp_CLICK_SELECT ||
pointer->buttons == wimp_CLICK_ADJUST) { pointer->buttons == wimp_CLICK_ADJUST)
error = xwimp_set_caret_position(state.w, -1, gui_window_place_caret(g, -100, -100, 0);
-100, -100, 32, -1);
if (error) {
LOG(("xwimp_set_caret_position: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
return false;
}
}
if (pointer->buttons == wimp_CLICK_MENU) if (pointer->buttons == wimp_CLICK_MENU)
ro_gui_menu_create(browser_menu, pointer->pos.x, ro_gui_menu_create(browser_menu, pointer->pos.x,
@ -1987,14 +1976,7 @@ void gui_window_remove_caret(struct gui_window *g)
return; return;
/* hide caret, but keep input focus */ /* hide caret, but keep input focus */
error = xwimp_set_caret_position(g->window, -1, gui_window_place_caret(g, -100, -100, 0);
-100, -100, 32, -1);
if (error) {
LOG(("xwimp_set_caret_position: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
return;
}
} }