Skip to content

Commit

Permalink
#2036 changes to window detection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Jan 3, 2024
1 parent 79bf9e9 commit eed5e98
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Changes to window detection logic [#2036](https://github.com/koekeishiya/yabai/issues/2036)

## [6.0.3] - 2024-01-03
### Changed
Expand Down
21 changes: 21 additions & 0 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,27 @@ bool window_is_standard(struct window *window)
return standard_win;
}

bool window_is_really_a_window(struct window *window)
{
bool win = false;
CFStringRef role = NULL;
CFStringRef srole = NULL;

if (!(role = window_role(window))) goto out;
if (!(srole = window_subrole(window))) goto role;

win = CFEqual(role, kAXWindowRole) &&
(CFEqual(srole, kAXStandardWindowSubrole) ||
CFEqual(srole, kAXFloatingWindowSubrole) ||
CFEqual(srole, kAXDialogSubrole));

CFRelease(srole);
role:
CFRelease(role);
out:
return win;
}

bool window_is_dialog(struct window *window)
{
bool standard_win = false;
Expand Down
1 change: 1 addition & 0 deletions src/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ bool window_is_undersized(struct window *window);
bool window_is_minimized(struct window *window);
bool window_is_fullscreen(struct window *window);
bool window_is_sticky(struct window *window);
bool window_is_really_a_window(struct window *window);
bool window_is_standard(struct window *window);
bool window_is_dialog(struct window *window);
bool window_is_group(struct window *window);
Expand Down
7 changes: 6 additions & 1 deletion src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ void window_manager_apply_rule_to_window(struct space_manager *sm, struct window
int regex_match_subrole = rule->subrole_regex_exclude ? REGEX_MATCH_YES : REGEX_MATCH_NO;
if (regex_match(rule->subrole_regex_valid, &rule->subrole_regex, window_subrole) == regex_match_subrole) return;

if (!window_rule_check_flag(window, WINDOW_RULE_MANAGED)) {
if (!rule->role_regex_valid && !string_equals(window_role , "AXWindow")) return;
if (!rule->subrole_regex_valid && !string_equals(window_subrole, "AXStandardWindow")) return;
}

if (rule->sid || rule->did) {
if (!window_is_fullscreen(window) && !space_is_fullscreen(window_space(window))) {
uint64_t sid = rule->did ? display_space_id(rule->did) : rule->sid;
Expand Down Expand Up @@ -1305,7 +1310,7 @@ struct window *window_manager_create_and_add_window(struct space_manager *sm, st

window_manager_apply_manage_rules_to_window(sm, wm, window, window_title, window_role, window_subrole);

if (!window_is_standard(window) && !window_rule_check_flag(window, WINDOW_RULE_MANAGED)) {
if (!window_is_really_a_window(window) && !window_rule_check_flag(window, WINDOW_RULE_MANAGED)) {
debug("%s ignoring incorrectly marked window %s %d\n", __FUNCTION__, window->application->name, window->id);

//
Expand Down

0 comments on commit eed5e98

Please sign in to comment.