summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2019-08-03 15:53:07 +0100
committerVincent Sanders <vince@kyllikki.org>2019-08-03 15:53:07 +0100
commit641f5fb07204a9deb256557902707cd28182463d (patch)
tree1f2cc6fc09ba52b3d92545629ecb6d6a0467affd
parent402e16e5d1e88a3844b900c485d9fc7c4093f2ab (diff)
downloadnetsurf-641f5fb07204a9deb256557902707cd28182463d.tar.gz
netsurf-641f5fb07204a9deb256557902707cd28182463d.tar.bz2
make use of improved browser_window_set_scale API in frontends
-rw-r--r--frontends/amiga/gui.c6
-rw-r--r--frontends/atari/deskmenu.c8
-rw-r--r--frontends/framebuffer/gui.c19
-rw-r--r--frontends/gtk/scaffolding.c6
-rw-r--r--frontends/riscos/window.c2
-rw-r--r--frontends/windows/window.c43
6 files changed, 19 insertions, 65 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index adce7dd0b..54273ee54 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 34d7be0b8..4426415bc 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 2ea893efb..7413739e2 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 8625d9a4c..619498900 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 c4d32bd28..5a46529ae 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 06e734628..b9a0dfc5e 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);
}