summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amiga/gui.c39
-rw-r--r--atari/deskmenu.c8
-rw-r--r--atari/gui.c21
-rwxr-xr-xatari/gui.h3
-rwxr-xr-xatari/rootwin.c2
-rw-r--r--beos/gui.cpp30
-rw-r--r--beos/window.cpp54
-rw-r--r--beos/window.h1
-rw-r--r--cocoa/BrowserView.m29
-rw-r--r--cocoa/gui.m17
-rw-r--r--desktop/browser.c23
-rw-r--r--desktop/browser.h17
-rw-r--r--desktop/browser_private.h3
-rw-r--r--desktop/gui.h15
-rw-r--r--desktop/gui_factory.c3
-rw-r--r--framebuffer/gui.c10
-rw-r--r--gtk/gui.c5
-rw-r--r--gtk/window.c32
-rw-r--r--gtk/window.h1
-rw-r--r--monkey/browser.c19
-rw-r--r--monkey/poll.c5
-rw-r--r--riscos/gui.c14
-rw-r--r--riscos/gui.h1
-rw-r--r--riscos/window.c45
-rw-r--r--windows/gui.c12
25 files changed, 187 insertions, 222 deletions
diff --git a/amiga/gui.c b/amiga/gui.c
index 8d6d19ee4..9bf049a15 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -2132,12 +2132,11 @@ void ami_handle_msg(void)
GetClickTabNodeAttrs(tab,
TNA_UserData, &bw,
TAG_DONE);
- bw->reformat_pending = true;
} while(tab=ntab);
}
ami_schedule(0, ami_gui_refresh_favicon, gwin);
- gwin->bw->reformat_pending = true;
+ browser_window_schedule_reformat(gwin->bw);
ami_schedule_redraw(gwin, true);
break;
}
@@ -2206,13 +2205,6 @@ void ami_handle_msg(void)
// ReplyMsg((struct Message *)message);
}
- if(node->Type == AMINS_WINDOW)
- {
- /* Catch any reformats tagged by the core - only used by scale? */
- if(gwin->bw->reformat_pending) {
- ami_schedule_redraw(gwin, true);
- }
- }
} while(node = nnode);
if(ami_menu_window_close)
@@ -2956,7 +2948,6 @@ void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
gwin->win, NULL, TRUE);
if(gwin->bw) {
- gwin->bw->reformat_pending = true;
ami_schedule_redraw(gwin, true);
}
}
@@ -2998,7 +2989,6 @@ void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
gwin->win, NULL, TRUE);
- gwin->bw->reformat_pending = true;
ami_schedule_redraw(gwin, true);
}
@@ -3111,7 +3101,6 @@ void ami_toggletabbar(struct gui_window_2 *gwin, bool show)
gwin->win, NULL, TRUE);
if(gwin->bw) {
- gwin->bw->reformat_pending = true;
ami_schedule_redraw(gwin, true);
}
}
@@ -4043,7 +4032,7 @@ static void ami_redraw_callback(void *p)
{
struct gui_window_2 *gwin = (struct gui_window_2 *)p;
- if(gwin->redraw_required || gwin->bw->reformat_pending) {
+ if(gwin->redraw_required) {
ami_do_redraw(gwin);
}
@@ -4072,7 +4061,6 @@ void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw)
if(full_redraw) gwin->redraw_required = true;
if(gwin->redraw_scheduled == true) return;
- if(gwin->bw->reformat_pending) ms = nsoption_int(reformat_delay) * 10;
ami_schedule(ms, ami_redraw_callback, gwin);
gwin->redraw_scheduled = true;
}
@@ -4303,6 +4291,21 @@ static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
ami_schedule_redraw(g->shared, false);
}
+/**
+ * callback from core to reformat a window.
+ */
+static void amiga_window_reformat(struct gui_window *gw)
+{
+ struct IBox *bbox;
+
+ if (gw != NULL) {
+ GetAttr(SPACE_AreaBox, (Object *)gw->shared->objects[GID_BROWSER], (ULONG *)&bbox);
+ browser_window_reformat(gw->shared->bw, false, bbox->Width, bbox->Height);
+
+ gw->shared->redraw_scroll = false;
+ }
+}
+
static void ami_do_redraw(struct gui_window_2 *gwin)
{
struct Rectangle rect;
@@ -4325,13 +4328,6 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
xoffset=bbox->Left;
yoffset=bbox->Top;
- if(gwin->bw->reformat_pending)
- {
- browser_window_reformat(gwin->bw, false, width, height);
- gwin->bw->reformat_pending = false;
- gwin->redraw_scroll = false;
- }
-
if(gwin->redraw_scroll)
{
if((abs(vcurrent-oldv) > height) || (abs(hcurrent-oldh) > width))
@@ -5073,6 +5069,7 @@ static struct gui_window_table amiga_window_table = {
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.update_extent = gui_window_update_extent,
+ .reformat = amiga_window_reformat,
.set_icon = gui_window_set_icon,
.set_title = gui_window_set_title,
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index 8de2e327f..53e24a4d4 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -394,7 +394,9 @@ static void __CDECL menu_inc_scale(short item, short title, void *data)
if(input_window == NULL)
return;
- gui_window_set_scale(input_window, gui_window_get_scale(input_window)+0.25);
+ browser_window_set_scale(input_window->bw,
+ browser_window_get_scale(input_window->bw) + 0.25,
+ true);
}
@@ -403,7 +405,9 @@ static void __CDECL menu_dec_scale(short item, short title, void *data)
if(input_window == NULL)
return;
- gui_window_set_scale(input_window, gui_window_get_scale(input_window)-0.25);
+ browser_window_set_scale(input_window->bw,
+ browser_window_get_scale(input_window->bw) - 0.25,
+ true);
}
diff --git a/atari/gui.c b/atari/gui.c
index 608d0d859..efa23efe4 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -201,7 +201,6 @@ gui_window_create(struct browser_window *bw,
option_window_x, option_window_y,
option_window_width, option_window_height
};
- gui_window_set_scale(gw, 1.0);
gui_window_set_url(gw, "");
gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT);
gui_set_input_gui_window(gw);
@@ -343,21 +342,14 @@ void gui_window_set_status(struct gui_window *w, const char *text)
window_set_stauts(w->root, (char*)text);
}
-float gui_window_get_scale(struct gui_window *gw)
+static void atari_window_reformat(struct gui_window *gw)
{
- return(gw->scale);
-}
-
-void gui_window_set_scale(struct gui_window *gw, float scale)
-{
- int width = 0, heigth = 0;
+ int width = 0, height = 0;
- LOG(("scale: %f", scale));
-
- gw->scale = MAX(scale, 0.25);
-
- gui_window_get_dimensions(gw, &width, &heigth, true);
- browser_window_reformat(gw->browser->bw, false, width, heigth);
+ if (gw != NULL) {
+ gui_window_get_dimensions(gw, &width, &height, true);
+ browser_window_reformat(gw->browser->bw, false, width, height);
+ }
}
static void gui_window_redraw_window(struct gui_window *gw)
@@ -1017,6 +1009,7 @@ static struct gui_window_table atari_window_table = {
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.update_extent = gui_window_update_extent,
+ .reformat = atari_window_reformat,
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
diff --git a/atari/gui.h b/atari/gui.h
index 978c0d093..10736c5f8 100755
--- a/atari/gui.h
+++ b/atari/gui.h
@@ -149,7 +149,6 @@ struct gui_window {
char * title;
char * url;
struct bitmap * icon;
- float scale;
struct s_caret caret;
struct s_search_form_session *search;
struct gui_window *next, *prev;
@@ -168,7 +167,5 @@ char *gui_window_get_title(struct gui_window *gw);
void gui_window_set_status(struct gui_window *w, const char *text);
void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape);
void gui_window_destroy(struct gui_window *w);
-void gui_window_set_scale(struct gui_window *gw, float scale);
-float gui_window_get_scale(struct gui_window *gw);
#endif
diff --git a/atari/rootwin.c b/atari/rootwin.c
index fde0bd3b5..7c2cdbcf1 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -834,7 +834,7 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
plot_set_dimensions(content_area->g_x, content_area->g_y,
content_area->g_w, content_area->g_h);
- oldscale = plot_set_scale(gui_window_get_scale(rootwin->active_gui_window));
+ oldscale = plot_set_scale(browser_window_get_scale(rootwin->active_gui_window->bw));
/* first, we make the coords relative to the content area: */
content_area_rel.g_x = clip->g_x - content_area->g_x;
diff --git a/beos/gui.cpp b/beos/gui.cpp
index eee56d8c6..cb7effead 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -719,7 +719,6 @@ static void gui_poll(bool active)
int max_fd;
struct timeval timeout;
unsigned int fd_count = 0;
- bool block = true;
bigtime_t next_schedule = 0;
/* get any active fetcher fd */
@@ -734,34 +733,23 @@ static void gui_poll(bool active)
// max of all the fds in the set, plus one for select()
max_fd = MAX(max_fd, sEventPipe[0]) + 1;
- // If there are pending events elsewhere, we should not be blocking
- if (!browser_reformat_pending) {
- if (earliest_callback_timeout != B_INFINITE_TIMEOUT) {
- next_schedule = earliest_callback_timeout - system_time();
- block = false;
- }
-
- // we're quite late already...
- if (next_schedule < 0)
- next_schedule = 0;
-
- } else {//we're not allowed to sleep, there is other activity going on.
- nsbeos_window_process_reformats();
- block = false;
+ // compute schedule timeout
+ if (earliest_callback_timeout != B_INFINITE_TIMEOUT) {
+ next_schedule = earliest_callback_timeout - system_time();
+ } else {
+ next_schedule = earliest_callback_timeout;
}
- /*
- LOG(("gui_poll: browser_reformat_pending:%d earliest_callback_timeout:%Ld"
- " next_schedule:%Ld block:%d ", browser_reformat_pending,
- earliest_callback_timeout, next_schedule, block));
- */
+ // we're quite late already...
+ if (next_schedule < 0)
+ next_schedule = 0;
timeout.tv_sec = (long)(next_schedule / 1000000LL);
timeout.tv_usec = (long)(next_schedule % 1000000LL);
//LOG(("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule));
fd_count = select(max_fd, &read_fd_set, &write_fd_set, &exc_fd_set,
- block ? NULL : &timeout);
+ &timeout);
//LOG(("select: %d\n", fd_count));
if (fd_count > 0 && FD_ISSET(sEventPipe[0], &read_fd_set)) {
diff --git a/beos/window.cpp b/beos/window.cpp
index 8975c1871..d27bca758 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -883,9 +883,7 @@ void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
width++;
height++;
-
- g->bw->reformat_pending = true;
- browser_reformat_pending = true;
+ browser_window_schedule_reformat(g->bw);
return;
}
@@ -901,51 +899,40 @@ void nsbeos_window_moved_event(BView *view, gui_window *g, BMessage *event)
//view->Invalidate(view->Bounds());
view->UnlockLooper();
- //g->bw->reformat_pending = true;
- //browser_reformat_pending = true;
-
-
return;
}
void nsbeos_reflow_all_windows(void)
{
- for (struct gui_window *g = window_list; g; g = g->next)
- g->bw->reformat_pending = true;
-
- browser_reformat_pending = true;
+ for (struct gui_window *g = window_list; g; g = g->next) {
+ browser_window_schedule_reformat(g->bw);
+ }
}
+
/**
- * Process pending reformats
+ * callback from core to reformat a window.
*/
-
-void nsbeos_window_process_reformats(void)
+static void beos_window_reformat(struct gui_window *g)
{
- struct gui_window *g;
-
- browser_reformat_pending = false;
- for (g = window_list; g; g = g->next) {
- NSBrowserFrameView *view = g->view;
- if (!g->bw->reformat_pending)
- continue;
- if (!view || !view->LockLooper())
- continue;
- g->bw->reformat_pending = false;
- BRect bounds = view->Bounds();
- view->UnlockLooper();
+ if (g == NULL) {
+ return;
+ }
+
+ NSBrowserFrameView *view = g->view;
+ if (view && view->LockLooper()) {
+ BRect bounds = view->Bounds();
+ view->UnlockLooper();
#warning XXX why - 1 & - 2 !???
- browser_window_reformat(g->bw,
- false,
- bounds.Width() + 1 /* - 2*/,
- bounds.Height() + 1);
- }
-
+ browser_window_reformat(g->bw,
+ false,
+ bounds.Width() + 1 /* - 2*/,
+ bounds.Height() + 1);
+ }
}
-
void nsbeos_window_destroy_browser(struct gui_window *g)
{
browser_window_destroy(g->bw);
@@ -1356,6 +1343,7 @@ static struct gui_window_table window_table = {
gui_window_set_scroll,
gui_window_get_dimensions,
gui_window_update_extent,
+ beos_window_reformat,
/* from scaffold */
gui_window_set_title,
diff --git a/beos/window.h b/beos/window.h
index fb67517d2..0e38d88ed 100644
--- a/beos/window.h
+++ b/beos/window.h
@@ -51,7 +51,6 @@ void nsbeos_dispatch_event(BMessage *message);
void nsbeos_reflow_all_windows(void);
-void nsbeos_window_process_reformats(void);
nsbeos_scaffolding *nsbeos_get_scaffold(struct gui_window *g);
struct browser_window *nsbeos_get_browser_for_gui(struct gui_window *g);
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index b0042f760..2a3382c8c 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -38,7 +38,6 @@
- (void) scrollVertical: (CGFloat) amount;
- (CGFloat) pageScroll;
-+ (void)reformatTimerFired: (NSTimer *) timer;
- (void) reformat;
- (void) popUpContextMenuForEvent: (NSEvent *) event;
@@ -60,8 +59,6 @@
static const CGFloat CaretWidth = 1.0;
static const NSTimeInterval CaretBlinkTime = 0.8;
-static NSMutableArray *cocoa_reformat_pending = nil;
-
- initWithFrame: (NSRect) frame;
{
@@ -438,13 +435,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
- (void) adjustFrame;
{
- browser->reformat_pending = true;
- browser_reformat_pending = true;
-
- if (cocoa_reformat_pending == nil) {
- cocoa_reformat_pending = [[NSMutableArray alloc] init];
- }
- [cocoa_reformat_pending addObject: self];
+ browser_window_schedule_reformat(browser);
[super adjustFrame];
}
@@ -492,24 +483,6 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
browser_window_reformat( browser, false, cocoa_pt_to_px( NSWidth( size ) ), cocoa_pt_to_px( NSHeight( size ) ) );
}
-+ (void)reformatTimerFired: (NSTimer *) timer;
-{
- if (browser_reformat_pending) {
- [cocoa_reformat_pending makeObjectsPerformSelector: @selector( reformat )];
- [cocoa_reformat_pending removeAllObjects];
- browser_reformat_pending = false;
- }
-}
-
-+ (void) initialize;
-{
- NSTimer *timer = [[NSTimer alloc] initWithFireDate: nil interval: 0.02
- target: self selector: @selector(reformatTimerFired:)
- userInfo: nil repeats: YES];
- [[NSRunLoop currentRunLoop] addTimer: timer forMode: NSRunLoopCommonModes];
- [timer release];
-}
-
- (void) popUpContextMenuForEvent: (NSEvent *) event;
{
if (content_get_type( browser->current_content ) != CONTENT_HTML) return;
diff --git a/cocoa/gui.m b/cocoa/gui.m
index 713f456cd..405dab9c2 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -129,8 +129,20 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
[[(BrowserViewController *)g browserView] scrollPoint: cocoa_point( sx, sy )];
}
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
- bool scaled)
+/**
+ * callback from core to reformat a window.
+ */
+static void cocoa_window_reformat(struct gui_window *gw)
+{
+ if (gw != NULL) {
+ [[(BrowserViewController *)g browserView] reformat ];
+ }
+}
+
+
+static void gui_window_get_dimensions(struct gui_window *g,
+ int *width, int *height,
+ bool scaled)
{
NSCParameterAssert( width != NULL && height != NULL );
@@ -278,6 +290,7 @@ static struct gui_window_table window_table = {
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.update_extent = gui_window_update_extent,
+ .reformat = cocoa_window_reformat,
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
diff --git a/desktop/browser.c b/desktop/browser.c
index 6e3ed9718..dc2db723c 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -66,14 +66,11 @@
#include "utils/utils.h"
#include "utils/utf8.h"
-/** one or more windows require a reformat */
-bool browser_reformat_pending;
/** maximum frame depth */
#define FRAME_DEPTH 8
-
/**
* Get position of scrollbar widget within browser window.
*
@@ -795,7 +792,6 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
/* window characteristics */
bw->refresh_interval = -1;
- bw->reformat_pending = false;
bw->drag_type = DRAGGING_NONE;
bw->scale = (float) nsoption_int(scale) / 100.0;
@@ -1623,7 +1619,13 @@ void browser_window_destroy_internal(struct browser_window *bw)
browser_window_destroy_children(bw);
}
+ /* clear any pending callbacks */
guit->browser->schedule(-1, browser_window_refresh, bw);
+ /* The ugly cast here is so the reformat function can be
+ * passed a gui window pointer in its API rather than void*
+ */
+ LOG(("Clearing schedule %p(%p)", guit->window->reformat, bw->window));
+ guit->browser->schedule(-1, (void(*)(void*))guit->window->reformat, bw->window);
/* If this brower window is not the root window, and has focus, unset
* the root browser window's focus pointer. */
@@ -2362,6 +2364,16 @@ void browser_window_set_pointer(struct browser_window *bw,
guit->window->set_pointer(root->window, gui_shape);
}
+/* exported function documented in desktop/browser.h */
+nserror browser_window_schedule_reformat(struct browser_window *bw)
+{
+ /* The ugly cast here is so the reformat function can be
+ * passed a gui window pointer in its API rather than void*
+ */
+ LOG(("Scheduleing %p(%p)", guit->window->reformat, bw->window));
+ guit->browser->schedule(0, (void(*)(void*))guit->window->reformat, bw->window);
+ return NSERROR_OK;
+}
/**
* Reformat a browser window contents to a new width or height.
@@ -2413,8 +2425,7 @@ static void browser_window_set_scale_internal(struct browser_window *bw,
if (content_can_reformat(c) == false) {
browser_window_update(bw, false);
} else {
- bw->reformat_pending = true;
- browser_reformat_pending = true;
+ browser_window_schedule_reformat(bw);
}
}
diff --git a/desktop/browser.h b/desktop/browser.h
index ca99a5d16..88b757727 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -60,8 +60,6 @@ typedef enum {
BW_EDITOR_CAN_PASTE = (1 << 2) /**< Can paste, input */
} browser_editor_flags;
-extern bool browser_reformat_pending;
-
/** flags to browser_window_create */
enum browser_window_create_flags {
/** No flags set */
@@ -259,6 +257,21 @@ struct browser_window *browser_window_find_target(
struct browser_window *bw, const char *target,
browser_mouse_state mouse);
+/**
+ * Cause the frontends reformat entry to be called in safe context.
+ *
+ * The browser_window_reformat call cannot safely be called from some
+ * contexts, this call allows for the reformat to happen from a safe
+ * top level context.
+ *
+ * The callback is frontend provided as the context information (size
+ * etc.) about the windowing toolkit is only available to the
+ * frontend.
+ */
+nserror browser_window_schedule_reformat(struct browser_window *bw);
+
+
+
void browser_select_menu_callback(void *client_data,
int x, int y, int width, int height);
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 339bc46ee..cbc29aaa3 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -87,9 +87,6 @@ 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 x;
int y;
diff --git a/desktop/gui.h b/desktop/gui.h
index d44b57d1c..a19f30115 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -105,7 +105,9 @@ struct gui_window_table {
struct gui_window *existing,
gui_window_create_flags flags);
- /** destroy previously created gui window */
+ /**
+ * Destroy previously created gui window
+ */
void (*destroy)(struct gui_window *g);
/**
@@ -168,6 +170,17 @@ struct gui_window_table {
*/
void (*update_extent)(struct gui_window *g);
+ /**
+ * Reformat a window.
+ *
+ * This is used to perform reformats when the page contents
+ * require reformating. The reformat is requested using
+ * browser_window_schedule_reformat and occours via a scheduled
+ * callback hence from top level context.
+ *
+ * \param g gui_window to reformat.
+ */
+ void (*reformat)(struct gui_window *g);
/* Optional entries */
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index fd0867491..977805e9c 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -154,6 +154,9 @@ static nserror verify_window_register(struct gui_window_table *gwt)
if (gwt->update_extent == NULL) {
return NSERROR_BAD_PARAMETER;
}
+ if (gwt->reformat == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
/* fill in the optional entries with defaults */
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 0632bf3c6..727319f0f 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -1758,6 +1758,15 @@ gui_window_remove_caret(struct gui_window *g)
}
}
+static void nsgtk_window_reformat(struct gui_window *gw)
+{
+ /** @todo if we ever do zooming reformat should be implemented */
+ LOG(("window:%p", gw));
+
+ /*
+ browser_window_reformat(gw->bw, false, width, height);
+ */
+}
static struct gui_window_table framebuffer_window_table = {
.create = gui_window_create,
@@ -1768,6 +1777,7 @@ static struct gui_window_table framebuffer_window_table = {
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.update_extent = gui_window_update_extent,
+ .reformat = framebuffer_window_reformat,
.set_url = gui_window_set_url,
.set_status = gui_window_set_status,
diff --git a/gtk/gui.c b/gtk/gui.c
index 9cd89e627..bb83721fe 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -518,11 +518,6 @@ static void nsgtk_poll(bool active)
schedule_run();
- if (browser_reformat_pending) {
- nsgtk_window_process_reformats();
- block = false;
- }
-
gtk_main_iteration_do(block);
for (unsigned int i = 0; i != fd_count; i++) {
diff --git a/gtk/window.c b/gtk/window.c
index a3d6d4936..d1cd6b1a5 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -638,9 +638,7 @@ static gboolean nsgtk_window_size_allocate_event(GtkWidget *widget,
{
struct gui_window *g = data;
- g->bw->reformat_pending = true;
- browser_reformat_pending = true;
-
+ browser_window_schedule_reformat(g->bw);
return TRUE;
}
@@ -854,35 +852,24 @@ gui_window_create(struct browser_window *bw,
void nsgtk_reflow_all_windows(void)
{
for (struct gui_window *g = window_list; g; g = g->next) {
- nsgtk_tab_options_changed(
- nsgtk_scaffolding_notebook(g->scaffold));
- g->bw->reformat_pending = true;
+ nsgtk_tab_options_changed(nsgtk_scaffolding_notebook(g->scaffold));
+ browser_window_schedule_reformat(g->bw);
}
-
- browser_reformat_pending = true;
}
/**
- * Process pending reformats
+ * callback from core to reformat a window.
*/
-
-void nsgtk_window_process_reformats(void)
+static void nsgtk_window_reformat(struct gui_window *gw)
{
- struct gui_window *g;
GtkAllocation alloc;
- browser_reformat_pending = false;
- for (g = window_list; g; g = g->next) {
- if (!g->bw->reformat_pending)
- continue;
-
- g->bw->reformat_pending = false;
-
- /* @todo consider gtk_widget_get_allocated_width() */
- nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc);
+ if (gw != NULL) {
+ /** @todo consider gtk_widget_get_allocated_width() */
+ nsgtk_widget_get_allocation(GTK_WIDGET(gw->layout), &alloc);
- browser_window_reformat(g->bw, false, alloc.width, alloc.height);
+ browser_window_reformat(gw->bw, false, alloc.width, alloc.height);
}
}
@@ -1242,6 +1229,7 @@ static struct gui_window_table window_table = {
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.update_extent = gui_window_update_extent,
+ .reformat = nsgtk_window_reformat,
.set_icon = gui_window_set_icon,
.set_status = gui_window_set_status,
diff --git a/gtk/window.h b/gtk/window.h
index e4a4fda6a..01345b993 100644
--- a/gtk/window.h
+++ b/gtk/window.h
@@ -36,7 +36,6 @@ struct browser_window *nsgtk_get_browser_window(struct gui_window *g);
nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g);
GdkPixbuf *nsgtk_get_icon(struct gui_window *gw);
void nsgtk_reflow_all_windows(void);
-void nsgtk_window_process_reformats(void);
float nsgtk_get_scale_for_gui(struct gui_window *g);
int nsgtk_gui_window_update_targets(struct gui_window *g);
void nsgtk_window_destroy_browser(struct gui_window *g);
diff --git a/monkey/browser.c b/monkey/browser.c
index e61d6deb3..0e488c578 100644
--- a/monkey/browser.c
+++ b/monkey/browser.c
@@ -64,19 +64,13 @@ monkey_find_window_by_content(hlcache_handle *content)
return ret;
}
-void
-monkey_window_process_reformats(void)
+
+/**
+ * callback from core to reformat a window.
+ */
+static void monkey_window_reformat(struct gui_window *gw)
{
- RING_ITERATE_START(struct gui_window, gw_ring, c_ring) {
- if (c_ring == NULL)
- RING_ITERATE_STOP(gw_ring, c_ring);
- if (c_ring->bw->reformat_pending) {
- browser_window_reformat(c_ring->bw,
- false,
- c_ring->width,
- c_ring->height);
- }
- } RING_ITERATE_END(gw_ring, c_ring);
+ browser_window_reformat(gw->bw, false, gw->width, gw->height);
}
void
@@ -511,6 +505,7 @@ static struct gui_window_table window_table = {
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.update_extent = gui_window_update_extent,
+ .reformat = monkey_window_reformat,
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
diff --git a/monkey/poll.c b/monkey/poll.c
index d5b49f059..e65f2d3e2 100644
--- a/monkey/poll.c
+++ b/monkey/poll.c
@@ -126,11 +126,6 @@ monkey_poll(bool active)
schedule_run();
- if (browser_reformat_pending) {
- monkey_window_process_reformats();
- block = false;
- }
-
LOG(("Iterate %sblocking", block?"":"non-"));
if (block) {
fprintf(stdout, "GENERIC POLL BLOCKING\n");
diff --git a/riscos/gui.c b/riscos/gui.c
index 00f6ebc11..3253f796f 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -1864,17 +1864,18 @@ static void riscos_poll(bool active)
/* Poll wimp. */
xhourglass_off();
track_poll_offset = ro_mouse_poll_interval();
- if (sched_active || (track_poll_offset > 0) ||
- browser_reformat_pending) {
+ if (sched_active || (track_poll_offset > 0)) {
os_t t = os_read_monotonic_time();
- if (track_poll_offset > 0)
+ if (track_poll_offset > 0) {
t += track_poll_offset;
- else
+ } else {
t += 10;
+ }
- if (sched_active && (sched_time - t) < 0)
+ if (sched_active && (sched_time - t) < 0) {
t = sched_time;
+ }
event = wimp_poll_idle(mask, &block, t, 0);
} else {
@@ -1895,9 +1896,6 @@ static void riscos_poll(bool active)
}
ro_gui_window_update_boxes();
-
- if (browser_reformat_pending && event == wimp_NULL_REASON_CODE)
- ro_gui_window_process_reformats();
}
diff --git a/riscos/gui.h b/riscos/gui.h
index bc59b5db9..3403f551e 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -134,7 +134,6 @@ void ro_gui_window_iconise(struct gui_window *g,
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);
void ro_gui_window_redraw_all(void);
void ro_gui_window_update_boxes(void);
-void ro_gui_window_process_reformats(void);
void ro_gui_window_quit(void);
/* void ro_gui_window_close_all(void); */
#define ro_gui_window_close_all ro_gui_window_quit /* no need for a separate fn */
diff --git a/riscos/window.c b/riscos/window.c
index 5a3369769..2ad432b2e 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -975,7 +975,6 @@ static void gui_window_update_extent(struct gui_window *g)
os_error *error;
wimp_window_info info;
wimp_window_state state;
- bool update;
unsigned int flags;
assert(g);
@@ -995,9 +994,8 @@ static void gui_window_update_extent(struct gui_window *g)
info.yscroll += scroll;
}
- /* only allow a further reformat if we've gained/lost scrollbars */
+ /* only schedule a reformat if we've gained/lost scrollbars */
flags = info.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL);
- update = g->bw->reformat_pending;
g->update_extent = true;
ro_gui_window_open(PTR_WIMP_OPEN(&info));
@@ -1009,8 +1007,9 @@ static void gui_window_update_extent(struct gui_window *g)
warn_user("WimpError", error->errmess);
return;
}
- if (flags == (state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL)))
- g->bw->reformat_pending = update;
+ if (flags == (state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL))) {
+ browser_window_schedule_reformat(g->bw);
+ }
}
@@ -1557,8 +1556,7 @@ void ro_gui_window_open(wimp_open *open)
height -= size;
state.visible.y0 += size;
if (h) {
- g->bw->reformat_pending = true;
- browser_reformat_pending = true;
+ browser_window_schedule_reformat(g->bw);
}
}
state.flags |= wimp_WINDOW_HSCROLL;
@@ -1567,8 +1565,7 @@ void ro_gui_window_open(wimp_open *open)
height += size;
state.visible.y0 -= size;
if (h) {
- g->bw->reformat_pending = true;
- browser_reformat_pending = true;
+ browser_window_schedule_reformat(g->bw);
}
}
state.flags &= ~wimp_WINDOW_HSCROLL;
@@ -1583,8 +1580,7 @@ void ro_gui_window_open(wimp_open *open)
width -= size;
state.visible.x1 -= size;
if (h) {
- g->bw->reformat_pending = true;
- browser_reformat_pending = true;
+ browser_window_schedule_reformat(g->bw);
}
}
state.flags |= wimp_WINDOW_VSCROLL;
@@ -1593,8 +1589,7 @@ void ro_gui_window_open(wimp_open *open)
width += size;
state.visible.x1 += size;
if (h) {
- g->bw->reformat_pending = true;
- browser_reformat_pending = true;
+ browser_window_schedule_reformat(g->bw);
}
}
state.flags &= ~wimp_WINDOW_VSCROLL;
@@ -1607,8 +1602,7 @@ void ro_gui_window_open(wimp_open *open)
if ((g->old_width > 0) && (g->old_width != width) &&
(ro_gui_ctrl_pressed()))
new_scale = (g->bw->scale * width) / g->old_width;
- g->bw->reformat_pending = true;
- browser_reformat_pending = true;
+ browser_window_schedule_reformat(g->bw);
}
if (g->update_extent || g->old_width != width ||
g->old_height != height) {
@@ -4379,25 +4373,17 @@ void ro_gui_window_update_boxes(void)
/**
- * Process pending reformats
+ * callback from core to reformat a window.
*/
-
-void ro_gui_window_process_reformats(void)
+static void riscos_window_reformat(struct gui_window *gw)
{
- struct gui_window *g;
-
- browser_reformat_pending = false;
- for (g = window_list; g; g = g->next) {
- if (!g->bw->reformat_pending)
- continue;
- g->bw->reformat_pending = false;
- browser_window_reformat(g->bw, false,
- g->old_width / 2,
- g->old_height / 2);
+ if (gw != NULL) {
+ browser_window_reformat(gw->bw, false,
+ gw->old_width / 2,
+ gw->old_height / 2);
}
}
-
/**
* Destroy all browser windows.
*/
@@ -5174,6 +5160,7 @@ static struct gui_window_table window_table = {
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.update_extent = gui_window_update_extent,
+ .reformat = riscos_window_reformat,
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
diff --git a/windows/gui.c b/windows/gui.c
index 824abade7..19a31c1be 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -93,7 +93,6 @@ static void nsws_set_scale(struct gui_window *gw, float scale)
return;
browser_window_set_scale(gw->bw, scale, true);
- browser_window_reformat(gw->bw, false, gw->width, gw->height);
}
@@ -1821,6 +1820,16 @@ nsws_create_main_class(HINSTANCE hinstance) {
}
/**
+ * callback from core to reformat a window.
+ */
+static void win32_window_reformat(struct gui_window *gw)
+{
+ if (gw != NULL) {
+ browser_window_reformat(gw->bw, false, gw->width, gw->height);
+ }
+}
+
+/**
* Generate a windows path from one or more component elemnts.
*
* If a string is allocated it must be freed by the caller.
@@ -2087,6 +2096,7 @@ static struct gui_window_table window_table = {
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.update_extent = gui_window_update_extent,
+ .reformat = win32_window_reformat,
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,