summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2012-10-12 11:48:38 +0200
committerChristoph Lohmann <20h@r-36.net>2012-10-12 11:48:38 +0200
commit23def74c9814c1db25081965febd8424c3207e2c (patch)
tree8d36965ccad8be67cc97f423befa33446ed5d060
parente28d27249e4c24a8f9c131911536d99b5b6c4587 (diff)
downloadsurf-23def74c9814c1db25081965febd8424c3207e2c.tar.gz
surf-23def74c9814c1db25081965febd8424c3207e2c.tar.bz2
surf-23def74c9814c1db25081965febd8424c3207e2c.zip
Fixing the shift key mask and cleaning up the scrolling code.
-rw-r--r--surf.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/surf.c b/surf.c
index 48a691a..f7d9f3c 100644
--- a/surf.c
+++ b/surf.c
@@ -21,6 +21,7 @@
#include <sys/file.h>
#define LENGTH(x) (sizeof x / sizeof x[0])
+#define CLEANMASK(mask) (mask & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
enum { AtomFind, AtomGo, AtomUri, AtomLast };
@@ -360,7 +361,7 @@ keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
updatewinid(c);
for(i = 0; i < LENGTH(keys); i++) {
if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval
- && (ev->state & keys[i].mod) == keys[i].mod
+ && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
&& keys[i].func) {
keys[i].func(c, &(keys[i].arg));
processed = TRUE;
@@ -648,31 +649,37 @@ reload(Client *c, const Arg *arg) {
void
scroll_h(Client *c, const Arg *arg) {
- scroll(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(c->scroll)), arg);
+ scroll(gtk_scrolled_window_get_hadjustment(
+ GTK_SCROLLED_WINDOW(c->scroll)), arg);
}
void
scroll_v(Client *c, const Arg *arg) {
- scroll(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(c->scroll)), arg);
+ scroll(gtk_scrolled_window_get_vadjustment(
+ GTK_SCROLLED_WINDOW(c->scroll)), arg);
}
void
scroll(GtkAdjustment *a, const Arg *arg) {
- gdouble v;
+ gdouble v;
+
+ v = gtk_adjustment_get_value(a);
+ switch (arg->i){
+ case +10000:
+ case -10000:
+ v += gtk_adjustment_get_page_increment(a) *
+ (arg->i / 10000);
+ break;
+ case +20000:
+ case -20000:
+ default:
+ v += gtk_adjustment_get_step_increment(a) * arg->i;
+ }
- v = gtk_adjustment_get_value(a);
- switch (arg->i){
- case +10000:
- case -10000:
- v += gtk_adjustment_get_page_increment(a) * (arg->i / 10000); break;
- case +20000:
- case -20000:
- default:
- v += gtk_adjustment_get_step_increment(a) * arg->i;
- }
- v = MAX(v, 0.0);
- v = MIN(v, gtk_adjustment_get_upper(a) - gtk_adjustment_get_page_size(a));
- gtk_adjustment_set_value(a, v);
+ v = MAX(v, 0.0);
+ v = MIN(v, gtk_adjustment_get_upper(a) -
+ gtk_adjustment_get_page_size(a));
+ gtk_adjustment_set_value(a, v);
}
void
@@ -782,7 +789,8 @@ spawn(Client *c, const Arg *arg) {
void
eval(Client *c, const Arg *arg) {
WebKitWebFrame *frame = webkit_web_view_get_main_frame(c->view);
- evalscript(webkit_web_frame_get_global_context(frame), ((char **)arg->v)[0], "");
+ evalscript(webkit_web_frame_get_global_context(frame),
+ ((char **)arg->v)[0], "");
}
void