alter conf_grab(_kbd) to first ungrab AnyKey/AnyModifier, then proceed
to grab keys in keybindingq. we don't need to ungrab/grab on every addition to the queue, just once with a complete keybindingq; simplify grabbing keys per screen (during init) and during a MappingNotify. while here, change conf_grab_{kbd,mouse} to require only a Window.
This commit is contained in:
parent
a6aa181292
commit
4c52391113
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $OpenBSD: calmwm.h,v 1.209 2013/05/22 16:32:15 okan Exp $
|
* $OpenBSD: calmwm.h,v 1.210 2013/05/23 16:52:39 okan Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CALMWM_H_
|
#ifndef _CALMWM_H_
|
||||||
@ -435,13 +435,12 @@ void conf_bindname(struct conf *, char *, char *);
|
|||||||
void conf_clear(struct conf *);
|
void conf_clear(struct conf *);
|
||||||
void conf_client(struct client_ctx *);
|
void conf_client(struct client_ctx *);
|
||||||
void conf_cmd_add(struct conf *, char *, char *);
|
void conf_cmd_add(struct conf *, char *, char *);
|
||||||
void conf_grab(struct conf *, struct keybinding *);
|
void conf_grab_kbd(Window);
|
||||||
void conf_grab_mouse(struct client_ctx *);
|
void conf_grab_mouse(Window);
|
||||||
void conf_init(struct conf *);
|
void conf_init(struct conf *);
|
||||||
void conf_ignore(struct conf *, char *);
|
void conf_ignore(struct conf *, char *);
|
||||||
int conf_mousebind(struct conf *, char *, char *);
|
int conf_mousebind(struct conf *, char *, char *);
|
||||||
void conf_screen(struct screen_ctx *);
|
void conf_screen(struct screen_ctx *);
|
||||||
void conf_ungrab(struct conf *, struct keybinding *);
|
|
||||||
|
|
||||||
void xev_loop(void);
|
void xev_loop(void);
|
||||||
|
|
||||||
@ -453,7 +452,6 @@ int xu_getprop(Window, Atom, Atom, long, u_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, u_int, KeySym);
|
|
||||||
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);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $OpenBSD: client.c,v 1.132 2013/05/20 21:13:58 okan Exp $
|
* $OpenBSD: client.c,v 1.133 2013/05/23 16:52:39 okan Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -213,7 +213,7 @@ client_setactive(struct client_ctx *cc, int fg)
|
|||||||
XInstallColormap(X_Dpy, cc->colormap);
|
XInstallColormap(X_Dpy, cc->colormap);
|
||||||
XSetInputFocus(X_Dpy, cc->win,
|
XSetInputFocus(X_Dpy, cc->win,
|
||||||
RevertToPointerRoot, CurrentTime);
|
RevertToPointerRoot, CurrentTime);
|
||||||
conf_grab_mouse(cc);
|
conf_grab_mouse(cc->win);
|
||||||
/*
|
/*
|
||||||
* If we're in the middle of alt-tabbing, don't change
|
* If we're in the middle of alt-tabbing, don't change
|
||||||
* the order please.
|
* the order please.
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $OpenBSD: conf.c,v 1.132 2013/05/22 20:23:21 okan Exp $
|
* $OpenBSD: conf.c,v 1.133 2013/05/23 16:52:39 okan Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -98,7 +98,6 @@ static char *color_binds[CWM_COLOR_MAX] = {
|
|||||||
void
|
void
|
||||||
conf_screen(struct screen_ctx *sc)
|
conf_screen(struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
struct keybinding *kb;
|
|
||||||
int i;
|
int i;
|
||||||
XftColor xc;
|
XftColor xc;
|
||||||
|
|
||||||
@ -141,8 +140,7 @@ conf_screen(struct screen_ctx *sc)
|
|||||||
if (sc->xftdraw == NULL)
|
if (sc->xftdraw == NULL)
|
||||||
errx(1, "XftDrawCreate");
|
errx(1, "XftDrawCreate");
|
||||||
|
|
||||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
conf_grab_kbd(sc->rootwin);
|
||||||
xu_key_grab(sc->rootwin, kb->modmask, kb->keysym);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@ -436,37 +434,6 @@ static struct {
|
|||||||
{.i = CWM_TILE_VERT } },
|
{.i = CWM_TILE_VERT } },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* The following two functions are used when grabbing and ungrabbing keys for
|
|
||||||
* bindings
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Grab key combination on all screens and add to the global queue
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
conf_grab(struct conf *c, struct keybinding *kb)
|
|
||||||
{
|
|
||||||
extern struct screen_ctx_q Screenq;
|
|
||||||
struct screen_ctx *sc;
|
|
||||||
|
|
||||||
TAILQ_FOREACH(sc, &Screenq, entry)
|
|
||||||
xu_key_grab(sc->rootwin, kb->modmask, kb->keysym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ungrab key combination from all screens and remove from global queue
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
conf_ungrab(struct conf *c, struct keybinding *kb)
|
|
||||||
{
|
|
||||||
extern struct screen_ctx_q Screenq;
|
|
||||||
struct screen_ctx *sc;
|
|
||||||
|
|
||||||
TAILQ_FOREACH(sc, &Screenq, entry)
|
|
||||||
xu_key_ungrab(sc->rootwin, kb->modmask, kb->keysym);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
char chr;
|
char chr;
|
||||||
int mask;
|
int mask;
|
||||||
@ -656,17 +623,26 @@ conf_mouseunbind(struct conf *c, struct mousebinding *unbind)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Grab the mouse buttons that we need for bindings for this client
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
conf_grab_mouse(struct client_ctx *cc)
|
conf_grab_mouse(Window win)
|
||||||
{
|
{
|
||||||
struct mousebinding *mb;
|
struct mousebinding *mb;
|
||||||
|
|
||||||
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
|
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
|
||||||
if (mb->context != MOUSEBIND_CTX_WIN)
|
if (mb->context != MOUSEBIND_CTX_WIN)
|
||||||
continue;
|
continue;
|
||||||
xu_btn_grab(cc->win, mb->modmask, mb->button);
|
xu_btn_grab(win, mb->modmask, mb->button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
conf_grab_kbd(Window win)
|
||||||
|
{
|
||||||
|
struct keybinding *kb;
|
||||||
|
|
||||||
|
XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
||||||
|
xu_key_grab(win, kb->modmask, kb->keysym);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $OpenBSD: xevents.c,v 1.82 2013/05/21 00:29:20 okan Exp $
|
* $OpenBSD: xevents.c,v 1.83 2013/05/23 16:52:39 okan Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -389,15 +389,13 @@ static void
|
|||||||
xev_handle_mappingnotify(XEvent *ee)
|
xev_handle_mappingnotify(XEvent *ee)
|
||||||
{
|
{
|
||||||
XMappingEvent *e = &ee->xmapping;
|
XMappingEvent *e = &ee->xmapping;
|
||||||
struct keybinding *kb;
|
struct screen_ctx *sc;
|
||||||
|
|
||||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
|
||||||
conf_ungrab(&Conf, kb);
|
|
||||||
|
|
||||||
XRefreshKeyboardMapping(e);
|
XRefreshKeyboardMapping(e);
|
||||||
|
if (e->request == MappingKeyboard) {
|
||||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
TAILQ_FOREACH(sc, &Screenq, entry)
|
||||||
conf_grab(&Conf, kb);
|
conf_grab_kbd(sc->rootwin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $OpenBSD: xutil.c,v 1.66 2013/05/21 00:29:20 okan Exp $
|
* $OpenBSD: xutil.c,v 1.67 2013/05/23 16:52:39 okan Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -105,21 +105,6 @@ xu_key_grab(Window win, u_int mask, KeySym keysym)
|
|||||||
True, GrabModeAsync, GrabModeAsync);
|
True, GrabModeAsync, GrabModeAsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xu_key_ungrab(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++)
|
|
||||||
XUngrabKey(X_Dpy, code, (mask | ign_mods[i]), win);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xu_configure(struct client_ctx *cc)
|
xu_configure(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user