[hackers] [surf] adding autozoom for small windows || Enno Boland (tox)

From: <hg_AT_suckless.org>
Date: Tue, 20 Oct 2009 18:31:48 +0000 (UTC)

changeset: 142:f25786dd737d
tag: tip
user: Enno Boland (tox) <tox_AT_s01.de>
date: Tue Oct 20 20:34:13 2009 +0200
files: surf.c
description:
adding autozoom for small windows

diff -r 1ae084e7bd14 -r f25786dd737d surf.c
--- a/surf.c Tue Oct 20 19:51:14 2009 +0200
+++ b/surf.c Tue Oct 20 20:34:13 2009 +0200
@@ -106,6 +106,7 @@
 static void progresschange(WebKitWebView *v, gint p, Client *c);
 static void reloadcookies();
 static void reload(Client *c, const Arg *arg);
+static void resize(GtkWidget *w, GtkAllocation *a, Client *c);
 static void sigchld(int unused);
 static void setup(void);
 static void spawn(Client *c, const Arg *arg);
@@ -470,6 +471,7 @@
         gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
         g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(destroywin), c);
         g_signal_connect(G_OBJECT(c->win), "key-press-event", G_CALLBACK(keypress), c);
+ g_signal_connect(G_OBJECT(c->win), "size-allocate", G_CALLBACK(resize), c);
 
         if(!(c->items = calloc(1, sizeof(GtkWidget *) * LENGTH(items))))
                 die("Cannot malloc!\n");
@@ -675,6 +677,19 @@
 }
 
 void
+resize(GtkWidget *w, GtkAllocation *a, Client *c) {
+ double zoom;
+
+ zoom = webkit_web_view_get_zoom_level(c->view);
+ if(a->width * a->height < 300 * 300 && zoom != 0.2)
+ webkit_web_view_set_zoom_level(c->view, 0.2);
+ else if(zoom != 1.0)
+ webkit_web_view_set_zoom_level(c->view, 1.0);
+}
+
+
+
+void
 sigchld(int unused) {
         if(signal(SIGCHLD, sigchld) == SIG_ERR)
                 die("Can't install SIGCHLD handler");
Received on Tue Oct 20 2009 - 18:31:48 UTC

This archive was generated by hypermail 2.2.0 : Tue Oct 20 2009 - 18:36:05 UTC