Menu as Clientlist
This commit is contained in:
parent
6f2d6385ac
commit
5363a7a8a9
78
src/client.c
78
src/client.c
@ -1176,4 +1176,82 @@ uicb_ignore_next_client_rules(uicb_t cmd)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Show clientlist menu
|
||||
*\param cmd uicb_t type
|
||||
*/
|
||||
void
|
||||
uicb_clientlist(uicb_t cmd)
|
||||
{
|
||||
int i, d, u, x, y;
|
||||
int n = 0;
|
||||
Window w;
|
||||
Client *c = NULL;
|
||||
Bool is_sel;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->tag == seltag[selscreen] && c->screen == selscreen)
|
||||
++n;
|
||||
|
||||
if(n > 0)
|
||||
{
|
||||
if(clientlist.nitem)
|
||||
menu_clear(&clientlist);
|
||||
|
||||
menu_init(&clientlist, "clientlist", n,
|
||||
/* Colors */
|
||||
conf.menu[0].colors.focus.bg,
|
||||
conf.menu[0].colors.focus.fg,
|
||||
conf.menu[0].colors.normal.bg,
|
||||
conf.menu[0].colors.normal.fg);
|
||||
|
||||
for(i = 0, c = clients; c; c = c->next)
|
||||
if(c->tag == seltag[selscreen] && c->screen == selscreen)
|
||||
{
|
||||
sprintf(clist_index[i].key, "%d", i);
|
||||
clist_index[i].client = c;
|
||||
|
||||
menu_new_item(&clientlist.item[i], c->title,
|
||||
uicb_client_select, clist_index[i].key);
|
||||
|
||||
if(c == sel)
|
||||
clientlist.item[i].check = name_to_func("check_clist", func_list);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
clist_index[i].client = NULL;
|
||||
|
||||
XQueryPointer(dpy, ROOT, &w, &w, &x, &y, &d, &d, (uint *)&u);
|
||||
menu_draw(clientlist, x, y);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Select client
|
||||
*\param cmd uicb_t type clientlist index
|
||||
*/
|
||||
void
|
||||
uicb_client_select(uicb_t cmd)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MAXCLIST && clist_index[i].client; ++i)
|
||||
if(!strcmp(cmd, clist_index[i].key))
|
||||
{
|
||||
client_focus(clist_index[i].client);
|
||||
client_raise(clist_index[i].client);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Check clientlist menu fake function
|
||||
* \param cmd uicb_t type unused
|
||||
*/
|
||||
Bool
|
||||
uicb_checkclist(uicb_t cmd)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,9 @@ func_name_list_t tmp_func_list[] =
|
||||
{"ignore_next_client_rules", uicb_ignore_next_client_rules },
|
||||
{"check_max", uicb_checkmax },
|
||||
{"check_free", uicb_checkfree },
|
||||
{"check_layout", uicb_checklayout }
|
||||
{"check_layout", uicb_checklayout },
|
||||
{"clientlist", uicb_clientlist },
|
||||
{"check_clist", uicb_checkclist }
|
||||
};
|
||||
|
||||
key_name_list_t key_list[] =
|
||||
|
||||
11
src/menu.c
11
src/menu.c
@ -315,3 +315,14 @@ uicb_menu(uicb_t cmd)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
menu_clear(Menu *menu)
|
||||
{
|
||||
/*menu->item = emalloc(sizeof(MenuItem), nitem);*/
|
||||
IFREE(menu->item);
|
||||
menu->nitem = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
13
src/wmfs.h
13
src/wmfs.h
@ -107,6 +107,7 @@
|
||||
#define CHECK(x) if(!(x)) return
|
||||
#define IFREE(x) if(x) free(x)
|
||||
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define MAXCLIST (64)
|
||||
|
||||
/* barwin.c */
|
||||
BarWindow *barwin_create(Window parent,
|
||||
@ -191,7 +192,9 @@ void uicb_client_screen_prev(uicb_t);
|
||||
void uicb_client_move(uicb_t cmd);
|
||||
void uicb_client_resize(uicb_t cmd);
|
||||
void uicb_ignore_next_client_rules(uicb_t cmd);
|
||||
|
||||
void uicb_clientlist(uicb_t cmd);
|
||||
void uicb_client_select(uicb_t cmd);
|
||||
Bool uicb_checkclist(uicb_t);
|
||||
|
||||
/* ewmh.c */
|
||||
void ewmh_init_hints(void);
|
||||
@ -240,6 +243,7 @@ void menu_focus_item(Menu *menu, int item, BarWindow *winitem[]);
|
||||
void menu_draw_item_name(Menu *menu, int item, BarWindow *winitem[]);
|
||||
int menu_get_longer_string(MenuItem *mi, int nitem);
|
||||
void uicb_menu(uicb_t cmd);
|
||||
void menu_clear(Menu *menu);
|
||||
|
||||
/* launcher.c */
|
||||
void launcher_execute(Launcher *launcher);
|
||||
@ -410,6 +414,13 @@ int *seltag;
|
||||
int *prevseltag;
|
||||
Menu menulayout;
|
||||
|
||||
/* ClientList */
|
||||
Menu clientlist;
|
||||
struct clndx {
|
||||
char key[4];
|
||||
Client *client;
|
||||
} clist_index[MAXCLIST];
|
||||
|
||||
/* Important Client */
|
||||
Client *clients;
|
||||
Client *sel;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user