Merge remote branch 'falconindy/mouse'
This commit is contained in:
commit
0497a7f69d
27
main.c
27
main.c
@ -31,10 +31,12 @@
|
|||||||
|
|
||||||
void on_keypress(XEvent*);
|
void on_keypress(XEvent*);
|
||||||
void on_configurenotify(XEvent*);
|
void on_configurenotify(XEvent*);
|
||||||
|
void on_buttonpress(XEvent*);
|
||||||
|
|
||||||
void update_title();
|
void update_title();
|
||||||
|
|
||||||
static void (*handler[LASTEvent])(XEvent*) = {
|
static void (*handler[LASTEvent])(XEvent*) = {
|
||||||
|
[ButtonPress] = on_buttonpress,
|
||||||
[KeyPress] = on_keypress,
|
[KeyPress] = on_keypress,
|
||||||
[ConfigureNotify] = on_configurenotify
|
[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) {
|
void on_keypress(XEvent *ev) {
|
||||||
char key;
|
char key;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
|
2
window.c
2
window.c
@ -69,7 +69,7 @@ void win_open(win_t *win) {
|
|||||||
DIE("could not create window");
|
DIE("could not create window");
|
||||||
|
|
||||||
XSelectInput(e->dpy, win->xwin,
|
XSelectInput(e->dpy, win->xwin,
|
||||||
StructureNotifyMask | KeyPressMask);
|
StructureNotifyMask | KeyPressMask | ButtonPressMask);
|
||||||
|
|
||||||
bgc = XCreateGC(e->dpy, win->xwin, 0, None);
|
bgc = XCreateGC(e->dpy, win->xwin, 0, None);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user