move synthetic responses and have client_msg only work with WM_PROTOCOLS,

since that's all ClientMessageEvent is for anyway.
This commit is contained in:
okan 2013-06-10 21:37:30 +00:00
parent b365ceac0e
commit 6059073a5f
4 changed files with 43 additions and 43 deletions

View File

@ -311,6 +311,7 @@ struct mwm_hints {
__dead void usage(void);
void client_applysizehints(struct client_ctx *);
void client_config(struct client_ctx *);
struct client_ctx *client_current(void);
void client_cycle(struct screen_ctx *, int);
void client_cycle_leave(struct screen_ctx *,
@ -327,6 +328,7 @@ void client_leave(struct client_ctx *);
void client_lower(struct client_ctx *);
void client_map(struct client_ctx *);
void client_maximize(struct client_ctx *);
void client_msg(struct client_ctx *, Atom);
void client_move(struct client_ctx *);
struct client_ctx *client_init(Window, struct screen_ctx *, int);
void client_ptrsave(struct client_ctx *);
@ -446,7 +448,6 @@ void xev_loop(void);
void xu_btn_grab(Window, int, u_int);
void xu_btn_ungrab(Window, int, u_int);
void xu_configure(struct client_ctx *);
void xu_getatoms(void);
int xu_getprop(Window, Atom, Atom, long, u_char **);
int xu_get_wm_state(Window, int *);
@ -457,7 +458,6 @@ int xu_ptr_grab(Window, u_int, Cursor);
int xu_ptr_regrab(u_int, Cursor);
void xu_ptr_setpos(Window, int, int);
void xu_ptr_ungrab(void);
void xu_sendmsg(Window, Atom, Atom);
void xu_set_wm_state(Window win, int);
void xu_xft_draw(struct screen_ctx *, const char *,
int, int, int);

View File

@ -123,7 +123,7 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
client_transient(cc);
/* Notify client of its configuration. */
xu_configure(cc);
client_config(cc);
(state == IconicState) ? client_hide(cc) : client_unhide(cc);
@ -400,14 +400,14 @@ client_resize(struct client_ctx *cc, int reset)
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
cc->geom.y, cc->geom.w, cc->geom.h);
xu_configure(cc);
client_config(cc);
}
void
client_move(struct client_ctx *cc)
{
XMoveWindow(X_Dpy, cc->win, cc->geom.x, cc->geom.y);
xu_configure(cc);
client_config(cc);
}
void
@ -422,6 +422,26 @@ client_raise(struct client_ctx *cc)
XRaiseWindow(X_Dpy, cc->win);
}
void
client_config(struct client_ctx *cc)
{
XConfigureEvent cn;
bzero(&cn, sizeof(cn));
cn.type = ConfigureNotify;
cn.event = cc->win;
cn.window = cc->win;
cn.x = cc->geom.x;
cn.y = cc->geom.y;
cn.width = cc->geom.w;
cn.height = cc->geom.h;
cn.border_width = cc->bwidth;
cn.above = None;
cn.override_redirect = 0;
XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&cn);
}
void
client_ptrwarp(struct client_ctx *cc)
{
@ -518,12 +538,27 @@ client_wm_protocols(struct client_ctx *cc)
}
}
void
client_msg(struct client_ctx *cc, Atom proto)
{
XClientMessageEvent cm;
bzero(&cm, sizeof(cm));
cm.type = ClientMessage;
cm.window = cc->win;
cm.message_type = cwmh[WM_PROTOCOLS].atom;
cm.format = 32;
cm.data.l[0] = proto;
cm.data.l[1] = CurrentTime;
XSendEvent(X_Dpy, cc->win, False, NoEventMask, (XEvent *)&cm);
}
void
client_send_delete(struct client_ctx *cc)
{
if (cc->xproto & _WM_DELETE_WINDOW)
xu_sendmsg(cc->win,
cwmh[WM_PROTOCOLS].atom, cwmh[WM_DELETE_WINDOW].atom);
client_msg(cc, cwmh[WM_DELETE_WINDOW].atom);
else
XKillClient(X_Dpy, cc->win);
}

View File

@ -169,7 +169,7 @@ xev_handle_configurerequest(XEvent *ee)
wc.border_width = cc->bwidth;
XConfigureWindow(X_Dpy, cc->win, e->value_mask, &wc);
xu_configure(cc);
client_config(cc);
} else {
/* let it do what it wants, it'll be ours when we map it. */
wc.x = e->x;

35
xutil.c
View File

@ -105,41 +105,6 @@ xu_key_grab(Window win, u_int mask, KeySym keysym)
True, GrabModeAsync, GrabModeAsync);
}
void
xu_configure(struct client_ctx *cc)
{
XConfigureEvent ce;
ce.type = ConfigureNotify;
ce.event = cc->win;
ce.window = cc->win;
ce.x = cc->geom.x;
ce.y = cc->geom.y;
ce.width = cc->geom.w;
ce.height = cc->geom.h;
ce.border_width = cc->bwidth;
ce.above = None;
ce.override_redirect = 0;
XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce);
}
void
xu_sendmsg(Window win, Atom type, Atom atm)
{
XClientMessageEvent e;
bzero(&e, sizeof(e));
e.type = ClientMessage;
e.window = win;
e.message_type = type;
e.format = 32;
e.data.l[0] = atm;
e.data.l[1] = CurrentTime;
XSendEvent(X_Dpy, win, False, 0L, (XEvent *)&e);
}
int
xu_getprop(Window win, Atom atm, Atom type, long len, u_char **p)
{