adding autozoom lock when site is already zoomed.

This commit is contained in:
Enno Boland (tox) 2009-10-20 20:49:33 +02:00
parent 92afa03d80
commit 31441e93f7
1 changed files with 8 additions and 2 deletions

10
surf.c
View File

@ -37,6 +37,7 @@ typedef struct Client {
char *title, *linkhover; char *title, *linkhover;
gint progress; gint progress;
struct Client *next; struct Client *next;
gboolean zoomed;
} Client; } Client;
typedef struct { typedef struct {
@ -680,8 +681,10 @@ void
resize(GtkWidget *w, GtkAllocation *a, Client *c) { resize(GtkWidget *w, GtkAllocation *a, Client *c) {
double zoom; double zoom;
if(c->zoomed)
return;
zoom = webkit_web_view_get_zoom_level(c->view); zoom = webkit_web_view_get_zoom_level(c->view);
if(a->width * a->height < 300 * 300 && zoom != 0.2) if(a->width * a->height < 300 * 400 && zoom != 0.2)
webkit_web_view_set_zoom_level(c->view, 0.2); webkit_web_view_set_zoom_level(c->view, 0.2);
else if(zoom != 1.0) else if(zoom != 1.0)
webkit_web_view_set_zoom_level(c->view, 1.0); webkit_web_view_set_zoom_level(c->view, 1.0);
@ -839,12 +842,15 @@ windowobjectcleared(GtkWidget *w, WebKitWebFrame *frame, JSContextRef js, JSObje
void void
zoom(Client *c, const Arg *arg) { zoom(Client *c, const Arg *arg) {
c->zoomed = TRUE;
if(arg->i < 0) /* zoom out */ if(arg->i < 0) /* zoom out */
webkit_web_view_zoom_out(c->view); webkit_web_view_zoom_out(c->view);
else if(arg->i > 0) /* zoom in */ else if(arg->i > 0) /* zoom in */
webkit_web_view_zoom_in(c->view); webkit_web_view_zoom_in(c->view);
else /* reset */ else { /* reset */
c->zoomed = FALSE;
webkit_web_view_set_zoom_level(c->view, 1.0); webkit_web_view_set_zoom_level(c->view, 1.0);
}
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {