mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 18:52:39 +03:00
change browser_window_get_features to use unscaled coordinates
This commit is contained in:
parent
0ebfff259f
commit
d4c01894c2
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,14 +664,16 @@ 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,
|
||||
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,
|
||||
if (browser_window_scroll_at_point(gw->bw,
|
||||
x, y,
|
||||
0, 100) == false)
|
||||
widget_scroll_y(gw, 100, false);
|
||||
break;
|
||||
|
@ -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, ¤t_menu_features);
|
||||
browser_window_get_features(bw, x, y, ¤t_menu_features);
|
||||
|
||||
if (current_menu_features.link != NULL) {
|
||||
/* menu is opening over a link */
|
||||
|
@ -467,8 +467,7 @@ 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),
|
||||
event->x, event->y,
|
||||
deltax, deltay) != true) {
|
||||
|
||||
/* core did not handle event so change adjustments */
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user