From 13eb5ac929eb99955b4c58192b0aed467db1a4a2 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 22 Jan 2011 22:03:49 -0500 Subject: window.c: include ButtonPress events in Input Signed-off-by: Dave Reisner --- window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window.c b/window.c index 752f045..0c6c53a 100644 --- a/window.c +++ b/window.c @@ -64,7 +64,7 @@ void win_open(win_t *win) { DIE("could not create window"); XSelectInput(e->dpy, win->xwin, - StructureNotifyMask | KeyPressMask); + StructureNotifyMask | KeyPressMask | ButtonPressMask); gcval.foreground = bgcol.pixel; win->bgc = XCreateGC(e->dpy, win->xwin, GCForeground, &gcval); -- cgit v1.2.3-54-g00ecf From 9a35f40224a08bfcc27b4ba79301e22a58cf4495 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 22 Jan 2011 22:04:55 -0500 Subject: main.c: add zooming on mousewheel events Signed-off-by: Dave Reisner --- main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/main.c b/main.c index a73fbf2..2910eb1 100644 --- a/main.c +++ b/main.c @@ -31,10 +31,12 @@ void on_keypress(XEvent*); void on_configurenotify(XEvent*); +void on_buttonpress(XEvent*); void update_title(); static void (*handler[LASTEvent])(XEvent*) = { + [ButtonPress] = on_buttonpress, [KeyPress] = on_keypress, [ConfigureNotify] = on_configurenotify }; @@ -126,6 +128,31 @@ void cleanup() { } } +void on_buttonpress(XEvent *ev) { + int changed; + XButtonEvent *buttonevent; + + changed = 0; + buttonevent = &ev->xbutton; + + switch (buttonevent->button) { + case Button4: + changed = img_zoom_in(&img); + break; + case Button5: + changed = img_zoom_out(&img); + break; + default: + return; + } + + if (changed) { + img_render(&img, &win); + update_title(); + timeout = 0; + } +} + void on_keypress(XEvent *ev) { char key; KeySym keysym; -- cgit v1.2.3-54-g00ecf