aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2011-01-22 22:04:55 -0500
committerDave Reisner <d@falconindy.com>2011-01-23 09:46:25 -0500
commit9a35f40224a08bfcc27b4ba79301e22a58cf4495 (patch)
treef0b4dc0b538d76509400c91d983c18ce6ec04527
parent13eb5ac929eb99955b4c58192b0aed467db1a4a2 (diff)
main.c: add zooming on mousewheel events
Signed-off-by: Dave Reisner <d@falconindy.com>
-rw-r--r--main.c27
1 files changed, 27 insertions, 0 deletions
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;