File indexing completed on 2024-04-14 14:20:37
0001 /* 0002 0003 Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org> 0004 0005 Permission is hereby granted, free of charge, to any person obtaining a 0006 copy of this software and associated documentation files (the "Software"), 0007 to deal in the Software without restriction, including without limitation 0008 the rights to use, copy, modify, merge, publish, distribute, sublicense, 0009 and/or sell copies of the Software, and to permit persons to whom the 0010 Software is furnished to do so, subject to the following conditions: 0011 0012 The above copyright notice and this permission notice shall be included in 0013 all copies or substantial portions of the Software. 0014 0015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 0018 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 0020 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 0021 DEALINGS IN THE SOFTWARE. 0022 0023 */ 0024 #include <QWidget> 0025 #include <X11/Xlib.h> 0026 #include <iostream> 0027 using namespace std; 0028 0029 #include <kxerrorhandler.h> 0030 0031 int handler1(Display *, XErrorEvent *e) 0032 { 0033 cout << "ERR1:" << e->resourceid << ":" << (int)e->error_code << ":" << (int)e->request_code << ":" << e->serial << endl; 0034 return 1; 0035 } 0036 0037 bool handler3(int request, int error_code, unsigned long resourceid) 0038 { 0039 cout << "ERR3:" << resourceid << ":" << error_code << ":" << request << endl; 0040 return true; 0041 } 0042 0043 int main() 0044 { 0045 Display *dpy = XOpenDisplay(nullptr); 0046 XSetWindowAttributes attrs; 0047 Window w = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 100, 100, 0, CopyFromParent, CopyFromParent, 0048 CopyFromParent, 0, &attrs); 0049 cout << w << ":" << XNextRequest(dpy) << endl; 0050 XMapWindow(dpy, w); 0051 ++w; 0052 // XSetInputFocus( dpy, w, RevertToParent, CurrentTime ); 0053 { 0054 KXErrorHandler handle1(handler1, dpy); 0055 cout << w << ":" << XNextRequest(dpy) << endl; 0056 XMapWindow(dpy, w); 0057 XWindowAttributes attr; 0058 { 0059 KXErrorHandler handle2(dpy); 0060 XGetWindowAttributes(dpy, w, &attr); 0061 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 0062 { 0063 KXErrorHandler handle3(handler3, dpy); 0064 XSetInputFocus(dpy, w, RevertToParent, CurrentTime); 0065 cout << "WAS3:" << handle3.error(/*false*/ true) << endl; 0066 } 0067 #endif 0068 cout << "WAS2:" << handle2.error(false) << endl; 0069 } 0070 // XSync( dpy, False ); 0071 cout << "WAS1:" << handle1.error(false) << endl; 0072 } 0073 for (;;) { 0074 XEvent ev; 0075 XNextEvent(dpy, &ev); 0076 } 0077 XCloseDisplay(dpy); 0078 }