nsxiv47d107e
React to ConfigureNotify
+24 −2
3 files changed
| @@ -30,6 +30,10 @@ void on_expose(app_t *app, XEvent *ev) { | |||
| 30 | 30 | } | |
| 31 | 31 | ||
| 32 | 32 | void on_configurenotify(app_t *app, XEvent *ev) { | |
| 33 | + | if (app == NULL || ev == NULL) | |
| 34 | + | return; | |
| 35 | + | ||
| 36 | + | win_configure(&app->win, &ev->xconfigure); | |
| 33 | 37 | } | |
| 34 | 38 | ||
| 35 | 39 | void on_keypress(app_t *app, XEvent *ev) { | |
| @@ -84,3 +84,19 @@ void win_close(win_t *win) { | |||
| 84 | 84 | XFreeGC(dpy, gc); | |
| 85 | 85 | XCloseDisplay(dpy); | |
| 86 | 86 | } | |
| 87 | + | ||
| 88 | + | int win_configure(win_t *win, XConfigureEvent *cev) { | |
| 89 | + | int changed; | |
| 90 | + | ||
| 91 | + | if (win == NULL) | |
| 92 | + | return 0; | |
| 93 | + | ||
| 94 | + | changed = win->x != cev->x || win->y != cev->y || | |
| 95 | + | win->w != cev->width || win->h != cev->height; | |
| 96 | + | win->x = cev->x; | |
| 97 | + | win->y = cev->y; | |
| 98 | + | win->w = cev->width; | |
| 99 | + | win->h = cev->height; | |
| 100 | + | win->bw = cev->border_width; | |
| 101 | + | return changed; | |
| 102 | + | } | |
| @@ -33,7 +33,9 @@ typedef struct win_s { | |||
| 33 | 33 | int fullscreen; | |
| 34 | 34 | } win_t; | |
| 35 | 35 | ||
| 36 | − | void win_open(win_t *win); | |
| 37 | − | void win_close(win_t *win); | |
| 36 | + | void win_open(win_t*); | |
| 37 | + | void win_close(win_t*); | |
| 38 | + | ||
| 39 | + | int win_configure(win_t*, XConfigureEvent*); | |
| 38 | 40 | ||
| 39 | 41 | #endif /* WINDOW_H */ | |