summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/content.c3
-rw-r--r--content/content.h2
-rw-r--r--desktop/browser.c21
-rw-r--r--desktop/browser.h7
-rw-r--r--desktop/frames.c4
-rw-r--r--desktop/gui.h1
-rw-r--r--desktop/options.c19
-rw-r--r--desktop/options.h1
-rw-r--r--gtk/gtk_gui.c14
-rw-r--r--gtk/gtk_window.c112
-rw-r--r--gtk/gtk_window.h2
-rw-r--r--riscos/dialog.c2
-rw-r--r--riscos/gui.c7
-rw-r--r--riscos/gui.h4
-rw-r--r--riscos/options.h3
-rw-r--r--riscos/window.c181
16 files changed, 190 insertions, 193 deletions
diff --git a/content/content.c b/content/content.c
index 6a87880b9..78ea76b54 100644
--- a/content/content.c
+++ b/content/content.c
@@ -513,7 +513,8 @@ struct content * content_get_ready(const char *url)
* \param c content to check
* \return whether the content can reformat
*/
-bool content_get_reformat(struct content *c) {
+bool content_can_reformat(struct content *c)
+{
return (handler_map[c->type].reformat != NULL);
}
diff --git a/content/content.h b/content/content.h
index 57334fba5..0335c96c8 100644
--- a/content/content.h
+++ b/content/content.h
@@ -237,7 +237,7 @@ content_type content_lookup(const char *mime_type);
struct content * content_create(const char *url);
struct content * content_get(const char *url);
struct content * content_get_ready(const char *url);
-bool content_get_reformat(struct content *c);
+bool content_can_reformat(struct content *c);
bool content_set_type(struct content *c, content_type type,
const char *mime_type, const char *params[]);
void content_set_status(struct content *c, const char *status_message, ...);
diff --git a/desktop/browser.c b/desktop/browser.c
index ca1885cbb..a55932ab4 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -57,6 +57,9 @@ struct browser_window *current_redraw_browser;
/** fake content for <a> being saved as a link */
struct content browser_window_href_content;
+/** one or more windows require a reformat */
+bool browser_reformat_pending;
+
/** maximum frame depth */
#define FRAME_DEPTH 8
@@ -146,7 +149,9 @@ struct browser_window *browser_window_create(const char *url,
/* window characteristics */
bw->sel = selection_create(bw);
bw->refresh_interval = -1;
+ bw->reformat_pending = false;
bw->drag_type = DRAGGING_NONE;
+ bw->scale = (float) option_scale / 100.0;
bw->browser_window_type = BROWSER_WINDOW_NORMAL;
bw->scrolling = SCROLLING_YES;
bw->border = true;
@@ -961,7 +966,7 @@ void browser_window_reformat(struct browser_window *bw, int width, int height)
if (!c)
return;
- content_reformat(c, width, height);
+ content_reformat(c, width / bw->scale, height / bw->scale);
}
@@ -986,6 +991,20 @@ void browser_window_set_scale(struct browser_window *bw, float scale, bool all)
void browser_window_set_scale_internal(struct browser_window *bw, float scale)
{
int i;
+ struct content *c;
+
+ if (bw->scale == scale)
+ return;
+ bw->scale = scale;
+ c = bw->current_content;
+ if (c) {
+ if (!content_can_reformat(c)) {
+ browser_window_update(bw, false);
+ } else {
+ bw->reformat_pending = true;
+ browser_reformat_pending = true;
+ }
+ }
gui_window_set_scale(bw->window, scale);
diff --git a/desktop/browser.h b/desktop/browser.h
index 676921dc3..3e1285324 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -115,12 +115,18 @@ struct browser_window {
/** Refresh interval (-1 if undefined) */
int refresh_interval;
+ /** Window has been resized, and content needs reformatting. */
+ bool reformat_pending;
+
/** Window dimensions */
int x0;
int y0;
int x1;
int y1;
+ /** scale of window contents */
+ float scale;
+
/** Window characteristics */
enum {
BROWSER_WINDOW_NORMAL,
@@ -177,6 +183,7 @@ typedef enum {
extern struct browser_window *current_redraw_browser;
+extern bool browser_reformat_pending;
struct browser_window * browser_window_create(const char *url,
struct browser_window *clone, const char *referer,
diff --git a/desktop/frames.c b/desktop/frames.c
index b08bdde97..cd2dc9e21 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -301,7 +301,7 @@ void browser_window_recalculate_frameset(struct browser_window *bw) {
switch (window->frame_width.unit) {
case FRAME_DIMENSION_PIXELS:
widths[col][row] = window->frame_width.value *
- gui_window_get_scale(window->window);
+ window->scale;
if (window->border) {
if (col != 0)
widths[col][row] += 1;
@@ -363,7 +363,7 @@ void browser_window_recalculate_frameset(struct browser_window *bw) {
switch (window->frame_height.unit) {
case FRAME_DIMENSION_PIXELS:
heights[col][row] = window->frame_height.value *
- gui_window_get_scale(window->window);
+ window->scale;
if (window->border) {
if (row != 0)
heights[col][row] += 1;
diff --git a/desktop/gui.h b/desktop/gui.h
index a38a6f6a5..7cf7ead2b 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -84,7 +84,6 @@ bool gui_window_box_scroll_start(struct gui_window *g,
int x0, int y0, int x1, int y1);
bool gui_window_frame_resize_start(struct gui_window *g);
void gui_window_save_as_link(struct gui_window *g, struct content *c);
-float gui_window_get_scale(struct gui_window *g);
void gui_window_set_scale(struct gui_window *g, float scale);
struct gui_download_window *gui_download_window_create(const char *url,
diff --git a/desktop/options.c b/desktop/options.c
index ed4af4ccd..5da514248 100644
--- a/desktop/options.c
+++ b/desktop/options.c
@@ -115,6 +115,8 @@ int option_toolbar_status_width = 400;
#else
int option_toolbar_status_width = 6667;
#endif
+/** default window scale */
+int option_scale = 100;
/* Fetcher configuration */
/** Maximum simultaneous active fetchers */
@@ -122,7 +124,7 @@ int option_max_fetchers = 24;
/** Maximum simultaneous active fetchers per host.
* (<=option_max_fetchers else it makes no sense
*/
-int option_max_fetchers_per_host = 2;
+int option_max_fetchers_per_host = 1;
/** Maximum number of inactive fetchers cached.
* The total number of handles netsurf will therefore have open
* is this plus option_max_fetchers.
@@ -171,13 +173,14 @@ struct {
{ "cookie_jar", OPTION_STRING, &option_cookie_jar },
{ "homepage_url", OPTION_STRING, &option_homepage_url },
{ "url_suggestion", OPTION_BOOL, &option_url_suggestion },
- { "window_x", OPTION_INTEGER, &option_window_x },
- { "window_y", OPTION_INTEGER, &option_window_y },
- { "window_width", OPTION_INTEGER, &option_window_width },
- { "window_height", OPTION_INTEGER, &option_window_height },
- { "window_screen_width", OPTION_INTEGER, &option_window_screen_width },
- { "window_screen_height", OPTION_INTEGER, &option_window_screen_height },
- { "toolbar_status_size", OPTION_INTEGER, &option_toolbar_status_width },
+ { "window_x", OPTION_INTEGER, &option_window_x },
+ { "window_y", OPTION_INTEGER, &option_window_y },
+ { "window_width", OPTION_INTEGER, &option_window_width },
+ { "window_height", OPTION_INTEGER, &option_window_height },
+ { "window_screen_width", OPTION_INTEGER, &option_window_screen_width },
+ { "window_screen_height",OPTION_INTEGER, &option_window_screen_height },
+ { "toolbar_status_size", OPTION_INTEGER, &option_toolbar_status_width },
+ { "option_scale", OPTION_INTEGER, &option_scale },
/* Fetcher options */
{ "max_fetchers", OPTION_INTEGER, &option_max_fetchers },
{ "max_fetchers_per_host",
diff --git a/desktop/options.h b/desktop/options.h
index 007605469..31288b306 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -68,6 +68,7 @@ extern int option_window_height;
extern int option_window_screen_width;
extern int option_window_screen_height;
extern int option_toolbar_status_width;
+extern int option_scale;
/* Fetcher configuration. */
extern int option_max_fetchers;
diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c
index 25c52d4bd..603e605f2 100644
--- a/gtk/gtk_gui.c
+++ b/gtk/gtk_gui.c
@@ -273,6 +273,10 @@ void gui_poll(bool active)
int max_fd;
GPollFD *fd_list[1000];
unsigned int fd_count = 0;
+ bool block = true;
+
+ if (browser_reformat_pending)
+ block = false;
if (active) {
fetch_poll();
@@ -309,12 +313,18 @@ void gui_poll(bool active)
}
}
}
- gtk_main_iteration_do(true);
+
+ gtk_main_iteration_do(block);
+
for (unsigned int i = 0; i != fd_count; i++) {
g_main_context_remove_poll(0, fd_list[i]);
free(fd_list[i]);
}
- schedule_run();
+
+ schedule_run();
+
+ if (browser_reformat_pending)
+ nsgtk_window_process_reformats();
}
diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c
index 068756a17..57c994491 100644
--- a/gtk/gtk_window.c
+++ b/gtk/gtk_window.c
@@ -8,6 +8,7 @@
#include "gtk/gtk_window.h"
#include "desktop/browser.h"
+#include "desktop/options.h"
#include "desktop/textinput.h"
#include "gtk/gtk_gui.h"
#include "gtk/gtk_scaffolding.h"
@@ -26,7 +27,6 @@ struct gui_window {
struct browser_window *bw;
/* These are the storage for the rendering */
- float scale;
int caretx, carety, careth;
gui_pointer_shape current_pointer;
int last_x, last_y;
@@ -80,7 +80,7 @@ struct browser_window *nsgtk_get_browser_for_gui(struct gui_window *g)
float nsgtk_get_scale_for_gui(struct gui_window *g)
{
- return g->scale;
+ return g->bw->scale;
}
/* Create a gui_window */
@@ -101,9 +101,9 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
g->bw = bw;
g->current_pointer = GUI_POINTER_DEFAULT;
if (clone != NULL)
- g->scale = clone->window->scale;
+ bw->scale = clone->scale;
else
- g->scale = 1.0;
+ bw->scale = (float) option_scale / 100;
g->careth = 0;
@@ -268,6 +268,7 @@ gboolean nsgtk_window_expose_event(GtkWidget *widget,
{
struct gui_window *g = data;
struct content *c;
+ float scale = g->bw->scale;
assert(g);
assert(g->bw);
@@ -281,6 +282,10 @@ gboolean nsgtk_window_expose_event(GtkWidget *widget,
c = g->bw->current_content;
if (c == NULL)
return FALSE;
+
+ /* HTML rendering handles scale itself */
+ if (c->type == CONTENT_HTML)
+ scale = 1;
current_widget = widget;
current_drawable = widget->window;
@@ -290,15 +295,15 @@ gboolean nsgtk_window_expose_event(GtkWidget *widget,
#endif
plot = nsgtk_plotters;
- nsgtk_plot_set_scale(g->scale);
+ nsgtk_plot_set_scale(g->bw->scale);
content_redraw(c, 0, 0,
- widget->allocation.width,
- widget->allocation.height,
+ widget->allocation.width * scale,
+ widget->allocation.height * scale,
event->area.x,
event->area.y,
event->area.x + event->area.width,
event->area.y + event->area.height,
- g->scale, 0xFFFFFF);
+ g->bw->scale, 0xFFFFFF);
if (g->careth != 0)
nsgtk_plot_caret(g->caretx, g->carety, g->careth);
@@ -316,8 +321,8 @@ gboolean nsgtk_window_motion_notify_event(GtkWidget *widget,
{
struct gui_window *g = data;
- browser_window_mouse_track(g->bw, 0, event->x / g->scale,
- event->y / g->scale);
+ browser_window_mouse_track(g->bw, 0, event->x / g->bw->scale,
+ event->y / g->bw->scale);
g->last_x = event->x;
g->last_y = event->y;
@@ -341,7 +346,8 @@ gboolean nsgtk_window_button_press_event(GtkWidget *widget,
}
browser_window_mouse_click(g->bw, button,
- event->x / g->scale, event->y / g->scale);
+ event->x / g->bw->scale,
+ event->y / g->bw->scale);
return TRUE;
}
@@ -489,51 +495,44 @@ gboolean nsgtk_window_size_allocate_event(GtkWidget *widget,
GtkAllocation *allocation, gpointer data)
{
struct gui_window *g = data;
-
- LOG(("Size allocate for %s scheduling reflow\n", g->bw->name ?
- g->bw->name : "(none"));
-
- /* schedule a callback to perform the resize for 1/10s from now */
- schedule(5, (gtk_callback)(nsgtk_window_reflow_content), g);
+
+ g->bw->reformat_pending = true;
+ browser_reformat_pending = true;
return TRUE;
}
-void nsgtk_window_reflow_content(struct gui_window *g)
-{
- GtkWidget *widget = GTK_WIDGET(g->viewport);
- if (gui_in_multitask)
- return;
+void nsgtk_reflow_all_windows(void)
+{
+ for (struct gui_window *g = window_list; g; g = g->next)
+ g->bw->reformat_pending = true;
- if (g->bw->current_content == NULL)
- return;
+ browser_reformat_pending = true;
+}
- if (g->bw->current_content->status != CONTENT_STATUS_READY &&
- g->bw->current_content->status != CONTENT_STATUS_DONE)
- return;
-
- LOG(("Doing reformat"));
-
- browser_window_reformat(g->bw,
- widget->allocation.width - 2,
- widget->allocation.height);
- if (nsgtk_scaffolding_is_busy(g->scaffold))
- schedule(100,
- (gtk_callback)(nsgtk_window_reflow_content), g);
-}
+/**
+ * Process pending reformats
+ */
-void nsgtk_reflow_all_windows(void)
+void nsgtk_window_process_reformats(void)
{
- struct gui_window *g = window_list;
+ struct gui_window *g;
- while (g != NULL) {
- nsgtk_window_reflow_content(g);
- g = g->next;
+ browser_reformat_pending = false;
+ for (g = window_list; g; g = g->next) {
+ GtkWidget *widget = GTK_WIDGET(g->viewport);
+ if (!g->bw->reformat_pending)
+ continue;
+ g->bw->reformat_pending = false;
+ browser_window_reformat(g->bw,
+ widget->allocation.width - 2,
+ widget->allocation.height);
}
}
+
void nsgtk_window_destroy_browser(struct gui_window *g)
{
browser_window_destroy(g->bw);
@@ -627,32 +626,27 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
gtk_adjustment_set_value(hadj, (double)sx);
}
-float gui_window_get_scale(struct gui_window *g)
-{
- return g->scale;
-}
+
+/**
+ * Set the scale setting of a window
+ *
+ * \param g gui window
+ * \param scale scale value (1.0 == normal scale)
+ */
void gui_window_set_scale(struct gui_window *g, float scale)
{
- if (g->scale == scale)
- return;
- g->scale = scale;
-
- if (g->bw->current_content != NULL)
- gui_window_update_extent(g);
-
- gtk_widget_queue_draw(GTK_WIDGET(g->drawing_area));
-
}
+
void gui_window_update_extent(struct gui_window *g)
{
if (!g->bw->current_content)
return;
gtk_widget_set_size_request(GTK_WIDGET(g->drawing_area),
- g->bw->current_content->width * g->scale,
- g->bw->current_content->height * g->scale);
+ g->bw->current_content->width * g->bw->scale,
+ g->bw->current_content->height * g->bw->scale);
gtk_widget_set_size_request(GTK_WIDGET(g->viewport), 0, 0);
@@ -837,8 +831,8 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
*height = GTK_WIDGET(g->viewport)->allocation.height;
if (scaled) {
- *width /= g->scale;
- *height /= g->scale;
+ *width /= g->bw->scale;
+ *height /= g->bw->scale;
}
}
diff --git a/gtk/gtk_window.h b/gtk/gtk_window.h
index 24ef508a9..7f9d6e9a5 100644
--- a/gtk/gtk_window.h
+++ b/gtk/gtk_window.h
@@ -11,8 +11,8 @@
#include "desktop/gui.h"
#include "gtk/gtk_scaffolding.h"
-void nsgtk_window_reflow_content(struct gui_window *g);
void nsgtk_reflow_all_windows(void);
+void nsgtk_window_process_reformats(void);
nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g);
struct browser_window *nsgtk_get_browser_for_gui(struct gui_window *g);
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 562ef052c..77a434b87 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -675,7 +675,7 @@ bool ro_gui_dialog_zoom_apply(wimp_w w) {
void ro_gui_dialog_prepare_zoom(struct gui_window *g)
{
char scale_buffer[8];
- sprintf(scale_buffer, "%.0f", g->option.scale * 100);
+ sprintf(scale_buffer, "%.0f", g->bw->scale * 100);
ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer);
ro_gui_set_icon_selected_state(dialog_zoom, ICON_ZOOM_FRAMES, true);
ro_gui_set_icon_shaded_state(dialog_zoom, ICON_ZOOM_FRAMES,
diff --git a/riscos/gui.c b/riscos/gui.c
index e0ccfb048..408f62f84 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -156,9 +156,6 @@ static wimp_w gui_track_wimp_w;
/** Browser window which the pointer is over, or 0 if none. */
struct gui_window *gui_track_gui_window;
-/** Some windows have been resized, and should be reformatted. */
-bool gui_reformat_pending = false;
-
gui_drag_type gui_current_drag_type;
wimp_t task_handle; /**< RISC OS wimp task handle. */
static clock_t gui_last_poll; /**< Time of last wimp_poll. */
@@ -883,7 +880,7 @@ void gui_poll(bool active)
xhourglass_off();
if (active) {
event = wimp_poll(mask, &block, 0);
- } else if (sched_active || gui_track || gui_reformat_pending ||
+ } else if (sched_active || gui_track || browser_reformat_pending ||
bitmap_maintenance) {
os_t t = os_read_monotonic_time();
@@ -914,7 +911,7 @@ void gui_poll(bool active)
schedule_run();
ro_gui_window_update_boxes();
- if (gui_reformat_pending && event == wimp_NULL_REASON_CODE)
+ if (browser_reformat_pending && event == wimp_NULL_REASON_CODE)
ro_gui_window_process_reformats();
else if (bitmap_maintenance_priority ||
(bitmap_maintenance && event == wimp_NULL_REASON_CODE))
diff --git a/riscos/gui.h b/riscos/gui.h
index 2bc251060..b9c05ee83 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -49,7 +49,6 @@ extern bool current_menu_open;
extern wimp_menu *recent_search_menu; /* search.c */
extern wimp_w history_window;
extern struct form_control *current_gadget;
-extern bool gui_reformat_pending;
extern bool gui_redraw_debug;
extern osspriteop_area *gui_sprites;
extern bool dialog_folder_add, dialog_entry_add, hotlist_insert;
@@ -79,8 +78,6 @@ struct gui_window {
wimp_w window; /**< RISC OS window handle. */
- /** Window has been resized, and content needs reformatting. */
- bool reformat_pending;
int old_width; /**< Width when last opened / os units. */
int old_height; /**< Height when last opened / os units. */
bool update_extent; /**< Update the extent on next opening */
@@ -96,7 +93,6 @@ struct gui_window {
/** Options. */
struct {
- float scale; /**< Scale, 1.0 = 100%. */
bool background_images; /**< Display background images. */
bool buffer_animations; /**< Use screen buffering for animations. */
bool buffer_everything; /**< Use screen buffering for everything. */
diff --git a/riscos/options.h b/riscos/options.h
index 1aa2c2f0f..f7bf56feb 100644
--- a/riscos/options.h
+++ b/riscos/options.h
@@ -23,7 +23,6 @@ extern char *option_language;
extern int option_fg_plot_style; /* tinct flagword */
extern int option_bg_plot_style; /* tinct flagword */
extern bool option_history_tooltip;
-extern int option_scale;
extern bool option_toolbar_show_buttons;
extern bool option_toolbar_show_address;
extern bool option_toolbar_show_throbber;
@@ -61,7 +60,6 @@ char *option_language = 0;\
int option_fg_plot_style = tinct_ERROR_DIFFUSE;\
int option_bg_plot_style = tinct_DITHER;\
bool option_history_tooltip = true; \
-int option_scale = 100; \
bool option_toolbar_show_buttons = true; \
bool option_toolbar_show_address = true; \
bool option_toolbar_show_throbber = true; \
@@ -99,7 +97,6 @@ bool option_thumbnail_iconise = true;
{ "plot_fg_quality", OPTION_INTEGER, &option_fg_plot_style },\
{ "plot_bg_quality", OPTION_INTEGER, &option_bg_plot_style },\
{ "history_tooltip", OPTION_BOOL, &option_history_tooltip }, \
-{ "scale", OPTION_INTEGER, &option_scale }, \
{ "toolbar_show_buttons", OPTION_BOOL, &option_toolbar_show_buttons }, \
{ "toolbar_show_address", OPTION_BOOL, &option_toolbar_show_address }, \
{ "toolbar_show_throbber", OPTION_BOOL, &option_toolbar_show_throbber }, \
diff --git a/riscos/window.c b/riscos/window.c
index c47d02c49..fb9900674 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -173,7 +173,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
g->bw = bw;
g->toolbar = 0;
g->status_bar = 0;
- g->reformat_pending = false;
g->old_width = 0;
g->old_height = 0;
g->update_extent = true;
@@ -469,13 +468,14 @@ void gui_window_set_title(struct gui_window *g, const char *title)
assert(g);
assert(title);
- if (g->option.scale != 1.0) {
- scale_disp = g->option.scale * 100;
- if (ABS((float)scale_disp - g->option.scale * 100) >= 0.05)
- snprintf(g->title, sizeof g->title, "%s (%.1f%%)", title,
- g->option.scale * 100);
+ if (g->bw->scale != 1.0) {
+ scale_disp = g->bw->scale * 100;
+ if (ABS((float)scale_disp - g->bw->scale * 100) >= 0.05)
+ snprintf(g->title, sizeof g->title, "%s (%.1f%%)",
+ title, g->bw->scale * 100);
else
- snprintf(g->title, sizeof g->title, "%s (%i%%)", title, scale_disp);
+ snprintf(g->title, sizeof g->title, "%s (%i%%)",
+ title, scale_disp);
} else {
strncpy(g->title, title, sizeof g->title);
}
@@ -558,10 +558,10 @@ void gui_window_update_box(struct gui_window *g,
if (!c)
return;
- x0 = floorf(data->redraw.x * 2 * g->option.scale);
- y0 = -ceilf((data->redraw.y + data->redraw.height) * 2 * g->option.scale);
- x1 = ceilf((data->redraw.x + data->redraw.width) * 2 * g->option.scale) + 1;
- y1 = -floorf(data->redraw.y * 2 * g->option.scale) + 1;
+ x0 = floorf(data->redraw.x * 2 * g->bw->scale);
+ y0 = -ceilf((data->redraw.y + data->redraw.height) * 2 * g->bw->scale);
+ x1 = ceilf((data->redraw.x + data->redraw.width) * 2 * g->bw->scale) + 1;
+ y1 = -floorf(data->redraw.y * 2 * g->bw->scale) + 1;
use_buffer = (data->redraw.full_redraw) &&
(g->option.buffer_everything || g->option.buffer_animations);
@@ -627,8 +627,8 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
if (g->toolbar)
toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
- *sx = state.xscroll / (2 * g->option.scale);
- *sy = -(state.yscroll - toolbar_height) / (2 * g->option.scale);
+ *sx = state.xscroll / (2 * g->bw->scale);
+ *sy = -(state.yscroll - toolbar_height) / (2 * g->bw->scale);
return true;
}
@@ -657,8 +657,8 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
return;
}
- state.xscroll = sx * 2 * g->option.scale;
- state.yscroll = -sy * 2 * g->option.scale;
+ state.xscroll = sx * 2 * g->bw->scale;
+ state.yscroll = -sy * 2 * g->bw->scale;
if (g->toolbar)
state.yscroll += ro_gui_theme_toolbar_full_height(g->toolbar);
ro_gui_window_open((wimp_open *)&state);
@@ -697,10 +697,10 @@ void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int
if (g->toolbar)
toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
- x0 = x0 * 2 * g->option.scale;
- y0 = y0 * 2 * g->option.scale;
- x1 = x1 * 2 * g->option.scale;
- y1 = y1 * 2 * g->option.scale;
+ x0 = x0 * 2 * g->bw->scale;
+ y0 = y0 * 2 * g->bw->scale;
+ x1 = x1 * 2 * g->bw->scale;
+ y1 = y1 * 2 * g->bw->scale;
cx0 = state.xscroll;
cy0 = -state.yscroll + toolbar_height;
@@ -790,7 +790,7 @@ void gui_window_position_frame(struct gui_window *g, int x0, int y0, int x1, int
/* only scale iframe locations */
if (bw->browser_window_type == BROWSER_WINDOW_IFRAME)
- scale = g->option.scale;
+ scale = g->bw->scale;
/* get the position of the top level window */
state.w = top->window->window;
@@ -858,8 +858,8 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bo
*width = g->old_width / 2;
*height = g->old_height / 2;
if (scaled) {
- *width /= g->option.scale;
- *height /= g->option.scale;
+ *width /= g->bw->scale;
+ *height /= g->bw->scale;
}
}
@@ -897,7 +897,7 @@ void gui_window_update_extent(struct gui_window *g)
/* only allow a further reformat if we've gained/lost scrollbars */
flags = state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL);
- update = g->reformat_pending;
+ update = g->bw->reformat_pending;
g->update_extent = true;
ro_gui_window_open((wimp_open *)&state);
@@ -910,7 +910,7 @@ void gui_window_update_extent(struct gui_window *g)
return;
}
if (flags == (state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL)))
- g->reformat_pending = update;
+ g->bw->reformat_pending = update;
if ((scroll != 0) && (g->bw->children))
browser_window_recalculate_frameset(g->bw);
}
@@ -1090,9 +1090,9 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
os_error *error;
error = xwimp_set_caret_position(g->window, -1,
- x * 2 * g->option.scale,
- -(y + height) * 2 * g->option.scale,
- height * 2 * g->option.scale, -1);
+ x * 2 * g->bw->scale,
+ -(y + height) * 2 * g->bw->scale,
+ height * 2 * g->bw->scale, -1);
if (error) {
LOG(("xwimp_set_caret_position: 0x%x: %s",
error->errnum, error->errmess));
@@ -1230,10 +1230,10 @@ bool gui_window_box_scroll_start(struct gui_window *g, int x0, int y0, int x1, i
}
drag.type = wimp_DRAG_USER_POINT;
- drag.bbox.x0 = pointer.pos.x + (int)(x0 * 2 * g->option.scale);
- drag.bbox.y0 = pointer.pos.y + (int)(y0 * 2 * g->option.scale);
- drag.bbox.x1 = pointer.pos.x + (int)(x1 * 2 * g->option.scale);
- drag.bbox.y1 = pointer.pos.y + (int)(y1 * 2 * g->option.scale);
+ drag.bbox.x0 = pointer.pos.x + (int)(x0 * 2 * g->bw->scale);
+ drag.bbox.y0 = pointer.pos.y + (int)(y0 * 2 * g->bw->scale);
+ drag.bbox.x1 = pointer.pos.x + (int)(x1 * 2 * g->bw->scale);
+ drag.bbox.y1 = pointer.pos.y + (int)(y1 * 2 * g->bw->scale);
error = xwimp_drag_box(&drag);
if (error) {
@@ -1363,19 +1363,6 @@ void gui_window_save_as_link(struct gui_window *g, struct content *c)
/**
- * Get the scale setting of a window
- *
- * \param g gui window
- * \return scale value (1.0 == normal scale)
- */
-
-float gui_window_get_scale(struct gui_window *g)
-{
- return g->option.scale;
-}
-
-
-/**
* Set the scale setting of a window
*
* \param g gui window
@@ -1384,21 +1371,7 @@ float gui_window_get_scale(struct gui_window *g)
void gui_window_set_scale(struct gui_window *g, float scale)
{
- struct content *c;
-
- if (g->option.scale == scale)
- return;
- g->option.scale = scale;
- c = g->bw->current_content;
- if (c) {
- ro_gui_dialog_update_zoom(g);
- if (!content_get_reformat(c)) {
- browser_window_update(g->bw, false);
- } else {
- g->reformat_pending = true;
- gui_reformat_pending = true;
- }
- }
+ ro_gui_dialog_update_zoom(g);
}
@@ -1422,7 +1395,7 @@ void ro_gui_window_redraw(wimp_draw *redraw)
osbool more;
bool knockout = true;
struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w);
- float scale = g->option.scale;
+ float scale = g->bw->scale;
struct content *c = g->bw->current_content;
int clip_x0, clip_y0, clip_x1, clip_y1, clear_x1, clear_y1;
os_error *error;
@@ -1439,9 +1412,9 @@ void ro_gui_window_redraw(wimp_draw *redraw)
ro_gui_current_redraw_gui = g;
current_redraw_browser = g->bw;
- /* rendering textplain has no advantages using knockout rendering other than to
- * slow things down. */
- if (c->type == CONTENT_TEXTPLAIN)
+ /* rendering textplain has no advantages using knockout rendering other
+ * than to slow things down. */
+ if (c->type == CONTENT_TEXTPLAIN || c->type == CONTENT_SVG)
knockout = false;
/* HTML rendering handles scale itself */
@@ -1477,7 +1450,7 @@ void ro_gui_window_redraw(wimp_draw *redraw)
content_redraw(c, 0, 0,
c->width * scale, c->height * scale,
clip_x0, clip_y0, clip_x1, clip_y1,
- g->option.scale,
+ g->bw->scale,
0xFFFFFF);
if (knockout)
knockout_plot_end();
@@ -1569,7 +1542,7 @@ void ro_gui_window_update_boxes(void) {
plot = ro_plotters;
ro_plot_origin_x = update.box.x0 - update.xscroll;
ro_plot_origin_y = update.box.y1 - update.yscroll;
- ro_plot_set_scale(g->option.scale);
+ ro_plot_set_scale(g->bw->scale);
/* We should clear the background, except for HTML.
*/
@@ -1601,21 +1574,21 @@ void ro_gui_window_update_boxes(void) {
content_redraw(c, 0, 0,
c->width, c->height,
clip_x0, clip_y0, clip_x1, clip_y1,
- g->option.scale,
+ g->bw->scale,
0xFFFFFF);
} else {
assert(data->redraw.object);
content_redraw(data->redraw.object,
floorf(data->redraw.object_x *
- g->option.scale),
+ g->bw->scale),
ceilf(data->redraw.object_y *
- g->option.scale),
+ g->bw->scale),
data->redraw.object_width *
- g->option.scale,
+ g->bw->scale,
data->redraw.object_height *
- g->option.scale,
+ g->bw->scale,
clip_x0, clip_y0, clip_x1, clip_y1,
- g->option.scale,
+ g->bw->scale,
0xFFFFFF);
}
@@ -1745,8 +1718,8 @@ void gui_window_set_extent(struct gui_window *g, int width, int height)
height -= ro_get_title_height(g->window);
}
if (content) {
- width = max(width, content->width * 2 * g->option.scale);
- height = max(height, content->height * 2 * g->option.scale);
+ width = max(width, content->width * 2 * g->bw->scale);
+ height = max(height, content->height * 2 * g->bw->scale);
}
os_box extent = { 0, -height, width, toolbar_height };
error = xwimp_set_extent(g->window, &extent);
@@ -1823,14 +1796,14 @@ void ro_gui_window_open(wimp_open *open)
if ((!no_hscroll) &&
((fheight > size) ||
(g->bw->browser_window_type == BROWSER_WINDOW_NORMAL)) &&
- ((content && width < content->width * 2 * g->option.scale) ||
+ ((content && width < content->width * 2 * g->bw->scale) ||
(g->bw->browser_window_type == BROWSER_WINDOW_NORMAL))) {
if (!(state.flags & wimp_WINDOW_HSCROLL)) {
height -= size;
state.visible.y0 += size;
if (content) {
- g->reformat_pending = true;
- gui_reformat_pending = true;
+ g->bw->reformat_pending = true;
+ browser_reformat_pending = true;
}
}
state.flags |= wimp_WINDOW_HSCROLL;
@@ -1839,8 +1812,8 @@ void ro_gui_window_open(wimp_open *open)
height += size;
state.visible.y0 -= size;
if (content) {
- g->reformat_pending = true;
- gui_reformat_pending = true;
+ g->bw->reformat_pending = true;
+ browser_reformat_pending = true;
}
}
state.flags &= ~wimp_WINDOW_HSCROLL;
@@ -1856,14 +1829,14 @@ void ro_gui_window_open(wimp_open *open)
if ((!no_vscroll) &&
((fwidth > size) ||
(g->bw->browser_window_type == BROWSER_WINDOW_NORMAL)) &&
- ((content && height < content->height * 2 * g->option.scale) ||
+ ((content && height < content->height * 2 * g->bw->scale) ||
(g->bw->scrolling == SCROLLING_YES))) {
if (!(state.flags & wimp_WINDOW_VSCROLL)) {
width -= size;
state.visible.x1 -= size;
if (content) {
- g->reformat_pending = true;
- gui_reformat_pending = true;
+ g->bw->reformat_pending = true;
+ browser_reformat_pending = true;
}
}
state.flags |= wimp_WINDOW_VSCROLL;
@@ -1872,8 +1845,8 @@ void ro_gui_window_open(wimp_open *open)
width += size;
state.visible.x1 += size;
if (content) {
- g->reformat_pending = true;
- gui_reformat_pending = true;
+ g->bw->reformat_pending = true;
+ browser_reformat_pending = true;
}
}
state.flags &= ~wimp_WINDOW_VSCROLL;
@@ -1885,9 +1858,9 @@ void ro_gui_window_open(wimp_open *open)
/* Ctrl-resize of a top-level window scales the content size */
if ((g->old_width > 0) && (g->old_width != width) && (!g->bw->parent) &&
(ro_gui_ctrl_pressed()))
- new_scale = (g->option.scale * width) / g->old_width;
- g->reformat_pending = true;
- gui_reformat_pending = true;
+ new_scale = (g->bw->scale * width) / g->old_width;
+ g->bw->reformat_pending = true;
+ browser_reformat_pending = true;
}
if (g->update_extent || g->old_width != width || g->old_height != height) {
g->old_width = width;
@@ -2514,16 +2487,16 @@ bool ro_gui_window_keypress(wimp_key *key)
case 23: /* CTRL+W (Zoom in) */
if (!content)
break;
- scale = g->option.scale;
+ scale = g->bw->scale;
if (ro_gui_shift_pressed() && c == 17)
- scale = g->option.scale - 0.1;
+ scale = g->bw->scale - 0.1;
else if (ro_gui_shift_pressed() && c == 23)
- scale = g->option.scale + 0.1;
+ scale = g->bw->scale + 0.1;
else if (c == 17) {
for (int i = SCALE_SNAP_TO_SIZE - 1;
i >= 0; i--)
if (scale_snap_to[i] <
- g->option.scale) {
+ g->bw->scale) {
scale = scale_snap_to[i];
break;
}
@@ -2531,7 +2504,7 @@ bool ro_gui_window_keypress(wimp_key *key)
for (unsigned int i = 0;
i < SCALE_SNAP_TO_SIZE; i++)
if (scale_snap_to[i] >
- g->option.scale) {
+ g->bw->scale) {
scale = scale_snap_to[i];
break;
}
@@ -2540,12 +2513,12 @@ bool ro_gui_window_keypress(wimp_key *key)
scale = scale_snap_to[0];
if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1])
scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
- if (g->option.scale != scale) {
+ if (g->bw->scale != scale) {
browser_window_set_scale(g->bw, scale, true);
// g->reformat_pending = true;
// if ((content) && (content->type != CONTENT_HTML))
// browser_window_update(g->bw, false);
-// gui_reformat_pending = true;
+// browser_reformat_pending = true;
}
return true;
@@ -2712,8 +2685,8 @@ bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *p
warn_user("WimpError", error->errmess);
return false;
}
- pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 / g->option.scale;
- pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 / g->option.scale;
+ pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 / g->bw->scale;
+ pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 / g->bw->scale;
return true;
}
@@ -2743,8 +2716,8 @@ bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y, os_coord *p
warn_user("WimpError", error->errmess);
return false;
}
- pos->x = (x * 2 * g->option.scale) + (state.visible.x0 - state.xscroll);
- pos->y = (state.visible.y1 - state.yscroll) - (y * 2 * g->option.scale);
+ pos->x = (x * 2 * g->bw->scale) + (state.visible.x0 - state.xscroll);
+ pos->y = (state.visible.y1 - state.yscroll) - (y * 2 * g->bw->scale);
return true;
}
@@ -2896,14 +2869,14 @@ void ro_gui_window_process_reformats(void)
{
struct gui_window *g;
- gui_reformat_pending = false;
+ browser_reformat_pending = false;
for (g = window_list; g; g = g->next) {
- if (!g->reformat_pending)
+ if (!g->bw->reformat_pending)
continue;
- g->reformat_pending = false;
+ g->bw->reformat_pending = false;
browser_window_reformat(g->bw,
- g->old_width / 2 / g->option.scale,
- g->old_height / 2 / g->option.scale);
+ g->old_width / 2,
+ g->old_height / 2);
}
}
@@ -2932,7 +2905,7 @@ void ro_gui_window_clone_options(struct browser_window *new_bw,
/* Clone the basic options
*/
if (!old_gui) {
- new_gui->option.scale = ((float)option_scale) / 100;
+ new_bw->scale = ((float)option_scale) / 100;
new_gui->option.background_images = option_background_images;
new_gui->option.buffer_animations = option_buffer_animations;
new_gui->option.buffer_everything = option_buffer_everything;
@@ -2975,7 +2948,7 @@ void ro_gui_window_default_options(struct browser_window *bw) {
/* Save the basic options
*/
- option_scale = gui->option.scale * 100;
+ option_scale = bw->scale * 100;
option_buffer_animations = gui->option.buffer_animations;
option_buffer_everything = gui->option.buffer_everything;