summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-06-28 21:09:57 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-06-28 21:09:57 +0000
commit416a6452d520b92d1317b9b52f54e01576cef9df (patch)
tree8c4c0e2f125a1b583006792901452e3ac7f9b508
parent3128ecf2a5c94102e0e1659f947a345d36750afe (diff)
downloadnetsurf-416a6452d520b92d1317b9b52f54e01576cef9df.tar.gz
netsurf-416a6452d520b92d1317b9b52f54e01576cef9df.tar.bz2
Function to get root browser window.
svn path=/trunk/netsurf/; revision=12531
-rw-r--r--desktop/browser.c34
-rw-r--r--desktop/browser.h8
2 files changed, 22 insertions, 20 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index fdd021369..1f09465b1 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -244,6 +244,15 @@ void browser_window_set_drag_type(struct browser_window *bw,
bw->drag_type = type;
}
+/* exported interface, documented in browser.h */
+struct browser_window * browser_window_get_root(struct browser_window *bw)
+{
+ while (bw && !bw->window && bw->parent) {
+ bw = bw->parent;
+ }
+ return bw;
+}
+
/**
* Create and open a new root browser window with the given page.
*
@@ -283,10 +292,7 @@ struct browser_window *browser_window_create(const char *url,
/* gui window */
/* from the front end's pov, it clones the top level browser window,
* so find that. */
- top = clone;
- while (top && !top->window && top->parent) {
- top = top->parent;
- }
+ top = browser_window_get_root(clone);
bw->window = gui_create_browser_window(bw, top, new_tab);
@@ -1051,10 +1057,7 @@ void browser_window_update_box(struct browser_window *bw,
case BROWSER_WINDOW_IFRAME:
browser_window_get_position(bw, true, &pos_x, &pos_y);
- top = bw;
- while (top && !top->window && top->parent) {
- top = top->parent;
- }
+ top = browser_window_get_root(bw);
/* TODO: update gui_window_update_box so it takes a struct rect
* instead of msg data. */
@@ -1213,11 +1216,7 @@ void browser_window_set_status(struct browser_window *bw, const char *text)
void browser_window_set_pointer(struct browser_window *bw,
gui_pointer_shape shape)
{
- struct browser_window *root = bw;
-
- while (root && !root->window && root->parent) {
- root = root->parent;
- }
+ struct browser_window *root = browser_window_get_root(bw);
assert(root);
assert(root->window);
@@ -1291,10 +1290,7 @@ void browser_window_destroy_internal(struct browser_window *bw)
/* If this brower window is not the root window, and has focus, unset
* the root browser window's focus pointer. */
if (!bw->window) {
- struct browser_window *top = bw;
-
- while (top && !top->window && top->parent)
- top = top->parent;
+ struct browser_window *top = browser_window_get_root(bw);
if (top->focus == bw)
top->focus = top;
@@ -1737,9 +1733,7 @@ void browser_window_mouse_click(struct browser_window *bw,
return;
/* Set focus browser window */
- top = bw;
- while (top && !top->window && top->parent)
- top = top->parent;
+ top = browser_window_get_root(bw);
top->focus = bw;
selection_set_browser_window(bw->sel, bw);
diff --git a/desktop/browser.h b/desktop/browser.h
index 6a313f032..39d6bf942 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -330,6 +330,14 @@ void browser_window_set_position(struct browser_window *bw, int x, int y);
void browser_window_set_drag_type(struct browser_window *bw,
browser_drag_type type);
+/*
+ * Get the root level browser window
+ *
+ * \param bw browser window to set the type of the current drag for
+ * \return root browser window
+ */
+struct browser_window * browser_window_get_root(struct browser_window *bw);
+
/* In platform specific hotlist.c. */
void hotlist_visited(struct hlcache_handle *c);