aboutsummaryrefslogtreecommitdiffstats
path: root/xevents.c
diff options
context:
space:
mode:
authorokan2008-06-14 21:48:54 +0000
committerokan2008-06-14 21:48:54 +0000
commitc13dbbd835133e5160bdeefa8251adef63c56a9e (patch)
tree7839e98d228f6339db838ea006fa49f539d18763 /xevents.c
parentb41388716ed8af14f5165df937627ad66200a0b5 (diff)
downloadcwm-c13dbbd835133e5160bdeefa8251adef63c56a9e.tar.gz
confable menu and window mouse bindings from rivo nurges (thanks!) with
some minor fixups, man page bits and knf. ok oga@
Diffstat (limited to 'xevents.c')
-rw-r--r--xevents.c111
1 files changed, 14 insertions, 97 deletions
diff --git a/xevents.c b/xevents.c
index 926cdc3..5ab7d70 100644
--- a/xevents.c
+++ b/xevents.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.
*
- * $Id: xevents.c,v 1.18 2008/06/13 03:41:58 oga Exp $
+ * $Id: xevents.c,v 1.19 2008/06/14 21:48:54 okan Exp $
*/
/*
@@ -221,113 +221,30 @@ void
xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
{
XButtonEvent *e = &ee->xbutton;
- struct client_ctx *cc, *old_cc = client_current();
+ struct client_ctx *cc;
struct screen_ctx *sc = screen_fromroot(e->root);
char *wname;
- int altcontrol = e->state == (ControlMask|Mod1Mask);
+ struct mousebinding *mb;
cc = client_find(e->window);
- if (sc->rootwin == e->window && !altcontrol) {
- struct menu_q menuq;
- struct menu *mi;
-
- /* XXXSIGH!!!! */
- if (e->button == Button2) {
- group_menu(e);
- goto out;
- }
-
- TAILQ_INIT(&menuq);
-
- switch (e->button) {
- case Button1:
- TAILQ_FOREACH(cc, &Clientq, entry) {
- if (cc->flags & CLIENT_HIDDEN) {
- if (cc->label != NULL)
- wname = cc->label;
- else
- wname = cc->name;
-
- if (wname == NULL)
- continue;
-
- XCALLOC(mi, struct menu);
- strlcpy(mi->text,
- wname, sizeof(mi->text));
- mi->ctx = cc;
- TAILQ_INSERT_TAIL(&menuq, mi, entry);
- }
- }
- break;
- case Button3: {
- struct cmd *cmd;
- conf_reload(&Conf);
- TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
- XCALLOC(mi, struct menu);
- strlcpy(mi->text, cmd->label, sizeof(mi->text));
- mi->ctx = cmd;
- TAILQ_INSERT_TAIL(&menuq, mi, entry);
- }
- break;
- }
- default:
- break;
- }
-
- if (TAILQ_EMPTY(&menuq))
- goto out;
-
- mi = menu_filter(&menuq, NULL, NULL, 0, NULL, NULL);
- if (mi == NULL)
- goto cleanup;
-
- switch (e->button) {
- case Button1:
- cc = (struct client_ctx *)mi->ctx;
- client_unhide(cc);
-
- if (old_cc != NULL)
- client_ptrsave(old_cc);
- client_ptrwarp(cc);
- break;
- case Button3:
- u_spawn(((struct cmd *)mi->ctx)->image);
- break;
- default:
- break;
- }
-
- cleanup:
- while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
- TAILQ_REMOVE(&menuq, mi, entry);
- xfree(mi);
+ if (sc->rootwin == e->window)
+ TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
+ if(e->button!=mb->button || e->state!=mb->modmask ||
+ mb->context!=MOUSEBIND_CTX_ROOT)
+ continue;
+ (*mb->callback)(cc, e);
}
- goto out;
- }
-
if (cc == NULL || e->state == 0)
goto out;
- sc = CCTOSC(cc);
+ TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
+ if(e->button!=mb->button || e->state!=mb->modmask ||
+ mb->context!=MOUSEBIND_CTX_WIN)
+ continue;
- switch (e->button) {
- case Button1:
- if (altcontrol)
- group_sticky_toggle_enter(cc);
- else {
- grab_drag(cc);
- client_move(cc);
- }
- break;
- case Button2:
- grab_sweep(cc);
- client_resize(cc);
- break;
- case Button3:
- client_ptrsave(cc);
- client_lower(cc);
+ (*mb->callback)(cc, NULL);
break;
}
out: