X-Git-Url: https://git.danieliu.xyz/?p=surf.git;a=blobdiff_plain;f=surf.c;h=33f5b50560b2839dabe046e79e2a077922fd6df1;hp=8a98e74d8c390c7ecb5b0ad54fdeb498fde5aa54;hb=320e4e4388ff65318f6daed76f2ab16b87e20c7b;hpb=42fdc77f5e4929fd618ab63e600ed550d52a0326 diff --git a/surf.c b/surf.c index 8a98e74..33f5b50 100644 --- a/surf.c +++ b/surf.c @@ -65,7 +65,7 @@ typedef struct Client { const char *needle; gint progress; struct Client *next; - gboolean zoomed, fullscreen; + gboolean fullscreen; } Client; typedef struct { @@ -152,7 +152,7 @@ static void mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, guint modifiers, Client *c); static void loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c); static void loaduri(Client *c, const Arg *arg); -static void navigate(Client *c, const Arg *arg); +static void navigate(Client *c, const Arg *a); static Client *newclient(Client *c); static WebKitWebView *newview(Client *c, WebKitWebView *rv); static void showview(WebKitWebView *v, Client *c); @@ -182,7 +182,7 @@ static void togglestyle(Client *c, const Arg *arg); static void updatetitle(Client *c); static void updatewinid(Client *c); static void usage(void); -static void zoom(Client *c, const Arg *arg); +static void zoom(Client *c, const Arg *a); /* configuration, allows nested code to access above variables */ #include "config.h" @@ -836,10 +836,12 @@ loaduri(Client *c, const Arg *arg) } void -navigate(Client *c, const Arg *arg) +navigate(Client *c, const Arg *a) { - int steps = *(int *)arg; - webkit_web_view_go_back_or_forward(c->view, steps); + if (a->i < 0) + webkit_web_view_go_back(c->view); + else if (a->i > 0) + webkit_web_view_go_forward(c->view); } Client * @@ -994,7 +996,6 @@ showview(WebKitWebView *v, Client *c) gdk_window_set_events(gwin, GDK_ALL_EVENTS_MASK); gdk_window_add_filter(gwin, processx, c); - /* This might conflict with _zoomto96dpi_. */ if (zoomlevel != 1.0) webkit_web_view_set_zoom_level(c->view, zoomlevel); @@ -1421,20 +1422,16 @@ usage(void) } void -zoom(Client *c, const Arg *arg) -{ - c->zoomed = TRUE; - if (arg->i < 0) { - /* zoom out */ - webkit_web_view_zoom_out(c->view); - } else if (arg->i > 0) { - /* zoom in */ - webkit_web_view_zoom_in(c->view); - } else { - /* reset */ - c->zoomed = FALSE; +zoom(Client *c, const Arg *a) +{ + if (a->i > 0) + webkit_web_view_set_zoom_level(c->view, zoomlevel + 0.1); + else if (a->i < 0) + webkit_web_view_set_zoom_level(c->view, zoomlevel - 0.1); + else webkit_web_view_set_zoom_level(c->view, 1.0); - } + + zoomlevel = webkit_web_view_get_zoom_level(c->view); } int