Merge commit 'robm/master' into experimental
[uzbl-mobile] / uzbl.c
diff --git a/uzbl.c b/uzbl.c
index 8eb8fda..c0cd77f 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -542,12 +542,24 @@ download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) {
 /* scroll a bar in a given direction */
 static void
 scroll (GtkAdjustment* bar, GArray *argv) {
-    gdouble amount;
     gchar *end;
+    gdouble max_value;
 
-    amount = g_ascii_strtod(g_array_index(argv, gchar*, 0), &end);
-    if (*end == '%') amount = gtk_adjustment_get_page_size(bar) * amount * 0.01;
-    gtk_adjustment_set_value (bar, gtk_adjustment_get_value(bar)+amount);
+    gdouble page_size = gtk_adjustment_get_page_size(bar);
+    gdouble value = gtk_adjustment_get_value(bar);
+    gdouble amount = g_ascii_strtod(g_array_index(argv, gchar*, 0), &end);
+
+    if (*end == '%')
+        value += page_size * amount * 0.01;
+    else
+        value += amount;
+
+    max_value = gtk_adjustment_get_upper(bar) - page_size;
+
+    if (value > max_value)
+        value = max_value; /* don't scroll past the end of the page */
+
+    gtk_adjustment_set_value (bar, value);
 }
 
 static void
@@ -2480,11 +2492,6 @@ settings_init () {
         parse_cmd_line(default_config[i].command, NULL);
     }
 
-    if (g_strcmp0(s->config_file, "-") == 0) {
-        s->config_file = NULL;
-        create_stdin();
-    }
-
     if (!s->config_file) {
         s->config_file = find_xdg_file (0, "/uzbl/config");
     }
@@ -2770,7 +2777,9 @@ main (int argc, char* argv[]) {
 
     /* WebInspector */
     set_up_inspector();
-    
+
+    create_stdin();
+
     if (verbose_override > uzbl.state.verbose)
         uzbl.state.verbose = verbose_override;