| 186 | } |
| 187 | |
| 188 | bool Window::is_user_window() const |
| 189 | { |
| 190 | if (valid()) |
| 191 | { |
| 192 | const auto ex_style = get_long_ptr(GWL_EXSTYLE).value_or(0); |
| 193 | const bool is_tool_window = (ex_style & WS_EX_TOOLWINDOW) == WS_EX_TOOLWINDOW; |
| 194 | |
| 195 | // check if the window is visible. A window with WS_EX_TOOLWINDOW is considered not visible. |
| 196 | if (!is_tool_window && visible() && !cloaked()) |
| 197 | { |
| 198 | // check if the window is top-level. |
| 199 | if (ancestor(GA_ROOT) == m_WindowHandle) |
| 200 | { |
| 201 | const bool is_no_activate = (ex_style & WS_EX_NOACTIVATE) == WS_EX_NOACTIVATE; |
| 202 | const bool is_app_window = (ex_style & WS_EX_APPWINDOW) == WS_EX_APPWINDOW; |
| 203 | |
| 204 | // check the window does not have WS_EX_NOACTIVATE (or if it does, it has WS_EX_APPWINDOW) |
| 205 | // then check if it's on the current virtual desktop (currently, a cloak check also catches these, but it's an implementation detail) |
| 206 | return (!is_no_activate || is_app_window) && on_current_desktop().value_or(false); |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | return false; |
| 212 | } |