MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / setWMAtom

Function setWMAtom

server/faker-glx.cpp:56–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55
56void setWMAtom(Display *dpy, Window win, faker::VirtualWin *vw)
57{
58 Atom *protocols = NULL, *newProtocols = NULL; int count = 0;
59
60 Atom deleteAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", True);
61 if(!deleteAtom) goto bailout;
62
63 if(XGetWMProtocols(dpy, win, &protocols, &count) && protocols && count > 0)
64 {
65 for(int i = 0; i < count; i++)
66 if(protocols[i] == deleteAtom)
67 {
68 _XFree(protocols); return;
69 }
70 newProtocols = (Atom *)malloc(sizeof(Atom) * (count + 1));
71 if(!newProtocols) goto bailout;
72 for(int i = 0; i < count; i++)
73 newProtocols[i] = protocols[i];
74 newProtocols[count] = deleteAtom;
75 if(!XSetWMProtocols(dpy, win, newProtocols, count + 1)) goto bailout;
76 _XFree(protocols);
77 free(newProtocols);
78 }
79 else if(!XSetWMProtocols(dpy, win, &deleteAtom, 1)) goto bailout;
80 vw->enableWMDeleteHandler();
81 return;
82
83 bailout:
84 if(protocols) _XFree(protocols);
85 free(newProtocols);
86 static bool alreadyWarned = false;
87 if(!alreadyWarned)
88 {
89 if(fconfig.verbose)
90 vglout.print("[VGL] WARNING: Could not set WM_DELETE_WINDOW on window 0x%.8x\n",
91 win);
92 alreadyWarned = true;
93 }
94}
95
96
97

Callers 3

glXMakeCurrentFunction · 0.85
glXMakeContextCurrentFunction · 0.85
eglMakeCurrentFunction · 0.85

Calls 2

enableWMDeleteHandlerMethod · 0.80
printMethod · 0.45

Tested by

no test coverage detected