mirror of
https://github.com/0intro/wmii
synced 2024-11-25 23:30:24 +03:00
added /def/grabmod, which allows to set the modifier key for mouse grab based moves/resizals (default is Mod1)
This commit is contained in:
parent
69ddb68f00
commit
5662a1b15c
30
cmd/wm/fs.c
30
cmd/wm/fs.c
@ -39,6 +39,7 @@ enum { WMII_IOUNIT = 2048 };
|
||||
* /def/normcolors FsFnormcolors normal colors
|
||||
* /def/rules FsFrules rules
|
||||
* /def/keys FsFkeys keys
|
||||
* /def/grabmod FsFgrabmod grab modifier
|
||||
* /tags FsFtags
|
||||
* /bar/ FsDbar
|
||||
* /bar/lab/ FsDlabel
|
||||
@ -182,6 +183,7 @@ qid2name(Qid *qid)
|
||||
case FsFselcolors: return "selcolors"; break;
|
||||
case FsFnormcolors: return "normcolors"; break;
|
||||
case FsFfont: return "font"; break;
|
||||
case FsFgrabmod: return "grabmod"; break;
|
||||
case FsFrules: return "rules"; break;
|
||||
case FsFkeys: return "keys"; break;
|
||||
case FsFcolors: return "colors"; break;
|
||||
@ -263,6 +265,8 @@ name2type(char *name, unsigned char dir_type)
|
||||
return FsFnormcolors;
|
||||
if(!strncmp(name, "font", 5))
|
||||
return FsFfont;
|
||||
if(!strncmp(name, "grabmod", 8))
|
||||
return FsFgrabmod;
|
||||
if(!strncmp(name, "keys", 5))
|
||||
return FsFkeys;
|
||||
if(!strncmp(name, "rules", 6))
|
||||
@ -400,6 +404,7 @@ mkqid(Qid *dir, char *wname, Qid *new)
|
||||
goto Mkfile;
|
||||
break;
|
||||
case FsFborder:
|
||||
case FsFgrabmod:
|
||||
case FsFfont:
|
||||
case FsFrules:
|
||||
case FsFselcolors:
|
||||
@ -544,6 +549,8 @@ type2stat(Stat *stat, char *wname, Qid *dir)
|
||||
break;
|
||||
case FsFfont:
|
||||
return mkstat(stat, dir, wname, strlen(def.font), IXP_DMREAD | IXP_DMWRITE);
|
||||
case FsFgrabmod:
|
||||
return mkstat(stat, dir, wname, strlen(def.grabmod), IXP_DMREAD | IXP_DMWRITE);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@ -920,6 +927,8 @@ xread(IXPConn *c, Fcall *fcall)
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
fcall->count += type2stat(&stat, "rules", &m->qid);
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
fcall->count += type2stat(&stat, "grabmod", &m->qid);
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
break;
|
||||
case FsDview:
|
||||
if(view.size) {
|
||||
@ -1088,6 +1097,10 @@ xread(IXPConn *c, Fcall *fcall)
|
||||
else if(fcall->count)
|
||||
memcpy(p, def.rules, fcall->count);
|
||||
break;
|
||||
case FsFgrabmod:
|
||||
if((fcall->count = strlen(def.grabmod)))
|
||||
memcpy(p, def.grabmod, fcall->count);
|
||||
break;
|
||||
case FsFfont:
|
||||
if((fcall->count = strlen(def.font)))
|
||||
memcpy(p, def.font, fcall->count);
|
||||
@ -1301,6 +1314,23 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
memcpy(def.rules + fcall->offset, fcall->data, fcall->count);
|
||||
def.rules[fcall->offset + fcall->count] = 0;
|
||||
break;
|
||||
case FsFgrabmod:
|
||||
{
|
||||
unsigned long mod;
|
||||
if(fcall->count > sizeof(buf))
|
||||
return Ebadvalue;
|
||||
memcpy(buf, fcall->data, fcall->count);
|
||||
buf[fcall->count] = 0;
|
||||
mod = mod_key_of_str(buf);
|
||||
if((mod != Mod1Mask) || (mod != Mod2Mask) || (mod != Mod3Mask)
|
||||
|| (mod != Mod4Mask) || (mod != Mod5Mask))
|
||||
return Ebadvalue;
|
||||
cext_strlcpy(def.grabmod, buf, sizeof(def.grabmod));
|
||||
def.mod = mod;
|
||||
if(view.size)
|
||||
restack_view(view.data[sel]);
|
||||
}
|
||||
break;
|
||||
case FsFfont:
|
||||
if(def.font)
|
||||
free(def.font);
|
||||
|
@ -36,8 +36,8 @@ init_lock_keys()
|
||||
valid_mask = 255 & ~(num_lock_mask | LockMask);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
blitz_strtomod(char *val)
|
||||
unsigned long
|
||||
mod_key_of_str(char *val)
|
||||
{
|
||||
unsigned long mod = 0;
|
||||
if (strstr(val, "Shift"))
|
||||
@ -130,7 +130,7 @@ get_key(const char *name)
|
||||
else
|
||||
kstr = seq[i];
|
||||
k->key = XKeysymToKeycode(dpy, XStringToKeysym(kstr));
|
||||
k->mod = blitz_strtomod(seq[i]);
|
||||
k->mod = mod_key_of_str(seq[i]);
|
||||
}
|
||||
if(r) {
|
||||
r->id = id++;
|
||||
|
@ -248,8 +248,8 @@ restack_view(View *v)
|
||||
Client *c = a->frame.data[j]->client;
|
||||
if((v->sel == i) && (a->sel == j)) {
|
||||
ungrab_mouse(c->framewin, AnyModifier, AnyButton);
|
||||
grab_mouse(c->framewin, Mod1Mask, Button1);
|
||||
grab_mouse(c->framewin, Mod1Mask, Button3);
|
||||
grab_mouse(c->framewin, def.mod, Button1);
|
||||
grab_mouse(c->framewin, def.mod, Button3);
|
||||
}
|
||||
else
|
||||
grab_mouse(c->framewin, AnyModifier, Button1);
|
||||
|
@ -296,6 +296,8 @@ main(int argc, char *argv[])
|
||||
blitz_loadcolor(dpy, screen, def.selcolor, &def.sel);
|
||||
cext_strlcpy(def.normcolor, BLITZ_NORMCOLORS, sizeof(def.normcolor));
|
||||
blitz_loadcolor(dpy, screen, def.normcolor, &def.norm);
|
||||
cext_strlcpy(def.grabmod, "Mod1", sizeof(def.grabmod));
|
||||
def.mod = Mod1Mask;
|
||||
|
||||
init_atoms();
|
||||
init_cursors();
|
||||
|
@ -50,6 +50,7 @@ enum {
|
||||
FsFselcolors,
|
||||
FsFnormcolors,
|
||||
FsFkeys,
|
||||
FsFgrabmod,
|
||||
FsFborder,
|
||||
FsFbar,
|
||||
FsFgeom,
|
||||
@ -149,6 +150,8 @@ typedef struct {
|
||||
unsigned int keyssz;
|
||||
char *rules;
|
||||
unsigned int rulessz;
|
||||
char grabmod[5];
|
||||
unsigned long mod;
|
||||
} Default;
|
||||
|
||||
/* global variables */
|
||||
@ -252,6 +255,7 @@ void new_ixp_conn(IXPConn *c);
|
||||
void handle_key(Window w, unsigned long mod, KeyCode keycode);
|
||||
void update_keys();
|
||||
void init_lock_keys();
|
||||
unsigned long mod_key_of_str(char *val);
|
||||
|
||||
/* mouse.c */
|
||||
void do_mouse_resize(Client *c, Align align);
|
||||
|
Loading…
Reference in New Issue
Block a user