X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ioncore%2Fbindmaps.c;h=5948c0224fedda8d2dd33aa95f5d017d3053fc9d;hb=ae4260bb64817c11f9a7140324cd3e3ba113e297;hp=dd4a1d041f3c3c991fa2dc61db196f68fd943259;hpb=8366314611bf30a0f31d25bf5f5023186fa87692;p=ion3.git diff --git a/ioncore/bindmaps.c b/ioncore/bindmaps.c index dd4a1d0..5948c02 100644 --- a/ioncore/bindmaps.c +++ b/ioncore/bindmaps.c @@ -1,21 +1,20 @@ /* * ion/ioncore/bindmaps.c * - * Copyright (c) Tuomo Valkonen 1999-2006. + * Copyright (c) Tuomo Valkonen 1999-2007. * - * Ion is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. + * See the included file LICENSE for details. */ #include +#include #include "common.h" #include "conf-bindings.h" #include "binding.h" -#include #include "framep.h" #include "bindmaps.h" +#include "global.h" +#include "regbind.h" /* @@ -23,7 +22,7 @@ */ -WBindmap *ioncore_rootwin_bindmap=NULL; +WBindmap *ioncore_screen_bindmap=NULL; WBindmap *ioncore_mplex_bindmap=NULL; WBindmap *ioncore_mplex_toplevel_bindmap=NULL; WBindmap *ioncore_frame_bindmap=NULL; @@ -56,7 +55,7 @@ static StringIntMap frame_areas[]={ void ioncore_deinit_bindmaps() { - DO_FREE(rootwin, "WScreen"); + DO_FREE(screen, "WScreen"); DO_FREE(mplex, "WMPlex"); DO_FREE(mplex_toplevel, "WMPlex.toplevel"); DO_FREE(frame, "WFrame"); @@ -86,7 +85,7 @@ bool ioncore_init_bindmaps() if(known_bindmaps==NULL) return FALSE; - DO_ALLOC(rootwin, "WScreen", NULL); + DO_ALLOC(screen, "WScreen", NULL); DO_ALLOC(mplex, "WMPlex", NULL); DO_ALLOC(mplex_toplevel, "WMPlex.toplevel", NULL); DO_ALLOC(frame, "WFrame", frame_areas); @@ -198,3 +197,53 @@ ExtlTab ioncore_do_getbindings() return tab; } + +WBindmap *ioncore_create_cycle_bindmap(uint kcb, uint state, + ExtlFn cycle, ExtlFn bcycle) +{ + WBindmap *bindmap=create_bindmap(); + WBinding b; + + if(bindmap==NULL) + return NULL; + + b.ksb=XKeycodeToKeysym(ioncore_g.dpy, kcb, 0); + b.kcb=kcb; + b.state=state; + b.act=BINDING_KEYPRESS; + b.area=0; + b.wait=FALSE; + b.submap=NULL; + b.func=extl_ref_fn(cycle); + + if(!bindmap_add_binding(bindmap, &b)){ + extl_unref_fn(b.func); + bindmap_destroy(bindmap); + return NULL; + } + + if((b.state&ShiftMask)==0 && bcycle!=extl_fn_none()){ + b.func=extl_ref_fn(bcycle); + b.state|=ShiftMask; + bindmap_add_binding(bindmap, &b); + } + + return bindmap; +} + + +WBindmap *region_add_cycle_bindmap(WRegion *reg, uint kcb, uint state, + ExtlFn cycle, ExtlFn bcycle) +{ + WBindmap *bindmap=ioncore_create_cycle_bindmap(kcb, state, cycle, bcycle); + + if(bindmap!=NULL){ + if(!region_add_bindmap(reg, bindmap)){ + bindmap_destroy(bindmap); + return NULL; + } + } + + return bindmap; +} +