From 07c54283e364bd66e21fbd659ea0dd469201a747 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Tue, 7 Aug 2007 03:55:18 +0000 Subject: Move window scaling from platform-specific code to desktop/browser.c. Modify gtk gui to handle scaling in the same way as RO. svn path=/trunk/netsurf/; revision=3478 --- desktop/browser.c | 21 ++++++++++++++++++++- desktop/browser.h | 7 +++++++ desktop/frames.c | 4 ++-- desktop/gui.h | 1 - desktop/options.c | 19 +++++++++++-------- desktop/options.h | 1 + 6 files changed, 41 insertions(+), 12 deletions(-) (limited to 'desktop') 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 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; -- cgit v1.2.3