Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/641f5fb07204a9deb256557902707cd28182463d
...commit
http://git.netsurf-browser.org/netsurf.git/commit/641f5fb07204a9deb256557902707cd28182463d
...tree
http://git.netsurf-browser.org/netsurf.git/tree/641f5fb07204a9deb256557902707cd28182463d
The branch, master has been updated
via 641f5fb07204a9deb256557902707cd28182463d (commit)
via 402e16e5d1e88a3844b900c485d9fc7c4093f2ab (commit)
via d4c01894c21559cd4199c0f15b9e8b7bec4b692c (commit)
via 0ebfff259fa4ec6aaf5e97a213d5c65c24052e96 (commit)
via 0a8ed41a1ad470bb62c908d0dc6272c1c541a1f2 (commit)
from 182c4ddefe6c1cd050361febb344ccd8cd5d1c96 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=641f5fb07204a9deb256557902707cd28182463d
commit 641f5fb07204a9deb256557902707cd28182463d
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
make use of improved browser_window_set_scale API in frontends
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index adce7dd..54273ee 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3927,14 +3927,14 @@ int ami_gui_count_windows(int window, int *tabs)
*/
void ami_gui_set_scale(struct gui_window *gw, float scale)
{
- if(scale <= 0.0) return;
- gw->scale = scale;
browser_window_set_scale(gw->bw, scale, true);
+ gw->scale = browser_window_get_scale(gw->bw);
}
void ami_gui_adjust_scale(struct gui_window *gw, float adjustment)
{
- ami_gui_set_scale(gw, gw->scale + adjustment);
+ browser_window_set_scale(gw->bw, adjustment, false);
+ gw->scale = browser_window_get_scale(gw->bw);
}
void ami_gui_switch_to_new_tab(struct gui_window_2 *gwin)
diff --git a/frontends/atari/deskmenu.c b/frontends/atari/deskmenu.c
index 34d7be0..4426415 100644
--- a/frontends/atari/deskmenu.c
+++ b/frontends/atari/deskmenu.c
@@ -387,9 +387,7 @@ static void __CDECL menu_inc_scale(short item, short title,
void *data)
if(input_window == NULL)
return;
- browser_window_set_scale(input_window->browser->bw,
-
browser_window_get_scale(input_window->browser->bw) + 0.25,
- true);
+ browser_window_set_scale(input_window->browser->bw, +0.25, false);
}
@@ -398,9 +396,7 @@ static void __CDECL menu_dec_scale(short item, short title,
void *data)
if(input_window == NULL)
return;
- browser_window_set_scale(input_window->browser->bw,
-
browser_window_get_scale(input_window->browser->bw) - 0.25,
- true);
+ browser_window_set_scale(input_window->browser->bw, -0.25, false);
}
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 2ea893e..7413739 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -912,34 +912,21 @@ fb_browser_window_input(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
case NSFB_KEY_MINUS:
if (modifier & FBTK_MOD_RCTRL ||
modifier & FBTK_MOD_LCTRL) {
- float scale = browser_window_get_scale(gw->bw);
- scale -= 0.1;
- if (scale < 0.1) {
- scale = 0.1;
- }
- if (scale > 0.95 && scale < 1.05) {
- scale = 1;
- }
- browser_window_set_scale(gw->bw, scale, true);
+ browser_window_set_scale(gw->bw, -0.1, false);
}
break;
case NSFB_KEY_EQUALS: /* PLUS */
if (modifier & FBTK_MOD_RCTRL ||
modifier & FBTK_MOD_LCTRL) {
- float scale = browser_window_get_scale(gw->bw);
- scale += 0.1;
- if (scale > 0.95 && scale < 1.05) {
- scale = 1;
- }
- browser_window_set_scale(gw->bw, scale, true);
+ browser_window_set_scale(gw->bw, 0.1, false);
}
break;
case NSFB_KEY_0:
if (modifier & FBTK_MOD_RCTRL ||
modifier & FBTK_MOD_LCTRL) {
- browser_window_set_scale(gw->bw, 1, true);
+ browser_window_set_scale(gw->bw, 1.0, true);
}
break;
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 8625d9a..6194989 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1255,9 +1255,8 @@ MULTIHANDLER(preferences)
MULTIHANDLER(zoomplus)
{
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- float old_scale = nsgtk_get_scale_for_gui(g->top_level);
- browser_window_set_scale(bw, old_scale + 0.05, true);
+ browser_window_set_scale(bw, 0.05, false);
return TRUE;
}
@@ -1274,9 +1273,8 @@ MULTIHANDLER(zoomnormal)
MULTIHANDLER(zoomminus)
{
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- float old_scale = nsgtk_get_scale_for_gui(g->top_level);
- browser_window_set_scale(bw, old_scale - 0.05, true);
+ browser_window_set_scale(bw, -0.05, false);
return TRUE;
}
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index c4d32bd..5a46529 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -4346,8 +4346,8 @@ nserror ro_gui_window_set_url(struct gui_window *g, nsurl
*url)
/* exported interface documented in riscos/window.h */
void ro_gui_window_set_scale(struct gui_window *g, float scale)
{
- g->scale = scale;
browser_window_set_scale(g->bw, scale, true);
+ g->scale = browser_window_get_scale(g->bw);
}
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index 06e7346..b9a0dfc 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -898,36 +898,6 @@ win32_window_invalidate_area(struct gui_window *gw, const
struct rect *rect)
/**
- * Set scale of a win32 browser window
- *
- * \param gw win32 frontend window context
- * \param scale The new scale
- */
-static void nsws_set_scale(struct gui_window *gw, float scale)
-{
- struct rect rect;
-
- assert(gw != NULL);
-
- if (gw->scale == scale) {
- return;
- }
-
- rect.x0 = rect.x1 = gw->scrollx;
- rect.y0 = rect.y1 = gw->scrolly;
-
- gw->scale = scale;
-
- if (gw->bw != NULL) {
- browser_window_set_scale(gw->bw, scale, true);
- }
-
- win32_window_invalidate_area(gw, NULL);
- win32_window_set_scroll(gw, &rect);
-}
-
-
-/**
* Create a new window due to menu selection
*
* \param gw frontends graphical window.
@@ -1136,15 +1106,15 @@ nsws_window_command(HWND hwnd,
break;
case IDM_VIEW_ZOOMPLUS:
- nsws_set_scale(gw, gw->scale * 1.1);
+ browser_window_set_scale(gw->bw, 0.1, false);
break;
case IDM_VIEW_ZOOMMINUS:
- nsws_set_scale(gw, gw->scale * 0.9);
+ browser_window_set_scale(gw->bw, -0.1, false);
break;
case IDM_VIEW_ZOOMNORMAL:
- nsws_set_scale(gw, 1.0);
+ browser_window_set_scale(gw->bw, 1.0, true);
break;
case IDM_VIEW_SOURCE:
@@ -1542,9 +1512,12 @@ win32_window_get_dimensions(struct gui_window *gw, int
*width, int *height)
*
* \param w gui_window to update the extent of
*/
-static void win32_window_update_extent(struct gui_window *w)
+static void win32_window_update_extent(struct gui_window *gw)
{
-
+ struct rect rect;
+ rect.x0 = rect.x1 = gw->scrollx;
+ rect.y0 = rect.y1 = gw->scrolly;
+ win32_window_set_scroll(gw, &rect);
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=402e16e5d1e88a3844b900c485d9fc7c4093f2ab
commit 402e16e5d1e88a3844b900c485d9fc7c4093f2ab
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
improve browser_window_set_scale
Allow scale setting to use an absolute value or a relative value. This
also imposes sanity limits on the scale range (currently 0.2 to 10.0)
and removes the old junk "all" parameter.
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index 00de0be..56b9477 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -28,6 +28,11 @@
* Browser window creation and manipulation implementation.
*/
+/** smallest scale that can be applied to a browser window*/
+#define SCALE_MINIMUM 0.2
+/** largests scale that can be applied to a browser window*/
+#define SCALE_MAXIMUM 10.0
+
#include "utils/config.h"
#include <assert.h>
@@ -1337,32 +1342,40 @@ static bool frag_scroll(struct browser_window *bw)
* Set browser window scale.
*
* \param bw Browser window.
- * \param scale value.
+ * \param absolute scale value.
+ * \return NSERROR_OK on success else error code
*/
-static void
+static nserror
browser_window_set_scale_internal(struct browser_window *bw, float scale)
{
int i;
- hlcache_handle *c;
+ nserror res = NSERROR_OK;
- if (fabs(bw->scale-scale) < 0.0001)
- return;
+ /* do not apply tiny changes in scale */
+ if (fabs(bw->scale - scale) < 0.0001)
+ return res;
bw->scale = scale;
- c = bw->current_content;
- if (c != NULL) {
- if (content_can_reformat(c) == false) {
+ if (bw->current_content != NULL) {
+ if (content_can_reformat(bw->current_content) == false) {
browser_window_update(bw, false);
} else {
- browser_window_schedule_reformat(bw);
+ res = browser_window_schedule_reformat(bw);
}
}
- for (i = 0; i < (bw->cols * bw->rows); i++)
- browser_window_set_scale_internal(&bw->children[i], scale);
- for (i = 0; i < bw->iframe_count; i++)
- browser_window_set_scale_internal(&bw->iframes[i], scale);
+ /* scale frames */
+ for (i = 0; i < (bw->cols * bw->rows); i++) {
+ res = browser_window_set_scale_internal(&bw->children[i],
scale);
+ }
+
+ /* sale iframes */
+ for (i = 0; i < bw->iframe_count; i++) {
+ res = browser_window_set_scale_internal(&bw->iframes[i], scale);
+ }
+
+ return res;
}
@@ -3269,9 +3282,7 @@ nserror browser_window_schedule_reformat(struct
browser_window *bw)
return NSERROR_BAD_PARAMETER;
}
- guit->misc->schedule(0, scheduled_reformat, bw);
-
- return NSERROR_OK;
+ return guit->misc->schedule(0, scheduled_reformat, bw);
}
@@ -3304,18 +3315,44 @@ void browser_window_reformat(struct browser_window *bw,
bool background,
/* exported interface documented in netsurf/browser_window.h */
-void browser_window_set_scale(struct browser_window *bw, float scale, bool all)
+nserror
+browser_window_set_scale(struct browser_window *bw, float scale, bool absolute)
{
- while (bw->parent && all) {
+ nserror res;
+
+ /* get top browser window */
+ while (bw->parent) {
bw = bw->parent;
}
- browser_window_set_scale_internal(bw, scale);
+ if (absolute) {
+ /* ensure "close" to 1 is treated as 1 */
+ if (scale > 0.95 && scale < 1.05) {
+ scale = 1.0;
+ }
+ } else {
+ /* ensure "close" to 1 is treated as 1 */
+ if ((scale + bw->scale) > (1.01 - scale) &&
+ (scale + bw->scale) < (0.99 + scale)) {
+ scale = 1.0;
+ } else {
+ scale += bw->scale;
+ }
+ }
+
+ /* clamp range between 0.1 and 10 (10% and 1000%) */
+ if (scale < SCALE_MINIMUM) {
+ scale = SCALE_MINIMUM;
+ } else if (scale > SCALE_MAXIMUM) {
+ scale = SCALE_MAXIMUM;
+ }
- if (bw->parent)
- bw = bw->parent;
+ res = browser_window_set_scale_internal(bw, scale);
+ if (res == NSERROR_OK) {
+ browser_window_recalculate_frameset(bw);
+ }
- browser_window_recalculate_frameset(bw);
+ return res;
}
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 8b5f56c..a14545f 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -337,9 +337,10 @@ void browser_window_reformat(struct browser_window *bw,
bool background, int wid
*
* \param bw The browser window to scale.
* \param scale The new scale.
- * \param all Scale all windows in the tree (ie work up as well as down)
+ * \param absolute If the scale value is absolute or relative to current value
+ * \return NSERROR_OK and scale applied else other error code caused by reflow
etc.
*/
-void browser_window_set_scale(struct browser_window *bw, float scale, bool
all);
+nserror browser_window_set_scale(struct browser_window *bw, float scale, bool
absolute);
/**
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=d4c01894c21559cd4199c0f15b9e8b7bec4b692c
commit d4c01894c21559cd4199c0f15b9e8b7bec4b692c
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
change browser_window_get_features to use unscaled coordinates
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index a27ebd7..1bbb4c6 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 10180ff..00de0be 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 9168518..adce7dd 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 588f05b..2ea893e 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 6b6f936..8625d9a 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,
¤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 */
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index ece586a..5e8538f 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 84029ef..c4d32bd 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;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=0ebfff259fa4ec6aaf5e97a213d5c65c24052e96
commit 0ebfff259fa4ec6aaf5e97a213d5c65c24052e96
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
change browser_window_mouse_track to use unscaled coordinates
diff --git a/content/handlers/html/html_interaction.c
b/content/handlers/html/html_interaction.c
index b6b9de8..992796c 100644
--- a/content/handlers/html/html_interaction.c
+++ b/content/handlers/html/html_interaction.c
@@ -849,10 +849,9 @@ void html_mouse_action(struct content *c, struct
browser_window *bw,
(x * scale) - pos_x,
(y * scale) - pos_y);
} else {
- pos_x /= scale;
- pos_y /= scale;
browser_window_mouse_track(iframe, mouse,
- x - pos_x, y - pos_y);
+ (x * scale) - pos_x,
+ (y * scale) - pos_y);
}
} else if (html_object_box) {
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index 659eabd..10180ff 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -1617,6 +1617,171 @@ browser_window_mouse_click_internal(struct
browser_window *bw,
}
+/**
+ * Process mouse movement event
+ *
+ * \param bw The browsing context receiving the event
+ * \param mouse The mouse event state
+ * \param x The scaled x co-ordinate of the event
+ * \param y The scaled y co-ordinate of the event
+ */
+static void
+browser_window_mouse_track_internal(struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
+{
+ hlcache_handle *c = bw->current_content;
+ const char *status = NULL;
+ browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
+
+ if (bw->window != NULL && bw->drag.window && bw != bw->drag.window) {
+ /* This is the root browser window and there's an active drag
+ * in a sub window.
+ * Pass the mouse action straight on to that bw. */
+ struct browser_window *drag_bw = bw->drag.window;
+ int off_x = 0;
+ int off_y = 0;
+
+ browser_window_get_position(drag_bw, true, &off_x, &off_y);
+
+ if (drag_bw->browser_window_type == BROWSER_WINDOW_FRAME) {
+ browser_window_mouse_track_internal(drag_bw, mouse,
+ x - off_x, y - off_y);
+
+ } else if (drag_bw->browser_window_type ==
+ BROWSER_WINDOW_IFRAME) {
+ browser_window_mouse_track_internal(drag_bw, mouse,
+ x - off_x / bw->scale,
+ y - off_y / bw->scale);
+ }
+ return;
+ }
+
+ if (bw->children) {
+ /* Browser window has children (frames) */
+ struct browser_window *child;
+ int cur_child;
+ int children = bw->rows * bw->cols;
+
+ for (cur_child = 0; cur_child < children; cur_child++) {
+
+ child = &bw->children[cur_child];
+
+ if ((x < child->x) ||
+ (y < child->y) ||
+ (child->x + child->width < x) ||
+ (child->y + child->height < y)) {
+ /* Click not in this child */
+ continue;
+ }
+
+ /* It's this child that contains the mouse; pass
+ * mouse action on to child */
+ browser_window_mouse_track_internal(
+ child,
+ mouse,
+ x - child->x +
scrollbar_get_offset(child->scroll_x),
+ y - child->y +
scrollbar_get_offset(child->scroll_y));
+
+ /* Mouse action was for this child, we're done */
+ return;
+ }
+
+ /* Odd if we reached here, but nothing else can use the click
+ * when there are children. */
+ return;
+ }
+
+ if (c == NULL && bw->drag.type != DRAGGING_FRAME) {
+ return;
+ }
+
+ if (bw->drag.type != DRAGGING_NONE && !mouse) {
+ browser_window_mouse_drag_end(bw, mouse, x, y);
+ }
+
+ /* Browser window's horizontal scrollbar */
+ if (bw->scroll_x != NULL && bw->drag.type != DRAGGING_SCR_Y) {
+ int scr_x, scr_y;
+ browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
+ scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
+ scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
+
+ if ((bw->drag.type == DRAGGING_SCR_X) ||
+ (scr_x > 0 &&
+ scr_x < get_horz_scrollbar_len(bw) &&
+ scr_y > 0 &&
+ scr_y < SCROLLBAR_WIDTH &&
+ bw->drag.type == DRAGGING_NONE)) {
+ /* Start a scrollbar drag, or continue existing drag */
+ status = scrollbar_mouse_status_to_message(
+ scrollbar_mouse_action(
+ bw->scroll_x, mouse,
+ scr_x, scr_y));
+ pointer = BROWSER_POINTER_DEFAULT;
+
+ if (status != NULL) {
+ browser_window_set_status(bw, status);
+ }
+
+ browser_window_set_pointer(bw, pointer);
+ return;
+ }
+ }
+
+ /* Browser window's vertical scrollbar */
+ if (bw->scroll_y != NULL) {
+ int scr_x, scr_y;
+ browser_window_get_scrollbar_pos(bw, false, &scr_x, &scr_y);
+ scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
+ scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
+
+ if ((bw->drag.type == DRAGGING_SCR_Y) ||
+ (scr_y > 0 &&
+ scr_y < get_vert_scrollbar_len(bw) &&
+ scr_x > 0 &&
+ scr_x < SCROLLBAR_WIDTH &&
+ bw->drag.type == DRAGGING_NONE)) {
+ /* Start a scrollbar drag, or continue existing drag */
+ status = scrollbar_mouse_status_to_message(
+ scrollbar_mouse_action(
+ bw->scroll_y, mouse,
+ scr_x, scr_y));
+ pointer = BROWSER_POINTER_DEFAULT;
+
+ if (status != NULL) {
+ browser_window_set_status(bw, status);
+ }
+
+ browser_window_set_pointer(bw, pointer);
+ return;
+ }
+ }
+
+ if (bw->drag.type == DRAGGING_FRAME) {
+ browser_window_resize_frame(bw, bw->x + x, bw->y + y);
+ } else if (bw->drag.type == DRAGGING_PAGE_SCROLL) {
+ /* mouse movement since drag started */
+ struct rect rect;
+
+ rect.x0 = bw->drag.start_x - x;
+ rect.y0 = bw->drag.start_y - y;
+
+ /* new scroll offsets */
+ rect.x0 += bw->drag.start_scroll_x;
+ rect.y0 += bw->drag.start_scroll_y;
+
+ bw->drag.start_scroll_x = rect.x1 = rect.x0;
+ bw->drag.start_scroll_y = rect.y1 = rect.y0;
+
+ browser_window_set_scroll(bw, &rect);
+ } else {
+ assert(c != NULL);
+ content_mouse_track(c, bw, mouse, x, y);
+ }
+}
+
+
/* exported interface, documented in netsurf/browser_window.h */
nserror
browser_window_get_name(struct browser_window *bw, const char **out_name)
@@ -3292,160 +3457,17 @@ browser_window_find_target(struct browser_window *bw,
/* exported interface documented in netsurf/browser_window.h */
-void browser_window_mouse_track(struct browser_window *bw,
- browser_mouse_state mouse, int x, int y)
+void
+browser_window_mouse_track(struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
{
- hlcache_handle *c = bw->current_content;
- const char *status = NULL;
- browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
-
- if (bw->window != NULL && bw->drag.window && bw != bw->drag.window) {
- /* This is the root browser window and there's an active drag
- * in a sub window.
- * Pass the mouse action straight on to that bw. */
- struct browser_window *drag_bw = bw->drag.window;
- int off_x = 0;
- int off_y = 0;
-
- browser_window_get_position(drag_bw, true, &off_x, &off_y);
-
- if (drag_bw->browser_window_type == BROWSER_WINDOW_FRAME) {
- browser_window_mouse_track(drag_bw, mouse,
- x - off_x, y - off_y);
-
- } else if (drag_bw->browser_window_type ==
- BROWSER_WINDOW_IFRAME) {
- browser_window_mouse_track(drag_bw, mouse,
- x - off_x / bw->scale,
- y - off_y / bw->scale);
- }
- return;
- }
-
- if (bw->children) {
- /* Browser window has children (frames) */
- struct browser_window *child;
- int cur_child;
- int children = bw->rows * bw->cols;
-
- for (cur_child = 0; cur_child < children; cur_child++) {
-
- child = &bw->children[cur_child];
-
- if (x < child->x || y < child->y ||
- child->x + child->width < x ||
- child->y + child->height < y) {
- /* Click not in this child */
- continue;
- }
-
- /* It's this child that contains the mouse; pass
- * mouse action on to child */
- browser_window_mouse_track(child, mouse,
- x - child->x +
scrollbar_get_offset(
- child->scroll_x),
- y - child->y +
scrollbar_get_offset(
- child->scroll_y));
-
- /* Mouse action was for this child, we're done */
- return;
- }
-
- /* Odd if we reached here, but nothing else can use the click
- * when there are children. */
- return;
- }
-
- if (c == NULL && bw->drag.type != DRAGGING_FRAME) {
- return;
- }
-
- if (bw->drag.type != DRAGGING_NONE && !mouse) {
- browser_window_mouse_drag_end(bw, mouse, x, y);
- }
-
- /* Browser window's horizontal scrollbar */
- if (bw->scroll_x != NULL && bw->drag.type != DRAGGING_SCR_Y) {
- int scr_x, scr_y;
- browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
- scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
- scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
-
- if ((bw->drag.type == DRAGGING_SCR_X) ||
- (scr_x > 0 &&
- scr_x < get_horz_scrollbar_len(bw) &&
- scr_y > 0 &&
- scr_y < SCROLLBAR_WIDTH &&
- bw->drag.type == DRAGGING_NONE)) {
- /* Start a scrollbar drag, or continue existing drag */
- status = scrollbar_mouse_status_to_message(
- scrollbar_mouse_action(
- bw->scroll_x, mouse,
- scr_x, scr_y));
- pointer = BROWSER_POINTER_DEFAULT;
-
- if (status != NULL) {
- browser_window_set_status(bw, status);
- }
-
- browser_window_set_pointer(bw, pointer);
- return;
- }
- }
-
- /* Browser window's vertical scrollbar */
- if (bw->scroll_y != NULL) {
- int scr_x, scr_y;
- browser_window_get_scrollbar_pos(bw, false, &scr_x, &scr_y);
- scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
- scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
-
- if ((bw->drag.type == DRAGGING_SCR_Y) ||
- (scr_y > 0 &&
- scr_y < get_vert_scrollbar_len(bw) &&
- scr_x > 0 &&
- scr_x < SCROLLBAR_WIDTH &&
- bw->drag.type == DRAGGING_NONE)) {
- /* Start a scrollbar drag, or continue existing drag */
- status = scrollbar_mouse_status_to_message(
- scrollbar_mouse_action(
- bw->scroll_y, mouse,
- scr_x, scr_y));
- pointer = BROWSER_POINTER_DEFAULT;
-
- if (status != NULL) {
- browser_window_set_status(bw, status);
- }
-
- browser_window_set_pointer(bw, pointer);
- return;
- }
- }
-
- if (bw->drag.type == DRAGGING_FRAME) {
- browser_window_resize_frame(bw, bw->x + x, bw->y + y);
- } else if (bw->drag.type == DRAGGING_PAGE_SCROLL) {
- /* mouse movement since drag started */
- struct rect rect;
-
- rect.x0 = bw->drag.start_x - x;
- rect.y0 = bw->drag.start_y - y;
-
- /* new scroll offsets */
- rect.x0 += bw->drag.start_scroll_x;
- rect.y0 += bw->drag.start_scroll_y;
-
- bw->drag.start_scroll_x = rect.x1 = rect.x0;
- bw->drag.start_scroll_y = rect.y1 = rect.y0;
-
- browser_window_set_scroll(bw, &rect);
- } else {
- assert(c != NULL);
- content_mouse_track(c, bw, mouse, x, y);
- }
+ browser_window_mouse_track_internal(bw,
+ mouse,
+ x / bw->scale,
+ y / bw->scale);
}
-
/* exported interface documented in netsurf/browser_window.h */
void
browser_window_mouse_click(struct browser_window *bw,
@@ -3454,8 +3476,8 @@ browser_window_mouse_click(struct browser_window *bw,
{
browser_window_mouse_click_internal(bw,
mouse,
- (x / bw->scale),
- (y / bw->scale));
+ x / bw->scale,
+ y / bw->scale);
}
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 59b6210..9168518 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -2438,8 +2438,8 @@ static BOOL ami_gui_event(void *w)
break;
}
- x = (ULONG)((gwin->win->MouseX - bbox->Left) /
gwin->gw->scale);
- y = (ULONG)((gwin->win->MouseY - bbox->Top) /
gwin->gw->scale);
+ x = (ULONG)((gwin->win->MouseX - bbox->Left));
+ y = (ULONG)((gwin->win->MouseY - bbox->Top));
ami_get_hscroll_pos(gwin, (ULONG *)&xs);
ami_get_vscroll_pos(gwin, (ULONG *)&ys);
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index 020c86f..dda2556 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -518,9 +518,10 @@ void nsbeos_dispatch_event(BMessage *message)
if (gui->mouse.state & BROWSER_MOUSE_MOD_2 && !ctrl)
gui->mouse.state ^= BROWSER_MOUSE_MOD_2;
- browser_window_mouse_track(gui->bw,
(browser_mouse_state)gui->mouse.state,
- (int)(where.x / gui->scale),
- (int)(where.y / gui->scale));
+ browser_window_mouse_track(gui->bw,
+
(browser_mouse_state)gui->mouse.state,
+ (int)(where.x),
+ (int)(where.y));
gui->last_x = (int)where.x;
gui->last_y = (int)where.y;
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 9572234..588f05b 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -702,7 +702,7 @@ fb_browser_window_click(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
gui_drag.state = GUI_DRAG_NONE;
/* Tell core */
- browser_window_mouse_track(gw->bw, 0, x/scale,
y/scale);
+ browser_window_mouse_track(gw->bw, 0, x, y);
break;
}
/* This is a click;
@@ -723,7 +723,7 @@ fb_browser_window_click(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
}
/* Tell core */
- browser_window_mouse_track(gw->bw, 0, x/scale,
y/scale);
+ browser_window_mouse_track(gw->bw, 0, x, y);
break;
}
/* This is a click;
@@ -781,7 +781,6 @@ fb_browser_window_move(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
browser_mouse_state mouse = 0;
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
- float scale = browser_window_get_scale(gw->bw);
int x = cbi->x + bwidget->scrollx;
int y = cbi->y + bwidget->scrolly;
@@ -812,7 +811,7 @@ fb_browser_window_move(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
mouse |= BROWSER_MOUSE_HOLDING_2;
}
- browser_window_mouse_track(gw->bw, mouse, x/scale, y/scale);
+ browser_window_mouse_track(gw->bw, mouse, x, y);
return 0;
}
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 341eb5d..ece586a 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -325,9 +325,7 @@ static gboolean nsgtk_window_motion_notify_event(GtkWidget
*widget,
if (g->mouse.state & BROWSER_MOUSE_MOD_2 && !ctrl)
g->mouse.state ^= BROWSER_MOUSE_MOD_2;
- browser_window_mouse_track(g->bw, g->mouse.state,
- event->x / browser_window_get_scale(g->bw),
- event->y / browser_window_get_scale(g->bw));
+ browser_window_mouse_track(g->bw, g->mouse.state, event->x, event->y);
return TRUE;
}
@@ -416,13 +414,9 @@ static gboolean
nsgtk_window_button_release_event(GtkWidget *widget,
g->mouse.state ^= BROWSER_MOUSE_MOD_2;
if (g->mouse.state & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) {
- browser_window_mouse_click(g->bw, g->mouse.state,
- event->x,
- event->y);
+ browser_window_mouse_click(g->bw, g->mouse.state, event->x,
event->y);
} else {
- browser_window_mouse_track(g->bw, 0,
- event->x / browser_window_get_scale(g->bw),
- event->y / browser_window_get_scale(g->bw));
+ browser_window_mouse_track(g->bw, 0, event->x, event->y);
}
g->mouse.state = 0;
diff --git a/frontends/riscos/textselection.c b/frontends/riscos/textselection.c
index e5be277..2300330 100644
--- a/frontends/riscos/textselection.c
+++ b/frontends/riscos/textselection.c
@@ -188,8 +188,9 @@ static void ro_gui_selection_drag_end(wimp_dragged *drag,
void *data)
return;
}
- if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0,
&pos))
+ if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0,
&pos)) {
browser_window_mouse_track(g->bw, 0, pos.x, pos.y);
+ }
}
/**
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index c439b65..84029ef 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -3831,8 +3831,9 @@ static void ro_gui_window_scroll_end(wimp_dragged *drag,
void *data)
ro_warn_user("WimpError", error->errmess);
}
- if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0,
&pos))
- browser_window_mouse_track(g->bw, 0, pos.x/g->scale,
pos.y/g->scale);
+ if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0,
&pos)) {
+ browser_window_mouse_track(g->bw, 0, pos.x, pos.y);
+ }
}
@@ -4388,11 +4389,14 @@ void ro_gui_window_mouse_at(wimp_pointer *pointer, void
*data)
os_coord pos;
struct gui_window *g = (struct gui_window *) data;
- if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y,
&pos))
- browser_window_mouse_track(g->bw,
- ro_gui_mouse_drag_state(pointer->buttons,
+ if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y,
&pos)) {
+ browser_window_mouse_track(
+ g->bw,
+ ro_gui_mouse_drag_state(pointer->buttons,
wimp_BUTTON_DOUBLE_CLICK_DRAG),
- pos.x/g->scale, pos.y/g->scale);
+ pos.x,
+ pos.y);
+ }
}
diff --git a/frontends/windows/drawable.c b/frontends/windows/drawable.c
index 3cded7e..9383f70 100644
--- a/frontends/windows/drawable.c
+++ b/frontends/windows/drawable.c
@@ -378,10 +378,15 @@ nsws_drawable_paint(struct gui_window *gw, HWND hwnd)
clip.x1 = ps.rcPaint.right;
clip.y1 = ps.rcPaint.bottom;
+ /**
+ * \todo work out why the heck scroll needs scaling
+ */
+
browser_window_redraw(gw->bw,
-gw->scrollx / gw->scale,
-gw->scrolly / gw->scale,
- &clip, &ctx);
+ &clip,
+ &ctx);
}
EndPaint(hwnd, &ps);
@@ -425,19 +430,21 @@ nsws_drawable_mouseup(struct gui_window *gw,
if ((gw->mouse->state & click) != 0) {
NSLOG(netsurf, INFO,
- "mouse click bw %p, state 0x%x, x %f, y %f", gw->bw,
- gw->mouse->state, (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ "mouse click bw %p, state 0x%x, x %d, y %d",
+ gw->bw,
+ gw->mouse->state,
+ x + gw->scrollx,
+ y + gw->scrolly);
browser_window_mouse_click(gw->bw,
gw->mouse->state,
- (x + gw->scrollx),
- (y + gw->scrolly));
+ x + gw->scrollx,
+ y + gw->scrolly);
} else {
browser_window_mouse_track(gw->bw,
0,
- (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ x + gw->scrollx,
+ y + gw->scrolly);
}
gw->mouse->state = 0;
@@ -468,16 +475,19 @@ nsws_drawable_mousedown(struct gui_window *gw,
if ((GetKeyState(VK_MENU) & 0x8000) == 0x8000)
gw->mouse->state |= BROWSER_MOUSE_MOD_3;
- gw->mouse->pressed_x = (x + gw->scrollx) / gw->scale;
- gw->mouse->pressed_y = (y + gw->scrolly) / gw->scale;
+ gw->mouse->pressed_x = x + gw->scrollx;
+ gw->mouse->pressed_y = y + gw->scrolly;
- NSLOG(netsurf, INFO, "mouse click bw %p, state %x, x %f, y %f",
- gw->bw, gw->mouse->state, (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ NSLOG(netsurf, INFO, "mouse click bw %p, state %x, x %d, y %d",
+ gw->bw,
+ gw->mouse->state,
+ x + gw->scrollx,
+ y + gw->scrolly);
- browser_window_mouse_click(gw->bw, gw->mouse->state,
- (x + gw->scrollx),
- (y + gw->scrolly));
+ browser_window_mouse_click(gw->bw,
+ gw->mouse->state,
+ x + gw->scrollx,
+ y + gw->scrolly);
return 0;
}
@@ -496,9 +506,9 @@ nsws_drawable_mousemove(struct gui_window *gw, int x, int y)
if ((gw == NULL) || (gw->mouse == NULL) || (gw->bw == NULL))
return 0;
- /* scale co-ordinates */
- x = (x + gw->scrollx) ;
- y = (y + gw->scrolly);
+ /* add scroll offsets */
+ x = x + gw->scrollx;
+ y = y + gw->scrolly;
/* if mouse button held down and pointer moved more than
* minimum distance drag is happening */
@@ -535,7 +545,7 @@ nsws_drawable_mousemove(struct gui_window *gw, int x, int y)
gw->mouse->state &= ~BROWSER_MOUSE_MOD_3;
- browser_window_mouse_track(gw->bw, gw->mouse->state, x/ gw->scale, y/
gw->scale);
+ browser_window_mouse_track(gw->bw, gw->mouse->state, x, y);
return 0;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=0a8ed41a1ad470bb62c908d0dc6272c1c541a1f2
commit 0a8ed41a1ad470bb62c908d0dc6272c1c541a1f2
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
change browser_window_mouse_click to use unscaled coordinates
this means frontends no longer need to scale mouse click events thus
simplifying their implementation.
diff --git a/content/handlers/html/html_interaction.c
b/content/handlers/html/html_interaction.c
index 985b325..b6b9de8 100644
--- a/content/handlers/html/html_interaction.c
+++ b/content/handlers/html/html_interaction.c
@@ -843,14 +843,14 @@ void html_mouse_action(struct content *c, struct
browser_window *bw,
browser_window_get_position(iframe, false, &pos_x, &pos_y);
- pos_x /= scale;
- pos_y /= scale;
-
if (mouse & BROWSER_MOUSE_CLICK_1 ||
- mouse & BROWSER_MOUSE_CLICK_2) {
+ mouse & BROWSER_MOUSE_CLICK_2) {
browser_window_mouse_click(iframe, mouse,
- x - pos_x, y - pos_y);
+ (x * scale) - pos_x,
+ (y * scale) - pos_y);
} else {
+ pos_x /= scale;
+ pos_y /= scale;
browser_window_mouse_track(iframe, mouse,
x - pos_x, y - pos_y);
}
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index ccab57f..659eabd 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -1485,6 +1485,137 @@ browser_window_mouse_drag_end(struct browser_window *bw,
}
}
+/**
+ * Process mouse click event
+ *
+ * \param bw The browsing context receiving the event
+ * \param mouse The mouse event state
+ * \param x The scaled x co-ordinate of the event
+ * \param y The scaled y co-ordinate of the event
+ */
+static void
+browser_window_mouse_click_internal(struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
+{
+ hlcache_handle *c = bw->current_content;
+ const char *status = NULL;
+ browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
+
+ if (bw->children) {
+ /* Browser window has children (frames) */
+ struct browser_window *child;
+ int cur_child;
+ int children = bw->rows * bw->cols;
+
+ for (cur_child = 0; cur_child < children; cur_child++) {
+
+ child = &bw->children[cur_child];
+
+ if ((x < child->x) ||
+ (y < child->y) ||
+ (child->x + child->width < x) ||
+ (child->y + child->height < y)) {
+ /* Click not in this child */
+ continue;
+ }
+
+ /* It's this child that contains the click; pass it
+ * on to child. */
+ browser_window_mouse_click_internal(child, mouse,
+ x - child->x + scrollbar_get_offset(
+ child->scroll_x),
+ y - child->y + scrollbar_get_offset(
+ child->scroll_y));
+
+ /* Mouse action was for this child, we're done */
+ return;
+ }
+
+ return;
+ }
+
+ if (!c)
+ return;
+
+ if (bw->scroll_x != NULL) {
+ int scr_x, scr_y;
+ browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
+ scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
+ scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
+
+ if (scr_x > 0 && scr_x < get_horz_scrollbar_len(bw) &&
+ scr_y > 0 && scr_y < SCROLLBAR_WIDTH) {
+ status = scrollbar_mouse_status_to_message(
+ scrollbar_mouse_action(
+ bw->scroll_x, mouse,
+ scr_x, scr_y));
+ pointer = BROWSER_POINTER_DEFAULT;
+
+ if (status != NULL)
+ browser_window_set_status(bw, status);
+
+ browser_window_set_pointer(bw, pointer);
+ return;
+ }
+ }
+
+ if (bw->scroll_y != NULL) {
+ int scr_x, scr_y;
+ browser_window_get_scrollbar_pos(bw, false, &scr_x, &scr_y);
+ scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
+ scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
+
+ if (scr_y > 0 && scr_y < get_vert_scrollbar_len(bw) &&
+ scr_x > 0 && scr_x < SCROLLBAR_WIDTH) {
+ status = scrollbar_mouse_status_to_message(
+ scrollbar_mouse_action(
+ bw->scroll_y, mouse,
+ scr_x, scr_y));
+ pointer = BROWSER_POINTER_DEFAULT;
+
+ if (status != NULL)
+ browser_window_set_status(bw, status);
+
+ browser_window_set_pointer(bw, pointer);
+ return;
+ }
+ }
+
+ switch (content_get_type(c)) {
+ case CONTENT_HTML:
+ case CONTENT_TEXTPLAIN:
+ {
+ /* Give bw focus */
+ struct browser_window *root_bw = browser_window_get_root(bw);
+ if (bw != root_bw->focus) {
+ browser_window_remove_caret(bw, false);
+ browser_window_set_selection(bw, false, true);
+ root_bw->focus = bw;
+ }
+
+ /* Pass mouse action to content */
+ content_mouse_action(c, bw, mouse, x, y);
+ }
+ break;
+ default:
+ if (mouse & BROWSER_MOUSE_MOD_2) {
+ if (mouse & BROWSER_MOUSE_DRAG_2) {
+ guit->window->drag_save_object(bw->window, c,
+
GUI_SAVE_OBJECT_NATIVE);
+ } else if (mouse & BROWSER_MOUSE_DRAG_1) {
+ guit->window->drag_save_object(bw->window, c,
+
GUI_SAVE_OBJECT_ORIG);
+ }
+ } else if (mouse & (BROWSER_MOUSE_DRAG_1 |
+ BROWSER_MOUSE_DRAG_2)) {
+ browser_window_page_drag_start(bw, x, y);
+ browser_window_set_pointer(bw, BROWSER_POINTER_MOVE);
+ }
+ break;
+ }
+}
+
/* exported interface, documented in netsurf/browser_window.h */
nserror
@@ -3316,124 +3447,15 @@ void browser_window_mouse_track(struct browser_window
*bw,
/* exported interface documented in netsurf/browser_window.h */
-void browser_window_mouse_click(struct browser_window *bw,
- browser_mouse_state mouse, int x, int y)
-{
- hlcache_handle *c = bw->current_content;
- const char *status = NULL;
- browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
-
- if (bw->children) {
- /* Browser window has children (frames) */
- struct browser_window *child;
- int cur_child;
- int children = bw->rows * bw->cols;
-
- for (cur_child = 0; cur_child < children; cur_child++) {
-
- child = &bw->children[cur_child];
-
- if (x < child->x || y < child->y ||
- child->x + child->width < x ||
- child->y + child->height < y) {
- /* Click not in this child */
- continue;
- }
-
- /* It's this child that contains the click; pass it
- * on to child. */
- browser_window_mouse_click(child, mouse,
- x - child->x +
scrollbar_get_offset(
- child->scroll_x),
- y - child->y +
scrollbar_get_offset(
- child->scroll_y));
-
- /* Mouse action was for this child, we're done */
- return;
- }
-
- return;
- }
-
- if (!c)
- return;
-
- if (bw->scroll_x != NULL) {
- int scr_x, scr_y;
- browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
- scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
- scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
-
- if (scr_x > 0 && scr_x < get_horz_scrollbar_len(bw) &&
- scr_y > 0 && scr_y < SCROLLBAR_WIDTH) {
- status = scrollbar_mouse_status_to_message(
- scrollbar_mouse_action(
- bw->scroll_x, mouse,
- scr_x, scr_y));
- pointer = BROWSER_POINTER_DEFAULT;
-
- if (status != NULL)
- browser_window_set_status(bw, status);
-
- browser_window_set_pointer(bw, pointer);
- return;
- }
- }
-
- if (bw->scroll_y != NULL) {
- int scr_x, scr_y;
- browser_window_get_scrollbar_pos(bw, false, &scr_x, &scr_y);
- scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
- scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
-
- if (scr_y > 0 && scr_y < get_vert_scrollbar_len(bw) &&
- scr_x > 0 && scr_x < SCROLLBAR_WIDTH) {
- status = scrollbar_mouse_status_to_message(
- scrollbar_mouse_action(
- bw->scroll_y, mouse,
- scr_x, scr_y));
- pointer = BROWSER_POINTER_DEFAULT;
-
- if (status != NULL)
- browser_window_set_status(bw, status);
-
- browser_window_set_pointer(bw, pointer);
- return;
- }
- }
-
- switch (content_get_type(c)) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- {
- /* Give bw focus */
- struct browser_window *root_bw = browser_window_get_root(bw);
- if (bw != root_bw->focus) {
- browser_window_remove_caret(bw, false);
- browser_window_set_selection(bw, false, true);
- root_bw->focus = bw;
- }
-
- /* Pass mouse action to content */
- content_mouse_action(c, bw, mouse, x, y);
- }
- break;
- default:
- if (mouse & BROWSER_MOUSE_MOD_2) {
- if (mouse & BROWSER_MOUSE_DRAG_2) {
- guit->window->drag_save_object(bw->window, c,
-
GUI_SAVE_OBJECT_NATIVE);
- } else if (mouse & BROWSER_MOUSE_DRAG_1) {
- guit->window->drag_save_object(bw->window, c,
-
GUI_SAVE_OBJECT_ORIG);
- }
- } else if (mouse & (BROWSER_MOUSE_DRAG_1 |
- BROWSER_MOUSE_DRAG_2)) {
- browser_window_page_drag_start(bw, x, y);
- browser_window_set_pointer(bw, BROWSER_POINTER_MOVE);
- }
- break;
- }
+void
+browser_window_mouse_click(struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
+{
+ browser_window_mouse_click_internal(bw,
+ mouse,
+ (x / bw->scale),
+ (y / bw->scale));
}
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index e90f0d3..59b6210 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -2499,8 +2499,8 @@ static BOOL ami_gui_event(void *w)
return FALSE;
}
- x = (ULONG)((gwin->win->MouseX - bbox->Left) /
gwin->gw->scale);
- y = (ULONG)((gwin->win->MouseY - bbox->Top) /
gwin->gw->scale);
+ x = (ULONG)(gwin->win->MouseX - bbox->Left);
+ y = (ULONG)(gwin->win->MouseY - bbox->Top);
ami_get_hscroll_pos(gwin, (ULONG *)&xs);
ami_get_vscroll_pos(gwin, (ULONG *)&ys);
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index 6c12e4e..020c86f 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -562,8 +562,8 @@ void nsbeos_dispatch_event(BMessage *message)
if (mods & B_CONTROL_KEY)
gui->mouse.state |= BROWSER_MOUSE_MOD_2;
- gui->mouse.pressed_x = where.x / gui->scale;
- gui->mouse.pressed_y = where.y / gui->scale;
+ gui->mouse.pressed_x = where.x;
+ gui->mouse.pressed_y = where.y;
// make sure the view is in focus
if (view && view->LockLooper()) {
@@ -624,8 +624,8 @@ void nsbeos_dispatch_event(BMessage *message)
if (gui->mouse.state &
(BROWSER_MOUSE_CLICK_1|BROWSER_MOUSE_CLICK_2))
browser_window_mouse_click(gui->bw,
(browser_mouse_state)gui->mouse.state,
- where.x / gui->scale,
- where.y / gui->scale);
+ where.x,
+ where.y);
else
browser_window_mouse_track(gui->bw,
(browser_mouse_state)0,
where.x, where.y);
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 09216ee..9572234 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -628,8 +628,8 @@ fb_browser_window_click(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
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) / scale;
- int y = (cbi->y + bwidget->scrolly) / scale;
+ int x = cbi->x + bwidget->scrollx;
+ int y = cbi->y + bwidget->scrolly;
uint64_t time_now;
static struct {
enum { CLICK_SINGLE, CLICK_DOUBLE, CLICK_TRIPLE } type;
@@ -640,8 +640,7 @@ fb_browser_window_click(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- NSLOG(netsurf, INFO, "browser window clicked at %d,%d", cbi->x,
- cbi->y);
+ NSLOG(netsurf, INFO, "browser window clicked at %d,%d", cbi->x, cbi->y);
switch (cbi->event->type) {
case NSFB_EVENT_KEY_DOWN:
@@ -666,14 +665,14 @@ 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, y,
+ if (browser_window_scroll_at_point(gw->bw, x/scale,
y/scale,
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, y,
+ if (browser_window_scroll_at_point(gw->bw, x/scale,
y/scale,
0, 100) == false)
widget_scroll_y(gw, 100, false);
break;
@@ -703,7 +702,7 @@ fb_browser_window_click(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
gui_drag.state = GUI_DRAG_NONE;
/* Tell core */
- browser_window_mouse_track(gw->bw, 0, x, y);
+ browser_window_mouse_track(gw->bw, 0, x/scale,
y/scale);
break;
}
/* This is a click;
@@ -724,7 +723,7 @@ fb_browser_window_click(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
}
/* Tell core */
- browser_window_mouse_track(gw->bw, 0, x, y);
+ browser_window_mouse_track(gw->bw, 0, x/scale,
y/scale);
break;
}
/* This is a click;
@@ -783,8 +782,8 @@ fb_browser_window_move(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
float scale = browser_window_get_scale(gw->bw);
- int x = (cbi->x + bwidget->scrollx) / scale;
- int y = (cbi->y + bwidget->scrolly) / scale;
+ int x = cbi->x + bwidget->scrollx;
+ int y = cbi->y + bwidget->scrolly;
if (gui_drag.state == GUI_DRAG_PRESSED &&
(abs(x - gui_drag.x) > 5 ||
@@ -813,7 +812,7 @@ fb_browser_window_move(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
mouse |= BROWSER_MOUSE_HOLDING_2;
}
- browser_window_mouse_track(gw->bw, mouse, x, y);
+ browser_window_mouse_track(gw->bw, mouse, x/scale, y/scale);
return 0;
}
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 8c46fd8..6b6f936 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -2715,10 +2715,14 @@ void nsgtk_scaffolding_context_menu(struct
nsgtk_scaffolding *g,
gdouble y)
{
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(nsgtk_get_browser_window(g->top_level),
- x, y, ¤t_menu_features);
+ browser_window_get_features(bw, x/scale, y/scale,
¤t_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 aab4597..341eb5d 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -332,8 +332,13 @@ static gboolean nsgtk_window_motion_notify_event(GtkWidget
*widget,
return TRUE;
}
-static gboolean nsgtk_window_button_press_event(GtkWidget *widget,
- GdkEventButton *event, gpointer data)
+/**
+ * GTK signal handler for button-press-event on layout
+ */
+static gboolean
+nsgtk_window_button_press_event(GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer data)
{
struct gui_window *g = data;
@@ -341,8 +346,8 @@ static gboolean nsgtk_window_button_press_event(GtkWidget
*widget,
gtk_widget_grab_focus(GTK_WIDGET(g->layout));
nsgtk_local_history_hide();
- g->mouse.pressed_x = event->x / browser_window_get_scale(g->bw);
- g->mouse.pressed_y = event->y / browser_window_get_scale(g->bw);
+ g->mouse.pressed_x = event->x;
+ g->mouse.pressed_y = event->y;
switch (event->button) {
case 1: /* Left button, usually. Pass to core as BUTTON 1. */
@@ -382,8 +387,10 @@ static gboolean nsgtk_window_button_press_event(GtkWidget
*widget,
g->last_x = event->x;
g->last_y = event->y;
- browser_window_mouse_click(g->bw, g->mouse.state, g->mouse.pressed_x,
- g->mouse.pressed_y);
+ browser_window_mouse_click(g->bw,
+ g->mouse.state,
+ g->mouse.pressed_x,
+ g->mouse.pressed_y);
return TRUE;
}
@@ -410,8 +417,8 @@ static gboolean nsgtk_window_button_release_event(GtkWidget
*widget,
if (g->mouse.state & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) {
browser_window_mouse_click(g->bw, g->mouse.state,
- event->x / browser_window_get_scale(g->bw),
- event->y / browser_window_get_scale(g->bw));
+ event->x,
+ event->y);
} else {
browser_window_mouse_track(g->bw, 0,
event->x / browser_window_get_scale(g->bw),
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index b949c02..c439b65 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -1152,10 +1152,12 @@ 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, pos.y,
- step_x, step_y);
+ 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,
+ step_x,
+ step_y);
/* If the core didn't do the scrolling, handle it via the Wimp.
* Windows which contain frames can only be scrolled by the core,
@@ -1249,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, pos.y, &cont);
+ browser_window_get_features(g->bw, pos.x/g->scale, pos.y/g->scale,
&cont);
switch (c) {
case IS_WIMP_KEY + wimp_KEY_F1: /* Help. */
@@ -2169,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, pos.y, &cont);
+ browser_window_get_features(bw, pos.x/g->scale,
pos.y/g->scale, &cont);
current_menu_main = cont.main;
current_menu_object = cont.object;
@@ -3830,7 +3832,7 @@ static void ro_gui_window_scroll_end(wimp_dragged *drag,
void *data)
}
if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0,
&pos))
- browser_window_mouse_track(g->bw, 0, pos.x, pos.y);
+ browser_window_mouse_track(g->bw, 0, pos.x/g->scale,
pos.y/g->scale);
}
@@ -4362,7 +4364,7 @@ bool ro_gui_window_dataload(struct gui_window *g,
wimp_message *message)
message->data.data_xfer.pos.y, &pos))
return false;
- if (browser_window_drop_file_at_point(g->bw, pos.x, pos.y,
+ if (browser_window_drop_file_at_point(g->bw, pos.x/g->scale,
pos.y/g->scale,
message->data.data_xfer.file_name) == false)
return false;
@@ -4390,7 +4392,7 @@ void ro_gui_window_mouse_at(wimp_pointer *pointer, void
*data)
browser_window_mouse_track(g->bw,
ro_gui_mouse_drag_state(pointer->buttons,
wimp_BUTTON_DOUBLE_CLICK_DRAG),
- pos.x, pos.y);
+ pos.x/g->scale, pos.y/g->scale);
}
@@ -4753,8 +4755,8 @@ ro_gui_window_to_window_pos(struct gui_window *g, int x,
int y, os_coord *pos)
ro_warn_user("WimpError", error->errmess);
return false;
}
- pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 / g->scale;
- pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 / g->scale;
+ pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 ;
+ pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 ;
return true;
}
diff --git a/frontends/windows/drawable.c b/frontends/windows/drawable.c
index e1fdbc8..3cded7e 100644
--- a/frontends/windows/drawable.c
+++ b/frontends/windows/drawable.c
@@ -431,8 +431,8 @@ nsws_drawable_mouseup(struct gui_window *gw,
browser_window_mouse_click(gw->bw,
gw->mouse->state,
- (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ (x + gw->scrollx),
+ (y + gw->scrolly));
} else {
browser_window_mouse_track(gw->bw,
0,
@@ -476,8 +476,8 @@ nsws_drawable_mousedown(struct gui_window *gw,
(y + gw->scrolly) / gw->scale);
browser_window_mouse_click(gw->bw, gw->mouse->state,
- (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ (x + gw->scrollx),
+ (y + gw->scrolly));
return 0;
}
@@ -497,8 +497,8 @@ nsws_drawable_mousemove(struct gui_window *gw, int x, int y)
return 0;
/* scale co-ordinates */
- x = (x + gw->scrollx) / gw->scale;
- y = (y + gw->scrolly) / gw->scale;
+ x = (x + gw->scrollx) ;
+ y = (y + gw->scrolly);
/* if mouse button held down and pointer moved more than
* minimum distance drag is happening */
@@ -535,7 +535,7 @@ nsws_drawable_mousemove(struct gui_window *gw, int x, int y)
gw->mouse->state &= ~BROWSER_MOUSE_MOD_3;
- browser_window_mouse_track(gw->bw, gw->mouse->state, x, y);
+ browser_window_mouse_track(gw->bw, gw->mouse->state, x/ gw->scale, y/
gw->scale);
return 0;
}
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/html.c | 15 +-
content/handlers/html/html_interaction.c | 11 +-
desktop/browser_window.c | 983 ++++++++++++++++--------------
frontends/amiga/gui.c | 17 +-
frontends/atari/deskmenu.c | 8 +-
frontends/beos/window.cpp | 15 +-
frontends/framebuffer/gui.c | 42 +-
frontends/gtk/scaffolding.c | 12 +-
frontends/gtk/window.c | 36 +-
frontends/riscos/textselection.c | 3 +-
frontends/riscos/window.c | 32 +-
frontends/windows/drawable.c | 48 +-
frontends/windows/window.c | 43 +-
include/netsurf/browser_window.h | 5 +-
14 files changed, 673 insertions(+), 597 deletions(-)
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index a27ebd7..1bbb4c6 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/content/handlers/html/html_interaction.c
b/content/handlers/html/html_interaction.c
index 985b325..992796c 100644
--- a/content/handlers/html/html_interaction.c
+++ b/content/handlers/html/html_interaction.c
@@ -843,16 +843,15 @@ void html_mouse_action(struct content *c, struct
browser_window *bw,
browser_window_get_position(iframe, false, &pos_x, &pos_y);
- pos_x /= scale;
- pos_y /= scale;
-
if (mouse & BROWSER_MOUSE_CLICK_1 ||
- mouse & BROWSER_MOUSE_CLICK_2) {
+ mouse & BROWSER_MOUSE_CLICK_2) {
browser_window_mouse_click(iframe, mouse,
- x - pos_x, y - pos_y);
+ (x * scale) - pos_x,
+ (y * scale) - pos_y);
} else {
browser_window_mouse_track(iframe, mouse,
- x - pos_x, y - pos_y);
+ (x * scale) - pos_x,
+ (y * scale) - pos_y);
}
} else if (html_object_box) {
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index ccab57f..56b9477 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -28,6 +28,11 @@
* Browser window creation and manipulation implementation.
*/
+/** smallest scale that can be applied to a browser window*/
+#define SCALE_MINIMUM 0.2
+/** largests scale that can be applied to a browser window*/
+#define SCALE_MAXIMUM 10.0
+
#include "utils/config.h"
#include <assert.h>
@@ -1337,32 +1342,40 @@ static bool frag_scroll(struct browser_window *bw)
* Set browser window scale.
*
* \param bw Browser window.
- * \param scale value.
+ * \param absolute scale value.
+ * \return NSERROR_OK on success else error code
*/
-static void
+static nserror
browser_window_set_scale_internal(struct browser_window *bw, float scale)
{
int i;
- hlcache_handle *c;
+ nserror res = NSERROR_OK;
- if (fabs(bw->scale-scale) < 0.0001)
- return;
+ /* do not apply tiny changes in scale */
+ if (fabs(bw->scale - scale) < 0.0001)
+ return res;
bw->scale = scale;
- c = bw->current_content;
- if (c != NULL) {
- if (content_can_reformat(c) == false) {
+ if (bw->current_content != NULL) {
+ if (content_can_reformat(bw->current_content) == false) {
browser_window_update(bw, false);
} else {
- browser_window_schedule_reformat(bw);
+ res = browser_window_schedule_reformat(bw);
}
}
- for (i = 0; i < (bw->cols * bw->rows); i++)
- browser_window_set_scale_internal(&bw->children[i], scale);
- for (i = 0; i < bw->iframe_count; i++)
- browser_window_set_scale_internal(&bw->iframes[i], scale);
+ /* scale frames */
+ for (i = 0; i < (bw->cols * bw->rows); i++) {
+ res = browser_window_set_scale_internal(&bw->children[i],
scale);
+ }
+
+ /* sale iframes */
+ for (i = 0; i < bw->iframe_count; i++) {
+ res = browser_window_set_scale_internal(&bw->iframes[i], scale);
+ }
+
+ return res;
}
@@ -1485,148 +1498,501 @@ browser_window_mouse_drag_end(struct browser_window
*bw,
}
}
-
-/* exported interface, documented in netsurf/browser_window.h */
-nserror
-browser_window_get_name(struct browser_window *bw, const char **out_name)
+/**
+ * Process mouse click event
+ *
+ * \param bw The browsing context receiving the event
+ * \param mouse The mouse event state
+ * \param x The scaled x co-ordinate of the event
+ * \param y The scaled y co-ordinate of the event
+ */
+static void
+browser_window_mouse_click_internal(struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
{
- assert(bw != NULL);
+ hlcache_handle *c = bw->current_content;
+ const char *status = NULL;
+ browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
- *out_name = bw->name;
+ if (bw->children) {
+ /* Browser window has children (frames) */
+ struct browser_window *child;
+ int cur_child;
+ int children = bw->rows * bw->cols;
- return NSERROR_OK;
-}
+ for (cur_child = 0; cur_child < children; cur_child++) {
+ child = &bw->children[cur_child];
-/* exported interface, documented in netsurf/browser_window.h */
-nserror
-browser_window_set_name(struct browser_window *bw, const char *name)
-{
- char *nname = NULL;
+ if ((x < child->x) ||
+ (y < child->y) ||
+ (child->x + child->width < x) ||
+ (child->y + child->height < y)) {
+ /* Click not in this child */
+ continue;
+ }
- assert(bw != NULL);
+ /* It's this child that contains the click; pass it
+ * on to child. */
+ browser_window_mouse_click_internal(child, mouse,
+ x - child->x + scrollbar_get_offset(
+ child->scroll_x),
+ y - child->y + scrollbar_get_offset(
+ child->scroll_y));
- if (name != NULL) {
- nname = strdup(name);
- if (nname == NULL) {
- return NSERROR_NOMEM;
+ /* Mouse action was for this child, we're done */
+ return;
}
- }
- if (bw->name != NULL) {
- free(bw->name);
+ return;
}
- bw->name = nname;
+ if (!c)
+ return;
- return NSERROR_OK;
-}
+ if (bw->scroll_x != NULL) {
+ int scr_x, scr_y;
+ browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
+ scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
+ scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
+ if (scr_x > 0 && scr_x < get_horz_scrollbar_len(bw) &&
+ scr_y > 0 && scr_y < SCROLLBAR_WIDTH) {
+ status = scrollbar_mouse_status_to_message(
+ scrollbar_mouse_action(
+ bw->scroll_x, mouse,
+ scr_x, scr_y));
+ pointer = BROWSER_POINTER_DEFAULT;
-/* exported interface, documented in netsurf/browser_window.h */
-bool
-browser_window_redraw(struct browser_window *bw,
- int x, int y,
- const struct rect *clip,
- const struct redraw_context *ctx)
-{
- struct redraw_context new_ctx = *ctx;
- int width = 0;
- int height = 0;
- bool plot_ok = true;
- content_type content_type;
- struct content_redraw_data data;
- struct rect content_clip;
- nserror res;
+ if (status != NULL)
+ browser_window_set_status(bw, status);
- if (bw == NULL) {
- NSLOG(netsurf, INFO, "NULL browser window");
- return false;
+ browser_window_set_pointer(bw, pointer);
+ return;
+ }
}
- if ((bw->current_content == NULL) &&
- (bw->children == NULL)) {
- /* Browser window has no content, render blank fill */
- ctx->plot->clip(ctx, clip);
- return (ctx->plot->rectangle(ctx, plot_style_fill_white, clip)
== NSERROR_OK);
+ if (bw->scroll_y != NULL) {
+ int scr_x, scr_y;
+ browser_window_get_scrollbar_pos(bw, false, &scr_x, &scr_y);
+ scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
+ scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
+
+ if (scr_y > 0 && scr_y < get_vert_scrollbar_len(bw) &&
+ scr_x > 0 && scr_x < SCROLLBAR_WIDTH) {
+ status = scrollbar_mouse_status_to_message(
+ scrollbar_mouse_action(
+ bw->scroll_y, mouse,
+ scr_x, scr_y));
+ pointer = BROWSER_POINTER_DEFAULT;
+
+ if (status != NULL)
+ browser_window_set_status(bw, status);
+
+ browser_window_set_pointer(bw, pointer);
+ return;
+ }
}
- /* Browser window has content OR children (frames) */
- if ((bw->window != NULL) &&
- (ctx->plot->option_knockout)) {
- /* Root browser window: start knockout */
- knockout_plot_start(ctx, &new_ctx);
+ switch (content_get_type(c)) {
+ case CONTENT_HTML:
+ case CONTENT_TEXTPLAIN:
+ {
+ /* Give bw focus */
+ struct browser_window *root_bw = browser_window_get_root(bw);
+ if (bw != root_bw->focus) {
+ browser_window_remove_caret(bw, false);
+ browser_window_set_selection(bw, false, true);
+ root_bw->focus = bw;
+ }
+
+ /* Pass mouse action to content */
+ content_mouse_action(c, bw, mouse, x, y);
+ }
+ break;
+ default:
+ if (mouse & BROWSER_MOUSE_MOD_2) {
+ if (mouse & BROWSER_MOUSE_DRAG_2) {
+ guit->window->drag_save_object(bw->window, c,
+
GUI_SAVE_OBJECT_NATIVE);
+ } else if (mouse & BROWSER_MOUSE_DRAG_1) {
+ guit->window->drag_save_object(bw->window, c,
+
GUI_SAVE_OBJECT_ORIG);
+ }
+ } else if (mouse & (BROWSER_MOUSE_DRAG_1 |
+ BROWSER_MOUSE_DRAG_2)) {
+ browser_window_page_drag_start(bw, x, y);
+ browser_window_set_pointer(bw, BROWSER_POINTER_MOVE);
+ }
+ break;
}
+}
- new_ctx.plot->clip(ctx, clip);
- /* Handle redraw of any browser window children */
+/**
+ * Process mouse movement event
+ *
+ * \param bw The browsing context receiving the event
+ * \param mouse The mouse event state
+ * \param x The scaled x co-ordinate of the event
+ * \param y The scaled y co-ordinate of the event
+ */
+static void
+browser_window_mouse_track_internal(struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
+{
+ hlcache_handle *c = bw->current_content;
+ const char *status = NULL;
+ browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
+
+ if (bw->window != NULL && bw->drag.window && bw != bw->drag.window) {
+ /* This is the root browser window and there's an active drag
+ * in a sub window.
+ * Pass the mouse action straight on to that bw. */
+ struct browser_window *drag_bw = bw->drag.window;
+ int off_x = 0;
+ int off_y = 0;
+
+ browser_window_get_position(drag_bw, true, &off_x, &off_y);
+
+ if (drag_bw->browser_window_type == BROWSER_WINDOW_FRAME) {
+ browser_window_mouse_track_internal(drag_bw, mouse,
+ x - off_x, y - off_y);
+
+ } else if (drag_bw->browser_window_type ==
+ BROWSER_WINDOW_IFRAME) {
+ browser_window_mouse_track_internal(drag_bw, mouse,
+ x - off_x / bw->scale,
+ y - off_y / bw->scale);
+ }
+ return;
+ }
+
if (bw->children) {
+ /* Browser window has children (frames) */
struct browser_window *child;
int cur_child;
int children = bw->rows * bw->cols;
- if (bw->window != NULL) {
- /* Root browser window; start with blank fill */
- plot_ok &= (new_ctx.plot->rectangle(ctx,
-
plot_style_fill_white,
- clip) ==
NSERROR_OK);
- }
-
- /* Loop through all children of bw */
for (cur_child = 0; cur_child < children; cur_child++) {
- /* Set current child */
- child = &bw->children[cur_child];
-
- /* Get frame edge box in global coordinates */
- content_clip.x0 = (x + child->x) * child->scale;
- content_clip.y0 = (y + child->y) * child->scale;
- content_clip.x1 = content_clip.x0 +
- child->width * child->scale;
- content_clip.y1 = content_clip.y0 +
- child->height * child->scale;
- /* Intersect it with clip rectangle */
- if (content_clip.x0 < clip->x0)
- content_clip.x0 = clip->x0;
- if (content_clip.y0 < clip->y0)
- content_clip.y0 = clip->y0;
- if (clip->x1 < content_clip.x1)
- content_clip.x1 = clip->x1;
- if (clip->y1 < content_clip.y1)
- content_clip.y1 = clip->y1;
+ child = &bw->children[cur_child];
- /* Skip this frame if it lies outside clip rectangle */
- if (content_clip.x0 >= content_clip.x1 ||
- content_clip.y0 >= content_clip.y1)
+ if ((x < child->x) ||
+ (y < child->y) ||
+ (child->x + child->width < x) ||
+ (child->y + child->height < y)) {
+ /* Click not in this child */
continue;
+ }
- /* Redraw frame */
- plot_ok &= browser_window_redraw(child,
- x + child->x,
- y + child->y,
- &content_clip,
- &new_ctx);
- }
+ /* It's this child that contains the mouse; pass
+ * mouse action on to child */
+ browser_window_mouse_track_internal(
+ child,
+ mouse,
+ x - child->x +
scrollbar_get_offset(child->scroll_x),
+ y - child->y +
scrollbar_get_offset(child->scroll_y));
- /* Nothing else to redraw for browser windows with children;
- * cleanup and return
- */
- if (bw->window != NULL && ctx->plot->option_knockout) {
- /* Root browser window: knockout end */
- knockout_plot_end(ctx);
+ /* Mouse action was for this child, we're done */
+ return;
}
- return plot_ok;
+ /* Odd if we reached here, but nothing else can use the click
+ * when there are children. */
+ return;
}
- /* Handle browser windows with content to redraw */
+ if (c == NULL && bw->drag.type != DRAGGING_FRAME) {
+ return;
+ }
- content_type = content_get_type(bw->current_content);
- if (content_type != CONTENT_HTML && content_type != CONTENT_TEXTPLAIN) {
- /* Set render area according to scale */
- width = content_get_width(bw->current_content) * bw->scale;
- height = content_get_height(bw->current_content) * bw->scale;
+ if (bw->drag.type != DRAGGING_NONE && !mouse) {
+ browser_window_mouse_drag_end(bw, mouse, x, y);
+ }
+
+ /* Browser window's horizontal scrollbar */
+ if (bw->scroll_x != NULL && bw->drag.type != DRAGGING_SCR_Y) {
+ int scr_x, scr_y;
+ browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
+ scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
+ scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
+
+ if ((bw->drag.type == DRAGGING_SCR_X) ||
+ (scr_x > 0 &&
+ scr_x < get_horz_scrollbar_len(bw) &&
+ scr_y > 0 &&
+ scr_y < SCROLLBAR_WIDTH &&
+ bw->drag.type == DRAGGING_NONE)) {
+ /* Start a scrollbar drag, or continue existing drag */
+ status = scrollbar_mouse_status_to_message(
+ scrollbar_mouse_action(
+ bw->scroll_x, mouse,
+ scr_x, scr_y));
+ pointer = BROWSER_POINTER_DEFAULT;
+
+ if (status != NULL) {
+ browser_window_set_status(bw, status);
+ }
+
+ browser_window_set_pointer(bw, pointer);
+ return;
+ }
+ }
+
+ /* Browser window's vertical scrollbar */
+ if (bw->scroll_y != NULL) {
+ int scr_x, scr_y;
+ browser_window_get_scrollbar_pos(bw, false, &scr_x, &scr_y);
+ scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
+ scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
+
+ if ((bw->drag.type == DRAGGING_SCR_Y) ||
+ (scr_y > 0 &&
+ scr_y < get_vert_scrollbar_len(bw) &&
+ scr_x > 0 &&
+ scr_x < SCROLLBAR_WIDTH &&
+ bw->drag.type == DRAGGING_NONE)) {
+ /* Start a scrollbar drag, or continue existing drag */
+ status = scrollbar_mouse_status_to_message(
+ scrollbar_mouse_action(
+ bw->scroll_y, mouse,
+ scr_x, scr_y));
+ pointer = BROWSER_POINTER_DEFAULT;
+
+ if (status != NULL) {
+ browser_window_set_status(bw, status);
+ }
+
+ browser_window_set_pointer(bw, pointer);
+ return;
+ }
+ }
+
+ if (bw->drag.type == DRAGGING_FRAME) {
+ browser_window_resize_frame(bw, bw->x + x, bw->y + y);
+ } else if (bw->drag.type == DRAGGING_PAGE_SCROLL) {
+ /* mouse movement since drag started */
+ struct rect rect;
+
+ rect.x0 = bw->drag.start_x - x;
+ rect.y0 = bw->drag.start_y - y;
+
+ /* new scroll offsets */
+ rect.x0 += bw->drag.start_scroll_x;
+ rect.y0 += bw->drag.start_scroll_y;
+
+ bw->drag.start_scroll_x = rect.x1 = rect.x0;
+ bw->drag.start_scroll_y = rect.y1 = rect.y0;
+
+ browser_window_set_scroll(bw, &rect);
+ } else {
+ assert(c != NULL);
+ content_mouse_track(c, bw, mouse, x, y);
+ }
+}
+
+
+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)
+{
+ assert(bw != NULL);
+
+ *out_name = bw->name;
+
+ return NSERROR_OK;
+}
+
+
+/* exported interface, documented in netsurf/browser_window.h */
+nserror
+browser_window_set_name(struct browser_window *bw, const char *name)
+{
+ char *nname = NULL;
+
+ assert(bw != NULL);
+
+ if (name != NULL) {
+ nname = strdup(name);
+ if (nname == NULL) {
+ return NSERROR_NOMEM;
+ }
+ }
+
+ if (bw->name != NULL) {
+ free(bw->name);
+ }
+
+ bw->name = nname;
+
+ return NSERROR_OK;
+}
+
+
+/* exported interface, documented in netsurf/browser_window.h */
+bool
+browser_window_redraw(struct browser_window *bw,
+ int x, int y,
+ const struct rect *clip,
+ const struct redraw_context *ctx)
+{
+ struct redraw_context new_ctx = *ctx;
+ int width = 0;
+ int height = 0;
+ bool plot_ok = true;
+ content_type content_type;
+ struct content_redraw_data data;
+ struct rect content_clip;
+ nserror res;
+
+ if (bw == NULL) {
+ NSLOG(netsurf, INFO, "NULL browser window");
+ return false;
+ }
+
+ if ((bw->current_content == NULL) &&
+ (bw->children == NULL)) {
+ /* Browser window has no content, render blank fill */
+ ctx->plot->clip(ctx, clip);
+ return (ctx->plot->rectangle(ctx, plot_style_fill_white, clip)
== NSERROR_OK);
+ }
+
+ /* Browser window has content OR children (frames) */
+ if ((bw->window != NULL) &&
+ (ctx->plot->option_knockout)) {
+ /* Root browser window: start knockout */
+ knockout_plot_start(ctx, &new_ctx);
+ }
+
+ new_ctx.plot->clip(ctx, clip);
+
+ /* Handle redraw of any browser window children */
+ if (bw->children) {
+ struct browser_window *child;
+ int cur_child;
+ int children = bw->rows * bw->cols;
+
+ if (bw->window != NULL) {
+ /* Root browser window; start with blank fill */
+ plot_ok &= (new_ctx.plot->rectangle(ctx,
+
plot_style_fill_white,
+ clip) ==
NSERROR_OK);
+ }
+
+ /* Loop through all children of bw */
+ for (cur_child = 0; cur_child < children; cur_child++) {
+ /* Set current child */
+ child = &bw->children[cur_child];
+
+ /* Get frame edge box in global coordinates */
+ content_clip.x0 = (x + child->x) * child->scale;
+ content_clip.y0 = (y + child->y) * child->scale;
+ content_clip.x1 = content_clip.x0 +
+ child->width * child->scale;
+ content_clip.y1 = content_clip.y0 +
+ child->height * child->scale;
+
+ /* Intersect it with clip rectangle */
+ if (content_clip.x0 < clip->x0)
+ content_clip.x0 = clip->x0;
+ if (content_clip.y0 < clip->y0)
+ content_clip.y0 = clip->y0;
+ if (clip->x1 < content_clip.x1)
+ content_clip.x1 = clip->x1;
+ if (clip->y1 < content_clip.y1)
+ content_clip.y1 = clip->y1;
+
+ /* Skip this frame if it lies outside clip rectangle */
+ if (content_clip.x0 >= content_clip.x1 ||
+ content_clip.y0 >= content_clip.y1)
+ continue;
+
+ /* Redraw frame */
+ plot_ok &= browser_window_redraw(child,
+ x + child->x,
+ y + child->y,
+ &content_clip,
+ &new_ctx);
+ }
+
+ /* Nothing else to redraw for browser windows with children;
+ * cleanup and return
+ */
+ if (bw->window != NULL && ctx->plot->option_knockout) {
+ /* Root browser window: knockout end */
+ knockout_plot_end(ctx);
+ }
+
+ return plot_ok;
+ }
+
+ /* Handle browser windows with content to redraw */
+
+ content_type = content_get_type(bw->current_content);
+ if (content_type != CONTENT_HTML && content_type != CONTENT_TEXTPLAIN) {
+ /* Set render area according to scale */
+ width = content_get_width(bw->current_content) * bw->scale;
+ height = content_get_height(bw->current_content) * bw->scale;
/* Non-HTML may not fill viewport to extents, so plot white
* background fill */
@@ -1948,7 +2314,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);
}
@@ -1958,53 +2325,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);
}
@@ -2957,9 +3282,7 @@ nserror browser_window_schedule_reformat(struct
browser_window *bw)
return NSERROR_BAD_PARAMETER;
}
- guit->misc->schedule(0, scheduled_reformat, bw);
-
- return NSERROR_OK;
+ return guit->misc->schedule(0, scheduled_reformat, bw);
}
@@ -2992,18 +3315,44 @@ void browser_window_reformat(struct browser_window *bw,
bool background,
/* exported interface documented in netsurf/browser_window.h */
-void browser_window_set_scale(struct browser_window *bw, float scale, bool all)
+nserror
+browser_window_set_scale(struct browser_window *bw, float scale, bool absolute)
{
- while (bw->parent && all) {
+ nserror res;
+
+ /* get top browser window */
+ while (bw->parent) {
bw = bw->parent;
}
- browser_window_set_scale_internal(bw, scale);
+ if (absolute) {
+ /* ensure "close" to 1 is treated as 1 */
+ if (scale > 0.95 && scale < 1.05) {
+ scale = 1.0;
+ }
+ } else {
+ /* ensure "close" to 1 is treated as 1 */
+ if ((scale + bw->scale) > (1.01 - scale) &&
+ (scale + bw->scale) < (0.99 + scale)) {
+ scale = 1.0;
+ } else {
+ scale += bw->scale;
+ }
+ }
+
+ /* clamp range between 0.1 and 10 (10% and 1000%) */
+ if (scale < SCALE_MINIMUM) {
+ scale = SCALE_MINIMUM;
+ } else if (scale > SCALE_MAXIMUM) {
+ scale = SCALE_MAXIMUM;
+ }
- if (bw->parent)
- bw = bw->parent;
+ res = browser_window_set_scale_internal(bw, scale);
+ if (res == NSERROR_OK) {
+ browser_window_recalculate_frameset(bw);
+ }
- browser_window_recalculate_frameset(bw);
+ return res;
}
@@ -3161,279 +3510,27 @@ browser_window_find_target(struct browser_window *bw,
/* exported interface documented in netsurf/browser_window.h */
-void browser_window_mouse_track(struct browser_window *bw,
- browser_mouse_state mouse, int x, int y)
+void
+browser_window_mouse_track(struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
{
- hlcache_handle *c = bw->current_content;
- const char *status = NULL;
- browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
-
- if (bw->window != NULL && bw->drag.window && bw != bw->drag.window) {
- /* This is the root browser window and there's an active drag
- * in a sub window.
- * Pass the mouse action straight on to that bw. */
- struct browser_window *drag_bw = bw->drag.window;
- int off_x = 0;
- int off_y = 0;
-
- browser_window_get_position(drag_bw, true, &off_x, &off_y);
-
- if (drag_bw->browser_window_type == BROWSER_WINDOW_FRAME) {
- browser_window_mouse_track(drag_bw, mouse,
- x - off_x, y - off_y);
-
- } else if (drag_bw->browser_window_type ==
- BROWSER_WINDOW_IFRAME) {
- browser_window_mouse_track(drag_bw, mouse,
- x - off_x / bw->scale,
- y - off_y / bw->scale);
- }
- return;
- }
-
- if (bw->children) {
- /* Browser window has children (frames) */
- struct browser_window *child;
- int cur_child;
- int children = bw->rows * bw->cols;
-
- for (cur_child = 0; cur_child < children; cur_child++) {
-
- child = &bw->children[cur_child];
-
- if (x < child->x || y < child->y ||
- child->x + child->width < x ||
- child->y + child->height < y) {
- /* Click not in this child */
- continue;
- }
-
- /* It's this child that contains the mouse; pass
- * mouse action on to child */
- browser_window_mouse_track(child, mouse,
- x - child->x +
scrollbar_get_offset(
- child->scroll_x),
- y - child->y +
scrollbar_get_offset(
- child->scroll_y));
-
- /* Mouse action was for this child, we're done */
- return;
- }
-
- /* Odd if we reached here, but nothing else can use the click
- * when there are children. */
- return;
- }
-
- if (c == NULL && bw->drag.type != DRAGGING_FRAME) {
- return;
- }
-
- if (bw->drag.type != DRAGGING_NONE && !mouse) {
- browser_window_mouse_drag_end(bw, mouse, x, y);
- }
-
- /* Browser window's horizontal scrollbar */
- if (bw->scroll_x != NULL && bw->drag.type != DRAGGING_SCR_Y) {
- int scr_x, scr_y;
- browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
- scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
- scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
-
- if ((bw->drag.type == DRAGGING_SCR_X) ||
- (scr_x > 0 &&
- scr_x < get_horz_scrollbar_len(bw) &&
- scr_y > 0 &&
- scr_y < SCROLLBAR_WIDTH &&
- bw->drag.type == DRAGGING_NONE)) {
- /* Start a scrollbar drag, or continue existing drag */
- status = scrollbar_mouse_status_to_message(
- scrollbar_mouse_action(
- bw->scroll_x, mouse,
- scr_x, scr_y));
- pointer = BROWSER_POINTER_DEFAULT;
-
- if (status != NULL) {
- browser_window_set_status(bw, status);
- }
-
- browser_window_set_pointer(bw, pointer);
- return;
- }
- }
-
- /* Browser window's vertical scrollbar */
- if (bw->scroll_y != NULL) {
- int scr_x, scr_y;
- browser_window_get_scrollbar_pos(bw, false, &scr_x, &scr_y);
- scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
- scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
-
- if ((bw->drag.type == DRAGGING_SCR_Y) ||
- (scr_y > 0 &&
- scr_y < get_vert_scrollbar_len(bw) &&
- scr_x > 0 &&
- scr_x < SCROLLBAR_WIDTH &&
- bw->drag.type == DRAGGING_NONE)) {
- /* Start a scrollbar drag, or continue existing drag */
- status = scrollbar_mouse_status_to_message(
- scrollbar_mouse_action(
- bw->scroll_y, mouse,
- scr_x, scr_y));
- pointer = BROWSER_POINTER_DEFAULT;
-
- if (status != NULL) {
- browser_window_set_status(bw, status);
- }
-
- browser_window_set_pointer(bw, pointer);
- return;
- }
- }
-
- if (bw->drag.type == DRAGGING_FRAME) {
- browser_window_resize_frame(bw, bw->x + x, bw->y + y);
- } else if (bw->drag.type == DRAGGING_PAGE_SCROLL) {
- /* mouse movement since drag started */
- struct rect rect;
-
- rect.x0 = bw->drag.start_x - x;
- rect.y0 = bw->drag.start_y - y;
-
- /* new scroll offsets */
- rect.x0 += bw->drag.start_scroll_x;
- rect.y0 += bw->drag.start_scroll_y;
-
- bw->drag.start_scroll_x = rect.x1 = rect.x0;
- bw->drag.start_scroll_y = rect.y1 = rect.y0;
-
- browser_window_set_scroll(bw, &rect);
- } else {
- assert(c != NULL);
- content_mouse_track(c, bw, mouse, x, y);
- }
+ browser_window_mouse_track_internal(bw,
+ mouse,
+ x / bw->scale,
+ y / bw->scale);
}
-
/* exported interface documented in netsurf/browser_window.h */
-void browser_window_mouse_click(struct browser_window *bw,
- browser_mouse_state mouse, int x, int y)
-{
- hlcache_handle *c = bw->current_content;
- const char *status = NULL;
- browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
-
- if (bw->children) {
- /* Browser window has children (frames) */
- struct browser_window *child;
- int cur_child;
- int children = bw->rows * bw->cols;
-
- for (cur_child = 0; cur_child < children; cur_child++) {
-
- child = &bw->children[cur_child];
-
- if (x < child->x || y < child->y ||
- child->x + child->width < x ||
- child->y + child->height < y) {
- /* Click not in this child */
- continue;
- }
-
- /* It's this child that contains the click; pass it
- * on to child. */
- browser_window_mouse_click(child, mouse,
- x - child->x +
scrollbar_get_offset(
- child->scroll_x),
- y - child->y +
scrollbar_get_offset(
- child->scroll_y));
-
- /* Mouse action was for this child, we're done */
- return;
- }
-
- return;
- }
-
- if (!c)
- return;
-
- if (bw->scroll_x != NULL) {
- int scr_x, scr_y;
- browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
- scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
- scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
-
- if (scr_x > 0 && scr_x < get_horz_scrollbar_len(bw) &&
- scr_y > 0 && scr_y < SCROLLBAR_WIDTH) {
- status = scrollbar_mouse_status_to_message(
- scrollbar_mouse_action(
- bw->scroll_x, mouse,
- scr_x, scr_y));
- pointer = BROWSER_POINTER_DEFAULT;
-
- if (status != NULL)
- browser_window_set_status(bw, status);
-
- browser_window_set_pointer(bw, pointer);
- return;
- }
- }
-
- if (bw->scroll_y != NULL) {
- int scr_x, scr_y;
- browser_window_get_scrollbar_pos(bw, false, &scr_x, &scr_y);
- scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
- scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
-
- if (scr_y > 0 && scr_y < get_vert_scrollbar_len(bw) &&
- scr_x > 0 && scr_x < SCROLLBAR_WIDTH) {
- status = scrollbar_mouse_status_to_message(
- scrollbar_mouse_action(
- bw->scroll_y, mouse,
- scr_x, scr_y));
- pointer = BROWSER_POINTER_DEFAULT;
-
- if (status != NULL)
- browser_window_set_status(bw, status);
-
- browser_window_set_pointer(bw, pointer);
- return;
- }
- }
-
- switch (content_get_type(c)) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- {
- /* Give bw focus */
- struct browser_window *root_bw = browser_window_get_root(bw);
- if (bw != root_bw->focus) {
- browser_window_remove_caret(bw, false);
- browser_window_set_selection(bw, false, true);
- root_bw->focus = bw;
- }
-
- /* Pass mouse action to content */
- content_mouse_action(c, bw, mouse, x, y);
- }
- break;
- default:
- if (mouse & BROWSER_MOUSE_MOD_2) {
- if (mouse & BROWSER_MOUSE_DRAG_2) {
- guit->window->drag_save_object(bw->window, c,
-
GUI_SAVE_OBJECT_NATIVE);
- } else if (mouse & BROWSER_MOUSE_DRAG_1) {
- guit->window->drag_save_object(bw->window, c,
-
GUI_SAVE_OBJECT_ORIG);
- }
- } else if (mouse & (BROWSER_MOUSE_DRAG_1 |
- BROWSER_MOUSE_DRAG_2)) {
- browser_window_page_drag_start(bw, x, y);
- browser_window_set_pointer(bw, BROWSER_POINTER_MOVE);
- }
- break;
- }
+void
+browser_window_mouse_click(struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
+{
+ browser_window_mouse_click_internal(bw,
+ mouse,
+ x / bw->scale,
+ y / bw->scale);
}
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index e90f0d3..54273ee 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;
@@ -2438,8 +2437,8 @@ static BOOL ami_gui_event(void *w)
break;
}
- x = (ULONG)((gwin->win->MouseX - bbox->Left) /
gwin->gw->scale);
- y = (ULONG)((gwin->win->MouseY - bbox->Top) /
gwin->gw->scale);
+ x = (ULONG)((gwin->win->MouseX - bbox->Left));
+ y = (ULONG)((gwin->win->MouseY - bbox->Top));
ami_get_hscroll_pos(gwin, (ULONG *)&xs);
ami_get_vscroll_pos(gwin, (ULONG *)&ys);
@@ -2499,8 +2498,8 @@ static BOOL ami_gui_event(void *w)
return FALSE;
}
- x = (ULONG)((gwin->win->MouseX - bbox->Left) /
gwin->gw->scale);
- y = (ULONG)((gwin->win->MouseY - bbox->Top) /
gwin->gw->scale);
+ x = (ULONG)(gwin->win->MouseX - bbox->Left);
+ y = (ULONG)(gwin->win->MouseY - bbox->Top);
ami_get_hscroll_pos(gwin, (ULONG *)&xs);
ami_get_vscroll_pos(gwin, (ULONG *)&ys);
@@ -3928,14 +3927,14 @@ int ami_gui_count_windows(int window, int *tabs)
*/
void ami_gui_set_scale(struct gui_window *gw, float scale)
{
- if(scale <= 0.0) return;
- gw->scale = scale;
browser_window_set_scale(gw->bw, scale, true);
+ gw->scale = browser_window_get_scale(gw->bw);
}
void ami_gui_adjust_scale(struct gui_window *gw, float adjustment)
{
- ami_gui_set_scale(gw, gw->scale + adjustment);
+ browser_window_set_scale(gw->bw, adjustment, false);
+ gw->scale = browser_window_get_scale(gw->bw);
}
void ami_gui_switch_to_new_tab(struct gui_window_2 *gwin)
diff --git a/frontends/atari/deskmenu.c b/frontends/atari/deskmenu.c
index 34d7be0..4426415 100644
--- a/frontends/atari/deskmenu.c
+++ b/frontends/atari/deskmenu.c
@@ -387,9 +387,7 @@ static void __CDECL menu_inc_scale(short item, short title,
void *data)
if(input_window == NULL)
return;
- browser_window_set_scale(input_window->browser->bw,
-
browser_window_get_scale(input_window->browser->bw) + 0.25,
- true);
+ browser_window_set_scale(input_window->browser->bw, +0.25, false);
}
@@ -398,9 +396,7 @@ static void __CDECL menu_dec_scale(short item, short title,
void *data)
if(input_window == NULL)
return;
- browser_window_set_scale(input_window->browser->bw,
-
browser_window_get_scale(input_window->browser->bw) - 0.25,
- true);
+ browser_window_set_scale(input_window->browser->bw, -0.25, false);
}
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index 6c12e4e..dda2556 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -518,9 +518,10 @@ void nsbeos_dispatch_event(BMessage *message)
if (gui->mouse.state & BROWSER_MOUSE_MOD_2 && !ctrl)
gui->mouse.state ^= BROWSER_MOUSE_MOD_2;
- browser_window_mouse_track(gui->bw,
(browser_mouse_state)gui->mouse.state,
- (int)(where.x / gui->scale),
- (int)(where.y / gui->scale));
+ browser_window_mouse_track(gui->bw,
+
(browser_mouse_state)gui->mouse.state,
+ (int)(where.x),
+ (int)(where.y));
gui->last_x = (int)where.x;
gui->last_y = (int)where.y;
@@ -562,8 +563,8 @@ void nsbeos_dispatch_event(BMessage *message)
if (mods & B_CONTROL_KEY)
gui->mouse.state |= BROWSER_MOUSE_MOD_2;
- gui->mouse.pressed_x = where.x / gui->scale;
- gui->mouse.pressed_y = where.y / gui->scale;
+ gui->mouse.pressed_x = where.x;
+ gui->mouse.pressed_y = where.y;
// make sure the view is in focus
if (view && view->LockLooper()) {
@@ -624,8 +625,8 @@ void nsbeos_dispatch_event(BMessage *message)
if (gui->mouse.state &
(BROWSER_MOUSE_CLICK_1|BROWSER_MOUSE_CLICK_2))
browser_window_mouse_click(gui->bw,
(browser_mouse_state)gui->mouse.state,
- where.x / gui->scale,
- where.y / gui->scale);
+ where.x,
+ where.y);
else
browser_window_mouse_track(gui->bw,
(browser_mouse_state)0,
where.x, where.y);
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 09216ee..7413739 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -627,9 +627,8 @@ 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) / scale;
- int y = (cbi->y + bwidget->scrolly) / scale;
+ int x = cbi->x + bwidget->scrollx;
+ int y = cbi->y + bwidget->scrolly;
uint64_t time_now;
static struct {
enum { CLICK_SINGLE, CLICK_DOUBLE, CLICK_TRIPLE } type;
@@ -640,8 +639,7 @@ fb_browser_window_click(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- NSLOG(netsurf, INFO, "browser window clicked at %d,%d", cbi->x,
- cbi->y);
+ NSLOG(netsurf, INFO, "browser window clicked at %d,%d", cbi->x, cbi->y);
switch (cbi->event->type) {
case NSFB_EVENT_KEY_DOWN:
@@ -666,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, y,
- 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, y,
- 0, 100) == false)
+ if (browser_window_scroll_at_point(gw->bw,
+ x, y,
+ 0, 100) == false)
widget_scroll_y(gw, 100, false);
break;
@@ -782,9 +782,8 @@ fb_browser_window_move(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
browser_mouse_state mouse = 0;
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
- float scale = browser_window_get_scale(gw->bw);
- int x = (cbi->x + bwidget->scrollx) / scale;
- int y = (cbi->y + bwidget->scrolly) / scale;
+ int x = cbi->x + bwidget->scrollx;
+ int y = cbi->y + bwidget->scrolly;
if (gui_drag.state == GUI_DRAG_PRESSED &&
(abs(x - gui_drag.x) > 5 ||
@@ -913,34 +912,21 @@ fb_browser_window_input(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
case NSFB_KEY_MINUS:
if (modifier & FBTK_MOD_RCTRL ||
modifier & FBTK_MOD_LCTRL) {
- float scale = browser_window_get_scale(gw->bw);
- scale -= 0.1;
- if (scale < 0.1) {
- scale = 0.1;
- }
- if (scale > 0.95 && scale < 1.05) {
- scale = 1;
- }
- browser_window_set_scale(gw->bw, scale, true);
+ browser_window_set_scale(gw->bw, -0.1, false);
}
break;
case NSFB_KEY_EQUALS: /* PLUS */
if (modifier & FBTK_MOD_RCTRL ||
modifier & FBTK_MOD_LCTRL) {
- float scale = browser_window_get_scale(gw->bw);
- scale += 0.1;
- if (scale > 0.95 && scale < 1.05) {
- scale = 1;
- }
- browser_window_set_scale(gw->bw, scale, true);
+ browser_window_set_scale(gw->bw, 0.1, false);
}
break;
case NSFB_KEY_0:
if (modifier & FBTK_MOD_RCTRL ||
modifier & FBTK_MOD_LCTRL) {
- browser_window_set_scale(gw->bw, 1, true);
+ browser_window_set_scale(gw->bw, 1.0, true);
}
break;
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 8c46fd8..6194989 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1255,9 +1255,8 @@ MULTIHANDLER(preferences)
MULTIHANDLER(zoomplus)
{
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- float old_scale = nsgtk_get_scale_for_gui(g->top_level);
- browser_window_set_scale(bw, old_scale + 0.05, true);
+ browser_window_set_scale(bw, 0.05, false);
return TRUE;
}
@@ -1274,9 +1273,8 @@ MULTIHANDLER(zoomnormal)
MULTIHANDLER(zoomminus)
{
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- float old_scale = nsgtk_get_scale_for_gui(g->top_level);
- browser_window_set_scale(bw, old_scale - 0.05, true);
+ browser_window_set_scale(bw, -0.05, false);
return TRUE;
}
@@ -2715,10 +2713,12 @@ void nsgtk_scaffolding_context_menu(struct
nsgtk_scaffolding *g,
gdouble y)
{
GtkMenu *gtkmenu;
+ struct browser_window *bw;
+
+ bw = nsgtk_get_browser_window(g->top_level);
/* update the global context menu features */
- browser_window_get_features(nsgtk_get_browser_window(g->top_level),
- x, y, ¤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 */
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index aab4597..5e8538f 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -325,15 +325,18 @@ static gboolean
nsgtk_window_motion_notify_event(GtkWidget *widget,
if (g->mouse.state & BROWSER_MOUSE_MOD_2 && !ctrl)
g->mouse.state ^= BROWSER_MOUSE_MOD_2;
- browser_window_mouse_track(g->bw, g->mouse.state,
- event->x / browser_window_get_scale(g->bw),
- event->y / browser_window_get_scale(g->bw));
+ browser_window_mouse_track(g->bw, g->mouse.state, event->x, event->y);
return TRUE;
}
-static gboolean nsgtk_window_button_press_event(GtkWidget *widget,
- GdkEventButton *event, gpointer data)
+/**
+ * GTK signal handler for button-press-event on layout
+ */
+static gboolean
+nsgtk_window_button_press_event(GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer data)
{
struct gui_window *g = data;
@@ -341,8 +344,8 @@ static gboolean nsgtk_window_button_press_event(GtkWidget
*widget,
gtk_widget_grab_focus(GTK_WIDGET(g->layout));
nsgtk_local_history_hide();
- g->mouse.pressed_x = event->x / browser_window_get_scale(g->bw);
- g->mouse.pressed_y = event->y / browser_window_get_scale(g->bw);
+ g->mouse.pressed_x = event->x;
+ g->mouse.pressed_y = event->y;
switch (event->button) {
case 1: /* Left button, usually. Pass to core as BUTTON 1. */
@@ -382,8 +385,10 @@ static gboolean nsgtk_window_button_press_event(GtkWidget
*widget,
g->last_x = event->x;
g->last_y = event->y;
- browser_window_mouse_click(g->bw, g->mouse.state, g->mouse.pressed_x,
- g->mouse.pressed_y);
+ browser_window_mouse_click(g->bw,
+ g->mouse.state,
+ g->mouse.pressed_x,
+ g->mouse.pressed_y);
return TRUE;
}
@@ -409,13 +414,9 @@ static gboolean
nsgtk_window_button_release_event(GtkWidget *widget,
g->mouse.state ^= BROWSER_MOUSE_MOD_2;
if (g->mouse.state & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) {
- browser_window_mouse_click(g->bw, g->mouse.state,
- event->x / browser_window_get_scale(g->bw),
- event->y / browser_window_get_scale(g->bw));
+ browser_window_mouse_click(g->bw, g->mouse.state, event->x,
event->y);
} else {
- browser_window_mouse_track(g->bw, 0,
- event->x / browser_window_get_scale(g->bw),
- event->y / browser_window_get_scale(g->bw));
+ browser_window_mouse_track(g->bw, 0, event->x, event->y);
}
g->mouse.state = 0;
@@ -466,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/textselection.c b/frontends/riscos/textselection.c
index e5be277..2300330 100644
--- a/frontends/riscos/textselection.c
+++ b/frontends/riscos/textselection.c
@@ -188,8 +188,9 @@ static void ro_gui_selection_drag_end(wimp_dragged *drag,
void *data)
return;
}
- if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0,
&pos))
+ if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0,
&pos)) {
browser_window_mouse_track(g->bw, 0, pos.x, pos.y);
+ }
}
/**
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index b949c02..5a46529 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -1152,10 +1152,12 @@ 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, pos.y,
- step_x, step_y);
+ ro_gui_window_to_window_pos(g, pointer.pos.x, pointer.pos.y, &pos))
+ handled = browser_window_scroll_at_point(g->bw,
+ pos.x,
+ pos.y,
+ step_x,
+ step_y);
/* If the core didn't do the scrolling, handle it via the Wimp.
* Windows which contain frames can only be scrolled by the core,
@@ -3829,8 +3831,9 @@ static void ro_gui_window_scroll_end(wimp_dragged *drag,
void *data)
ro_warn_user("WimpError", error->errmess);
}
- if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0,
&pos))
+ if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0,
&pos)) {
browser_window_mouse_track(g->bw, 0, pos.x, pos.y);
+ }
}
@@ -4343,8 +4346,8 @@ nserror ro_gui_window_set_url(struct gui_window *g, nsurl
*url)
/* exported interface documented in riscos/window.h */
void ro_gui_window_set_scale(struct gui_window *g, float scale)
{
- g->scale = scale;
browser_window_set_scale(g->bw, scale, true);
+ g->scale = browser_window_get_scale(g->bw);
}
@@ -4362,7 +4365,7 @@ bool ro_gui_window_dataload(struct gui_window *g,
wimp_message *message)
message->data.data_xfer.pos.y, &pos))
return false;
- if (browser_window_drop_file_at_point(g->bw, pos.x, pos.y,
+ if (browser_window_drop_file_at_point(g->bw, pos.x/g->scale,
pos.y/g->scale,
message->data.data_xfer.file_name) == false)
return false;
@@ -4386,11 +4389,14 @@ void ro_gui_window_mouse_at(wimp_pointer *pointer, void
*data)
os_coord pos;
struct gui_window *g = (struct gui_window *) data;
- if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y,
&pos))
- browser_window_mouse_track(g->bw,
- ro_gui_mouse_drag_state(pointer->buttons,
+ if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y,
&pos)) {
+ browser_window_mouse_track(
+ g->bw,
+ ro_gui_mouse_drag_state(pointer->buttons,
wimp_BUTTON_DOUBLE_CLICK_DRAG),
- pos.x, pos.y);
+ pos.x,
+ pos.y);
+ }
}
@@ -4753,8 +4759,8 @@ ro_gui_window_to_window_pos(struct gui_window *g, int x,
int y, os_coord *pos)
ro_warn_user("WimpError", error->errmess);
return false;
}
- pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 / g->scale;
- pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 / g->scale;
+ pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 ;
+ pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 ;
return true;
}
diff --git a/frontends/windows/drawable.c b/frontends/windows/drawable.c
index e1fdbc8..9383f70 100644
--- a/frontends/windows/drawable.c
+++ b/frontends/windows/drawable.c
@@ -378,10 +378,15 @@ nsws_drawable_paint(struct gui_window *gw, HWND hwnd)
clip.x1 = ps.rcPaint.right;
clip.y1 = ps.rcPaint.bottom;
+ /**
+ * \todo work out why the heck scroll needs scaling
+ */
+
browser_window_redraw(gw->bw,
-gw->scrollx / gw->scale,
-gw->scrolly / gw->scale,
- &clip, &ctx);
+ &clip,
+ &ctx);
}
EndPaint(hwnd, &ps);
@@ -425,19 +430,21 @@ nsws_drawable_mouseup(struct gui_window *gw,
if ((gw->mouse->state & click) != 0) {
NSLOG(netsurf, INFO,
- "mouse click bw %p, state 0x%x, x %f, y %f", gw->bw,
- gw->mouse->state, (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ "mouse click bw %p, state 0x%x, x %d, y %d",
+ gw->bw,
+ gw->mouse->state,
+ x + gw->scrollx,
+ y + gw->scrolly);
browser_window_mouse_click(gw->bw,
gw->mouse->state,
- (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ x + gw->scrollx,
+ y + gw->scrolly);
} else {
browser_window_mouse_track(gw->bw,
0,
- (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ x + gw->scrollx,
+ y + gw->scrolly);
}
gw->mouse->state = 0;
@@ -468,16 +475,19 @@ nsws_drawable_mousedown(struct gui_window *gw,
if ((GetKeyState(VK_MENU) & 0x8000) == 0x8000)
gw->mouse->state |= BROWSER_MOUSE_MOD_3;
- gw->mouse->pressed_x = (x + gw->scrollx) / gw->scale;
- gw->mouse->pressed_y = (y + gw->scrolly) / gw->scale;
+ gw->mouse->pressed_x = x + gw->scrollx;
+ gw->mouse->pressed_y = y + gw->scrolly;
- NSLOG(netsurf, INFO, "mouse click bw %p, state %x, x %f, y %f",
- gw->bw, gw->mouse->state, (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ NSLOG(netsurf, INFO, "mouse click bw %p, state %x, x %d, y %d",
+ gw->bw,
+ gw->mouse->state,
+ x + gw->scrollx,
+ y + gw->scrolly);
- browser_window_mouse_click(gw->bw, gw->mouse->state,
- (x + gw->scrollx) / gw->scale,
- (y + gw->scrolly) / gw->scale);
+ browser_window_mouse_click(gw->bw,
+ gw->mouse->state,
+ x + gw->scrollx,
+ y + gw->scrolly);
return 0;
}
@@ -496,9 +506,9 @@ nsws_drawable_mousemove(struct gui_window *gw, int x, int y)
if ((gw == NULL) || (gw->mouse == NULL) || (gw->bw == NULL))
return 0;
- /* scale co-ordinates */
- x = (x + gw->scrollx) / gw->scale;
- y = (y + gw->scrolly) / gw->scale;
+ /* add scroll offsets */
+ x = x + gw->scrollx;
+ y = y + gw->scrolly;
/* if mouse button held down and pointer moved more than
* minimum distance drag is happening */
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index 06e7346..b9a0dfc 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -898,36 +898,6 @@ win32_window_invalidate_area(struct gui_window *gw, const
struct rect *rect)
/**
- * Set scale of a win32 browser window
- *
- * \param gw win32 frontend window context
- * \param scale The new scale
- */
-static void nsws_set_scale(struct gui_window *gw, float scale)
-{
- struct rect rect;
-
- assert(gw != NULL);
-
- if (gw->scale == scale) {
- return;
- }
-
- rect.x0 = rect.x1 = gw->scrollx;
- rect.y0 = rect.y1 = gw->scrolly;
-
- gw->scale = scale;
-
- if (gw->bw != NULL) {
- browser_window_set_scale(gw->bw, scale, true);
- }
-
- win32_window_invalidate_area(gw, NULL);
- win32_window_set_scroll(gw, &rect);
-}
-
-
-/**
* Create a new window due to menu selection
*
* \param gw frontends graphical window.
@@ -1136,15 +1106,15 @@ nsws_window_command(HWND hwnd,
break;
case IDM_VIEW_ZOOMPLUS:
- nsws_set_scale(gw, gw->scale * 1.1);
+ browser_window_set_scale(gw->bw, 0.1, false);
break;
case IDM_VIEW_ZOOMMINUS:
- nsws_set_scale(gw, gw->scale * 0.9);
+ browser_window_set_scale(gw->bw, -0.1, false);
break;
case IDM_VIEW_ZOOMNORMAL:
- nsws_set_scale(gw, 1.0);
+ browser_window_set_scale(gw->bw, 1.0, true);
break;
case IDM_VIEW_SOURCE:
@@ -1542,9 +1512,12 @@ win32_window_get_dimensions(struct gui_window *gw, int
*width, int *height)
*
* \param w gui_window to update the extent of
*/
-static void win32_window_update_extent(struct gui_window *w)
+static void win32_window_update_extent(struct gui_window *gw)
{
-
+ struct rect rect;
+ rect.x0 = rect.x1 = gw->scrollx;
+ rect.y0 = rect.y1 = gw->scrolly;
+ win32_window_set_scroll(gw, &rect);
}
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 8b5f56c..a14545f 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -337,9 +337,10 @@ void browser_window_reformat(struct browser_window *bw,
bool background, int wid
*
* \param bw The browser window to scale.
* \param scale The new scale.
- * \param all Scale all windows in the tree (ie work up as well as down)
+ * \param absolute If the scale value is absolute or relative to current value
+ * \return NSERROR_OK and scale applied else other error code caused by reflow
etc.
*/
-void browser_window_set_scale(struct browser_window *bw, float scale, bool
all);
+nserror browser_window_set_scale(struct browser_window *bw, float scale, bool
absolute);
/**
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org