change reformat to be driven from the scheduler like redraw

This commit is contained in:
Vincent Sanders 2014-06-30 16:40:56 +01:00
parent 06eb81235d
commit 18aefabd20
25 changed files with 186 additions and 219 deletions

View File

@ -2128,12 +2128,11 @@ void ami_handle_msg(void)
GetClickTabNodeAttrs(tab,
TNA_UserData, &bw,
TAG_DONE);
bw->reformat_pending = true;
} while(tab=ntab);
}
refresh_favicon = TRUE;
gwin->bw->reformat_pending = true;
browser_window_schedule_reformat(gwin->bw);
ami_schedule_redraw(gwin, true);
break;
}
@ -2204,11 +2203,6 @@ void ami_handle_msg(void)
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);
}
if(gwin->bw->window->throbbing)
ami_update_throbber(gwin,false);
}
@ -2950,7 +2944,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);
}
}
@ -2992,7 +2985,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);
}
@ -3105,7 +3097,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);
}
}
@ -4031,7 +4022,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);
}
@ -4060,7 +4051,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;
}
@ -4291,6 +4281,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;
@ -4313,13 +4318,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))
@ -5060,6 +5058,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,

View File

@ -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);
}

View File

@ -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);
}
int width = 0, height = 0;
void gui_window_set_scale(struct gui_window *gw, float scale)
{
int width = 0, heigth = 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,

View File

@ -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

View File

@ -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;

View File

@ -713,7 +713,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 */
@ -728,34 +727,23 @@ static void gui_poll(bool active)
/** @todo Check if this max_fd should have + 1 */
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)) {

View File

@ -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;
if (g == NULL) {
return;
}
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();
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,

View File

@ -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);

View File

@ -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;

View File

@ -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,

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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 */

View File

@ -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 */

View File

@ -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,

View File

@ -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++) {

View File

@ -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;
if (gw != NULL) {
/** @todo consider gtk_widget_get_allocated_width() */
nsgtk_widget_get_allocation(GTK_WIDGET(gw->layout), &alloc);
g->bw->reformat_pending = false;
/* @todo consider gtk_widget_get_allocated_width() */
nsgtk_widget_get_allocation(GTK_WIDGET(g->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,

View File

@ -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);

View File

@ -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,

View File

@ -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");

View File

@ -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();
}

View File

@ -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 */

View File

@ -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);
}
}
@ -1563,8 +1562,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;
@ -1573,8 +1571,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;
@ -1589,8 +1586,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;
@ -1599,8 +1595,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;
@ -1613,8 +1608,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) {
@ -4385,25 +4379,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.
*/
@ -5180,6 +5166,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,

View File

@ -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);
}
@ -1820,6 +1819,16 @@ nsws_create_main_class(HINSTANCE hinstance) {
return ret;
}
/**
* 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.
*
@ -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,