Do not trigger resize when window is moved

This commit is contained in:
dec05eba 2020-03-31 18:53:07 +02:00
parent 066f2b652c
commit ac7eec12f0

View File

@ -579,19 +579,28 @@ int main(int argc, char **argv) {
exit(1); exit(1);
} }
XWindowAttributes xwa;
XGetWindowAttributes(dpy, src_window_id, &xwa);
int window_width = xwa.width;
int window_height = xwa.height;
XEvent e; XEvent e;
while (!glfwWindowShouldClose(window)) { while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
if (XCheckTypedEvent(dpy, ConfigureNotify, &e)) { if (XCheckTypedWindowEvent(dpy, src_window_id, ConfigureNotify, &e) && e.xconfigure.window == src_window_id) {
// Window resize // Window resize
fprintf(stderr, "Resize window!\n"); if(e.xconfigure.width != window_width || e.xconfigure.height != window_height) {
recreate_window_pixmap(dpy, src_window_id, window_pixmap); 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"); // fprintf(stderr, "Redraw!\n");
XDamageNotifyEvent *de = (XDamageNotifyEvent *)&e; XDamageNotifyEvent *de = (XDamageNotifyEvent *)&e;
// de->drawable is the window ID of the damaged window // de->drawable is the window ID of the damaged window