summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-06-30 16:40:56 +0100
committerVincent Sanders <vince@kyllikki.org>2014-07-01 09:27:20 +0100
commit18aefabd20a16dda9ed5363088f0da5ada0d4431 (patch)
tree9447e1e0edb1d93b8ad575472e67bf7f844c5ca3 /desktop
parent06eb81235d975bc7721719d25ac114b4ab2c94da (diff)
downloadnetsurf-18aefabd20a16dda9ed5363088f0da5ada0d4431.tar.gz
netsurf-18aefabd20a16dda9ed5363088f0da5ada0d4431.tar.bz2
change reformat to be driven from the scheduler like redraw
Diffstat (limited to 'desktop')
-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
5 files changed, 49 insertions, 12 deletions
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 */