add support for NET_CLOSE_WINDOW
This commit is contained in:
parent
38c3547dfb
commit
87fce96644
|
@ -366,6 +366,7 @@ main(int argc, char *argv[])
|
|||
handler[MapRequest] = handle_event_maprequest;
|
||||
handler[PropertyNotify] = handle_event_propertynotify;
|
||||
handler[UnmapNotify] = handle_event_unmapnotify;
|
||||
handler[ClientMessage] = handle_event_clientmessage;
|
||||
|
||||
/* check for shape extension */
|
||||
if((globalconf.have_shape = XShapeQueryExtension(dpy, &shape_event, &e_dummy)))
|
||||
|
|
37
client.c
37
client.c
|
@ -781,6 +781,26 @@ uicb_client_moveresize(int screen, char *arg)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
client_kill(Client *c)
|
||||
{
|
||||
XEvent ev;
|
||||
|
||||
if(isprotodel(c->display, c->win))
|
||||
{
|
||||
ev.type = ClientMessage;
|
||||
ev.xclient.window = c->win;
|
||||
ev.xclient.message_type = XInternAtom(globalconf.display, "WM_PROTOCOLS", False);
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.data.l[0] = XInternAtom(globalconf.display, "WM_DELETE_WINDOW", False);
|
||||
ev.xclient.data.l[1] = CurrentTime;
|
||||
XSendEvent(globalconf.display, c->win, False, NoEventMask, &ev);
|
||||
}
|
||||
else
|
||||
XKillClient(globalconf.display, c->win);
|
||||
}
|
||||
|
||||
/** Kill selected client
|
||||
* \param screen Screen ID
|
||||
* \param arg unused
|
||||
|
@ -789,22 +809,9 @@ uicb_client_moveresize(int screen, char *arg)
|
|||
void
|
||||
uicb_client_kill(int screen __attribute__ ((unused)), char *arg __attribute__ ((unused)))
|
||||
{
|
||||
XEvent ev;
|
||||
Client *sel = globalconf.focus->client;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
if(isprotodel(sel->display, sel->win))
|
||||
{
|
||||
ev.type = ClientMessage;
|
||||
ev.xclient.window = sel->win;
|
||||
ev.xclient.message_type = XInternAtom(globalconf.display, "WM_PROTOCOLS", False);
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.data.l[0] = XInternAtom(globalconf.display, "WM_DELETE_WINDOW", False);
|
||||
ev.xclient.data.l[1] = CurrentTime;
|
||||
XSendEvent(globalconf.display, sel->win, False, NoEventMask, &ev);
|
||||
}
|
||||
else
|
||||
XKillClient(globalconf.display, sel->win);
|
||||
if(sel)
|
||||
client_kill(sel);
|
||||
}
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
1
client.h
1
client.h
|
@ -39,6 +39,7 @@ void client_updatewmhints(Client *);
|
|||
void client_updatesizehints(Client *);
|
||||
void client_updatetitle(Client *);
|
||||
void client_saveprops(Client *, int);
|
||||
void client_kill(Client *);
|
||||
|
||||
UICB_PROTO(uicb_client_kill);
|
||||
UICB_PROTO(uicb_client_moveresize);
|
||||
|
|
7
event.c
7
event.c
|
@ -34,6 +34,7 @@
|
|||
#include "util.h"
|
||||
#include "window.h"
|
||||
#include "mouse.h"
|
||||
#include "ewmh.h"
|
||||
#include "layouts/tile.h"
|
||||
#include "layouts/floating.h"
|
||||
|
||||
|
@ -403,6 +404,12 @@ handle_event_randr_screen_change_notify(XEvent *e)
|
|||
XRRUpdateConfiguration(e);
|
||||
}
|
||||
|
||||
void
|
||||
handle_event_clientmessage(XEvent *e)
|
||||
{
|
||||
ewmh_process_client_message(&e->xclient);
|
||||
}
|
||||
|
||||
void
|
||||
grabkeys(int phys_screen)
|
||||
{
|
||||
|
|
1
event.h
1
event.h
|
@ -42,6 +42,7 @@ void handle_event_propertynotify(XEvent *);
|
|||
void handle_event_unmapnotify(XEvent *);
|
||||
void handle_event_shape(XEvent *);
|
||||
void handle_event_randr_screen_change_notify(XEvent *);
|
||||
void handle_event_clientmessage(XEvent *);
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
16
ewmh.c
16
ewmh.c
|
@ -36,6 +36,8 @@ static Atom net_current_desktop;
|
|||
static Atom net_desktop_names;
|
||||
static Atom net_active_window;
|
||||
|
||||
static Atom net_close_window;
|
||||
|
||||
static Atom net_wm_name;
|
||||
static Atom net_wm_icon;
|
||||
|
||||
|
@ -56,6 +58,8 @@ static AtomItem AtomNames[] =
|
|||
{ "_NET_DESKTOP_NAMES", &net_desktop_names },
|
||||
{ "_NET_ACTIVE_WINDOW", &net_active_window },
|
||||
|
||||
{ "_NET_CLOSE_WINDOW", &net_close_window },
|
||||
|
||||
{ "_NET_WM_NAME", &net_wm_name },
|
||||
{ "_NET_WM_ICON", &net_wm_icon },
|
||||
|
||||
|
@ -90,6 +94,8 @@ ewmh_set_supported_hints(int phys_screen)
|
|||
atom[i++] = net_current_desktop;
|
||||
atom[i++] = net_desktop_names;
|
||||
atom[i++] = net_active_window;
|
||||
|
||||
atom[i++] = net_close_window;
|
||||
|
||||
atom[i++] = net_wm_name;
|
||||
atom[i++] = net_wm_icon;
|
||||
|
@ -184,4 +190,14 @@ ewmh_update_net_active_window(int phys_screen)
|
|||
net_active_window, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &win, 1);
|
||||
}
|
||||
|
||||
void
|
||||
ewmh_process_client_message(XClientMessageEvent *ev)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
if(ev->message_type == net_close_window)
|
||||
if((c = get_client_bywin(globalconf.clients, ev->window)))
|
||||
client_kill(c);
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
3
ewmh.h
3
ewmh.h
|
@ -22,6 +22,8 @@
|
|||
#ifndef AWESOME_EWMH_H
|
||||
#define AWESOME_EWMH_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
void ewmh_init_atoms(void);
|
||||
void ewmh_set_supported_hints(int);
|
||||
void ewmh_update_net_client_list(int);
|
||||
|
@ -29,6 +31,7 @@ void ewmh_update_net_numbers_of_desktop(int);
|
|||
void ewmh_update_net_current_desktop(int);
|
||||
void ewmh_update_net_desktop_names(int);
|
||||
void ewmh_update_net_active_window(int);
|
||||
void ewmh_process_client_message(XClientMessageEvent *);
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue