summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@blame.services>2022-07-24 00:52:13 +0200
committerDave Davenport <qball@blame.services>2022-07-24 00:52:13 +0200
commitd20926abab20bcd2478e1d3472ab75336f16724b (patch)
treec109d67f08badf67554feec8d961e8920e4dc8e6
parent5a5d333fdff6f0c35d2e0ee4816f9b9cc5a26b82 (diff)
[window] Add an option to hide active window.
fixes: #1336
-rw-r--r--doc/rofi.119
-rw-r--r--doc/rofi.1.markdown12
-rw-r--r--source/modes/window.c26
3 files changed, 54 insertions, 3 deletions
diff --git a/doc/rofi.1 b/doc/rofi.1
index 465c44a7..956203e7 100644
--- a/doc/rofi.1
+++ b/doc/rofi.1
@@ -977,6 +977,25 @@ configuration {
.fi
.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
.PP
\fB\fC-combi-modes\fR \fImode1\fP,\fImode2\fP
diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown
index ab6b0972..9f02f93d 100644
--- a/doc/rofi.1.markdown
+++ b/doc/rofi.1.markdown
@@ -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
diff --git a/source/modes/window.c b/source/modes/window.c
index 768292c4..c8690212 100644
--- a/source/modes/window.c
+++ b/source/modes/window.c
@@ -148,6 +148,8 @@ typedef struct {
unsigned int title_len;
unsigned int role_len;
GRegex *window_regex;
+ // Hide current active window
+ gboolean hide_active_window;
} WindowModePrivateData;
winlist *cache_client = NULL;
@@ -664,7 +666,9 @@ static void _window_mode_load_data(Mode *sw, unsigned int cd) {
if (cd && winclient->wmdesktop != current_desktop) {
continue;
}
- winlist_append(pd->ids, winclient->window, NULL);
+ if (!pd->hide_active_window || winclient->window != curr_win_id) {
+ winlist_append(pd->ids, winclient->window, NULL);
+ }
}
}
@@ -676,7 +680,14 @@ static void _window_mode_load_data(Mode *sw, unsigned int cd) {
}
static int window_mode_init(Mode *sw) {
if (mode_get_private_data(sw) == NULL) {
+
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);
mode_set_private_data(sw, (void *)pd);
_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) {
if (mode_get_private_data(sw) == NULL) {
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);
mode_set_private_data(sw, (void *)pd);
_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.
* \param width The width 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,
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;
}
- /* 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]);