浏览代码

main.c: add zooming on mousewheel events

Signed-off-by: Dave Reisner <d@falconindy.com>
master
Dave Reisner 13 年前
父节点
当前提交
9a35f40224
共有 1 个文件被更改,包括 27 次插入0 次删除
  1. +27
    -0
      main.c

+ 27
- 0
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;


正在加载...
取消
保存