cvsimport

This commit is contained in:
okan 2013-10-25 19:46:16 +00:00
commit 0c99788f66
8 changed files with 63 additions and 69 deletions

View File

@ -385,7 +385,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 *); void client_delete(struct client_ctx *, int);
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 *);
@ -523,11 +523,12 @@ void conf_screen(struct screen_ctx *);
void xev_loop(void); void xev_loop(void);
void xu_btn_grab(Window, int, u_int); void xu_btn_grab(Window, int, u_int);
void xu_btn_ungrab(Window, int, u_int); void xu_btn_ungrab(Window);
int xu_getprop(Window, Atom, Atom, long, unsigned char **); int xu_getprop(Window, Atom, Atom, long, unsigned char **);
int xu_get_wm_state(Window, int *); int xu_get_wm_state(Window, int *);
int xu_getstrprop(Window, Atom, char **); int xu_getstrprop(Window, Atom, char **);
void xu_key_grab(Window, u_int, KeySym); void xu_key_grab(Window, u_int, KeySym);
void xu_key_ungrab(Window);
void xu_ptr_getpos(Window, int *, int *); void xu_ptr_getpos(Window, int *, int *);
int xu_ptr_grab(Window, u_int, Cursor); int xu_ptr_grab(Window, u_int, Cursor);
int xu_ptr_regrab(u_int, Cursor); int xu_ptr_regrab(u_int, Cursor);

View File

@ -145,17 +145,19 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
} }
void void
client_delete(struct client_ctx *cc) client_delete(struct client_ctx *cc, int destroy)
{ {
struct screen_ctx *sc = cc->sc; struct screen_ctx *sc = cc->sc;
struct winname *wn; struct winname *wn;
XGrabServer(X_Dpy); if (destroy) {
cc->state = WithdrawnState; XGrabServer(X_Dpy);
xu_set_wm_state(cc->win, cc->state); cc->state = WithdrawnState;
XRemoveFromSaveSet(X_Dpy, cc->win); xu_set_wm_state(cc->win, cc->state);
XSync(X_Dpy, False); XRemoveFromSaveSet(X_Dpy, cc->win);
XUngrabServer(X_Dpy); 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);
@ -186,15 +188,10 @@ client_delete(struct client_ctx *cc)
void void
client_leave(struct client_ctx *cc) client_leave(struct client_ctx *cc)
{ {
struct screen_ctx *sc;
if (cc == NULL) if (cc == NULL)
cc = client_current(); cc = client_current();
if (cc == NULL) if (cc == NULL)
return; return;
sc = cc->sc;
xu_btn_ungrab(sc->rootwin, AnyModifier, Button1);
} }
void void
@ -396,8 +393,6 @@ 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);
@ -493,7 +488,6 @@ client_unhide(struct client_ctx *cc)
cc->flags &= ~CLIENT_HIDDEN; cc->flags &= ~CLIENT_HIDDEN;
cc->state = NormalState; cc->state = NormalState;
xu_set_wm_state(cc->win, cc->state); xu_set_wm_state(cc->win, cc->state);
client_draw_border(cc);
} }
void void

4
conf.c
View File

@ -649,6 +649,8 @@ conf_grab_mouse(Window win)
{ {
struct mousebinding *mb; struct mousebinding *mb;
xu_btn_ungrab(win);
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
if (mb->flags != MOUSEBIND_CTX_WIN) if (mb->flags != MOUSEBIND_CTX_WIN)
continue; continue;
@ -661,7 +663,7 @@ conf_grab_kbd(Window win)
{ {
struct keybinding *kb; struct keybinding *kb;
XUngrabKey(X_Dpy, AnyKey, AnyModifier, win); xu_key_ungrab(win);
TAILQ_FOREACH(kb, &Conf.keybindingq, entry) TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
xu_key_grab(win, kb->modmask, kb->keysym); xu_key_grab(win, kb->modmask, kb->keysym);

View File

@ -177,7 +177,7 @@ group_movetogroup(struct client_ctx *cc, int idx)
struct group_ctx *gc; struct group_ctx *gc;
if (idx < 0 || idx >= CALMWM_NGROUPS) if (idx < 0 || idx >= CALMWM_NGROUPS)
err(1, "group_movetogroup: index out of range (%d)", idx); errx(1, "group_movetogroup: index out of range (%d)", idx);
gc = &sc->groups[idx]; gc = &sc->groups[idx];
if (cc->group == gc) if (cc->group == gc)
@ -240,7 +240,7 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
struct group_ctx *gc; struct group_ctx *gc;
if (idx < 0 || idx >= CALMWM_NGROUPS) if (idx < 0 || idx >= CALMWM_NGROUPS)
err(1, "group_hidetoggle: index out of range (%d)", idx); errx(1, "group_hidetoggle: index out of range (%d)", idx);
gc = &sc->groups[idx]; gc = &sc->groups[idx];
group_fix_hidden_state(gc); group_fix_hidden_state(gc);
@ -261,7 +261,7 @@ group_only(struct screen_ctx *sc, int idx)
int i; int i;
if (idx < 0 || idx >= CALMWM_NGROUPS) if (idx < 0 || idx >= CALMWM_NGROUPS)
err(1, "group_only: index out of range (%d)", idx); errx(1, "group_only: index out of range (%d)", idx);
for (i = 0; i < CALMWM_NGROUPS; i++) { for (i = 0; i < CALMWM_NGROUPS; i++) {
if (i == idx) if (i == idx)

View File

@ -250,7 +250,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
label = "wm"; label = "wm";
break; break;
default: default:
err(1, "kbfunc_exec: invalid cmd %d", cmd); errx(1, "kbfunc_exec: invalid cmd %d", cmd);
/*NOTREACHED*/ /*NOTREACHED*/
} }
@ -305,7 +305,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
warn("%s", mi->text); warn("%s", mi->text);
break; break;
default: default:
err(1, "kb_func: egad, cmd changed value!"); errx(1, "kb_func: egad, cmd changed value!");
break; break;
} }
} }

View File

@ -88,12 +88,9 @@ mousefunc_client_resize(struct client_ctx *cc, void *arg)
mousefunc_sweep_draw(cc); mousefunc_sweep_draw(cc);
for (;;) { for (;;) {
XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev); XMaskEvent(X_Dpy, MOUSEMASK, &ev);
switch (ev.type) { switch (ev.type) {
case Expose:
client_draw_border(cc);
break;
case MotionNotify: case MotionNotify:
mousefunc_sweep_calc(cc, x, y, mousefunc_sweep_calc(cc, x, y,
ev.xmotion.x_root, ev.xmotion.y_root); ev.xmotion.x_root, ev.xmotion.y_root);
@ -143,12 +140,9 @@ mousefunc_client_move(struct client_ctx *cc, void *arg)
xu_ptr_getpos(cc->win, &px, &py); xu_ptr_getpos(cc->win, &px, &py);
for (;;) { for (;;) {
XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev); XMaskEvent(X_Dpy, MOUSEMASK, &ev);
switch (ev.type) { switch (ev.type) {
case Expose:
client_draw_border(cc);
break;
case MotionNotify: case MotionNotify:
cc->geom.x = ev.xmotion.x_root - px - cc->bwidth; cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth; cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;

View File

@ -113,7 +113,7 @@ xev_handle_unmapnotify(XEvent *ee)
*/ */
if (XCheckTypedWindowEvent(X_Dpy, cc->win, if (XCheckTypedWindowEvent(X_Dpy, cc->win,
DestroyNotify, &ev) || e->send_event != 0) { DestroyNotify, &ev) || e->send_event != 0) {
client_delete(cc); client_delete(cc, 1);
} else } else
client_hide(cc); client_hide(cc);
} }
@ -127,7 +127,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); client_delete(cc, 0);
} }
static void static void

75
xutil.c
View File

@ -32,6 +32,45 @@
static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask }; static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask };
void
xu_btn_grab(Window win, int mask, u_int btn)
{
u_int i;
for (i = 0; i < nitems(ign_mods); i++)
XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
False, BUTTONMASK, GrabModeAsync,
GrabModeSync, None, None);
}
void
xu_btn_ungrab(Window win)
{
XUngrabButton(X_Dpy, AnyButton, AnyModifier, win);
}
void
xu_key_grab(Window win, u_int mask, KeySym keysym)
{
KeyCode code;
u_int i;
code = XKeysymToKeycode(X_Dpy, keysym);
if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
(XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
mask |= ShiftMask;
for (i = 0; i < nitems(ign_mods); i++)
XGrabKey(X_Dpy, code, (mask | ign_mods[i]), win,
True, GrabModeAsync, GrabModeAsync);
}
void
xu_key_ungrab(Window win)
{
XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
}
int int
xu_ptr_grab(Window win, u_int mask, Cursor curs) xu_ptr_grab(Window win, u_int mask, Cursor curs)
{ {
@ -53,26 +92,6 @@ xu_ptr_ungrab(void)
XUngrabPointer(X_Dpy, CurrentTime); XUngrabPointer(X_Dpy, CurrentTime);
} }
void
xu_btn_grab(Window win, int mask, u_int btn)
{
u_int i;
for (i = 0; i < nitems(ign_mods); i++)
XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
False, BUTTONMASK, GrabModeAsync,
GrabModeSync, None, None);
}
void
xu_btn_ungrab(Window win, int mask, u_int btn)
{
u_int i;
for (i = 0; i < nitems(ign_mods); i++)
XUngrabButton(X_Dpy, btn, (mask | ign_mods[i]), win);
}
void void
xu_ptr_getpos(Window win, int *x, int *y) xu_ptr_getpos(Window win, int *x, int *y)
{ {
@ -89,22 +108,6 @@ xu_ptr_setpos(Window win, int x, int y)
XWarpPointer(X_Dpy, None, win, 0, 0, 0, 0, x, y); XWarpPointer(X_Dpy, None, win, 0, 0, 0, 0, x, y);
} }
void
xu_key_grab(Window win, u_int mask, KeySym keysym)
{
KeyCode code;
u_int i;
code = XKeysymToKeycode(X_Dpy, keysym);
if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
(XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
mask |= ShiftMask;
for (i = 0; i < nitems(ign_mods); i++)
XGrabKey(X_Dpy, code, (mask | ign_mods[i]), win,
True, GrabModeAsync, GrabModeAsync);
}
int int
xu_getprop(Window win, Atom atm, Atom type, long len, unsigned char **p) xu_getprop(Window win, Atom atm, Atom type, long len, unsigned char **p)
{ {