X bug fix so that window closes properly when using a window manager
This commit is contained in:
parent
6b158b8a0b
commit
a9e802395e
1 changed files with 9 additions and 0 deletions
|
@ -81,6 +81,7 @@ static XEvent evt;
|
||||||
static Colormap cmap;
|
static Colormap cmap;
|
||||||
static XVisualInfo vis;
|
static XVisualInfo vis;
|
||||||
static XContext cxt;
|
static XContext cxt;
|
||||||
|
static Atom wmDelete;
|
||||||
|
|
||||||
typedef struct xPriv {
|
typedef struct xPriv {
|
||||||
Pixmap pix;
|
Pixmap pix;
|
||||||
|
@ -103,6 +104,12 @@ static void ProcessEvent(GDisplay *g, xPriv *priv) {
|
||||||
XCloseDisplay(dis);
|
XCloseDisplay(dis);
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
|
case ClientMessage:
|
||||||
|
if ((Atom)evt.xclient.data.l[0] == wmDelete) {
|
||||||
|
XCloseDisplay(dis);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case Expose:
|
case Expose:
|
||||||
XCopyArea(dis, priv->pix, evt.xexpose.window, priv->gc,
|
XCopyArea(dis, priv->pix, evt.xexpose.window, priv->gc,
|
||||||
evt.xexpose.x, evt.xexpose.y,
|
evt.xexpose.x, evt.xexpose.y,
|
||||||
|
@ -184,6 +191,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
||||||
dis = XOpenDisplay(0);
|
dis = XOpenDisplay(0);
|
||||||
scr = DefaultScreen(dis);
|
scr = DefaultScreen(dis);
|
||||||
cxt = XUniqueContext();
|
cxt = XUniqueContext();
|
||||||
|
wmDelete = XInternAtom(dis, "WM_DELETE_WINDOW", False);
|
||||||
XSetIOErrorHandler(FatalXIOError);
|
XSetIOErrorHandler(FatalXIOError);
|
||||||
|
|
||||||
#if GDISP_FORCE_24BIT
|
#if GDISP_FORCE_24BIT
|
||||||
|
@ -227,6 +235,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
||||||
XSync(dis, TRUE);
|
XSync(dis, TRUE);
|
||||||
|
|
||||||
XSaveContext(dis, priv->win, cxt, (XPointer)g);
|
XSaveContext(dis, priv->win, cxt, (XPointer)g);
|
||||||
|
XSetWMProtocols(dis, priv->win, &wmDelete, 1);
|
||||||
|
|
||||||
{
|
{
|
||||||
char buf[132];
|
char buf[132];
|
||||||
|
|
Loading…
Add table
Reference in a new issue