Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/a08a1a1d1451e43fd7a2b3a0e7967e3095313992
...commit
http://git.netsurf-browser.org/netsurf.git/commit/a08a1a1d1451e43fd7a2b3a0e7967e3095313992
...tree
http://git.netsurf-browser.org/netsurf.git/tree/a08a1a1d1451e43fd7a2b3a0e7967e3095313992
The branch, master has been updated
via a08a1a1d1451e43fd7a2b3a0e7967e3095313992 (commit)
via f98de0d3474c98ea3a477340420c0e782533a803 (commit)
via 99cb0d6bc6dcf313a33f3784f684f40f193c5b9f (commit)
via 7c2811f5f66b8dce0e39057048922cceef94eb7f (commit)
via 5e8b2d46535f61cfeda79c1571f52cd210d4b429 (commit)
via c078c3f50932f9fc0bcb20ed8ddaaf648f6acda2 (commit)
via 818f4018d2a2e8a16e2c65c97ecd56c2f583f2c1 (commit)
via 1ee32fe96275798c465375cf1d990c11749c63af (commit)
from ad67eeff4bfe15c2aaf2c6b537a8327825687411 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=a08a1a1d1451e43fd7a2b3a0e7967e3095313992
commit a08a1a1d1451e43fd7a2b3a0e7967e3095313992
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
amiga/history_local: Scroll to cursor on open
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/amiga/history_local.c b/frontends/amiga/history_local.c
index fc980be..5ad77ea 100644
--- a/frontends/amiga/history_local.c
+++ b/frontends/amiga/history_local.c
@@ -319,6 +319,8 @@ nserror ami_history_local_present(struct gui_window *gw)
history_local_window = ncwin;
ami_gui_set_history_window(gw, ncwin);
+ local_history_scroll_to_cursor(ncwin->session);
+
return NSERROR_OK;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=f98de0d3474c98ea3a477340420c0e782533a803
commit f98de0d3474c98ea3a477340420c0e782533a803
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
riscos/local_history: Scroll to cursor on open.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/riscos/local_history.c b/frontends/riscos/local_history.c
index bbe6a1d..20ca9e2 100644
--- a/frontends/riscos/local_history.c
+++ b/frontends/riscos/local_history.c
@@ -394,6 +394,8 @@ ro_local_history_open(struct ro_local_history_window *lhw,
wimp_w parent)
ro_gui_dialog_open_persistent(parent, lhw->core.wh, true);
+ local_history_scroll_to_cursor(lhw->session);
+
return NSERROR_OK;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=99cb0d6bc6dcf313a33f3784f684f40f193c5b9f
commit 99cb0d6bc6dcf313a33f3784f684f40f193c5b9f
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
windows/local_history: Scroll to cursor on open
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/windows/local_history.c
b/frontends/windows/local_history.c
index 722d365..823901b 100644
--- a/frontends/windows/local_history.c
+++ b/frontends/windows/local_history.c
@@ -215,6 +215,7 @@ nsw32_local_history_present(HWND hWndParent, struct
browser_window *bw)
width,
height,
SWP_SHOWWINDOW);
+ local_history_scroll_to_cursor(local_history_window->session);
}
return res;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=7c2811f5f66b8dce0e39057048922cceef94eb7f
commit 7c2811f5f66b8dce0e39057048922cceef94eb7f
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
framebuffer/local_history: Scroll to cursor on open
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/framebuffer/local_history.c
b/frontends/framebuffer/local_history.c
index cc45b1f..c1963e2 100644
--- a/frontends/framebuffer/local_history.c
+++ b/frontends/framebuffer/local_history.c
@@ -205,6 +205,7 @@ nserror fb_local_history_present(fbtk_widget_t *parent,
fbtk_set_zorder(local_history_window->core.wnd, INT_MIN);
fbtk_set_mapping(local_history_window->core.wnd, true);
+ local_history_scroll_to_cursor(local_history_window->session);
}
return res;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=5e8b2d46535f61cfeda79c1571f52cd210d4b429
commit 5e8b2d46535f61cfeda79c1571f52cd210d4b429
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
gtk/local_history: Scroll local history to cursor on display
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/gtk/local_history.c b/frontends/gtk/local_history.c
index 35b7a4a..010fa31 100644
--- a/frontends/gtk/local_history.c
+++ b/frontends/gtk/local_history.c
@@ -225,6 +225,8 @@ nserror nsgtk_local_history_present(GtkWindow *parent,
gtk_window_resize(local_history_window->wnd, width, height);
gtk_window_present(local_history_window->wnd);
+
+ local_history_scroll_to_cursor(local_history_window->session);
}
return res;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c078c3f50932f9fc0bcb20ed8ddaaf648f6acda2
commit c078c3f50932f9fc0bcb20ed8ddaaf648f6acda2
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
gtk/corewindow.c: Correctly handle scroll_visible
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/gtk/corewindow.c b/frontends/gtk/corewindow.c
index 4f05648..9dc388c 100644
--- a/frontends/gtk/corewindow.c
+++ b/frontends/gtk/corewindow.c
@@ -608,26 +608,52 @@ static void
nsgtk_cw_scroll_visible(struct core_window *cw, const struct rect *r)
{
struct nsgtk_corewindow *nsgtk_cw = (struct nsgtk_corewindow *)cw;
- int y = 0, height = 0, y0, y1;
- gdouble page;
+ int x0, y0, x1, y1;
+ gdouble vpage, hpage;
GtkAdjustment *vadj;
+ GtkAdjustment *hadj;
vadj = gtk_scrolled_window_get_vadjustment(nsgtk_cw->scrolled);
+ hadj = gtk_scrolled_window_get_hadjustment(nsgtk_cw->scrolled);
- assert(vadj);
+ assert(vadj != NULL);
+ assert(hadj != NULL);
- g_object_get(vadj, "page-size", &page, NULL);
+ g_object_get(vadj, "page-size", &vpage, NULL);
+ g_object_get(hadj, "page-size", &hpage, NULL);
y0 = (int)(gtk_adjustment_get_value(vadj));
- y1 = y0 + page;
-
- if ((y >= y0) && (y + height <= y1))
- return;
- if (y + height > y1)
- y0 = y0 + (y + height - y1);
- if (y < y0)
- y0 = y;
+ y1 = y0 + vpage;
+ x0 = (int)(gtk_adjustment_get_value(hadj));
+ x1 = x0 + hpage;
+
+ if (r->y1 > y1) {
+ /* The bottom of the rectangle is off the bottom of the
+ * window, so scroll down to fit it
+ */
+ y0 = r->y1 - vpage;
+ }
+ if (r->y0 < y0) {
+ /* The top of the rectangle is off the top of the window,
+ * so scroll up to fit it
+ */
+ y0 = r->y0;
+ }
+ if (r->x1 > x1) {
+ /* The right of the rectangle is off the right of the window
+ * so scroll right to fit it
+ */
+ x0 = r->x1 - hpage;
+ }
+ if (r->x0 < x0) {
+ /* The left of the rectangle is off the left of the window
+ * so scroll left to fit it
+ */
+ x0 = r->x0;
+ }
+
gtk_adjustment_set_value(vadj, y0);
+ gtk_adjustment_set_value(hadj, x0);
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=818f4018d2a2e8a16e2c65c97ecd56c2f583f2c1
commit 818f4018d2a2e8a16e2c65c97ecd56c2f583f2c1
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
local_history: Handle keys for navigating local history
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/desktop/local_history.c b/desktop/local_history.c
index 4c75a80..8e52af7 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -31,6 +31,7 @@
#include "netsurf/browser_window.h"
#include "netsurf/core_window.h"
#include "netsurf/plotters.h"
+#include "netsurf/keypress.h"
#include "desktop/gui_internal.h"
#include "desktop/system_colour.h"
@@ -438,6 +439,59 @@ local_history_mouse_action(struct local_history_session
*session,
bool
local_history_keypress(struct local_history_session *session, uint32_t key)
{
+ switch (key) {
+ case NS_KEY_NL:
+ case NS_KEY_CR:
+ /* pressed enter */
+ if (session->cursor != session->bw->history->current) {
+ browser_window_history_go(session->bw, session->cursor,
+ false);
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ case NS_KEY_LEFT:
+ /* Go to parent */
+ if (session->cursor->back) {
+ session->cursor = session->cursor->back;
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ case NS_KEY_RIGHT:
+ /* Go to preferred child if there is one */
+ if (session->cursor->forward_pref) {
+ session->cursor = session->cursor->forward_pref;
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ case NS_KEY_DOWN:
+ /* Go to next sibling down, if there is one */
+ if (session->cursor->next) {
+ session->cursor = session->cursor->next;
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ case NS_KEY_UP:
+ /* Go to next sibling up, if there is one */
+ if (session->cursor->back) {
+ struct history_entry *ent =
session->cursor->back->forward;
+ while (ent->next != NULL && ent->next !=
session->cursor) {
+ ent = ent->next;
+ }
+ session->cursor = ent;
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ }
return false;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=1ee32fe96275798c465375cf1d990c11749c63af
commit 1ee32fe96275798c465375cf1d990c11749c63af
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
local_history: Add concept of a cursor to the local history
So that we can eventually navigate around local history by
keyboard, add the concept of a history cursor to the local
history core window.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/desktop/local_history.c b/desktop/local_history.c
index a977416..4c75a80 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -40,6 +40,8 @@
#define WIDTH 100
#define HEIGHT 86
+#define RIGHT_MARGIN 50
+#define BOTTOM_MARGIN 30
/**
* local history viewer context
@@ -48,6 +50,7 @@ struct local_history_session {
struct browser_window *bw;
struct core_window_callback_table *cw_t;
void *core_window_handle;
+ struct history_entry *cursor;
};
@@ -87,6 +90,15 @@ static plot_style_t pstyle_rect_sel = {
/**
+ * plot style for drawing rectangle round the cursor node
+ */
+static plot_style_t pstyle_rect_cursor = {
+ .stroke_type = PLOT_OP_TYPE_DASH,
+ .stroke_width = plot_style_int_to_fixed(3),
+};
+
+
+/**
* plot style for font on unselected nodes
*/
static plot_font_style_t pfstyle_node = {
@@ -121,6 +133,7 @@ static plot_font_style_t pfstyle_node_sel = {
static nserror
redraw_entry(struct history *history,
struct history_entry *entry,
+ struct history_entry *cursor,
struct rect *clip,
int x, int y,
const struct redraw_context *ctx)
@@ -167,6 +180,15 @@ redraw_entry(struct history *history,
return res;
}
+ /* If this is the cursor, show that */
+ if (entry == cursor) {
+ rect.x0 -= 1;
+ rect.y0 -= 1;
+ rect.x1 += 2;
+ rect.y1 += 2;
+ ctx->plot->rectangle(ctx, &pstyle_rect_cursor, &rect);
+ }
+
res = guit->layout->position(plot_style_font, entry->page.title,
strlen(entry->page.title), WIDTH,
&char_offset, &actual_x);
@@ -213,7 +235,7 @@ redraw_entry(struct history *history,
return res;
}
- res = redraw_entry(history, child, clip, x, y, ctx);
+ res = redraw_entry(history, child, cursor, clip, x, y, ctx);
if (res != NSERROR_OK) {
return res;
}
@@ -258,6 +280,25 @@ find_entry_position(struct history_entry *entry, int x,
int y)
return NULL;
}
+/* exported interface documented in desktop/local_history.h */
+nserror
+local_history_scroll_to_cursor(struct local_history_session *session)
+{
+ rect cursor;
+
+ if (session->cursor == NULL) {
+ return NSERROR_OK;
+ }
+
+ cursor.x0 = session->cursor->x - RIGHT_MARGIN / 2;
+ cursor.y0 = session->cursor->y - BOTTOM_MARGIN / 2;
+ cursor.x1 = cursor.x0 + WIDTH + RIGHT_MARGIN / 2;
+ cursor.y1 = cursor.y0 + HEIGHT + BOTTOM_MARGIN / 2;
+
+ session->cw_t->scroll_visible(session->core_window_handle, &cursor);
+
+ return NSERROR_OK;
+}
/* exported interface documented in desktop/local_history.h */
nserror
@@ -283,12 +324,17 @@ local_history_init(struct core_window_callback_table
*cw_t,
pstyle_rect.stroke_colour = pstyle_line.stroke_colour;
pfstyle_node.foreground = pstyle_line.stroke_colour;
- res = ns_system_colour_char("Highlight",
&pstyle_rect_sel.stroke_colour);
+ res = ns_system_colour_char("ButtonText",
&pstyle_rect_sel.stroke_colour);
if (res != NSERROR_OK) {
return res;
}
pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour;
+ res = ns_system_colour_char("Highlight",
&pstyle_rect_cursor.stroke_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
nses = calloc(1, sizeof(struct local_history_session));
if (nses == NULL) {
return NSERROR_NOMEM;
@@ -339,11 +385,13 @@ local_history_redraw(struct local_history_session
*session,
ctx->plot->clip(ctx, &r);
ctx->plot->rectangle(ctx, &pstyle_bg, &r);
- return redraw_entry(session->bw->history,
- session->bw->history->start,
- clip,
- x, y,
- ctx);
+ return redraw_entry(
+ session->bw->history,
+ session->bw->history->start,
+ session->cursor,
+ clip,
+ x, y,
+ ctx);
}
/* exported interface documented in desktop/local_history.h */
@@ -399,12 +447,16 @@ local_history_set(struct local_history_session *session,
struct browser_window *bw)
{
session->bw = bw;
+ session->cursor = NULL;
+
if (bw != NULL) {
assert(session->bw->history != NULL);
+ session->cursor = bw->history->current;
session->cw_t->update_size(session->core_window_handle,
session->bw->history->width,
session->bw->history->height);
+ local_history_scroll_to_cursor(session);
}
return NSERROR_OK;
diff --git a/desktop/local_history.h b/desktop/local_history.h
index 7f85a63..d0d9209 100644
--- a/desktop/local_history.h
+++ b/desktop/local_history.h
@@ -140,5 +140,12 @@ nserror local_history_get_size(struct
local_history_session *session, int *width
*/
nserror local_history_get_url(struct local_history_session *session, int x,
int y, struct nsurl **url_out);
+/**
+ * Scroll the local history window to ensure the current cursor is shown.
+ *
+ * \param session The local history session
+ */
+nserror local_history_scroll_to_cursor(struct local_history_session *session);
+
#endif
-----------------------------------------------------------------------
Summary of changes:
desktop/local_history.c | 120 +++++++++++++++++++++++++++++++--
desktop/local_history.h | 7 ++
frontends/amiga/history_local.c | 2 +
frontends/framebuffer/local_history.c | 1 +
frontends/gtk/corewindow.c | 50 ++++++++++----
frontends/gtk/local_history.c | 2 +
frontends/riscos/local_history.c | 2 +
frontends/windows/local_history.c | 1 +
8 files changed, 166 insertions(+), 19 deletions(-)
diff --git a/desktop/local_history.c b/desktop/local_history.c
index a977416..8e52af7 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -31,6 +31,7 @@
#include "netsurf/browser_window.h"
#include "netsurf/core_window.h"
#include "netsurf/plotters.h"
+#include "netsurf/keypress.h"
#include "desktop/gui_internal.h"
#include "desktop/system_colour.h"
@@ -40,6 +41,8 @@
#define WIDTH 100
#define HEIGHT 86
+#define RIGHT_MARGIN 50
+#define BOTTOM_MARGIN 30
/**
* local history viewer context
@@ -48,6 +51,7 @@ struct local_history_session {
struct browser_window *bw;
struct core_window_callback_table *cw_t;
void *core_window_handle;
+ struct history_entry *cursor;
};
@@ -87,6 +91,15 @@ static plot_style_t pstyle_rect_sel = {
/**
+ * plot style for drawing rectangle round the cursor node
+ */
+static plot_style_t pstyle_rect_cursor = {
+ .stroke_type = PLOT_OP_TYPE_DASH,
+ .stroke_width = plot_style_int_to_fixed(3),
+};
+
+
+/**
* plot style for font on unselected nodes
*/
static plot_font_style_t pfstyle_node = {
@@ -121,6 +134,7 @@ static plot_font_style_t pfstyle_node_sel = {
static nserror
redraw_entry(struct history *history,
struct history_entry *entry,
+ struct history_entry *cursor,
struct rect *clip,
int x, int y,
const struct redraw_context *ctx)
@@ -167,6 +181,15 @@ redraw_entry(struct history *history,
return res;
}
+ /* If this is the cursor, show that */
+ if (entry == cursor) {
+ rect.x0 -= 1;
+ rect.y0 -= 1;
+ rect.x1 += 2;
+ rect.y1 += 2;
+ ctx->plot->rectangle(ctx, &pstyle_rect_cursor, &rect);
+ }
+
res = guit->layout->position(plot_style_font, entry->page.title,
strlen(entry->page.title), WIDTH,
&char_offset, &actual_x);
@@ -213,7 +236,7 @@ redraw_entry(struct history *history,
return res;
}
- res = redraw_entry(history, child, clip, x, y, ctx);
+ res = redraw_entry(history, child, cursor, clip, x, y, ctx);
if (res != NSERROR_OK) {
return res;
}
@@ -258,6 +281,25 @@ find_entry_position(struct history_entry *entry, int x,
int y)
return NULL;
}
+/* exported interface documented in desktop/local_history.h */
+nserror
+local_history_scroll_to_cursor(struct local_history_session *session)
+{
+ rect cursor;
+
+ if (session->cursor == NULL) {
+ return NSERROR_OK;
+ }
+
+ cursor.x0 = session->cursor->x - RIGHT_MARGIN / 2;
+ cursor.y0 = session->cursor->y - BOTTOM_MARGIN / 2;
+ cursor.x1 = cursor.x0 + WIDTH + RIGHT_MARGIN / 2;
+ cursor.y1 = cursor.y0 + HEIGHT + BOTTOM_MARGIN / 2;
+
+ session->cw_t->scroll_visible(session->core_window_handle, &cursor);
+
+ return NSERROR_OK;
+}
/* exported interface documented in desktop/local_history.h */
nserror
@@ -283,12 +325,17 @@ local_history_init(struct core_window_callback_table
*cw_t,
pstyle_rect.stroke_colour = pstyle_line.stroke_colour;
pfstyle_node.foreground = pstyle_line.stroke_colour;
- res = ns_system_colour_char("Highlight",
&pstyle_rect_sel.stroke_colour);
+ res = ns_system_colour_char("ButtonText",
&pstyle_rect_sel.stroke_colour);
if (res != NSERROR_OK) {
return res;
}
pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour;
+ res = ns_system_colour_char("Highlight",
&pstyle_rect_cursor.stroke_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
nses = calloc(1, sizeof(struct local_history_session));
if (nses == NULL) {
return NSERROR_NOMEM;
@@ -339,11 +386,13 @@ local_history_redraw(struct local_history_session
*session,
ctx->plot->clip(ctx, &r);
ctx->plot->rectangle(ctx, &pstyle_bg, &r);
- return redraw_entry(session->bw->history,
- session->bw->history->start,
- clip,
- x, y,
- ctx);
+ return redraw_entry(
+ session->bw->history,
+ session->bw->history->start,
+ session->cursor,
+ clip,
+ x, y,
+ ctx);
}
/* exported interface documented in desktop/local_history.h */
@@ -390,6 +439,59 @@ local_history_mouse_action(struct local_history_session
*session,
bool
local_history_keypress(struct local_history_session *session, uint32_t key)
{
+ switch (key) {
+ case NS_KEY_NL:
+ case NS_KEY_CR:
+ /* pressed enter */
+ if (session->cursor != session->bw->history->current) {
+ browser_window_history_go(session->bw, session->cursor,
+ false);
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ case NS_KEY_LEFT:
+ /* Go to parent */
+ if (session->cursor->back) {
+ session->cursor = session->cursor->back;
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ case NS_KEY_RIGHT:
+ /* Go to preferred child if there is one */
+ if (session->cursor->forward_pref) {
+ session->cursor = session->cursor->forward_pref;
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ case NS_KEY_DOWN:
+ /* Go to next sibling down, if there is one */
+ if (session->cursor->next) {
+ session->cursor = session->cursor->next;
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ case NS_KEY_UP:
+ /* Go to next sibling up, if there is one */
+ if (session->cursor->back) {
+ struct history_entry *ent =
session->cursor->back->forward;
+ while (ent->next != NULL && ent->next !=
session->cursor) {
+ ent = ent->next;
+ }
+ session->cursor = ent;
+ local_history_scroll_to_cursor(session);
+ session->cw_t->invalidate(session->core_window_handle,
NULL);
+ }
+ /* We have handled this keypress */
+ return true;
+ }
return false;
}
@@ -399,12 +501,16 @@ local_history_set(struct local_history_session *session,
struct browser_window *bw)
{
session->bw = bw;
+ session->cursor = NULL;
+
if (bw != NULL) {
assert(session->bw->history != NULL);
+ session->cursor = bw->history->current;
session->cw_t->update_size(session->core_window_handle,
session->bw->history->width,
session->bw->history->height);
+ local_history_scroll_to_cursor(session);
}
return NSERROR_OK;
diff --git a/desktop/local_history.h b/desktop/local_history.h
index 7f85a63..d0d9209 100644
--- a/desktop/local_history.h
+++ b/desktop/local_history.h
@@ -140,5 +140,12 @@ nserror local_history_get_size(struct
local_history_session *session, int *width
*/
nserror local_history_get_url(struct local_history_session *session, int x,
int y, struct nsurl **url_out);
+/**
+ * Scroll the local history window to ensure the current cursor is shown.
+ *
+ * \param session The local history session
+ */
+nserror local_history_scroll_to_cursor(struct local_history_session *session);
+
#endif
diff --git a/frontends/amiga/history_local.c b/frontends/amiga/history_local.c
index fc980be..5ad77ea 100644
--- a/frontends/amiga/history_local.c
+++ b/frontends/amiga/history_local.c
@@ -319,6 +319,8 @@ nserror ami_history_local_present(struct gui_window *gw)
history_local_window = ncwin;
ami_gui_set_history_window(gw, ncwin);
+ local_history_scroll_to_cursor(ncwin->session);
+
return NSERROR_OK;
}
diff --git a/frontends/framebuffer/local_history.c
b/frontends/framebuffer/local_history.c
index cc45b1f..c1963e2 100644
--- a/frontends/framebuffer/local_history.c
+++ b/frontends/framebuffer/local_history.c
@@ -205,6 +205,7 @@ nserror fb_local_history_present(fbtk_widget_t *parent,
fbtk_set_zorder(local_history_window->core.wnd, INT_MIN);
fbtk_set_mapping(local_history_window->core.wnd, true);
+ local_history_scroll_to_cursor(local_history_window->session);
}
return res;
diff --git a/frontends/gtk/corewindow.c b/frontends/gtk/corewindow.c
index 4f05648..9dc388c 100644
--- a/frontends/gtk/corewindow.c
+++ b/frontends/gtk/corewindow.c
@@ -608,26 +608,52 @@ static void
nsgtk_cw_scroll_visible(struct core_window *cw, const struct rect *r)
{
struct nsgtk_corewindow *nsgtk_cw = (struct nsgtk_corewindow *)cw;
- int y = 0, height = 0, y0, y1;
- gdouble page;
+ int x0, y0, x1, y1;
+ gdouble vpage, hpage;
GtkAdjustment *vadj;
+ GtkAdjustment *hadj;
vadj = gtk_scrolled_window_get_vadjustment(nsgtk_cw->scrolled);
+ hadj = gtk_scrolled_window_get_hadjustment(nsgtk_cw->scrolled);
- assert(vadj);
+ assert(vadj != NULL);
+ assert(hadj != NULL);
- g_object_get(vadj, "page-size", &page, NULL);
+ g_object_get(vadj, "page-size", &vpage, NULL);
+ g_object_get(hadj, "page-size", &hpage, NULL);
y0 = (int)(gtk_adjustment_get_value(vadj));
- y1 = y0 + page;
-
- if ((y >= y0) && (y + height <= y1))
- return;
- if (y + height > y1)
- y0 = y0 + (y + height - y1);
- if (y < y0)
- y0 = y;
+ y1 = y0 + vpage;
+ x0 = (int)(gtk_adjustment_get_value(hadj));
+ x1 = x0 + hpage;
+
+ if (r->y1 > y1) {
+ /* The bottom of the rectangle is off the bottom of the
+ * window, so scroll down to fit it
+ */
+ y0 = r->y1 - vpage;
+ }
+ if (r->y0 < y0) {
+ /* The top of the rectangle is off the top of the window,
+ * so scroll up to fit it
+ */
+ y0 = r->y0;
+ }
+ if (r->x1 > x1) {
+ /* The right of the rectangle is off the right of the window
+ * so scroll right to fit it
+ */
+ x0 = r->x1 - hpage;
+ }
+ if (r->x0 < x0) {
+ /* The left of the rectangle is off the left of the window
+ * so scroll left to fit it
+ */
+ x0 = r->x0;
+ }
+
gtk_adjustment_set_value(vadj, y0);
+ gtk_adjustment_set_value(hadj, x0);
}
diff --git a/frontends/gtk/local_history.c b/frontends/gtk/local_history.c
index 35b7a4a..010fa31 100644
--- a/frontends/gtk/local_history.c
+++ b/frontends/gtk/local_history.c
@@ -225,6 +225,8 @@ nserror nsgtk_local_history_present(GtkWindow *parent,
gtk_window_resize(local_history_window->wnd, width, height);
gtk_window_present(local_history_window->wnd);
+
+ local_history_scroll_to_cursor(local_history_window->session);
}
return res;
diff --git a/frontends/riscos/local_history.c b/frontends/riscos/local_history.c
index bbe6a1d..20ca9e2 100644
--- a/frontends/riscos/local_history.c
+++ b/frontends/riscos/local_history.c
@@ -394,6 +394,8 @@ ro_local_history_open(struct ro_local_history_window *lhw,
wimp_w parent)
ro_gui_dialog_open_persistent(parent, lhw->core.wh, true);
+ local_history_scroll_to_cursor(lhw->session);
+
return NSERROR_OK;
}
diff --git a/frontends/windows/local_history.c
b/frontends/windows/local_history.c
index 722d365..823901b 100644
--- a/frontends/windows/local_history.c
+++ b/frontends/windows/local_history.c
@@ -215,6 +215,7 @@ nsw32_local_history_present(HWND hWndParent, struct
browser_window *bw)
width,
height,
SWP_SHOWWINDOW);
+ local_history_scroll_to_cursor(local_history_window->session);
}
return res;
}
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org