1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Issue: #224 test version window current desktop

run: rofi -show windowcd -modi windowcd,window

Using ctrl-tab you can switch between two modes (all windows, or just current desktop).
This commit is contained in:
Dave Davenport 2015-09-07 17:41:48 +02:00
parent ca602383f1
commit 092a2c5037
3 changed files with 46 additions and 3 deletions

View file

@ -2,4 +2,5 @@
#define __WINDOW_DIALOG_H__
extern Switcher window_mode;
extern Switcher window_mode_cd;
#endif // __WINDOW_DIALOG_H__

View file

@ -171,8 +171,12 @@ static int winlist_find ( winlist *l, Window w )
*/
static void x11_cache_create ( void )
{
cache_client = winlist_new ();
cache_xattr = winlist_new ();
if ( cache_client == NULL ) {
cache_client = winlist_new ();
}
if ( cache_xattr == NULL ) {
cache_xattr = winlist_new ();
}
}
/**
@ -364,7 +368,7 @@ static void window_mode_init ( Switcher *sw )
}
}
static char ** window_mode_get_data ( unsigned int *length, Switcher *sw )
static char ** _window_mode_get_data ( unsigned int *length, Switcher *sw, unsigned int cd )
{
SwitcherModePrivateData *pd = (SwitcherModePrivateData *) sw->private_data;
if ( !pd->init ) {
@ -389,6 +393,12 @@ static char ** window_mode_get_data ( unsigned int *length, Switcher *sw )
curr_win_id = 0;
}
// Get the current desktop.
unsigned long current_desktop = 0;
if ( !window_get_cardinal_prop ( display, root, netatoms[_NET_CURRENT_DESKTOP], &current_desktop, 1 ) ) {
current_desktop = 0;
}
if ( window_get_prop ( display, root, netatoms[_NET_CLIENT_LIST_STACKING],
&type, &nwins, wins, 100 * sizeof ( Window ) )
&& type == XA_WINDOW ) {
@ -457,6 +467,10 @@ static char ** window_mode_get_data ( unsigned int *length, Switcher *sw )
// Assume the client is on all desktops.
wmdesktop = 0xFFFFFFFF;
}
else if ( cd && wmdesktop != current_desktop ) {
g_free ( line );
continue;
}
if ( wmdesktop < 0xFFFFFFFF ) {
sprintf ( desktop, "%d", (int) wmdesktop );
@ -477,6 +491,14 @@ static char ** window_mode_get_data ( unsigned int *length, Switcher *sw )
*length = pd->cmd_list_length;
return pd->cmd_list;
}
static char ** window_mode_get_data_cd ( unsigned int *length, Switcher *sw )
{
return _window_mode_get_data ( length, sw, TRUE );
}
static char ** window_mode_get_data ( unsigned int *length, Switcher *sw )
{
return _window_mode_get_data ( length, sw, FALSE );
}
static SwitcherMode window_mode_result ( int mretv, G_GNUC_UNUSED char **input, unsigned int selected_line, Switcher *sw )
{
SwitcherModePrivateData *rmpd = (SwitcherModePrivateData *) sw->private_data;
@ -556,3 +578,19 @@ Switcher window_mode =
.private_data = NULL,
.free = NULL
};
Switcher window_mode_cd =
{
.name = "windowcd",
.tb = NULL,
.keycfg = NULL,
.keystr = NULL,
.modmask = AnyModifier,
.init = window_mode_init,
.get_data = window_mode_get_data_cd,
.result = window_mode_result,
.destroy = window_mode_destroy,
.token_match = window_match,
.mgrv = mgrv,
.private_data = NULL,
.free = NULL
};

View file

@ -1593,6 +1593,10 @@ static void setup_switchers ( void )
switchers[num_switchers] = &window_mode;
num_switchers++;
}
else if ( strcasecmp ( token, "windowcd" ) == 0 ) {
switchers[num_switchers] = &window_mode_cd;
num_switchers++;
}
// SSh dialog
else if ( strcasecmp ( token, "ssh" ) == 0 ) {
switchers[num_switchers] = &ssh_mode;