From 23eea5de9fc46283123248bc3c1306266297205c Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 27 Jun 2011 17:29:49 +0000 Subject: [PATCH] Fix bw->drag_type to be aware of remaining drag types. svn path=/trunk/netsurf/; revision=12514 --- desktop/browser.c | 37 +++++++++++++++++++++++-------------- desktop/browser.h | 28 +++++++++++++++++++++------- render/form.c | 2 ++ render/html_interaction.c | 2 ++ 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/desktop/browser.c b/desktop/browser.c index df6ce480b..babd5d49c 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -224,6 +224,13 @@ void browser_window_set_position(struct browser_window *bw, int x, int y) } } +/* exported interface, documented in browser.h */ +void browser_window_set_drag_type(struct browser_window *bw, + browser_drag_type type) +{ + bw->drag_type = type; +} + /** * Create and open a new root browser window with the given page. * @@ -1770,20 +1777,9 @@ void browser_window_mouse_click(struct browser_window *bw, void browser_window_mouse_drag_end(struct browser_window *bw, browser_mouse_state mouse, int x, int y) { - - if (bw->visible_select_menu != NULL) { - form_select_mouse_drag_end(bw->visible_select_menu, mouse, - x, y); - return; - } - - if (bw->scrollbar != NULL) { - html_overflow_scroll_drag_end(bw->scrollbar, mouse, x, y); - return; - } - switch (bw->drag_type) { - case DRAGGING_SELECTION: { + case DRAGGING_SELECTION: + { hlcache_handle *h = bw->current_content; if (h) { int dir = -1; @@ -1807,7 +1803,20 @@ void browser_window_mouse_drag_end(struct browser_window *bw, } selection_drag_end(bw->sel); } - break; + break; + + case DRAGGING_OTHER: + + if (bw->visible_select_menu != NULL) { + form_select_mouse_drag_end(bw->visible_select_menu, + mouse, x, y); + } + + if (bw->scrollbar != NULL) { + html_overflow_scroll_drag_end(bw->scrollbar, + mouse, x, y); + } + break; default: break; diff --git a/desktop/browser.h b/desktop/browser.h index 830b22b0a..cdf071645 100644 --- a/desktop/browser.h +++ b/desktop/browser.h @@ -55,6 +55,15 @@ typedef void (*browser_move_callback)(struct browser_window *bw, void *p); +typedef enum { + DRAGGING_NONE, + DRAGGING_SELECTION, + DRAGGING_PAGE_SCROLL, + DRAGGING_FRAME, + DRAGGING_OTHER +} browser_drag_type; + + /** Browser window data. */ struct browser_window { @@ -91,12 +100,7 @@ struct browser_window { char *frag_id; /** Current drag status. */ - enum { - DRAGGING_NONE, - DRAGGING_SELECTION, - DRAGGING_PAGE_SCROLL, - DRAGGING_FRAME - } drag_type; + browser_drag_type drag_type; /** Mouse position at start of current scroll drag. */ int drag_start_x; @@ -323,12 +327,22 @@ void browser_window_get_position(struct browser_window *bw, bool root, * Set the position of the current browser window with respect to the parent * browser window * - * \param bw browser window to get the position of + * \param bw browser window to set the position of * \param x x position of bw * \param y y position of bw */ void browser_window_set_position(struct browser_window *bw, int x, int y); +/* + * Set the position of the current browser window with respect to the parent + * browser window + * + * \param bw browser window to set the type of the current drag for + * \param type drag type + */ +void browser_window_set_drag_type(struct browser_window *bw, + browser_drag_type type); + /* In platform specific hotlist.c. */ void hotlist_visited(struct hlcache_handle *c); diff --git a/render/form.c b/render/form.c index 6a50581d1..eb89975f6 100644 --- a/render/form.c +++ b/render/form.c @@ -1295,6 +1295,8 @@ void form_select_menu_scroll_callback(void *client_data, menu->height); break; case SCROLLBAR_MSG_SCROLL_START: + browser_window_set_drag_type(menu->bw, DRAGGING_OTHER); + menu->scroll_capture = true; gui_window_box_scroll_start(menu->bw->window, scrollbar_data->x0, scrollbar_data->y0, diff --git a/render/html_interaction.c b/render/html_interaction.c index 834181cdc..3b0dd767f 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -789,6 +789,8 @@ void html_overflow_scroll_callback(void *client_data, html_redraw_a_box(bw->current_content, box); break; case SCROLLBAR_MSG_SCROLL_START: + browser_window_set_drag_type(bw, DRAGGING_OTHER); + bw->scrollbar = scrollbar_data->scrollbar; gui_window_box_scroll_start(bw->window, scrollbar_data->x0, scrollbar_data->y0,