inital version of weechat scratchpad
This commit is contained in:
parent
48dbac7fb3
commit
42e6f73f47
2
config.h
2
config.h
@ -54,7 +54,7 @@ typedef struct {
|
||||
} Sp;
|
||||
const char *spcmd1[] = {"st", "-n", "scratchpadterm", "-t", "Scratchpad", "-g", "120x34", NULL };
|
||||
const char *spcmd2[] = {"st", "-n", "scratchcalc", "-t", "Calculator", "-g", "120x34", "-e", "dropdowncalc", NULL };
|
||||
const char *spcmd3[] = {"st", "-n", "matrix", "-e", "weechat", NULL };
|
||||
const char *spcmd3[] = {"st", "-n", "matrix", "-A", "0.1", "-e", "weechat", NULL };
|
||||
|
||||
static Sp scratchpads[] = {
|
||||
/* name cmd */
|
||||
|
70
dwm.c
70
dwm.c
@ -58,6 +58,7 @@
|
||||
#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
|
||||
#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
@ -174,6 +175,7 @@ static void fibonacci(Monitor *mon, int s);
|
||||
static void focus(Client *c);
|
||||
static void focusin(XEvent *e);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusclientmon(Monitor *msearch);
|
||||
static void focusstack(const Arg *arg);
|
||||
static Atom getatomprop(Client *c, Atom prop);
|
||||
static int getrootptr(int *x, int *y);
|
||||
@ -203,6 +205,7 @@ static void run(void);
|
||||
static void scan(void);
|
||||
static int sendevent(Client *c, Atom proto);
|
||||
static void sendmon(Client *c, Monitor *m);
|
||||
static void sendmontags(Client *c, Monitor *m, unsigned int tags);
|
||||
static void setclientstate(Client *c, long state);
|
||||
static void setfocus(Client *c);
|
||||
static void setfloating(const Arg *arg);
|
||||
@ -790,7 +793,6 @@ drawbar(Monitor *m)
|
||||
/* do not draw vacant tags */
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
continue;
|
||||
|
||||
w = TEXTW(tags[i]);
|
||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
||||
@ -913,6 +915,20 @@ focusmon(const Arg *arg)
|
||||
warp(selmon->sel);
|
||||
}
|
||||
|
||||
void
|
||||
focusclientmon(Monitor *msearch)
|
||||
{
|
||||
Monitor *m;
|
||||
|
||||
if (!mons->next)
|
||||
return;
|
||||
if ((m = msearch) == selmon)
|
||||
return;
|
||||
unfocus(selmon->sel, 0);
|
||||
selmon = m;
|
||||
focus(NULL);
|
||||
warp(selmon->sel);
|
||||
}
|
||||
void
|
||||
focusstack(const Arg *arg)
|
||||
{
|
||||
@ -1496,13 +1512,29 @@ scan(void)
|
||||
void
|
||||
sendmon(Client *c, Monitor *m)
|
||||
{
|
||||
sendmontags(c, m, m->tagset[m->seltags]);
|
||||
//if (c->mon == m)
|
||||
// return;
|
||||
//unfocus(c, 1);
|
||||
//detach(c);
|
||||
//detachstack(c);
|
||||
//c->mon = m;
|
||||
//c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||
//attach(c);
|
||||
//attachstack(c);
|
||||
//focus(NULL);
|
||||
//arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sendmontags(Client *c, Monitor *m, unsigned int tags){
|
||||
if (c->mon == m)
|
||||
return;
|
||||
unfocus(c, 1);
|
||||
detach(c);
|
||||
detachstack(c);
|
||||
c->mon = m;
|
||||
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||
c->tags = tags;
|
||||
attach(c);
|
||||
attachstack(c);
|
||||
focus(NULL);
|
||||
@ -1883,12 +1915,26 @@ void
|
||||
togglescratch(const Arg *arg)
|
||||
{
|
||||
Client *c;
|
||||
Client *cfound;
|
||||
Monitor *m;
|
||||
unsigned int found = 0;
|
||||
unsigned int scratchtag = SPTAG(arg->ui);
|
||||
Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
||||
|
||||
for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
|
||||
for (m = mons; m; m = m->next){
|
||||
fprintf(stderr,"searching monitor %d\n", m->num);
|
||||
for (c = m->clients; c && !(found = c->tags & scratchtag); c = c->next){
|
||||
fprintf(stderr, "client: %s\n", c->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (found){
|
||||
cfound=c;
|
||||
fprintf(stderr, "found client %s\n", cfound->name);
|
||||
fprintf(stderr, "tags of scratchpad: %d\n", cfound->tags);
|
||||
fprintf(stderr, "scratchtag: %d\n", scratchtag);
|
||||
fprintf(stderr, "num of monitor: %d\n", cfound->mon->num);
|
||||
if (cfound->mon == selmon) {
|
||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
|
||||
if (newtagset) {
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
@ -1899,7 +1945,23 @@ togglescratch(const Arg *arg)
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, "we should move to selmon\n");
|
||||
//move client from cfound->mon to selmon but still in scratchtag
|
||||
// remove scratchtag from tagset of cfound->mon ->
|
||||
unsigned int newtagset = cfound->mon->tagset[cfound->mon->seltags] ^ scratchtag;
|
||||
if (newtagset)
|
||||
cfound->mon->tagset[cfound->mon->seltags] = newtagset;
|
||||
//add scratchtag to monitor where client is sent to
|
||||
selmon->tagset[selmon->seltags] |= scratchtag;
|
||||
sendmontags(cfound, selmon, scratchtag);
|
||||
fprintf(stderr, "tags of scratchpad: %d\n", cfound->tags);
|
||||
fprintf(stderr, "num of monitor: %d\n", cfound->mon->num);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Did not find client");
|
||||
selmon->tagset[selmon->seltags] |= scratchtag;
|
||||
spawn(&sparg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user