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 *);
|
char *);
|
||||||
void search_print_client(struct menu *, int);
|
void search_print_client(struct menu *, int);
|
||||||
void search_print_cmd(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 geom screen_apply_gap(struct screen_ctx *, struct geom);
|
||||||
struct screen_ctx *screen_find(Window);
|
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_exec(struct client_ctx *, union arg *);
|
||||||
void kbfunc_lock(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_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_ssh(struct client_ctx *, union arg *);
|
||||||
void kbfunc_term(struct client_ctx *, union arg *);
|
void kbfunc_term(struct client_ctx *, union arg *);
|
||||||
void kbfunc_tile(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();
|
oldcc = client_current();
|
||||||
if (oldcc == NULL)
|
if (oldcc == NULL)
|
||||||
oldcc = (flags & CWM_RCYCLE ?
|
oldcc = ((flags & CWM_RCYCLE) ?
|
||||||
TAILQ_LAST(&sc->clientq, client_ctx_q) :
|
TAILQ_LAST(&sc->clientq, client_ctx_q) :
|
||||||
TAILQ_FIRST(&sc->clientq));
|
TAILQ_FIRST(&sc->clientq));
|
||||||
|
|
||||||
@ -663,7 +663,7 @@ client_cycle(struct screen_ctx *sc, int flags)
|
|||||||
while (again) {
|
while (again) {
|
||||||
again = 0;
|
again = 0;
|
||||||
|
|
||||||
newcc = (flags & CWM_RCYCLE ? client_prev(newcc) :
|
newcc = ((flags & CWM_RCYCLE) ? client_prev(newcc) :
|
||||||
client_next(newcc));
|
client_next(newcc));
|
||||||
|
|
||||||
/* Only cycle visible and non-ignored windows. */
|
/* Only cycle visible and non-ignored windows. */
|
||||||
@ -707,7 +707,7 @@ client_next(struct client_ctx *cc)
|
|||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
struct client_ctx *ccc;
|
struct client_ctx *ccc;
|
||||||
|
|
||||||
return((ccc = TAILQ_NEXT(cc, entry)) != NULL ?
|
return(((ccc = TAILQ_NEXT(cc, entry)) != NULL) ?
|
||||||
ccc : TAILQ_FIRST(&sc->clientq));
|
ccc : TAILQ_FIRST(&sc->clientq));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -717,7 +717,7 @@ client_prev(struct client_ctx *cc)
|
|||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
struct client_ctx *ccc;
|
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));
|
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->bwidth = (ignore) ? 0 : Conf.bwidth;
|
||||||
cc->flags |= ignore ? CLIENT_IGNORE : 0;
|
cc->flags |= (ignore) ? CLIENT_IGNORE : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
@ -360,6 +360,7 @@ static const struct {
|
|||||||
{ "raise", kbfunc_client_raise, CWM_WIN, {0} },
|
{ "raise", kbfunc_client_raise, CWM_WIN, {0} },
|
||||||
{ "search", kbfunc_client_search, 0, {0} },
|
{ "search", kbfunc_client_search, 0, {0} },
|
||||||
{ "menusearch", kbfunc_menu_cmd, 0, {0} },
|
{ "menusearch", kbfunc_menu_cmd, 0, {0} },
|
||||||
|
{ "groupsearch", kbfunc_menu_group, 0, {0} },
|
||||||
{ "hide", kbfunc_client_hide, CWM_WIN, {0} },
|
{ "hide", kbfunc_client_hide, CWM_WIN, {0} },
|
||||||
{ "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} },
|
{ "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} },
|
||||||
{ "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} },
|
{ "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.
|
Launch window search menu.
|
||||||
.It menusearch
|
.It menusearch
|
||||||
Launch application search menu.
|
Launch application search menu.
|
||||||
|
.It groupsearch
|
||||||
|
Launch group search menu.
|
||||||
.It exec
|
.It exec
|
||||||
Launch
|
Launch
|
||||||
.Dq exec program
|
.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_INIT(&menuq);
|
||||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry)
|
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,
|
if ((mi = menu_filter(sc, &menuq, "application", NULL, 0,
|
||||||
search_match_text, search_print_cmd)) != NULL)
|
search_match_text, search_print_cmd)) != NULL)
|
||||||
@ -187,6 +187,31 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg)
|
|||||||
menuq_clear(&menuq);
|
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
|
void
|
||||||
kbfunc_client_cycle(struct client_ctx *cc, union arg *arg)
|
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) {
|
TAILQ_FOREACH(mi, resultq, resultentry) {
|
||||||
char *text;
|
if (mc->print != NULL)
|
||||||
|
|
||||||
if (mc->print != NULL) {
|
|
||||||
(*mc->print)(mi, mc->listing);
|
(*mc->print)(mi, mc->listing);
|
||||||
text = mi->print;
|
else
|
||||||
} else {
|
(void)snprintf(mi->print, sizeof(mi->print),
|
||||||
mi->print[0] = '\0';
|
"%s", mi->text);
|
||||||
text = mi->text;
|
|
||||||
}
|
|
||||||
|
|
||||||
mc->geom.w = MAX(mc->geom.w, xu_xft_width(sc->xftfont, text,
|
mc->geom.w = MAX(mc->geom.w, xu_xft_width(sc->xftfont,
|
||||||
MIN(strlen(text), MENU_MAXENTRY)));
|
mi->print, MIN(strlen(mi->print), MENU_MAXENTRY)));
|
||||||
mc->geom.h += sc->xftfont->height + 1;
|
mc->geom.h += sc->xftfont->height + 1;
|
||||||
mc->num++;
|
mc->num++;
|
||||||
}
|
}
|
||||||
@ -411,15 +407,13 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
|
|||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
TAILQ_FOREACH(mi, resultq, resultentry) {
|
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;
|
int y = n * (sc->xftfont->height + 1) + sc->xftfont->ascent + 1;
|
||||||
|
|
||||||
/* Stop drawing when menu doesn't fit inside the screen. */
|
/* Stop drawing when menu doesn't fit inside the screen. */
|
||||||
if (mc->geom.y + y > area.h)
|
if (mc->geom.y + y > area.h)
|
||||||
break;
|
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++;
|
n++;
|
||||||
}
|
}
|
||||||
if (mc->hasprompt && n > 1)
|
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 screen_ctx *sc = mc->sc;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
char *text;
|
|
||||||
int color, i = 0;
|
int color, i = 0;
|
||||||
|
|
||||||
if (mc->hasprompt)
|
if (mc->hasprompt)
|
||||||
@ -444,13 +437,12 @@ menu_draw_entry(struct menu_ctx *mc, struct menu_q *resultq,
|
|||||||
if (mi == NULL)
|
if (mi == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
color = active ? CWM_COLOR_MENU_FG : CWM_COLOR_MENU_BG;
|
color = (active) ? CWM_COLOR_MENU_FG : CWM_COLOR_MENU_BG;
|
||||||
text = mi->print[0] != '\0' ? mi->print : mi->text;
|
|
||||||
XftDrawRect(sc->xftdraw, &sc->xftcolor[color], 0,
|
XftDrawRect(sc->xftdraw, &sc->xftcolor[color], 0,
|
||||||
(sc->xftfont->height + 1) * entry, mc->geom.w,
|
(sc->xftfont->height + 1) * entry, mc->geom.w,
|
||||||
(sc->xftfont->height + 1) + sc->xftfont->descent);
|
(sc->xftfont->height + 1) + sc->xftfont->descent);
|
||||||
color = active ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT;
|
color = (active) ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT;
|
||||||
xu_xft_draw(sc, text, color,
|
xu_xft_draw(sc, mi->print, color,
|
||||||
0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1);
|
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);
|
client_applysizehints(cc);
|
||||||
|
|
||||||
cc->geom.x = x <= mx ? x : x - cc->geom.w;
|
cc->geom.x = (x <= mx) ? x : x - cc->geom.w;
|
||||||
cc->geom.y = y <= my ? y : y - cc->geom.h;
|
cc->geom.y = (y <= my) ? y : y - cc->geom.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -182,13 +182,11 @@ mousefunc_menu_group(struct client_ctx *cc, union arg *arg)
|
|||||||
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
||||||
if (group_holds_only_sticky(gc))
|
if (group_holds_only_sticky(gc))
|
||||||
continue;
|
continue;
|
||||||
menuq_add(&menuq, gc,
|
menuq_add(&menuq, gc, "%d %s", gc->num, gc->name);
|
||||||
group_holds_only_hidden(gc) ? "%d: [%s]" : "%d: %s",
|
|
||||||
gc->num, gc->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST,
|
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;
|
gc = (struct group_ctx *)mi->ctx;
|
||||||
(group_holds_only_hidden(gc)) ?
|
(group_holds_only_hidden(gc)) ?
|
||||||
group_show(gc) : group_hide(gc);
|
group_show(gc) : group_hide(gc);
|
||||||
|
39
search.c
39
search.c
@ -137,6 +137,16 @@ search_print_cmd(struct menu *mi, int i)
|
|||||||
(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
|
void
|
||||||
search_print_client(struct menu *mi, int list)
|
search_print_client(struct menu *mi, int list)
|
||||||
{
|
{
|
||||||
@ -148,35 +158,12 @@ search_print_client(struct menu *mi, int list)
|
|||||||
else if (cc->flags & CLIENT_HIDDEN)
|
else if (cc->flags & CLIENT_HIDDEN)
|
||||||
flag = '&';
|
flag = '&';
|
||||||
|
|
||||||
if (list)
|
if ((list) || (cc->matchname == cc->label))
|
||||||
cc->matchname = cc->name;
|
cc->matchname = cc->name;
|
||||||
|
|
||||||
(void)snprintf(mi->print, sizeof(mi->print), "(%d) %c[%s] %s",
|
(void)snprintf(mi->print, sizeof(mi->print), "(%d) %c[%s] %s",
|
||||||
cc->group ? cc->group->num : 0, flag,
|
(cc->group) ? cc->group->num : 0, flag,
|
||||||
cc->label ? cc->label : "", cc->matchname);
|
(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -279,7 +279,7 @@ xev_handle_keypress(XEvent *ee)
|
|||||||
if ((kb->modmask | modshift) != e->state)
|
if ((kb->modmask | modshift) != e->state)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (kb->press.keysym == (modshift == 0 ? keysym : skeysym))
|
if (kb->press.keysym == ((modshift == 0) ? keysym : skeysym))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user