[project @ 2004-06-25 17:38:39 by jmb]

Tighten up parameter checking in ro_gui_window_click.

svn path=/import/netsurf/; revision=1008
This commit is contained in:
John Mark Bell 2004-06-25 17:38:39 +00:00
parent b3d4ce0883
commit 45b1be0d67

View File

@ -722,72 +722,102 @@ void ro_gui_window_click(gui_window* g, wimp_pointer* pointer) {
int x,y; int x,y;
wimp_window_state state; wimp_window_state state;
wimp_caret caret; wimp_caret caret;
os_error *error;
assert(g != NULL);
assert(pointer != NULL);
if (g->type != GUI_BROWSER_WINDOW) return; if (g->type != GUI_BROWSER_WINDOW) return;
state.w = pointer->w; state.w = pointer->w;
wimp_get_window_state(&state); error = xwimp_get_window_state(&state);
if (error) {
LOG(("Failed reading window state"));
warn_user("WimpError", "Failed reading window state");
return;
}
x = window_x_units(pointer->pos.x, &state) / 2 / g->scale; x = window_x_units(pointer->pos.x, &state) / 2 / g->scale;
y = -window_y_units(pointer->pos.y, &state) / 2 / g->scale; y = -window_y_units(pointer->pos.y, &state) / 2 / g->scale;
/* set input focus */ /* set input focus */
wimp_get_caret_position(&caret); error = xwimp_get_caret_position(&caret);
if (pointer->buttons == wimp_CLICK_SELECT && caret.w != state.w) { if (error) {
wimp_set_caret_position(state.w, -1, -100, -100, 32, -1); LOG(("Failed reading caret position"));
} warn_user("WimpError", "Failed reading caret position");
return;
}
if (pointer->buttons == wimp_CLICK_MENU) { if (pointer->buttons == wimp_CLICK_SELECT && caret.w != state.w) {
ro_gui_create_menu(browser_menu, pointer->pos.x - 64, pointer->pos.y, g); error = xwimp_set_caret_position(state.w, -1, -100,
} else if (g->data.browser.bw->current_content != NULL) { -100, 32, -1);
if (g->data.browser.bw->current_content->type == CONTENT_HTML) if (error) {
{ LOG(("Failed setting caret position"));
if (pointer->buttons == wimp_CLICK_SELECT) warn_user("WimpError",
{ "Failed setting caret position");
msg.type = act_MOUSE_CLICK;
msg.data.mouse.x = x;
msg.data.mouse.y = y;
if (browser_window_action(g->data.browser.bw, &msg) == 1)
return; return;
msg.type = act_UNKNOWN; }
}
if (pointer->buttons == wimp_CLICK_SELECT && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
msg.type = act_CLEAR_SELECTION;
else if (pointer->buttons == wimp_CLICK_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
msg.type = act_ALTER_SELECTION;
else if (pointer->buttons == wimp_DRAG_SELECT ||
pointer->buttons == wimp_DRAG_ADJUST)
{
msg.type = act_START_NEW_SELECTION;
if (pointer->buttons == wimp_DRAG_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
msg.type = act_ALTER_SELECTION;
ro_gui_start_selection(pointer, &state, g);
g->drag_status = drag_BROWSER_TEXT_SELECTION;
}
msg.data.mouse.x = x;
msg.data.mouse.y = y;
if (msg.type != act_UNKNOWN)
browser_window_action(g->data.browser.bw, &msg);
if (pointer->buttons == wimp_CLICK_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
{
current_gui->data.browser.bw->current_content->data.html.text_selection.altering = alter_UNKNOWN;
} }
if (pointer->buttons == wimp_CLICK_SELECT if (pointer->buttons == wimp_CLICK_MENU) {
|| pointer->buttons == wimp_CLICK_ADJUST) ro_gui_create_menu(browser_menu, pointer->pos.x - 64,
{ pointer->pos.y, g);
if (pointer->buttons == wimp_CLICK_SELECT) }
msg.type = act_FOLLOW_LINK; else {
else if (g->data.browser.bw != NULL &&
msg.type = act_FOLLOW_LINK_NEW_WINDOW; g->data.browser.bw->current_content != NULL &&
msg.data.mouse.x = x; g->data.browser.bw->current_content->type == CONTENT_HTML) {
msg.data.mouse.y = y; if (pointer->buttons == wimp_CLICK_SELECT) {
browser_window_action(g->data.browser.bw, &msg); msg.type = act_MOUSE_CLICK;
msg.data.mouse.x = x;
msg.data.mouse.y = y;
if (browser_window_action(
g->data.browser.bw, &msg) == 1)
return;
msg.type = act_UNKNOWN;
}
if (pointer->buttons == wimp_CLICK_SELECT && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
msg.type = act_CLEAR_SELECTION;
else if (pointer->buttons == wimp_CLICK_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
msg.type = act_ALTER_SELECTION;
else if (pointer->buttons == wimp_DRAG_SELECT ||
pointer->buttons == wimp_DRAG_ADJUST) {
msg.type = act_START_NEW_SELECTION;
if (pointer->buttons == wimp_DRAG_ADJUST && g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
msg.type = act_ALTER_SELECTION;
ro_gui_start_selection(pointer, &state, g);
g->drag_status = drag_BROWSER_TEXT_SELECTION;
}
msg.data.mouse.x = x;
msg.data.mouse.y = y;
if (msg.type != act_UNKNOWN)
browser_window_action(g->data.browser.bw, &msg);
if (pointer->buttons == wimp_CLICK_ADJUST &&
g->data.browser.bw->current_content->data.html.text_selection.selected == 1 &&
current_gui != NULL &&
current_gui->data.browser.bw != NULL &&
current_gui->data.browser.bw->current_content != NULL) {
current_gui->data.browser.bw->current_content->data.html.text_selection.altering = alter_UNKNOWN;
}
if (pointer->buttons == wimp_CLICK_SELECT
|| pointer->buttons == wimp_CLICK_ADJUST) {
if (pointer->buttons == wimp_CLICK_SELECT)
msg.type = act_FOLLOW_LINK;
else
msg.type = act_FOLLOW_LINK_NEW_WINDOW;
msg.data.mouse.x = x;
msg.data.mouse.y = y;
browser_window_action(g->data.browser.bw, &msg);
}
}
} }
}
}
} }