1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

[window] Add an option to hide active window.

fixes: #1336
This commit is contained in:
Dave Davenport 2022-07-24 00:52:13 +02:00
parent 5a5d333fdf
commit d20926abab
3 changed files with 54 additions and 3 deletions

View file

@ -977,6 +977,25 @@ configuration {
.fi .fi
.RE .RE
.PP
You can hide the currently active window with the 'hide-active-window' setting:
.PP
.RS
.nf
configuration {
window {
hide-active-window: true;
}
}
.fi
.RE
.PP
or pass \fB\fC-window-hide-active-window true\fR on command line.
.SS Combi settings .SS Combi settings
.PP .PP
\fB\fC-combi-modes\fR \fImode1\fP,\fImode2\fP \fB\fC-combi-modes\fR \fImode1\fP,\fImode2\fP

View file

@ -592,6 +592,18 @@ configuration {
} }
} }
``` ```
You can hide the currently active window with the 'hide-active-window' setting:
```css
configuration {
window {
hide-active-window: true;
}
}
```
or pass `-window-hide-active-window true` on command line.
### Combi settings ### Combi settings

View file

@ -148,6 +148,8 @@ typedef struct {
unsigned int title_len; unsigned int title_len;
unsigned int role_len; unsigned int role_len;
GRegex *window_regex; GRegex *window_regex;
// Hide current active window
gboolean hide_active_window;
} WindowModePrivateData; } WindowModePrivateData;
winlist *cache_client = NULL; winlist *cache_client = NULL;
@ -664,9 +666,11 @@ static void _window_mode_load_data(Mode *sw, unsigned int cd) {
if (cd && winclient->wmdesktop != current_desktop) { if (cd && winclient->wmdesktop != current_desktop) {
continue; continue;
} }
if (!pd->hide_active_window || winclient->window != curr_win_id) {
winlist_append(pd->ids, winclient->window, NULL); winlist_append(pd->ids, winclient->window, NULL);
} }
} }
}
if (has_names) { if (has_names) {
xcb_ewmh_get_utf8_strings_reply_wipe(&names); xcb_ewmh_get_utf8_strings_reply_wipe(&names);
@ -676,7 +680,14 @@ static void _window_mode_load_data(Mode *sw, unsigned int cd) {
} }
static int window_mode_init(Mode *sw) { static int window_mode_init(Mode *sw) {
if (mode_get_private_data(sw) == NULL) { if (mode_get_private_data(sw) == NULL) {
WindowModePrivateData *pd = g_malloc0(sizeof(*pd)); WindowModePrivateData *pd = g_malloc0(sizeof(*pd));
ThemeWidget *wid = rofi_config_find_widget(sw->name, NULL, TRUE);
Property *p =
rofi_theme_find_property(wid, P_BOOLEAN, "hide-active-window", FALSE);
if (p && p->type == P_BOOLEAN && p->value.b == TRUE) {
pd->hide_active_window = TRUE;
}
pd->window_regex = g_regex_new("{[-\\w]+(:-?[0-9]+)?}", 0, 0, NULL); pd->window_regex = g_regex_new("{[-\\w]+(:-?[0-9]+)?}", 0, 0, NULL);
mode_set_private_data(sw, (void *)pd); mode_set_private_data(sw, (void *)pd);
_window_mode_load_data(sw, FALSE); _window_mode_load_data(sw, FALSE);
@ -689,6 +700,13 @@ static int window_mode_init(Mode *sw) {
static int window_mode_init_cd(Mode *sw) { static int window_mode_init_cd(Mode *sw) {
if (mode_get_private_data(sw) == NULL) { if (mode_get_private_data(sw) == NULL) {
WindowModePrivateData *pd = g_malloc0(sizeof(*pd)); WindowModePrivateData *pd = g_malloc0(sizeof(*pd));
ThemeWidget *wid = rofi_config_find_widget(sw->name, NULL, TRUE);
Property *p =
rofi_theme_find_property(wid, P_BOOLEAN, "hide-active-window", FALSE);
if (p && p->type == P_BOOLEAN && p->value.b == TRUE) {
pd->hide_active_window = TRUE;
}
pd->window_regex = g_regex_new("{[-\\w]+(:-?[0-9]+)?}", 0, 0, NULL); pd->window_regex = g_regex_new("{[-\\w]+(:-?[0-9]+)?}", 0, 0, NULL);
mode_set_private_data(sw, (void *)pd); mode_set_private_data(sw, (void *)pd);
_window_mode_load_data(sw, TRUE); _window_mode_load_data(sw, TRUE);
@ -931,7 +949,8 @@ static cairo_user_data_key_t data_key;
/** Create a surface object from this image data. /** Create a surface object from this image data.
* \param width The width of the image. * \param width The width of the image.
* \param height The height of the image * \param height The height of the image
* \param data The image's data in ARGB format, will be copied by this function. * \param data The image's data in ARGB format, will be copied by this
* function.
*/ */
static cairo_surface_t *draw_surface_from_data(int width, int height, static cairo_surface_t *draw_surface_from_data(int width, int height,
uint32_t const *const data) { uint32_t const *const data) {
@ -985,7 +1004,8 @@ static cairo_surface_t *ewmh_window_icon_from_reply(xcb_get_property_reply_t *r,
break; break;
} }
/* use the greater of the two dimensions to match against the preferred size /* use the greater of the two dimensions to match against the preferred
* size
*/ */
uint32_t size = MAX(data[0], data[1]); uint32_t size = MAX(data[0], data[1]);