Skip to content

Commit

Permalink
#208 ability to set duration of transition between active / normal wi…
Browse files Browse the repository at this point in the history
…ndow opacity
  • Loading branch information
koekeishiya committed Aug 17, 2019
1 parent 68c3d26 commit f5d67fb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions doc/yabai.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions doc/yabai.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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*.

Expand Down
1 change: 1 addition & 0 deletions examples/yabairc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 2 additions & 1 deletion src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f5d67fb

Please sign in to comment.