diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-03-31 18:53:07 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-03-31 18:53:07 +0200 |
commit | ac7eec12f0ae73e449bdeb487e70820a2ac25d82 (patch) | |
tree | 08991f4bf56f4d805b8ae9a6d740a346dde263dd /src/main.cpp | |
parent | 066f2b652c25687dbb1e51c9baa5f4c62140cf07 (diff) |
Do not trigger resize when window is moved
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index df63a1b..c228a06 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -579,19 +579,28 @@ int main(int argc, char **argv) { exit(1); } + XWindowAttributes xwa; + XGetWindowAttributes(dpy, src_window_id, &xwa); + int window_width = xwa.width; + int window_height = xwa.height; + XEvent e; while (!glfwWindowShouldClose(window)) { glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(window); glfwPollEvents(); - if (XCheckTypedEvent(dpy, ConfigureNotify, &e)) { + if (XCheckTypedWindowEvent(dpy, src_window_id, ConfigureNotify, &e) && e.xconfigure.window == src_window_id) { // Window resize - fprintf(stderr, "Resize window!\n"); - recreate_window_pixmap(dpy, src_window_id, window_pixmap); + if(e.xconfigure.width != window_width || e.xconfigure.height != window_height) { + window_width = e.xconfigure.width; + window_height = e.xconfigure.height; + fprintf(stderr, "Resize window!\n"); + recreate_window_pixmap(dpy, src_window_id, window_pixmap); + } } - if (XCheckTypedEvent(dpy, damage_event + XDamageNotify, &e)) { + if (XCheckTypedWindowEvent(dpy, src_window_id, damage_event + XDamageNotify, &e)) { // fprintf(stderr, "Redraw!\n"); XDamageNotifyEvent *de = (XDamageNotifyEvent *)&e; // de->drawable is the window ID of the damaged window |