diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-03-17 12:26:41 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-03-17 12:26:41 +0000 |
commit | 58cd1423383babef4a59e25f3e9f6a950d2fa6dc (patch) | |
tree | 66ecca9b8efa5fc429fd51cc6412d39df45b8f54 /desktop/history_core.c | |
parent | 6e9618484eef9646115cea549c8e4453b9b9e565 (diff) | |
download | netsurf-58cd1423383babef4a59e25f3e9f6a950d2fa6dc.tar.gz netsurf-58cd1423383babef4a59e25f3e9f6a950d2fa6dc.tar.bz2 |
Remember the scroll position in the history, so that it's maintained when going back. (credit: Paweł Blokus)
svn path=/trunk/netsurf/; revision=6793
Diffstat (limited to 'desktop/history_core.c')
-rw-r--r-- | desktop/history_core.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/desktop/history_core.c b/desktop/history_core.c index d6feb69be..433889bea 100644 --- a/desktop/history_core.c +++ b/desktop/history_core.c @@ -29,6 +29,7 @@ #include "content/content.h" #include "content/urldb.h" #include "css/css.h" +#include "desktop/browser.h" #include "desktop/gui.h" #include "desktop/history_core.h" #include "desktop/plotters.h" @@ -63,6 +64,8 @@ struct history_entry { int x; /**< Position of node. */ int y; /**< Position of node. */ struct bitmap *bitmap; /**< Thumbnail bitmap, or 0. */ + int sx; /**< X scroll offset. */ + int sy; /**< Y scroll offset. */ }; /** History tree for a window. */ @@ -259,6 +262,8 @@ void history_add(struct history *history, struct content *content, entry->forward = entry->forward_pref = entry->forward_last = 0; entry->children = 0; entry->bitmap = 0; + entry->sx = -1; + entry->sy = -1; if (history->current) { if (history->current->forward_last) history->current->forward_last->next = entry; @@ -755,3 +760,37 @@ struct history_entry *history_find_position(struct history_entry *entry, return 0; } + +/** + * Save in the history the scroll offsets of the current page + * \param history history with the page + * \param sx x offset to be set + * \param sy y offset to be set + */ + +void history_set_current_scroll(struct history *history, int sx, int sy) +{ + if (!history || !history->current) + return; + + history->current->sx = sx; + history->current->sy = sy; +} + +/** + * Load from the history the scroll offsets of the current page + * \param history history with the page + * \param sx updated to x offset + * \param sy updated to y offset + * \return true on success + */ + +bool history_get_current_scroll(struct history *history, int *sx, int *sy) +{ + if (!history || !history->current) + return false; + + *sx = history->current->sx; + *sy = history->current->sy; + return true; +} |