mirror of
https://github.com/hyprwm/hyprland-plugins.git
synced 2025-01-15 16:19:47 +01:00
xtra-dispatchers: add closeUnfocused
This commit is contained in:
parent
948d70b26e
commit
b4c0fa3ebc
2 changed files with 19 additions and 1 deletions
|
@ -4,8 +4,11 @@ Adds some additional dispatchers to Hyprland.
|
|||
|
||||
## Dispatchers
|
||||
|
||||
All dispatchers here are called `plugin:xtd:name` e.g. `plugin:xtd:moveorexec`.
|
||||
|
||||
| name | description | params |
|
||||
| -- | -- | -- |
|
||||
| moveorexec | moves window to the current workspace, or executes if it's not found. `WINDOW` cannot contain commas | `WINDOW,CMD` |
|
||||
| throwunfocused | throws all unfocused windows on the current workspace to the given workspace | `WORKSPACE` |
|
||||
| bringallfrom | kinda inverse of throwunfocused. Bring all windows from a given workspace to the current one. | `WORKSPACE` |
|
||||
| closeunfocused | close all unfocused windows on the current workspace. | none |
|
||||
|
|
|
@ -99,6 +99,20 @@ static SDispatchResult bringAllFrom(std::string in) {
|
|||
return SDispatchResult{};
|
||||
}
|
||||
|
||||
static SDispatchResult closeUnfocused(std::string in) {
|
||||
if (!g_pCompositor->m_pLastMonitor)
|
||||
return SDispatchResult{.success = false, .error = "No focused monitor"};
|
||||
|
||||
for (const auto& w : g_pCompositor->m_vWindows) {
|
||||
if (w->m_pWorkspace != g_pCompositor->m_pLastMonitor->activeWorkspace || w->m_pMonitor != g_pCompositor->m_pLastMonitor || !w->m_bIsMapped)
|
||||
continue;
|
||||
|
||||
g_pCompositor->closeWindow(w);
|
||||
}
|
||||
|
||||
return SDispatchResult{};
|
||||
}
|
||||
|
||||
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||
PHANDLE = handle;
|
||||
|
||||
|
@ -114,6 +128,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
success = success && HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:xtd:moveorexec", ::moveOrExec);
|
||||
success = success && HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:xtd:throwunfocused", ::throwUnfocused);
|
||||
success = success && HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:xtd:bringallfrom", ::bringAllFrom);
|
||||
success = success && HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:xtd:closeunfocused", ::closeUnfocused);
|
||||
|
||||
if (success)
|
||||
HyprlandAPI::addNotification(PHANDLE, "[xtra-dispatchers] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000);
|
||||
|
|
Loading…
Reference in a new issue