summaryrefslogtreecommitdiff
path: root/desktop/browser.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-11-29 14:20:25 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-11-29 14:20:25 +0000
commit64c405c541eef1f17d848b1538a7175134d4c14c (patch)
tree30e34d3d76fc49794fb06f1f55868705208cd5eb /desktop/browser.c
parent449e41e306624bd89f84976435d16291ca0405a8 (diff)
downloadnetsurf-64c405c541eef1f17d848b1538a7175134d4c14c.tar.gz
netsurf-64c405c541eef1f17d848b1538a7175134d4c14c.tar.bz2
New function for sending a scroll request into a core browser window at a given coordinate. Currently handles frames only. TODO: iframes and css overflow scrollable boxes. Front ends should call this to pass scroll wheel actions to the core.
svn path=/trunk/netsurf/; revision=13197
Diffstat (limited to 'desktop/browser.c')
-rw-r--r--desktop/browser.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 760849f6a..124821ff2 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -526,6 +526,52 @@ void browser_window_get_contextual_content(struct browser_window *bw,
browser_window__get_contextual_content(bw, x, y, data);
}
+/* exported interface, documented in browser.h */
+bool browser_window_scroll_at_point(struct browser_window *bw,
+ int x, int y, int scrx, int scry)
+{
+ bool handled_scroll = false;
+ assert(bw != NULL);
+
+ if (bw->children) {
+ /* Browser window has children, so pass request on to
+ * appropriate child */
+ struct browser_window *bwc;
+ int cur_child;
+ int children = bw->rows * bw->cols;
+
+ /* Loop through all children of bw */
+ for (cur_child = 0; cur_child < children; cur_child++) {
+ /* Set current child */
+ bwc = &bw->children[cur_child];
+
+ /* Skip this frame if (x, y) coord lies outside */
+ if (x < bwc->x || bwc->x + bwc->width < x ||
+ y < bwc->y || bwc->y + bwc->height < y)
+ continue;
+
+ /* Pass request into this child */
+ return browser_window_scroll_at_point(bwc,
+ (x - bwc->x), (y - bwc->y),
+ scrx, scry);
+ }
+ }
+
+ /* TODO:
+ * Pass scroll to content to try scrolling something at this point */
+
+ /* Try to scroll this window, if scroll not already handled */
+ if (handled_scroll == false) {
+ if (bw->scroll_y && scrollbar_scroll(bw->scroll_y, scry))
+ handled_scroll = true;
+
+ if (bw->scroll_x && scrollbar_scroll(bw->scroll_x, scrx))
+ handled_scroll = true;
+ }
+
+ return handled_scroll;
+}
+
/**
* Create and open a new root browser window with the given page.