summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2017-04-26 22:24:57 +0100
committerVincent Sanders <vince@kyllikki.org>2017-04-26 22:24:57 +0100
commit0f039b44212d312fa6920ec60e59df1313182913 (patch)
treebcc90ce09b90de10b00f46704380e418a0ebd5f4 /frontends
parenta696720cd605439be5473de209531c5113f47a97 (diff)
downloadnetsurf-0f039b44212d312fa6920ec60e59df1313182913.tar.gz
netsurf-0f039b44212d312fa6920ec60e59df1313182913.tar.bz2
Update GTK frontend for set_scroll API change
Diffstat (limited to 'frontends')
-rw-r--r--frontends/gtk/window.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index ecd6d0a35..78a6f6274 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1041,11 +1041,25 @@ static void gui_window_set_status(struct gui_window *g, const char *text)
}
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+/**
+ * Set the scroll position of a gtk browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The GTK implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout);
GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout);
- gdouble vlower, vpage, vupper, hlower, hpage, hupper, x = (double)sx, y = (double)sy;
+ gdouble vlower, vpage, vupper, hlower, hpage, hupper;
+ gdouble x = (gdouble)rect->x0;
+ gdouble y = (gdouble)rect->y0;
assert(vadj);
assert(hadj);
@@ -1053,17 +1067,23 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
g_object_get(vadj, "page-size", &vpage, "lower", &vlower, "upper", &vupper, NULL);
g_object_get(hadj, "page-size", &hpage, "lower", &hlower, "upper", &hupper, NULL);
- if (x < hlower)
+ if (x < hlower) {
x = hlower;
- if (x > (hupper - hpage))
+ }
+ if (x > (hupper - hpage)) {
x = hupper - hpage;
- if (y < vlower)
+ }
+ if (y < vlower) {
y = vlower;
- if (y > (vupper - vpage))
+ }
+ if (y > (vupper - vpage)) {
y = vupper - vpage;
+ }
gtk_adjustment_set_value(vadj, y);
gtk_adjustment_set_value(hadj, x);
+
+ return NSERROR_OK;
}
static void gui_window_update_extent(struct gui_window *g)