mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
cvsimport
This commit is contained in:
commit
c0f2d0cc75
2
calmwm.h
2
calmwm.h
@ -471,6 +471,7 @@ void search_match_text(struct menu_q *, struct menu_q *,
|
||||
char *);
|
||||
void search_print_client(struct menu *, int);
|
||||
void search_print_cmd(struct menu *, int);
|
||||
void search_print_group(struct menu *, int);
|
||||
|
||||
struct geom screen_apply_gap(struct screen_ctx *, struct geom);
|
||||
struct screen_ctx *screen_find(Window);
|
||||
@ -517,6 +518,7 @@ void kbfunc_cwm_status(struct client_ctx *, union arg *);
|
||||
void kbfunc_exec(struct client_ctx *, union arg *);
|
||||
void kbfunc_lock(struct client_ctx *, union arg *);
|
||||
void kbfunc_menu_cmd(struct client_ctx *, union arg *);
|
||||
void kbfunc_menu_group(struct client_ctx *, union arg *);
|
||||
void kbfunc_ssh(struct client_ctx *, union arg *);
|
||||
void kbfunc_term(struct client_ctx *, union arg *);
|
||||
void kbfunc_tile(struct client_ctx *, union arg *);
|
||||
|
8
client.c
8
client.c
@ -655,7 +655,7 @@ client_cycle(struct screen_ctx *sc, int flags)
|
||||
|
||||
oldcc = client_current();
|
||||
if (oldcc == NULL)
|
||||
oldcc = (flags & CWM_RCYCLE ?
|
||||
oldcc = ((flags & CWM_RCYCLE) ?
|
||||
TAILQ_LAST(&sc->clientq, client_ctx_q) :
|
||||
TAILQ_FIRST(&sc->clientq));
|
||||
|
||||
@ -663,7 +663,7 @@ client_cycle(struct screen_ctx *sc, int flags)
|
||||
while (again) {
|
||||
again = 0;
|
||||
|
||||
newcc = (flags & CWM_RCYCLE ? client_prev(newcc) :
|
||||
newcc = ((flags & CWM_RCYCLE) ? client_prev(newcc) :
|
||||
client_next(newcc));
|
||||
|
||||
/* Only cycle visible and non-ignored windows. */
|
||||
@ -707,7 +707,7 @@ client_next(struct client_ctx *cc)
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct client_ctx *ccc;
|
||||
|
||||
return((ccc = TAILQ_NEXT(cc, entry)) != NULL ?
|
||||
return(((ccc = TAILQ_NEXT(cc, entry)) != NULL) ?
|
||||
ccc : TAILQ_FIRST(&sc->clientq));
|
||||
}
|
||||
|
||||
@ -717,7 +717,7 @@ client_prev(struct client_ctx *cc)
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct client_ctx *ccc;
|
||||
|
||||
return((ccc = TAILQ_PREV(cc, client_ctx_q, entry)) != NULL ?
|
||||
return(((ccc = TAILQ_PREV(cc, client_ctx_q, entry)) != NULL) ?
|
||||
ccc : TAILQ_LAST(&sc->clientq, client_ctx_q));
|
||||
}
|
||||
|
||||
|
5
conf.c
5
conf.c
@ -346,8 +346,8 @@ conf_client(struct client_ctx *cc)
|
||||
}
|
||||
}
|
||||
|
||||
cc->bwidth = ignore ? 0 : Conf.bwidth;
|
||||
cc->flags |= ignore ? CLIENT_IGNORE : 0;
|
||||
cc->bwidth = (ignore) ? 0 : Conf.bwidth;
|
||||
cc->flags |= (ignore) ? CLIENT_IGNORE : 0;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
@ -360,6 +360,7 @@ static const struct {
|
||||
{ "raise", kbfunc_client_raise, CWM_WIN, {0} },
|
||||
{ "search", kbfunc_client_search, 0, {0} },
|
||||
{ "menusearch", kbfunc_menu_cmd, 0, {0} },
|
||||
{ "groupsearch", kbfunc_menu_group, 0, {0} },
|
||||
{ "hide", kbfunc_client_hide, CWM_WIN, {0} },
|
||||
{ "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} },
|
||||
{ "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} },
|
||||
|
2
cwmrc.5
2
cwmrc.5
@ -251,6 +251,8 @@ Lock the screen.
|
||||
Launch window search menu.
|
||||
.It menusearch
|
||||
Launch application search menu.
|
||||
.It groupsearch
|
||||
Launch group search menu.
|
||||
.It exec
|
||||
Launch
|
||||
.Dq exec program
|
||||
|
27
kbfunc.c
27
kbfunc.c
@ -178,7 +178,7 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg)
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry)
|
||||
menuq_add(&menuq, cmd, NULL);
|
||||
menuq_add(&menuq, cmd, "%s", cmd->name);
|
||||
|
||||
if ((mi = menu_filter(sc, &menuq, "application", NULL, 0,
|
||||
search_match_text, search_print_cmd)) != NULL)
|
||||
@ -187,6 +187,31 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg)
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_menu_group(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct group_ctx *gc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
||||
if (group_holds_only_sticky(gc))
|
||||
continue;
|
||||
menuq_add(&menuq, gc, "%d %s", gc->num, gc->name);
|
||||
}
|
||||
|
||||
if ((mi = menu_filter(sc, &menuq, "group", NULL, CWM_MENU_LIST,
|
||||
search_match_text, search_print_group)) != NULL) {
|
||||
gc = (struct group_ctx *)mi->ctx;
|
||||
(group_holds_only_hidden(gc)) ?
|
||||
group_show(gc) : group_hide(gc);
|
||||
}
|
||||
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_cycle(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
|
28
menu.c
28
menu.c
@ -359,18 +359,14 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(mi, resultq, resultentry) {
|
||||
char *text;
|
||||
|
||||
if (mc->print != NULL) {
|
||||
if (mc->print != NULL)
|
||||
(*mc->print)(mi, mc->listing);
|
||||
text = mi->print;
|
||||
} else {
|
||||
mi->print[0] = '\0';
|
||||
text = mi->text;
|
||||
}
|
||||
else
|
||||
(void)snprintf(mi->print, sizeof(mi->print),
|
||||
"%s", mi->text);
|
||||
|
||||
mc->geom.w = MAX(mc->geom.w, xu_xft_width(sc->xftfont, text,
|
||||
MIN(strlen(text), MENU_MAXENTRY)));
|
||||
mc->geom.w = MAX(mc->geom.w, xu_xft_width(sc->xftfont,
|
||||
mi->print, MIN(strlen(mi->print), MENU_MAXENTRY)));
|
||||
mc->geom.h += sc->xftfont->height + 1;
|
||||
mc->num++;
|
||||
}
|
||||
@ -411,15 +407,13 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
|
||||
n = 0;
|
||||
|
||||
TAILQ_FOREACH(mi, resultq, resultentry) {
|
||||
char *text = mi->print[0] != '\0' ?
|
||||
mi->print : mi->text;
|
||||
int y = n * (sc->xftfont->height + 1) + sc->xftfont->ascent + 1;
|
||||
|
||||
/* Stop drawing when menu doesn't fit inside the screen. */
|
||||
if (mc->geom.y + y > area.h)
|
||||
break;
|
||||
|
||||
xu_xft_draw(sc, text, CWM_COLOR_MENU_FONT, 0, y);
|
||||
xu_xft_draw(sc, mi->print, CWM_COLOR_MENU_FONT, 0, y);
|
||||
n++;
|
||||
}
|
||||
if (mc->hasprompt && n > 1)
|
||||
@ -432,7 +426,6 @@ menu_draw_entry(struct menu_ctx *mc, struct menu_q *resultq,
|
||||
{
|
||||
struct screen_ctx *sc = mc->sc;
|
||||
struct menu *mi;
|
||||
char *text;
|
||||
int color, i = 0;
|
||||
|
||||
if (mc->hasprompt)
|
||||
@ -444,13 +437,12 @@ menu_draw_entry(struct menu_ctx *mc, struct menu_q *resultq,
|
||||
if (mi == NULL)
|
||||
return;
|
||||
|
||||
color = active ? CWM_COLOR_MENU_FG : CWM_COLOR_MENU_BG;
|
||||
text = mi->print[0] != '\0' ? mi->print : mi->text;
|
||||
color = (active) ? CWM_COLOR_MENU_FG : CWM_COLOR_MENU_BG;
|
||||
XftDrawRect(sc->xftdraw, &sc->xftcolor[color], 0,
|
||||
(sc->xftfont->height + 1) * entry, mc->geom.w,
|
||||
(sc->xftfont->height + 1) + sc->xftfont->descent);
|
||||
color = active ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT;
|
||||
xu_xft_draw(sc, text, color,
|
||||
color = (active) ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT;
|
||||
xu_xft_draw(sc, mi->print, color,
|
||||
0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1);
|
||||
}
|
||||
|
||||
|
10
mousefunc.c
10
mousefunc.c
@ -43,8 +43,8 @@ mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
|
||||
|
||||
client_applysizehints(cc);
|
||||
|
||||
cc->geom.x = x <= mx ? x : x - cc->geom.w;
|
||||
cc->geom.y = y <= my ? y : y - cc->geom.h;
|
||||
cc->geom.x = (x <= mx) ? x : x - cc->geom.w;
|
||||
cc->geom.y = (y <= my) ? y : y - cc->geom.h;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -182,13 +182,11 @@ mousefunc_menu_group(struct client_ctx *cc, union arg *arg)
|
||||
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
||||
if (group_holds_only_sticky(gc))
|
||||
continue;
|
||||
menuq_add(&menuq, gc,
|
||||
group_holds_only_hidden(gc) ? "%d: [%s]" : "%d: %s",
|
||||
gc->num, gc->name);
|
||||
menuq_add(&menuq, gc, "%d %s", gc->num, gc->name);
|
||||
}
|
||||
|
||||
if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST,
|
||||
NULL, NULL)) != NULL) {
|
||||
NULL, search_print_group)) != NULL) {
|
||||
gc = (struct group_ctx *)mi->ctx;
|
||||
(group_holds_only_hidden(gc)) ?
|
||||
group_show(gc) : group_hide(gc);
|
||||
|
41
search.c
41
search.c
@ -134,7 +134,17 @@ search_print_cmd(struct menu *mi, int i)
|
||||
special = 1;
|
||||
|
||||
(void)snprintf(mi->print, sizeof(mi->print),
|
||||
(special) ? "[%s]" : "%s", cmd->name);
|
||||
(special) ? "[%s]" : "%s", cmd->name);
|
||||
}
|
||||
|
||||
void
|
||||
search_print_group(struct menu *mi, int i)
|
||||
{
|
||||
struct group_ctx *gc = (struct group_ctx *)mi->ctx;
|
||||
|
||||
(void)snprintf(mi->print, sizeof(mi->print),
|
||||
(group_holds_only_hidden(gc)) ? "%d: [%s]" : "%d: %s",
|
||||
gc->num, gc->name);
|
||||
}
|
||||
|
||||
void
|
||||
@ -148,35 +158,12 @@ search_print_client(struct menu *mi, int list)
|
||||
else if (cc->flags & CLIENT_HIDDEN)
|
||||
flag = '&';
|
||||
|
||||
if (list)
|
||||
if ((list) || (cc->matchname == cc->label))
|
||||
cc->matchname = cc->name;
|
||||
|
||||
(void)snprintf(mi->print, sizeof(mi->print), "(%d) %c[%s] %s",
|
||||
cc->group ? cc->group->num : 0, flag,
|
||||
cc->label ? cc->label : "", cc->matchname);
|
||||
|
||||
if (!list && cc->matchname != cc->name &&
|
||||
strlen(mi->print) < sizeof(mi->print) - 1) {
|
||||
const char *marker = "";
|
||||
char buf[MENU_MAXENTRY + 1];
|
||||
int diff;
|
||||
|
||||
diff = sizeof(mi->print) - 1 - strlen(mi->print);
|
||||
|
||||
/* One for the ':' */
|
||||
diff -= 1;
|
||||
|
||||
if (strlen(cc->name) > diff) {
|
||||
marker = "..";
|
||||
diff -= 2;
|
||||
} else {
|
||||
diff = strlen(cc->name);
|
||||
}
|
||||
|
||||
(void)strlcpy(buf, mi->print, sizeof(buf));
|
||||
(void)snprintf(mi->print, sizeof(mi->print),
|
||||
"%s:%.*s%s", buf, diff, cc->name, marker);
|
||||
}
|
||||
(cc->group) ? cc->group->num : 0, flag,
|
||||
(cc->label) ? cc->label : "", cc->matchname);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user