Krolyxon
Commit 8c24034

Branches

Refs →

nsxiv8c24034

Added event handlers

Author
Bert
Date
2011-01-17 16:43 +0100
Parent
49a69a3
Commit
8c240341f1c457b92a703b88087b03ccb774f4d4

+84 −0

2 files changed

  1. A events.c +58 −0
  2. A events.h +26 −0
A events.c View
@@ -0,0 +1,58 @@
1+/* sxiv: events.c
2+ * Copyright (c) 2011 Bert Muennich <muennich at informatik.hu-berlin.de>
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; either version 2 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program; if not, write to the Free Software
16+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17+ */
18+
19+#include <stdlib.h>
20+
21+#include <X11/Xlib.h>
22+#include <X11/keysym.h>
23+
24+#include "events.h"
25+
26+extern Display *dpy;
27+
28+void on_expose(app_t *app, XEvent *ev) {
29+}
30+
31+void on_configurenotify(app_t *app, XEvent *ev) {
32+}
33+
34+void on_keypress(app_t *app, XEvent *ev) {
35+ KeySym keysym;
36+ XKeyEvent *kev;
37+
38+ if (app == NULL || ev == NULL)
39+ return;
40+
41+ kev = &ev->xkey;
42+ keysym = XKeycodeToKeysym(dpy, (KeyCode) kev->keycode, 0);
43+
44+ switch (keysym) {
45+ case XK_q:
46+ app_quit(app);
47+ exit(0);
48+ }
49+}
50+
51+static void (*handler[LASTEvent])(app_t*, XEvent*) = {
52+ [Expose] = on_expose,
53+ [ConfigureNotify] = on_configurenotify,
54+ [KeyPress] = on_keypress
55+};
56+
57+void event_loop(app_t *app) {
58+}
A events.h View
@@ -0,0 +1,26 @@
1+/* sxiv: events.h
2+ * Copyright (c) 2011 Bert Muennich <muennich at informatik.hu-berlin.de>
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; either version 2 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program; if not, write to the Free Software
16+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17+ */
18+
19+#ifndef EVENTS_H
20+#define EVENTS_H
21+
22+#include "app.h"
23+
24+void event_loop(app_t*);
25+
26+#endif /* EVENTS_H */