diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2013-05-19 17:02:05 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2013-05-19 17:02:05 +0000 |
commit | 8890c6b9266135aeb05f08fb94d87ea04e05133d (patch) | |
tree | 428b03ae33efec96b40efb3921f6a07237f17713 | |
parent | ac840a8313987cb6d73e8f213f219e75c33ae968 (diff) |
use XGetWMProtocols and simplify WM_PROTOCOL handling
-rw-r--r-- | app/cwm/calmwm.h | 11 | ||||
-rw-r--r-- | app/cwm/client.c | 35 |
2 files changed, 23 insertions, 23 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index ca5b6c166..4684929ba 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.199 2013/05/14 12:35:56 okan Exp $ + * $OpenBSD: calmwm.h,v 1.200 2013/05/19 17:02:04 okan Exp $ */ #ifndef _CALMWM_H_ @@ -121,6 +121,11 @@ struct winname { }; TAILQ_HEAD(winname_q, winname); +enum wm_protocols { + _WM_DELETE_WINDOW = 0x0001, + _WM_TAKE_FOCUS = 0x0002, +}; + struct client_ctx { TAILQ_ENTRY(client_ctx) entry; TAILQ_ENTRY(client_ctx) group_entry; @@ -147,9 +152,7 @@ struct client_ctx { int x; /* x position */ int y; /* y position */ } ptr; -#define CLIENT_PROTO_DELETE 0x0001 -#define CLIENT_PROTO_TAKEFOCUS 0x0002 - int xproto; + enum wm_protocols xproto; #define CLIENT_HIDDEN 0x0001 #define CLIENT_IGNORE 0x0002 #define CLIENT_VMAXIMIZED 0x0004 diff --git a/app/cwm/client.c b/app/cwm/client.c index e71e22bfb..147f3926c 100644 --- a/app/cwm/client.c +++ b/app/cwm/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: client.c,v 1.129 2013/05/11 22:01:07 okan Exp $ + * $OpenBSD: client.c,v 1.130 2013/05/19 17:02:04 okan Exp $ */ #include <sys/param.h> @@ -36,7 +36,7 @@ static struct client_ctx *client_mruprev(struct client_ctx *); static void client_mtf(struct client_ctx *); static void client_none(struct screen_ctx *); static void client_placecalc(struct client_ctx *); -static void client_update(struct client_ctx *); +static void client_wm_protocols(struct client_ctx *); static void client_getmwmhints(struct client_ctx *); static int client_inbound(struct client_ctx *, int, int); @@ -132,7 +132,7 @@ client_init(Window win, struct screen_ctx *sc, int mapped) xu_ewmh_net_client_list(sc); - client_update(cc); + client_wm_protocols(cc); if (mapped) group_autogroup(cc); @@ -497,29 +497,26 @@ client_draw_border(struct client_ctx *cc) } static void -client_update(struct client_ctx *cc) +client_wm_protocols(struct client_ctx *cc) { Atom *p; - int i; - long n; - - if ((n = xu_getprop(cc->win, cwmh[WM_PROTOCOLS].atom, - XA_ATOM, 20L, (u_char **)&p)) <= 0) - return; - - for (i = 0; i < n; i++) - if (p[i] == cwmh[WM_DELETE_WINDOW].atom) - cc->xproto |= CLIENT_PROTO_DELETE; - else if (p[i] == cwmh[WM_TAKE_FOCUS].atom) - cc->xproto |= CLIENT_PROTO_TAKEFOCUS; - - XFree(p); + int i, j; + + if (XGetWMProtocols(X_Dpy, cc->win, &p, &j)) { + for (i = 0; i < j; i++) { + if (p[i] == cwmh[WM_DELETE_WINDOW].atom) + cc->xproto |= _WM_DELETE_WINDOW; + else if (p[i] == cwmh[WM_TAKE_FOCUS].atom) + cc->xproto |= _WM_TAKE_FOCUS; + } + XFree(p); + } } void client_send_delete(struct client_ctx *cc) { - if (cc->xproto & CLIENT_PROTO_DELETE) + if (cc->xproto & _WM_DELETE_WINDOW) xu_sendmsg(cc->win, cwmh[WM_PROTOCOLS].atom, cwmh[WM_DELETE_WINDOW].atom); else |