From f5d67fb2db8d999e90b01993385b7fadd02fe981 Mon Sep 17 00:00:00 2001 From: koekeishiya Date: Sat, 17 Aug 2019 14:48:41 +0200 Subject: [PATCH] #208 ability to set duration of transition between active / normal window opacity --- CHANGELOG.md | 1 + doc/yabai.1 | 9 +++++++-- doc/yabai.asciidoc | 7 +++++-- examples/yabairc | 1 + src/message.c | 8 ++++++++ src/window_manager.c | 3 ++- src/window_manager.h | 1 + 7 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 005bfa2a..d9b91006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Commands to toggle mission-control, show-desktop, and application expose [#147](https://github.com/koekeishiya/yabai/issues/147) - Command to close windows that provide a close button in its titlebar [#84](https://github.com/koekeishiya/yabai/issues/84) - Expose window shadow as a property in window queries and add shadow as an option to *window --toggle* [#171](https://github.com/koekeishiya/yabai/issues/171) +- Config option to set the duration of the transition between active / normal window opacity [#208](https://github.com/koekeishiya/yabai/issues/208) ### Changed - Automatically restart Dock.app after installing the scripting-addition, and tweak messages shown when a payload gets loaded, is already loaded or does not support the version of macOS it's running on [#135](https://github.com/koekeishiya/yabai/issues/135) diff --git a/doc/yabai.1 b/doc/yabai.1 index 3e3364e8..ee34e654 100644 --- a/doc/yabai.1 +++ b/doc/yabai.1 @@ -60,12 +60,12 @@ Use the specified configuration file. .sp \fB\-\-install\-sa\fP .RS 4 -Install scripting\-addition. Must be ran as root. Path is /System/Library/ScriptingAdditions on macOS High Sierra, and /Library/ScriptingAdditions on Mojave and newer. +Install scripting\-addition. Must be run as root. Path is /System/Library/ScriptingAdditions on macOS High Sierra, and /Library/ScriptingAdditions on Mojave and newer. .RE .sp \fB\-\-uninstall\-sa\fP .RS 4 -Uninstall scripting\-addition. Must be ran as root. Path is /System/Library/ScriptingAdditions on macOS High Sierra, and /Library/ScriptingAdditions on Mojave and newer. +Uninstall scripting\-addition. Must be run as root. Path is /System/Library/ScriptingAdditions on macOS High Sierra, and /Library/ScriptingAdditions on Mojave and newer. .RE .sp \fB\-\-check\-sa\fP @@ -186,6 +186,11 @@ Make floating windows stay on top. Enable opacity for windows. .RE .sp +\fIwindow_opacity_duration\fP +.RS 4 +Duration of transition between active / normal opacity. +.RE +.sp \fIwindow_shadow\fP .RS 4 Draw shadow for windows. Accept the following values: \fBon\fP, \fBfloat\fP, \fBoff\fP. diff --git a/doc/yabai.asciidoc b/doc/yabai.asciidoc index ba828b1c..f53dcfff 100644 --- a/doc/yabai.asciidoc +++ b/doc/yabai.asciidoc @@ -46,10 +46,10 @@ Options Use the specified configuration file. *--install-sa*:: - Install scripting-addition. Must be ran as root. Path is /System/Library/ScriptingAdditions on macOS High Sierra, and /Library/ScriptingAdditions on Mojave and newer. + Install scripting-addition. Must be run as root. Path is /System/Library/ScriptingAdditions on macOS High Sierra, and /Library/ScriptingAdditions on Mojave and newer. *--uninstall-sa*:: - Uninstall scripting-addition. Must be ran as root. Path is /System/Library/ScriptingAdditions on macOS High Sierra, and /Library/ScriptingAdditions on Mojave and newer. + Uninstall scripting-addition. Must be run as root. Path is /System/Library/ScriptingAdditions on macOS High Sierra, and /Library/ScriptingAdditions on Mojave and newer. *--check-sa*:: Returns a zero exit-code if the latest version of the scripting-addition is installed. @@ -141,6 +141,9 @@ Colors are in the form '#AARRGGBB'. 'window_opacity':: Enable opacity for windows. +'window_opacity_duration':: + Duration of transition between active / normal opacity. + 'window_shadow':: Draw shadow for windows. Accept the following values: *on*, *float*, *off*. diff --git a/examples/yabairc b/examples/yabairc index a0ffeea2..795c85e6 100755 --- a/examples/yabairc +++ b/examples/yabairc @@ -17,6 +17,7 @@ yabai -m config focus_follows_mouse off yabai -m config window_placement second_child yabai -m config window_topmost off yabai -m config window_opacity off +yabai -m config window_opacity_duration 0.0 yabai -m config window_shadow on yabai -m config window_border off yabai -m config window_border_width 4 diff --git a/src/message.c b/src/message.c index 05a7caa6..630aaa1b 100644 --- a/src/message.c +++ b/src/message.c @@ -22,6 +22,7 @@ extern struct bar g_bar; #define COMMAND_CONFIG_WINDOW_PLACEMENT "window_placement" #define COMMAND_CONFIG_TOPMOST "window_topmost" #define COMMAND_CONFIG_OPACITY "window_opacity" +#define COMMAND_CONFIG_OPACITY_DURATION "window_opacity_duration" #define COMMAND_CONFIG_SHADOW "window_shadow" #define COMMAND_CONFIG_BORDER "window_border" #define COMMAND_CONFIG_BORDER_WIDTH "window_border_width" @@ -367,6 +368,13 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message) } else { daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text); } + } else if (token_equals(command, COMMAND_CONFIG_OPACITY)) { + struct token value = get_token(&message); + if (!token_is_valid(value)) { + fprintf(rsp, "%f\n", g_window_manager.window_opacity_duration); + } else { + g_window_manager.window_opacity_duration = token_to_float(value); + } } else if (token_equals(command, COMMAND_CONFIG_SHADOW)) { struct token value = get_token(&message); if (!token_is_valid(value)) { diff --git a/src/window_manager.c b/src/window_manager.c index 47408be9..11d57f04 100644 --- a/src/window_manager.c +++ b/src/window_manager.c @@ -423,7 +423,7 @@ void window_manager_set_window_opacity(struct window_manager *wm, struct window char message[MAXLEN]; if (socket_connect_un(&sockfd, g_sa_socket_file)) { - snprintf(message, sizeof(message), "window_alpha_fade %d %f %f", window->id, opacity, 0.2f); + snprintf(message, sizeof(message), "window_alpha_fade %d %f %f", window->id, opacity, wm->window_opacity_duration); socket_write(sockfd, message); socket_wait(sockfd); } @@ -1501,6 +1501,7 @@ void window_manager_init(struct window_manager *wm) wm->insert_window_border_color = 0xfff57f7f; wm->active_window_opacity = 1.0f; wm->normal_window_opacity = 1.0f; + wm->window_opacity_duration = 0.2f; table_init(&wm->application, 150, hash_wm, compare_wm); table_init(&wm->window, 150, hash_wm, compare_wm); diff --git a/src/window_manager.h b/src/window_manager.h index e467ca1b..0b2106dd 100644 --- a/src/window_manager.h +++ b/src/window_manager.h @@ -71,6 +71,7 @@ struct window_manager uint32_t insert_window_border_color; float active_window_opacity; float normal_window_opacity; + float window_opacity_duration; }; void window_manager_query_windows_for_space(FILE *rsp, uint64_t sid);