summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/handlers/html/html.c15
-rw-r--r--desktop/browser_window.c112
-rw-r--r--frontends/amiga/gui.c3
-rw-r--r--frontends/framebuffer/gui.c11
-rw-r--r--frontends/gtk/scaffolding.c4
-rw-r--r--frontends/gtk/window.c5
-rw-r--r--frontends/riscos/window.c8
7 files changed, 89 insertions, 69 deletions
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index a27ebd79a..1bbb4c699 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -1925,8 +1925,11 @@ html_get_contextual_content(struct content *c, int x, int y,
}
if (box->iframe) {
- browser_window_get_features(box->iframe,
- x - box_x, y - box_y, data);
+ browser_window_get_features(
+ box->iframe,
+ (x - box_x) * browser_window_get_scale(box->iframe),
+ (y - box_y) * browser_window_get_scale(box->iframe),
+ data);
}
if (box->object)
@@ -2001,8 +2004,12 @@ html_scroll_at_point(struct content *c, int x, int y, int scrx, int scry)
continue;
/* Pass into iframe */
- if (box->iframe && browser_window_scroll_at_point(box->iframe,
- x - box_x, y - box_y, scrx, scry) == true)
+ if (box->iframe &&
+ browser_window_scroll_at_point(
+ box->iframe,
+ (x - box_x) * browser_window_get_scale(box->iframe),
+ (y - box_y) * browser_window_get_scale(box->iframe),
+ scrx, scry) == true)
return true;
/* Pass into textarea widget */
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index 10180ff49..00de0bef6 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -1782,6 +1782,63 @@ browser_window_mouse_track_internal(struct browser_window *bw,
}
+static bool
+browser_window_scroll_at_point_internal(struct browser_window *bw,
+ int x, int y,
+ int scrx, int scry)
+{
+ bool handled_scroll = false;
+ assert(bw != NULL);
+
+ /* Handle (i)frame scroll offset (core-managed browser windows only) */
+ x += scrollbar_get_offset(bw->scroll_x);
+ y += scrollbar_get_offset(bw->scroll_y);
+
+ 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_internal(
+ bwc,
+ (x - bwc->x),
+ (y - bwc->y),
+ scrx, scry);
+ }
+ }
+
+ /* Try to scroll any current content */
+ if (bw->current_content != NULL && content_scroll_at_point(
+ bw->current_content, x, y, scrx, scry) == true)
+ /* Scroll handled by current content */
+ return true;
+
+ /* 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;
+}
+
+
/* exported interface, documented in netsurf/browser_window.h */
nserror
browser_window_get_name(struct browser_window *bw, const char **out_name)
@@ -2244,7 +2301,8 @@ browser_window_get_features(struct browser_window *bw,
data->main = NULL;
data->form_features = CTX_FORM_NONE;
- return browser_window__get_contextual_content(bw, x, y, data);
+ return browser_window__get_contextual_content(
+ bw, x / bw->scale, y / bw->scale, data);
}
@@ -2254,53 +2312,11 @@ browser_window_scroll_at_point(struct browser_window *bw,
int x, int y,
int scrx, int scry)
{
- bool handled_scroll = false;
- assert(bw != NULL);
-
- /* Handle (i)frame scroll offset (core-managed browser windows only) */
- x += scrollbar_get_offset(bw->scroll_x);
- y += scrollbar_get_offset(bw->scroll_y);
-
- 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);
- }
- }
-
- /* Try to scroll any current content */
- if (bw->current_content != NULL && content_scroll_at_point(
- bw->current_content, x, y, scrx, scry) == true)
- /* Scroll handled by current content */
- return true;
-
- /* 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;
+ return browser_window_scroll_at_point_internal(bw,
+ x / bw->scale,
+ y / bw->scale,
+ scrx,
+ scry);
}
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 916851846..adce7dd0b 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1919,8 +1919,7 @@ static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
if(ami_mouse_to_ns_coords(gwin, &x, &y, -1, -1) == true)
{
- if(browser_window_scroll_at_point(gwin->gw->bw, x, y,
- xs, ys) == false)
+ if(browser_window_scroll_at_point(gwin->gw->bw, x, y, xs, ys) == false)
{
int width, height;
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 588f05b98..2ea893efb 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -627,7 +627,6 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
browser_mouse_state mouse;
- float scale = browser_window_get_scale(gw->bw);
int x = cbi->x + bwidget->scrollx;
int y = cbi->y + bwidget->scrolly;
uint64_t time_now;
@@ -665,15 +664,17 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_KEY_MOUSE_4:
/* scroll up */
- if (browser_window_scroll_at_point(gw->bw, x/scale, y/scale,
- 0, -100) == false)
+ if (browser_window_scroll_at_point(gw->bw,
+ x, y,
+ 0, -100) == false)
widget_scroll_y(gw, -100, false);
break;
case NSFB_KEY_MOUSE_5:
/* scroll down */
- if (browser_window_scroll_at_point(gw->bw, x/scale, y/scale,
- 0, 100) == false)
+ if (browser_window_scroll_at_point(gw->bw,
+ x, y,
+ 0, 100) == false)
widget_scroll_y(gw, 100, false);
break;
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 6b6f936ff..8625d9a4c 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -2716,13 +2716,11 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
{
GtkMenu *gtkmenu;
struct browser_window *bw;
- float scale;
bw = nsgtk_get_browser_window(g->top_level);
- scale = browser_window_get_scale(bw);
/* update the global context menu features */
- browser_window_get_features(bw, x/scale, y/scale, &current_menu_features);
+ browser_window_get_features(bw, x, y, &current_menu_features);
if (current_menu_features.link != NULL) {
/* menu is opening over a link */
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index ece586a85..5e8538f26 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -467,9 +467,8 @@ nsgtk_window_scroll_event(GtkWidget *widget,
deltay *= nsgtk_adjustment_get_step_increment(vscroll);
if (browser_window_scroll_at_point(g->bw,
- event->x / browser_window_get_scale(g->bw),
- event->y / browser_window_get_scale(g->bw),
- deltax, deltay) != true) {
+ event->x, event->y,
+ deltax, deltay) != true) {
/* core did not handle event so change adjustments */
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index 84029ef87..c4d32bd28 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -1154,8 +1154,8 @@ ro_gui_window_scroll_action(struct gui_window *g,
if (pointer.w == g->window &&
ro_gui_window_to_window_pos(g, pointer.pos.x, pointer.pos.y, &pos))
handled = browser_window_scroll_at_point(g->bw,
- pos.x/g->scale,
- pos.y/g->scale,
+ pos.x,
+ pos.y,
step_x,
step_y);
@@ -1251,7 +1251,7 @@ ro_gui_window_handle_local_keypress(struct gui_window *g,
if (!ro_gui_window_to_window_pos(g, pointer.pos.x, pointer.pos.y, &pos))
return false;
- browser_window_get_features(g->bw, pos.x/g->scale, pos.y/g->scale, &cont);
+ browser_window_get_features(g->bw, pos.x, pos.y, &cont);
switch (c) {
case IS_WIMP_KEY + wimp_KEY_F1: /* Help. */
@@ -2171,7 +2171,7 @@ ro_gui_window_menu_prepare(wimp_w w,
if (ro_gui_window_to_window_pos(g, pointer->pos.x,
pointer->pos.y, &pos)) {
- browser_window_get_features(bw, pos.x/g->scale, pos.y/g->scale, &cont);
+ browser_window_get_features(bw, pos.x, pos.y, &cont);
current_menu_main = cont.main;
current_menu_object = cont.object;