input: don’t try to close an invalid FD

This commit is contained in:
Daniel Eklöf 2021-01-04 18:32:22 +01:00
parent 9d8ca321d6
commit 21c1d9739b
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -1596,7 +1596,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
xdg_toplevel_set_maximized(win->xdg_toplevel);
}
else if (button == BTN_LEFT && win->csd.move_timeout_fd == -1) {
else if (button == BTN_LEFT && win->csd.move_timeout_fd < 0) {
const struct itimerspec timeout = {
.it_value = {.tv_nsec = 200000000},
};
@ -1610,14 +1610,15 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
win->csd.serial = serial;
} else {
LOG_ERRNO("failed to configure XDG toplevel move timer FD");
close(fd);
if (fd >= 0)
close(fd);
}
}
}
else if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
struct wl_window *win = term->window;
if (win->csd.move_timeout_fd != -1) {
if (win->csd.move_timeout_fd >= 0) {
fdm_del(wayl->fdm, win->csd.move_timeout_fd);
win->csd.move_timeout_fd = -1;
}