nsxiv0497a7f
Merge remote branch 'falconindy/mouse'
+28 −1
2 files changed
| @@ -31,10 +31,12 @@ | |||
| 31 | 31 | ||
| 32 | 32 | void on_keypress(XEvent*); | |
| 33 | 33 | void on_configurenotify(XEvent*); | |
| 34 | + | void on_buttonpress(XEvent*); | |
| 34 | 35 | ||
| 35 | 36 | void update_title(); | |
| 36 | 37 | ||
| 37 | 38 | static void (*handler[LASTEvent])(XEvent*) = { | |
| 39 | + | [ButtonPress] = on_buttonpress, | |
| 38 | 40 | [KeyPress] = on_keypress, | |
| 39 | 41 | [ConfigureNotify] = on_configurenotify | |
| 40 | 42 | }; | |
| @@ -126,6 +128,31 @@ void cleanup() { | |||
| 126 | 128 | } | |
| 127 | 129 | } | |
| 128 | 130 | ||
| 131 | + | void on_buttonpress(XEvent *ev) { | |
| 132 | + | int changed; | |
| 133 | + | XButtonEvent *buttonevent; | |
| 134 | + | ||
| 135 | + | changed = 0; | |
| 136 | + | buttonevent = &ev->xbutton; | |
| 137 | + | ||
| 138 | + | switch (buttonevent->button) { | |
| 139 | + | case Button4: | |
| 140 | + | changed = img_zoom_in(&img); | |
| 141 | + | break; | |
| 142 | + | case Button5: | |
| 143 | + | changed = img_zoom_out(&img); | |
| 144 | + | break; | |
| 145 | + | default: | |
| 146 | + | return; | |
| 147 | + | } | |
| 148 | + | ||
| 149 | + | if (changed) { | |
| 150 | + | img_render(&img, &win); | |
| 151 | + | update_title(); | |
| 152 | + | timeout = 0; | |
| 153 | + | } | |
| 154 | + | } | |
| 155 | + | ||
| 129 | 156 | void on_keypress(XEvent *ev) { | |
| 130 | 157 | char key; | |
| 131 | 158 | KeySym keysym; | |
| @@ -69,7 +69,7 @@ void win_open(win_t *win) { | |||
| 69 | 69 | DIE("could not create window"); | |
| 70 | 70 | ||
| 71 | 71 | XSelectInput(e->dpy, win->xwin, | |
| 72 | − | StructureNotifyMask | KeyPressMask); | |
| 72 | + | StructureNotifyMask | KeyPressMask | ButtonPressMask); | |
| 73 | 73 | ||
| 74 | 74 | bgc = XCreateGC(e->dpy, win->xwin, 0, None); | |
| 75 | 75 | ||