Skip to content
Snippets Groups Projects
Commit 128576c5 authored by deuce's avatar deuce
Browse files

Support CIO_KEY_QUIT in X11 mode.

parent a1c65ae3
No related branches found
No related tags found
No related merge requests found
......@@ -348,6 +348,14 @@ int x_init(void)
xp_dlclose(dl);
return(-1);
}
if((x11.XSetWMProtocols=xp_dlsym(dl,XSetWMProtocols))==NULL) {
xp_dlclose(dl);
return(-1);
}
if((x11.XInternAtom=xp_dlsym(dl,XInternAtom))==NULL) {
xp_dlclose(dl);
return(-1);
}
if(sem_init(&pastebuf_set, 0, 0)) {
xp_dlclose(dl);
......
......@@ -54,6 +54,7 @@ int x11_initialized=0;
/* Sets the atom to be used for copy/paste operations */
#define CONSOLE_CLIPBOARD XA_PRIMARY
static Atom WM_DELETE_WINDOW=0;
static Display *dpy=NULL;
static Window win;
......@@ -218,6 +219,8 @@ static int init_window()
x11.XSetWMProperties(dpy, win, NULL, NULL, 0, 0, NULL, wmhints, NULL);
}
WM_DELETE_WINDOW = x11.XInternAtom(dpy, "WM_DELETE_WINDOW", False);
gcv.function = GXcopy;
gcv.foreground = white;
gcv.background = black;
......@@ -242,6 +245,7 @@ static int init_window()
x11.XStoreName(dpy, win, "SyncConsole");
depth = DefaultDepth(dpy, DefaultScreen(dpy));
x11.XSetWMProtocols(dpy, win, &WM_DELETE_WINDOW, 1);
return(0);
}
......@@ -460,6 +464,12 @@ static void expose_rect(x,y,width,height)
static int x11_event(XEvent *ev)
{
switch (ev->type) {
case ClientMessage:
if (ev->xclient.format == 32 && ev->xclient.data.l[0] == WM_DELETE_WINDOW) {
uint16_t key=CIO_KEY_QUIT;
write(key_pipe[1], &key, 2);
}
break;
/* Graphics related events */
case ConfigureNotify:
x11_window_xpos=ev->xconfigure.x;
......
......@@ -80,6 +80,8 @@ struct x11 {
Status (*XGetWindowAttributes) (Display*,Window,XWindowAttributes*);
XWMHints* (*XAllocWMHints) (void);
void (*XSetWMProperties) (Display*, Window, XTextProperty*, XTextProperty*, char**, int, XSizeHints*, XWMHints*, XClassHint*);
Status (*XSetWMProtocols) (Display*, Window, Atom *, int);
Atom (*XInternAtom) (Display *, char *, Bool);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment