cvsimport

This commit is contained in:
okan 2013-11-12 21:25:00 +00:00
commit 3c78191e2e
3 changed files with 16 additions and 38 deletions

View File

@ -138,11 +138,6 @@ struct winname {
}; };
TAILQ_HEAD(winname_q, winname); TAILQ_HEAD(winname_q, winname);
enum wm_protocols {
_WM_DELETE_WINDOW = 0x0001,
_WM_TAKE_FOCUS = 0x0002,
};
struct client_ctx { struct client_ctx {
TAILQ_ENTRY(client_ctx) entry; TAILQ_ENTRY(client_ctx) entry;
TAILQ_ENTRY(client_ctx) group_entry; TAILQ_ENTRY(client_ctx) group_entry;
@ -169,7 +164,6 @@ struct client_ctx {
int x; /* x position */ int x; /* x position */
int y; /* y position */ int y; /* y position */
} ptr; } ptr;
enum wm_protocols xproto;
#define CLIENT_HIDDEN 0x0001 #define CLIENT_HIDDEN 0x0001
#define CLIENT_IGNORE 0x0002 #define CLIENT_IGNORE 0x0002
#define CLIENT_VMAXIMIZED 0x0004 #define CLIENT_VMAXIMIZED 0x0004
@ -178,6 +172,8 @@ struct client_ctx {
#define CLIENT_GROUP 0x0020 #define CLIENT_GROUP 0x0020
#define CLIENT_UNGROUP 0x0040 #define CLIENT_UNGROUP 0x0040
#define CLIENT_INPUT 0x0080 #define CLIENT_INPUT 0x0080
#define CLIENT_WM_DELETE_WINDOW 0x0100
#define CLIENT_WM_TAKE_FOCUS 0x0200
#define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP) #define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP)
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) #define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
@ -386,7 +382,7 @@ struct client_ctx *client_current(void);
void client_cycle(struct screen_ctx *, int); void client_cycle(struct screen_ctx *, int);
void client_cycle_leave(struct screen_ctx *, void client_cycle_leave(struct screen_ctx *,
struct client_ctx *); struct client_ctx *);
void client_delete(struct client_ctx *, int); void client_delete(struct client_ctx *);
void client_draw_border(struct client_ctx *); void client_draw_border(struct client_ctx *);
struct client_ctx *client_find(Window); struct client_ctx *client_find(Window);
void client_freeze(struct client_ctx *); void client_freeze(struct client_ctx *);

View File

@ -149,20 +149,11 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
} }
void void
client_delete(struct client_ctx *cc, int destroy) client_delete(struct client_ctx *cc)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct winname *wn; struct winname *wn;
if (destroy) {
XGrabServer(X_Dpy);
cc->state = WithdrawnState;
xu_set_wm_state(cc->win, cc->state);
XRemoveFromSaveSet(X_Dpy, cc->win);
XSync(X_Dpy, False);
XUngrabServer(X_Dpy);
}
TAILQ_REMOVE(&sc->mruq, cc, mru_entry); TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
TAILQ_REMOVE(&Clientq, cc, entry); TAILQ_REMOVE(&Clientq, cc, entry);
@ -211,11 +202,12 @@ client_setactive(struct client_ctx *cc, int fg)
if (fg) { if (fg) {
XInstallColormap(X_Dpy, cc->colormap); XInstallColormap(X_Dpy, cc->colormap);
if (cc->flags & CLIENT_INPUT) { if ((cc->flags & CLIENT_INPUT) ||
((cc->flags & CLIENT_WM_TAKE_FOCUS) == 0)) {
XSetInputFocus(X_Dpy, cc->win, XSetInputFocus(X_Dpy, cc->win,
RevertToPointerRoot, CurrentTime); RevertToPointerRoot, CurrentTime);
} }
if (cc->xproto & _WM_TAKE_FOCUS) if (cc->flags & CLIENT_WM_TAKE_FOCUS)
client_msg(cc, cwmh[WM_TAKE_FOCUS]); client_msg(cc, cwmh[WM_TAKE_FOCUS]);
conf_grab_mouse(cc->win); conf_grab_mouse(cc->win);
/* /*
@ -400,6 +392,8 @@ client_resize(struct client_ctx *cc, int reset)
xu_ewmh_set_net_wm_state(cc); xu_ewmh_set_net_wm_state(cc);
} }
client_draw_border(cc);
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x, XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
cc->geom.y, cc->geom.w, cc->geom.h); cc->geom.y, cc->geom.w, cc->geom.h);
client_config(cc); client_config(cc);
@ -531,9 +525,9 @@ client_wm_protocols(struct client_ctx *cc)
if (XGetWMProtocols(X_Dpy, cc->win, &p, &j)) { if (XGetWMProtocols(X_Dpy, cc->win, &p, &j)) {
for (i = 0; i < j; i++) { for (i = 0; i < j; i++) {
if (p[i] == cwmh[WM_DELETE_WINDOW]) if (p[i] == cwmh[WM_DELETE_WINDOW])
cc->xproto |= _WM_DELETE_WINDOW; cc->flags |= CLIENT_WM_DELETE_WINDOW;
else if (p[i] == cwmh[WM_TAKE_FOCUS]) else if (p[i] == cwmh[WM_TAKE_FOCUS])
cc->xproto |= _WM_TAKE_FOCUS; cc->flags |= CLIENT_WM_TAKE_FOCUS;
} }
XFree(p); XFree(p);
} }
@ -558,7 +552,7 @@ client_msg(struct client_ctx *cc, Atom proto)
void void
client_send_delete(struct client_ctx *cc) client_send_delete(struct client_ctx *cc)
{ {
if (cc->xproto & _WM_DELETE_WINDOW) if (cc->flags & CLIENT_WM_DELETE_WINDOW)
client_msg(cc, cwmh[WM_DELETE_WINDOW]); client_msg(cc, cwmh[WM_DELETE_WINDOW]);
else else
XKillClient(X_Dpy, cc->win); XKillClient(X_Dpy, cc->win);

View File

@ -97,27 +97,15 @@ static void
xev_handle_unmapnotify(XEvent *ee) xev_handle_unmapnotify(XEvent *ee)
{ {
XUnmapEvent *e = &ee->xunmap; XUnmapEvent *e = &ee->xunmap;
XEvent ev;
struct client_ctx *cc; struct client_ctx *cc;
/* XXX, we need a recursive locking wrapper around grab server */
XGrabServer(X_Dpy);
if ((cc = client_find(e->window)) != NULL) { if ((cc = client_find(e->window)) != NULL) {
/* if (e->send_event) {
* If it's going to die anyway, nuke it. cc->state = WithdrawnState;
* xu_set_wm_state(cc->win, cc->state);
* Else, if it's a synthetic event delete state, since they
* want it to be withdrawn. ICCM recommends you withdraw on
* this even if we haven't alredy been told to iconify, to
* deal with legacy clients.
*/
if (XCheckTypedWindowEvent(X_Dpy, cc->win,
DestroyNotify, &ev) || e->send_event != 0) {
client_delete(cc, 1);
} else } else
client_hide(cc); client_hide(cc);
} }
XUngrabServer(X_Dpy);
} }
static void static void
@ -127,7 +115,7 @@ xev_handle_destroynotify(XEvent *ee)
struct client_ctx *cc; struct client_ctx *cc;
if ((cc = client_find(e->window)) != NULL) if ((cc = client_find(e->window)) != NULL)
client_delete(cc, 0); client_delete(cc);
} }
static void static void