/* * This file is part of firk's window manager for x11 (fwm) * Copyright (C) 2016-2021 firk * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include #include #include "error.h" static int (*def_handle)(Display * dis, XErrorEvent * e); static int error_handle(Display * dis, XErrorEvent * e) { /* error conditions caused by latency (ex. we handling pending ConfigureRequest event for a window but that window was already destroyed and we got BadWindow) */ if(e->error_code==BadWindow || e->request_code==X_SetInputFocus && e->error_code==BadMatch || e->request_code==X_ConfigureWindow && e->error_code==BadMatch || e->request_code==X_GrabButton && e->error_code==BadAccess || e->request_code==X_GrabKey && e->error_code==BadAccess ) return 0; /* dwm also ignores (why?) BadDrawable for X_PolyText8, X_PolyFillRectangle, X_PolySegment and X_CopyArea */ return def_handle(dis, e); } extern void error_init(void) { def_handle = XSetErrorHandler(error_handle); }