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) {
|
if (box->iframe) {
|
||||||
browser_window_get_features(box->iframe,
|
browser_window_get_features(
|
||||||
x - box_x, y - box_y, data);
|
box->iframe,
|
||||||
|
(x - box_x) * browser_window_get_scale(box->iframe),
|
||||||
|
(y - box_y) * browser_window_get_scale(box->iframe),
|
||||||
|
data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (box->object)
|
if (box->object)
|
||||||
@ -2001,8 +2004,12 @@ html_scroll_at_point(struct content *c, int x, int y, int scrx, int scry)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Pass into iframe */
|
/* Pass into iframe */
|
||||||
if (box->iframe && browser_window_scroll_at_point(box->iframe,
|
if (box->iframe &&
|
||||||
x - box_x, y - box_y, scrx, scry) == true)
|
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;
|
return true;
|
||||||
|
|
||||||
/* Pass into textarea widget */
|
/* 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 */
|
/* exported interface, documented in netsurf/browser_window.h */
|
||||||
nserror
|
nserror
|
||||||
browser_window_get_name(struct browser_window *bw, const char **out_name)
|
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->main = NULL;
|
||||||
data->form_features = CTX_FORM_NONE;
|
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 x, int y,
|
||||||
int scrx, int scry)
|
int scrx, int scry)
|
||||||
{
|
{
|
||||||
bool handled_scroll = false;
|
return browser_window_scroll_at_point_internal(bw,
|
||||||
assert(bw != NULL);
|
x / bw->scale,
|
||||||
|
y / bw->scale,
|
||||||
/* Handle (i)frame scroll offset (core-managed browser windows only) */
|
scrx,
|
||||||
x += scrollbar_get_offset(bw->scroll_x);
|
scry);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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(ami_mouse_to_ns_coords(gwin, &x, &y, -1, -1) == true)
|
||||||
{
|
{
|
||||||
if(browser_window_scroll_at_point(gwin->gw->bw, x, y,
|
if(browser_window_scroll_at_point(gwin->gw->bw, x, y, xs, ys) == false)
|
||||||
xs, ys) == false)
|
|
||||||
{
|
{
|
||||||
int width, height;
|
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 gui_window *gw = cbi->context;
|
||||||
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
|
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
|
||||||
browser_mouse_state mouse;
|
browser_mouse_state mouse;
|
||||||
float scale = browser_window_get_scale(gw->bw);
|
|
||||||
int x = cbi->x + bwidget->scrollx;
|
int x = cbi->x + bwidget->scrollx;
|
||||||
int y = cbi->y + bwidget->scrolly;
|
int y = cbi->y + bwidget->scrolly;
|
||||||
uint64_t time_now;
|
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:
|
case NSFB_KEY_MOUSE_4:
|
||||||
/* scroll up */
|
/* scroll up */
|
||||||
if (browser_window_scroll_at_point(gw->bw, x/scale, y/scale,
|
if (browser_window_scroll_at_point(gw->bw,
|
||||||
0, -100) == false)
|
x, y,
|
||||||
|
0, -100) == false)
|
||||||
widget_scroll_y(gw, -100, false);
|
widget_scroll_y(gw, -100, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSFB_KEY_MOUSE_5:
|
case NSFB_KEY_MOUSE_5:
|
||||||
/* scroll down */
|
/* scroll down */
|
||||||
if (browser_window_scroll_at_point(gw->bw, x/scale, y/scale,
|
if (browser_window_scroll_at_point(gw->bw,
|
||||||
0, 100) == false)
|
x, y,
|
||||||
|
0, 100) == false)
|
||||||
widget_scroll_y(gw, 100, false);
|
widget_scroll_y(gw, 100, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2716,13 +2716,11 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
|
|||||||
{
|
{
|
||||||
GtkMenu *gtkmenu;
|
GtkMenu *gtkmenu;
|
||||||
struct browser_window *bw;
|
struct browser_window *bw;
|
||||||
float scale;
|
|
||||||
|
|
||||||
bw = nsgtk_get_browser_window(g->top_level);
|
bw = nsgtk_get_browser_window(g->top_level);
|
||||||
scale = browser_window_get_scale(bw);
|
|
||||||
|
|
||||||
/* update the global context menu features */
|
/* 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) {
|
if (current_menu_features.link != NULL) {
|
||||||
/* menu is opening over a link */
|
/* menu is opening over a link */
|
||||||
|
@ -467,9 +467,8 @@ nsgtk_window_scroll_event(GtkWidget *widget,
|
|||||||
deltay *= nsgtk_adjustment_get_step_increment(vscroll);
|
deltay *= nsgtk_adjustment_get_step_increment(vscroll);
|
||||||
|
|
||||||
if (browser_window_scroll_at_point(g->bw,
|
if (browser_window_scroll_at_point(g->bw,
|
||||||
event->x / browser_window_get_scale(g->bw),
|
event->x, event->y,
|
||||||
event->y / browser_window_get_scale(g->bw),
|
deltax, deltay) != true) {
|
||||||
deltax, deltay) != true) {
|
|
||||||
|
|
||||||
/* core did not handle event so change adjustments */
|
/* 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 &&
|
if (pointer.w == g->window &&
|
||||||
ro_gui_window_to_window_pos(g, pointer.pos.x, pointer.pos.y, &pos))
|
ro_gui_window_to_window_pos(g, pointer.pos.x, pointer.pos.y, &pos))
|
||||||
handled = browser_window_scroll_at_point(g->bw,
|
handled = browser_window_scroll_at_point(g->bw,
|
||||||
pos.x/g->scale,
|
pos.x,
|
||||||
pos.y/g->scale,
|
pos.y,
|
||||||
step_x,
|
step_x,
|
||||||
step_y);
|
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))
|
if (!ro_gui_window_to_window_pos(g, pointer.pos.x, pointer.pos.y, &pos))
|
||||||
return false;
|
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) {
|
switch (c) {
|
||||||
case IS_WIMP_KEY + wimp_KEY_F1: /* Help. */
|
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,
|
if (ro_gui_window_to_window_pos(g, pointer->pos.x,
|
||||||
pointer->pos.y, &pos)) {
|
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_main = cont.main;
|
||||||
current_menu_object = cont.object;
|
current_menu_object = cont.object;
|
||||||
|
Loading…
Reference in New Issue
Block a user