diff options
author | jcid <devnull@localhost> | 2007-10-20 00:09:51 +0200 |
---|---|---|
committer | jcid <devnull@localhost> | 2007-10-20 00:09:51 +0200 |
commit | 9ef21280a66c7d77761fd1e4e5deab02314e7e61 (patch) | |
tree | 06af21f1ecd964bf57510773bff5e064cab88871 | |
parent | ccb2b7179eccf5b0e96475e277e716a46977e7f3 (diff) |
Fixed the problem of scrolling position (remember position in a page)
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/nav.c | 17 | ||||
-rw-r--r-- | src/uicmd.cc | 13 | ||||
-rw-r--r-- | src/uicmd.hh | 1 | ||||
-rw-r--r-- | src/web.cc | 22 |
5 files changed, 31 insertions, 23 deletions
@@ -30,6 +30,7 @@ dillo-fltk2 - Rewrote the CCC's OpAbort handling. - Rewrote the DNS API and the Dpid start code inside Dillo. - Implemented Stop button to not only stop rendering but also networking. + - Fixed the problem of scrolling position (remember position in a page). Patches: Jorge Arellano +- Connected signals to <li> elements (fixes links within lists). - Enabled text, background-color and geometry in preferences. @@ -135,7 +135,7 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, int offset) { DilloUrl *old_url = NULL; bool_t MustLoad; - int ClientKey; + int x, y, ClientKey; DilloWeb *Web; char *loc_text; bool_t ForceReload = (URL_FLAGS(url) & URL_E2EReload); @@ -149,17 +149,10 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, int offset) /* Record current scrolling position * (the strcmp check is necessary because of redirections) */ loc_text = a_UIcmd_get_location_text(bw); - if (old_url && - !strcmp(URL_STR(old_url), loc_text)) { - - //old_url->scrolling_position_x = - // a_Dw_gtk_scrolled_window_get_scrolling_position_x( - // GTK_DW_SCROLLED_WINDOW(bw->docwin)); - //old_url->scrolling_position_y = - // a_Dw_gtk_scrolled_window_get_scrolling_position_y( - // GTK_DW_SCROLLED_WINDOW(bw->docwin)); - - a_Url_set_pos(old_url, 0, 0); + if (old_url && !strcmp(URL_STR(old_url), loc_text)) { + a_UIcmd_get_scroll_xy(bw, &x, &y); + _MSG("NAV: ScrollPosXY: x=%d y=%d\n",x,y); + a_Url_set_pos(old_url, x, y); } /* Update navigation-stack-pointer (offset may be zero) */ diff --git a/src/uicmd.cc b/src/uicmd.cc index 2b3f0f48..8b5157f1 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -533,6 +533,19 @@ void a_UIcmd_get_wh(BrowserWindow *bw, int *w, int *h) } /* + * Get the scroll position (x, y offset pair) + */ +void a_UIcmd_get_scroll_xy(BrowserWindow *bw, int *x, int *y) +{ + Layout *layout = (Layout*)bw->render_layout; + + if (layout) { + *x = layout->getScrollPosX(); + *y = layout->getScrollPosY(); + } +} + +/* * Get location's text */ char *a_UIcmd_get_location_text(BrowserWindow *bw) diff --git a/src/uicmd.hh b/src/uicmd.hh index 4216dfb3..125e87a3 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -44,6 +44,7 @@ void a_UIcmd_set_save_dir(const char *dir); // UI binding functions ------------------------------------------------------- void a_UIcmd_get_wh(BrowserWindow *bw, int *w, int *h); +void a_UIcmd_get_scroll_xy(BrowserWindow *bw, int *x, int *y); char *a_UIcmd_get_location_text(BrowserWindow *bw); void a_UIcmd_set_location_text(void *vbw, const char *text); void a_UIcmd_set_page_prog(BrowserWindow *bw, size_t nbytes, int cmd); @@ -93,17 +93,17 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web, /* This method frees the old dw if any */ layout->setWidget(dw); - if (URL_POSX(Web->url) || URL_POSY(Web->url)) { - layout->scrollTo(HPOS_LEFT, VPOS_TOP, - URL_POSX(Web->url), URL_POSY(Web->url), - 0, 0); - } else { - char *pf = a_Url_decode_hex_str(URL_FRAGMENT_(Web->url)); - if (pf) { - layout->setAnchor(pf); - dFree(pf); - } - } + /* Scroll to were we were in this page */ + layout->scrollTo(HPOS_LEFT, VPOS_TOP, + URL_POSX(Web->url), URL_POSY(Web->url), 0, 0); + /* If we're at the origin and there's a fragment, go there instead */ + if (URL_POSX(Web->url) == 0 && URL_POSY(Web->url) == 0) { + char *f = a_Url_decode_hex_str(URL_FRAGMENT_(Web->url)); + if (f) { + layout->setAnchor(f); + dFree(f); + } + } /* Clear the title bar for pages without a <TITLE> tag */ a_UIcmd_set_page_title(Web->bw, ""); |