Przeglądaj źródła

Reordered function definitions

master
Bert 14 lat temu
rodzic
commit
544fd83718
2 zmienionych plików z 30 dodań i 26 usunięć
  1. +23
    -19
      events.c
  2. +7
    -7
      main.c

+ 23
- 19
events.c Wyświetl plik

@@ -24,16 +24,25 @@
#include "events.h" #include "events.h"
#include "window.h" #include "window.h"


void on_keypress(app_t*, XEvent*);
void on_configurenotify(app_t*, XEvent*);
void on_expose(app_t*, XEvent*);

extern Display *dpy; extern Display *dpy;


void on_expose(app_t *app, XEvent *ev) {
}
static void (*handler[LASTEvent])(app_t*, XEvent*) = {
[Expose] = on_expose,
[ConfigureNotify] = on_configurenotify,
[KeyPress] = on_keypress
};


void on_configurenotify(app_t *app, XEvent *ev) {
if (!app || !ev)
return;
win_configure(&app->win, &ev->xconfigure);
void event_loop(app_t *app) {
XEvent ev;

while (!XNextEvent(dpy, &ev)) {
if (handler[ev.type])
handler[ev.type](app, &ev);
}
} }


void on_keypress(app_t *app, XEvent *ev) { void on_keypress(app_t *app, XEvent *ev) {
@@ -56,17 +65,12 @@ void on_keypress(app_t *app, XEvent *ev) {
} }
} }


static void (*handler[LASTEvent])(app_t*, XEvent*) = {
[Expose] = on_expose,
[ConfigureNotify] = on_configurenotify,
[KeyPress] = on_keypress
};

void event_loop(app_t *app) {
XEvent ev;
void on_configurenotify(app_t *app, XEvent *ev) {
if (!app || !ev)
return;
win_configure(&app->win, &ev->xconfigure);
}


while (!XNextEvent(dpy, &ev)) {
if (handler[ev.type])
handler[ev.type](app, &ev);
}
void on_expose(app_t *app, XEvent *ev) {
} }

+ 7
- 7
main.c Wyświetl plik

@@ -23,13 +23,6 @@


app_t app; app_t app;


void cleanup() {
static int in = 0;

if (!in++)
app_quit(&app);
}

int main(int argc, char **argv) { int main(int argc, char **argv) {


// TODO: parse cmd line arguments properly // TODO: parse cmd line arguments properly
@@ -42,3 +35,10 @@ int main(int argc, char **argv) {


return 0; return 0;
} }

void cleanup() {
static int in = 0;

if (!in++)
app_quit(&app);
}

Ładowanie…
Anuluj
Zapisz