3814: Fix x11 notify by Maiski r=def- a=Jupeyy

This works on KDE without problems, he also tested on i3

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
bors[bot] 2021-05-07 21:33:46 +00:00 committed by GitHub
commit 5d0e820af4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1116,21 +1116,22 @@ void CGraphicsBackend_SDL_OpenGL::NotifyWindow()
FlashWindowEx(&desc);
#elif defined(SDL_VIDEO_DRIVER_X11) && !defined(CONF_PLATFORM_MACOS)
Display *dpy = info.info.x11.display;
Window win = info.info.x11.window;
Display *pX11Dpy = info.info.x11.display;
Window X11Win = info.info.x11.window;
// Old hints
XWMHints *wmhints;
wmhints = XAllocWMHints();
wmhints->flags = XUrgencyHint;
XSetWMHints(dpy, win, wmhints);
XFree(wmhints);
static Atom s_DemandsAttention = XInternAtom(pX11Dpy, "_NET_WM_STATE_DEMANDS_ATTENTION", true);
static Atom s_WmState = XInternAtom(pX11Dpy, "_NET_WM_STATE", true);
// More modern way of notifying
static Atom demandsAttention = XInternAtom(dpy, "_NET_WM_STATE_DEMANDS_ATTENTION", true);
static Atom wmState = XInternAtom(dpy, "_NET_WM_STATE", true);
XChangeProperty(dpy, win, wmState, XA_ATOM, 32, PropModeReplace,
(unsigned char *)&demandsAttention, 1);
XEvent SndNtfyEvent = {ClientMessage};
SndNtfyEvent.xclient.window = X11Win;
SndNtfyEvent.xclient.message_type = s_WmState;
SndNtfyEvent.xclient.format = 32;
SndNtfyEvent.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD
SndNtfyEvent.xclient.data.l[1] = s_DemandsAttention;
SndNtfyEvent.xclient.data.l[2] = 0;
SndNtfyEvent.xclient.data.l[3] = 1; // normal application
SndNtfyEvent.xclient.data.l[4] = 0;
XSendEvent(pX11Dpy, XDefaultRootWindow(pX11Dpy), False, SubstructureNotifyMask | SubstructureRedirectMask, &SndNtfyEvent);
#endif
}