2022-03-19 17:48:18 +01:00
|
|
|
#include "KeybindManager.hpp"
|
|
|
|
|
2022-06-10 12:06:27 +02:00
|
|
|
#include <regex>
|
|
|
|
|
2022-04-21 15:50:52 +02:00
|
|
|
CKeybindManager::CKeybindManager() {
|
|
|
|
// initialize all dispatchers
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
m_mDispatchers["exec"] = spawn;
|
|
|
|
m_mDispatchers["killactive"] = killActive;
|
|
|
|
m_mDispatchers["closewindow"] = kill;
|
|
|
|
m_mDispatchers["togglefloating"] = toggleActiveFloating;
|
|
|
|
m_mDispatchers["workspace"] = changeworkspace;
|
2023-01-08 14:19:18 +01:00
|
|
|
m_mDispatchers["renameworkspace"] = renameWorkspace;
|
2022-12-16 18:17:31 +01:00
|
|
|
m_mDispatchers["fullscreen"] = fullscreenActive;
|
2023-01-01 16:54:13 +01:00
|
|
|
m_mDispatchers["fakefullscreen"] = fakeFullscreenActive;
|
2022-12-16 18:17:31 +01:00
|
|
|
m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
|
|
|
|
m_mDispatchers["movetoworkspacesilent"] = moveActiveToWorkspaceSilent;
|
|
|
|
m_mDispatchers["pseudo"] = toggleActivePseudo;
|
|
|
|
m_mDispatchers["movefocus"] = moveFocusTo;
|
|
|
|
m_mDispatchers["movewindow"] = moveActiveTo;
|
|
|
|
m_mDispatchers["centerwindow"] = centerWindow;
|
|
|
|
m_mDispatchers["togglegroup"] = toggleGroup;
|
|
|
|
m_mDispatchers["changegroupactive"] = changeGroupActive;
|
|
|
|
m_mDispatchers["togglesplit"] = toggleSplit;
|
|
|
|
m_mDispatchers["splitratio"] = alterSplitRatio;
|
|
|
|
m_mDispatchers["focusmonitor"] = focusMonitor;
|
|
|
|
m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
|
|
|
|
m_mDispatchers["workspaceopt"] = workspaceOpt;
|
|
|
|
m_mDispatchers["exit"] = exitHyprland;
|
2022-05-30 20:05:38 +02:00
|
|
|
m_mDispatchers["movecurrentworkspacetomonitor"] = moveCurrentWorkspaceToMonitor;
|
2022-12-16 18:17:31 +01:00
|
|
|
m_mDispatchers["moveworkspacetomonitor"] = moveWorkspaceToMonitor;
|
|
|
|
m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace;
|
|
|
|
m_mDispatchers["forcerendererreload"] = forceRendererReload;
|
|
|
|
m_mDispatchers["resizeactive"] = resizeActive;
|
|
|
|
m_mDispatchers["moveactive"] = moveActive;
|
|
|
|
m_mDispatchers["cyclenext"] = circleNext;
|
|
|
|
m_mDispatchers["focuswindowbyclass"] = focusWindow;
|
|
|
|
m_mDispatchers["focuswindow"] = focusWindow;
|
|
|
|
m_mDispatchers["submap"] = setSubmap;
|
|
|
|
m_mDispatchers["pass"] = pass;
|
|
|
|
m_mDispatchers["layoutmsg"] = layoutmsg;
|
|
|
|
m_mDispatchers["toggleopaque"] = toggleOpaque;
|
|
|
|
m_mDispatchers["dpms"] = dpms;
|
|
|
|
m_mDispatchers["movewindowpixel"] = moveWindow;
|
|
|
|
m_mDispatchers["resizewindowpixel"] = resizeWindow;
|
|
|
|
m_mDispatchers["swapnext"] = swapnext;
|
|
|
|
m_mDispatchers["swapactiveworkspaces"] = swapActiveWorkspaces;
|
|
|
|
m_mDispatchers["pin"] = pinActive;
|
|
|
|
m_mDispatchers["mouse"] = mouse;
|
|
|
|
m_mDispatchers["bringactivetotop"] = bringActiveToTop;
|
2022-07-26 23:34:03 +02:00
|
|
|
|
|
|
|
m_tScrollTimer.reset();
|
2022-04-21 15:50:52 +02:00
|
|
|
}
|
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
void CKeybindManager::addKeybind(SKeybind kb) {
|
2022-04-21 17:06:43 +02:00
|
|
|
m_lKeybinds.push_back(kb);
|
2022-07-25 14:42:49 +02:00
|
|
|
|
|
|
|
m_pActiveKeybind = nullptr;
|
2022-04-21 17:06:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::removeKeybind(uint32_t mod, const std::string& key) {
|
|
|
|
for (auto it = m_lKeybinds.begin(); it != m_lKeybinds.end(); ++it) {
|
2022-07-08 09:32:09 +02:00
|
|
|
if (isNumber(key) && std::stoi(key) > 9) {
|
|
|
|
const auto KEYNUM = std::stoi(key);
|
|
|
|
|
|
|
|
if (it->modmask == mod && it->keycode == KEYNUM) {
|
|
|
|
it = m_lKeybinds.erase(it);
|
|
|
|
|
|
|
|
if (it == m_lKeybinds.end())
|
|
|
|
break;
|
|
|
|
}
|
2022-12-16 18:17:31 +01:00
|
|
|
} else if (it->modmask == mod && it->key == key) {
|
2022-04-21 17:06:43 +02:00
|
|
|
it = m_lKeybinds.erase(it);
|
2022-07-08 09:32:09 +02:00
|
|
|
|
|
|
|
if (it == m_lKeybinds.end())
|
|
|
|
break;
|
2022-04-21 17:06:43 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-25 14:42:49 +02:00
|
|
|
|
|
|
|
m_pActiveKeybind = nullptr;
|
2022-03-19 17:48:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t CKeybindManager::stringToModMask(std::string mods) {
|
|
|
|
uint32_t modMask = 0;
|
2022-07-06 16:50:11 +02:00
|
|
|
if (mods.contains("SHIFT"))
|
2022-03-19 17:48:18 +01:00
|
|
|
modMask |= WLR_MODIFIER_SHIFT;
|
2022-07-06 16:50:11 +02:00
|
|
|
if (mods.contains("CAPS"))
|
2022-03-19 17:48:18 +01:00
|
|
|
modMask |= WLR_MODIFIER_CAPS;
|
2022-07-06 16:50:11 +02:00
|
|
|
if (mods.contains("CTRL") || mods.contains("CONTROL"))
|
2022-03-19 17:48:18 +01:00
|
|
|
modMask |= WLR_MODIFIER_CTRL;
|
2022-07-06 16:50:11 +02:00
|
|
|
if (mods.contains("ALT"))
|
2022-03-19 17:48:18 +01:00
|
|
|
modMask |= WLR_MODIFIER_ALT;
|
2022-07-06 16:50:11 +02:00
|
|
|
if (mods.contains("MOD2"))
|
2022-03-19 17:48:18 +01:00
|
|
|
modMask |= WLR_MODIFIER_MOD2;
|
2022-07-06 16:50:11 +02:00
|
|
|
if (mods.contains("MOD3"))
|
2022-03-19 17:48:18 +01:00
|
|
|
modMask |= WLR_MODIFIER_MOD3;
|
2022-07-06 16:50:11 +02:00
|
|
|
if (mods.contains("SUPER") || mods.contains("WIN") || mods.contains("LOGO") || mods.contains("MOD4"))
|
2022-03-19 17:48:18 +01:00
|
|
|
modMask |= WLR_MODIFIER_LOGO;
|
2022-07-06 16:50:11 +02:00
|
|
|
if (mods.contains("MOD5"))
|
2022-03-19 17:48:18 +01:00
|
|
|
modMask |= WLR_MODIFIER_MOD5;
|
|
|
|
|
|
|
|
return modMask;
|
|
|
|
}
|
|
|
|
|
2022-08-21 16:43:18 +02:00
|
|
|
void CKeybindManager::updateXKBTranslationState() {
|
|
|
|
if (m_pXKBTranslationState) {
|
|
|
|
xkb_keymap_unref(xkb_state_get_keymap(m_pXKBTranslationState));
|
|
|
|
xkb_state_unref(m_pXKBTranslationState);
|
|
|
|
|
|
|
|
m_pXKBTranslationState = nullptr;
|
|
|
|
}
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto FILEPATH = g_pConfigManager->getString("input:kb_file");
|
|
|
|
const auto RULES = g_pConfigManager->getString("input:kb_rules");
|
|
|
|
const auto MODEL = g_pConfigManager->getString("input:kb_model");
|
|
|
|
const auto LAYOUT = g_pConfigManager->getString("input:kb_layout");
|
|
|
|
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
|
|
|
|
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
|
2022-08-21 16:43:18 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()};
|
2022-08-21 16:43:18 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
2022-08-21 16:43:18 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
auto PKEYMAP = FILEPATH == "" ? xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS) :
|
|
|
|
xkb_keymap_new_from_file(PCONTEXT, fopen(FILEPATH.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
2022-09-24 22:07:18 +02:00
|
|
|
|
|
|
|
if (!PKEYMAP) {
|
2022-12-16 18:17:31 +01:00
|
|
|
g_pHyprError->queueCreate("[Runtime Error] Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS +
|
|
|
|
", layout: " + LAYOUT + " )",
|
2023-01-05 19:25:45 +01:00
|
|
|
CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
|
2022-09-24 22:07:18 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
Debug::log(ERR, "[XKBTranslationState] Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant,
|
|
|
|
rules.rules, rules.model, rules.options);
|
2022-09-24 22:07:18 +02:00
|
|
|
memset(&rules, 0, sizeof(rules));
|
|
|
|
|
|
|
|
PKEYMAP = xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
|
|
|
}
|
2022-08-21 16:43:18 +02:00
|
|
|
|
|
|
|
xkb_context_unref(PCONTEXT);
|
|
|
|
m_pXKBTranslationState = xkb_state_new(PKEYMAP);
|
|
|
|
}
|
|
|
|
|
2022-09-20 23:23:02 +02:00
|
|
|
bool CKeybindManager::ensureMouseBindState() {
|
2022-09-20 11:02:20 +02:00
|
|
|
if (!m_bIsMouseBindActive)
|
2022-09-20 23:23:02 +02:00
|
|
|
return false;
|
2022-09-20 11:02:20 +02:00
|
|
|
|
|
|
|
if (g_pInputManager->currentlyDraggedWindow) {
|
2022-09-20 23:23:02 +02:00
|
|
|
m_bIsMouseBindActive = false;
|
2022-09-20 11:02:20 +02:00
|
|
|
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
|
|
|
g_pInputManager->currentlyDraggedWindow = nullptr;
|
2022-12-16 18:17:31 +01:00
|
|
|
g_pInputManager->dragMode = MBIND_INVALID;
|
2022-09-20 23:23:02 +02:00
|
|
|
|
|
|
|
return true;
|
2022-09-20 11:02:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
m_bIsMouseBindActive = false;
|
2022-09-20 23:23:02 +02:00
|
|
|
|
|
|
|
return false;
|
2022-09-20 11:02:20 +02:00
|
|
|
}
|
|
|
|
|
2022-07-20 22:45:06 +02:00
|
|
|
bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
|
2022-08-29 11:17:42 +02:00
|
|
|
if (!g_pCompositor->m_bSessionActive) {
|
|
|
|
m_dPressedKeycodes.clear();
|
|
|
|
m_dPressedKeysyms.clear();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-11-07 23:22:13 +01:00
|
|
|
if (pKeyboard->isVirtual && g_pInputManager->shouldIgnoreVirtualKeyboard(pKeyboard))
|
2022-08-05 16:21:08 +02:00
|
|
|
return true;
|
|
|
|
|
2022-08-21 16:43:18 +02:00
|
|
|
if (!m_pXKBTranslationState) {
|
|
|
|
Debug::log(ERR, "BUG THIS: m_pXKBTranslationState NULL!");
|
|
|
|
updateXKBTranslationState();
|
|
|
|
|
|
|
|
if (!m_pXKBTranslationState)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto KEYCODE = e->keycode + 8; // Because to xkbcommon it's +8 from libinput
|
2022-07-20 22:45:06 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
const xkb_keysym_t keysym = xkb_state_key_get_one_sym(m_pXKBTranslationState, KEYCODE);
|
2022-08-26 19:19:34 +02:00
|
|
|
const xkb_keysym_t internalKeysym = xkb_state_key_get_one_sym(wlr_keyboard_from_input_device(pKeyboard->keyboard)->xkb_state, KEYCODE);
|
|
|
|
|
|
|
|
if (handleInternalKeybinds(internalKeysym))
|
|
|
|
return true;
|
2022-07-20 22:45:06 +02:00
|
|
|
|
|
|
|
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
m_uTimeLastMs = e->time_msec;
|
|
|
|
m_uLastCode = KEYCODE;
|
2022-08-28 17:01:48 +02:00
|
|
|
m_uLastMouseCode = 0;
|
2022-07-20 23:17:26 +02:00
|
|
|
|
2022-09-20 23:23:02 +02:00
|
|
|
bool mouseBindWasActive = ensureMouseBindState();
|
2022-09-20 11:02:20 +02:00
|
|
|
|
2022-07-20 22:45:06 +02:00
|
|
|
bool found = false;
|
|
|
|
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
2022-07-25 14:42:49 +02:00
|
|
|
// clean repeat
|
|
|
|
if (m_pActiveKeybindEventSource) {
|
|
|
|
wl_event_source_remove(m_pActiveKeybindEventSource);
|
|
|
|
m_pActiveKeybindEventSource = nullptr;
|
2022-12-16 18:17:31 +01:00
|
|
|
m_pActiveKeybind = nullptr;
|
2022-07-25 14:42:49 +02:00
|
|
|
}
|
|
|
|
|
2022-07-20 23:17:26 +02:00
|
|
|
m_dPressedKeycodes.push_back(KEYCODE);
|
|
|
|
m_dPressedKeysyms.push_back(keysym);
|
|
|
|
|
2022-10-04 21:07:21 +02:00
|
|
|
found = handleKeybinds(MODS, "", keysym, 0, true, e->time_msec) || found;
|
2022-07-20 22:45:06 +02:00
|
|
|
|
2022-10-04 21:07:21 +02:00
|
|
|
found = handleKeybinds(MODS, "", 0, KEYCODE, true, e->time_msec) || found;
|
2022-07-24 14:35:58 +02:00
|
|
|
|
|
|
|
if (found)
|
2022-07-25 14:24:02 +02:00
|
|
|
shadowKeybinds(keysym, KEYCODE);
|
2022-07-20 22:45:06 +02:00
|
|
|
} else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
2022-07-25 14:42:49 +02:00
|
|
|
// clean repeat
|
|
|
|
if (m_pActiveKeybindEventSource) {
|
|
|
|
wl_event_source_remove(m_pActiveKeybindEventSource);
|
|
|
|
m_pActiveKeybindEventSource = nullptr;
|
2022-12-16 18:17:31 +01:00
|
|
|
m_pActiveKeybind = nullptr;
|
2022-07-25 14:42:49 +02:00
|
|
|
}
|
2022-07-20 22:45:06 +02:00
|
|
|
|
2022-09-13 20:27:07 +02:00
|
|
|
m_dPressedKeycodes.erase(std::remove(m_dPressedKeycodes.begin(), m_dPressedKeycodes.end(), KEYCODE), m_dPressedKeycodes.end());
|
|
|
|
m_dPressedKeysyms.erase(std::remove(m_dPressedKeysyms.begin(), m_dPressedKeysyms.end(), keysym), m_dPressedKeysyms.end());
|
2022-07-20 23:17:26 +02:00
|
|
|
|
2022-10-04 21:07:21 +02:00
|
|
|
found = handleKeybinds(MODS, "", keysym, 0, false, e->time_msec) || found;
|
2022-07-20 23:17:26 +02:00
|
|
|
|
2022-10-04 21:07:21 +02:00
|
|
|
found = handleKeybinds(MODS, "", 0, KEYCODE, false, e->time_msec) || found;
|
2022-07-20 23:17:26 +02:00
|
|
|
|
|
|
|
shadowKeybinds();
|
2022-07-20 22:45:06 +02:00
|
|
|
}
|
|
|
|
|
2022-09-20 23:23:02 +02:00
|
|
|
return !found && !mouseBindWasActive;
|
2022-07-20 22:45:06 +02:00
|
|
|
}
|
|
|
|
|
2022-07-21 18:18:03 +02:00
|
|
|
bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) {
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
2022-07-21 18:18:03 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
static auto* const PDELAY = &g_pConfigManager->getConfigValuePtr("binds:scroll_event_delay")->intValue;
|
2022-07-26 23:34:03 +02:00
|
|
|
|
|
|
|
if (m_tScrollTimer.getMillis() < *PDELAY) {
|
|
|
|
m_tScrollTimer.reset();
|
|
|
|
return true; // timer hasn't passed yet!
|
|
|
|
}
|
|
|
|
|
|
|
|
m_tScrollTimer.reset();
|
|
|
|
|
2022-07-21 18:18:03 +02:00
|
|
|
bool found = false;
|
|
|
|
if (e->source == WLR_AXIS_SOURCE_WHEEL && e->orientation == WLR_AXIS_ORIENTATION_VERTICAL) {
|
2022-09-25 20:07:48 +02:00
|
|
|
if (e->delta < 0) {
|
2022-10-04 21:07:21 +02:00
|
|
|
found = handleKeybinds(MODS, "mouse_down", 0, 0, true, 0);
|
2022-07-21 18:18:03 +02:00
|
|
|
} else {
|
2022-10-04 21:07:21 +02:00
|
|
|
found = handleKeybinds(MODS, "mouse_up", 0, 0, true, 0);
|
2022-07-21 18:18:03 +02:00
|
|
|
}
|
2022-07-26 14:50:21 +02:00
|
|
|
|
|
|
|
if (found)
|
|
|
|
shadowKeybinds();
|
|
|
|
}
|
|
|
|
|
|
|
|
return !found;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CKeybindManager::onMouseEvent(wlr_pointer_button_event* e) {
|
|
|
|
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
bool found = false;
|
2022-07-26 14:50:21 +02:00
|
|
|
|
2022-08-28 17:01:48 +02:00
|
|
|
m_uLastMouseCode = e->button;
|
2022-12-16 18:17:31 +01:00
|
|
|
m_uLastCode = 0;
|
|
|
|
m_uTimeLastMs = e->time_msec;
|
2022-08-28 17:01:48 +02:00
|
|
|
|
2022-09-20 23:23:02 +02:00
|
|
|
bool mouseBindWasActive = ensureMouseBindState();
|
|
|
|
|
2022-07-26 14:50:21 +02:00
|
|
|
if (e->state == WLR_BUTTON_PRESSED) {
|
2022-10-04 21:07:21 +02:00
|
|
|
found = handleKeybinds(MODS, "mouse:" + std::to_string(e->button), 0, 0, true, 0);
|
2022-07-26 14:50:21 +02:00
|
|
|
|
|
|
|
if (found)
|
|
|
|
shadowKeybinds();
|
|
|
|
} else {
|
2022-10-04 21:07:21 +02:00
|
|
|
found = handleKeybinds(MODS, "mouse:" + std::to_string(e->button), 0, 0, false, 0);
|
2022-07-26 14:50:21 +02:00
|
|
|
|
|
|
|
shadowKeybinds();
|
2022-07-21 18:18:03 +02:00
|
|
|
}
|
|
|
|
|
2022-09-20 23:23:02 +02:00
|
|
|
return !found && !mouseBindWasActive;
|
2022-07-21 18:18:03 +02:00
|
|
|
}
|
|
|
|
|
2022-10-04 21:07:21 +02:00
|
|
|
void CKeybindManager::onSwitchEvent(const std::string& switchName) {
|
|
|
|
handleKeybinds(0, "switch:" + switchName, 0, 0, true, 0);
|
|
|
|
}
|
|
|
|
|
2023-01-08 16:35:24 +01:00
|
|
|
void CKeybindManager::onSwitchOnEvent(const std::string& switchName) {
|
|
|
|
handleKeybinds(0, "switch:on:" + switchName, 0, 0, true, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::onSwitchOffEvent(const std::string& switchName) {
|
|
|
|
handleKeybinds(0, "switch:off:" + switchName, 0, 0, true, 0);
|
|
|
|
}
|
|
|
|
|
2022-07-25 14:42:49 +02:00
|
|
|
int repeatKeyHandler(void* data) {
|
|
|
|
SKeybind** ppActiveKeybind = (SKeybind**)data;
|
|
|
|
|
|
|
|
if (!*ppActiveKeybind)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find((*ppActiveKeybind)->handler);
|
|
|
|
|
|
|
|
Debug::log(LOG, "Keybind repeat triggered, calling dispatcher.");
|
|
|
|
DISPATCHER->second((*ppActiveKeybind)->arg);
|
|
|
|
|
|
|
|
wl_event_source_timer_update(g_pKeybindManager->m_pActiveKeybindEventSource, 1000 / g_pInputManager->m_pActiveKeyboard->repeatRate);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-21 18:18:03 +02:00
|
|
|
bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string& key, const xkb_keysym_t& keysym, const int& keycode, bool pressed, uint32_t time) {
|
2022-03-19 22:03:40 +01:00
|
|
|
bool found = false;
|
2022-03-27 19:32:50 +02:00
|
|
|
|
2022-06-21 22:47:27 +02:00
|
|
|
if (g_pCompositor->m_sSeat.exclusiveClient)
|
|
|
|
Debug::log(LOG, "Keybind handling only locked (inhibitor)");
|
2022-04-18 17:16:01 +02:00
|
|
|
|
2022-07-20 23:17:26 +02:00
|
|
|
if (pressed && m_kHeldBack) {
|
|
|
|
// release the held back event
|
|
|
|
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, time, m_kHeldBack, WL_KEYBOARD_KEY_STATE_PRESSED);
|
|
|
|
m_kHeldBack = 0;
|
|
|
|
}
|
|
|
|
|
2022-04-21 17:06:43 +02:00
|
|
|
for (auto& k : m_lKeybinds) {
|
2022-12-16 18:17:31 +01:00
|
|
|
if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap ||
|
|
|
|
(!pressed && !k.release && k.handler != "pass" && k.handler != "mouse") || k.shadowed)
|
2022-03-19 17:48:18 +01:00
|
|
|
continue;
|
|
|
|
|
2022-07-15 20:54:05 +02:00
|
|
|
if (!key.empty()) {
|
|
|
|
if (key != k.key)
|
|
|
|
continue;
|
|
|
|
} else if (k.keycode != -1) {
|
2022-07-08 09:27:17 +02:00
|
|
|
if (keycode != k.keycode)
|
|
|
|
continue;
|
|
|
|
} else {
|
2022-07-15 20:54:05 +02:00
|
|
|
if (keysym == 0)
|
2022-12-16 18:17:31 +01:00
|
|
|
continue; // this is a keycode check run
|
2022-07-08 09:27:17 +02:00
|
|
|
|
|
|
|
// oMg such performance hit!!11!
|
|
|
|
// this little maneouver is gonna cost us 4µs
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
2022-07-08 09:27:17 +02:00
|
|
|
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
|
|
|
|
// small TODO: fix 0-9 keys and other modified ones with shift
|
|
|
|
|
2022-07-15 20:54:05 +02:00
|
|
|
if (keysym != KBKEY && keysym != KBKEYUPPER)
|
2022-07-08 09:27:17 +02:00
|
|
|
continue;
|
|
|
|
}
|
2022-04-21 15:50:52 +02:00
|
|
|
|
2022-07-20 22:45:06 +02:00
|
|
|
if (pressed && k.release) {
|
|
|
|
// suppress down event
|
2022-07-21 18:48:34 +02:00
|
|
|
m_kHeldBack = keysym;
|
2022-07-20 22:45:06 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-19 20:04:48 +02:00
|
|
|
const auto DISPATCHER = m_mDispatchers.find(k.mouse ? "mouse" : k.handler);
|
2022-04-21 15:50:52 +02:00
|
|
|
|
|
|
|
// Should never happen, as we check in the ConfigManager, but oh well
|
|
|
|
if (DISPATCHER == m_mDispatchers.end()) {
|
2022-04-14 23:02:10 +02:00
|
|
|
Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str());
|
2022-04-21 15:50:52 +02:00
|
|
|
} else {
|
|
|
|
// call the dispatcher
|
2022-07-30 23:04:31 +02:00
|
|
|
Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %s, %d)", modmask, key.c_str(), keysym);
|
2022-08-27 19:29:28 +02:00
|
|
|
|
|
|
|
m_iPassPressed = (int)pressed;
|
|
|
|
|
2022-09-19 20:04:48 +02:00
|
|
|
if (k.handler == "mouse")
|
|
|
|
DISPATCHER->second((pressed ? "1" : "0") + k.arg);
|
|
|
|
else
|
|
|
|
DISPATCHER->second(k.arg);
|
2022-08-09 19:54:06 +02:00
|
|
|
|
2022-08-27 19:29:28 +02:00
|
|
|
m_iPassPressed = -1;
|
|
|
|
|
2022-08-09 19:54:06 +02:00
|
|
|
if (k.handler == "submap") {
|
|
|
|
found = true; // don't process keybinds on submap change.
|
|
|
|
break;
|
|
|
|
}
|
2022-04-14 23:02:10 +02:00
|
|
|
}
|
2022-03-19 22:03:40 +01:00
|
|
|
|
2022-07-25 14:42:49 +02:00
|
|
|
if (k.repeat) {
|
2022-12-16 18:17:31 +01:00
|
|
|
m_pActiveKeybind = &k;
|
2022-07-25 14:42:49 +02:00
|
|
|
m_pActiveKeybindEventSource = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, repeatKeyHandler, &m_pActiveKeybind);
|
|
|
|
|
|
|
|
const auto PACTIVEKEEB = g_pInputManager->m_pActiveKeyboard;
|
|
|
|
|
|
|
|
wl_event_source_timer_update(m_pActiveKeybindEventSource, PACTIVEKEEB->repeatDelay);
|
|
|
|
}
|
|
|
|
|
2022-03-19 22:03:40 +01:00
|
|
|
found = true;
|
2022-03-19 17:48:18 +01:00
|
|
|
}
|
2022-03-19 22:03:40 +01:00
|
|
|
|
|
|
|
return found;
|
2022-03-19 17:48:18 +01:00
|
|
|
}
|
|
|
|
|
2022-07-25 14:06:49 +02:00
|
|
|
void CKeybindManager::shadowKeybinds(const xkb_keysym_t& doesntHave, const int& doesntHaveCode) {
|
2022-07-20 23:17:26 +02:00
|
|
|
// shadow disables keybinds after one has been triggered
|
|
|
|
|
|
|
|
for (auto& k : m_lKeybinds) {
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
bool shadow = false;
|
2022-07-20 23:17:26 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
2022-07-20 23:17:26 +02:00
|
|
|
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
|
|
|
|
|
|
|
|
for (auto& pk : m_dPressedKeysyms) {
|
|
|
|
if ((pk == KBKEY || pk == KBKEYUPPER)) {
|
|
|
|
shadow = true;
|
2022-09-25 20:07:48 +02:00
|
|
|
|
2022-07-25 16:12:06 +02:00
|
|
|
if (pk == doesntHave && doesntHave != 0) {
|
|
|
|
shadow = false;
|
|
|
|
break;
|
|
|
|
}
|
2022-07-24 12:16:26 +02:00
|
|
|
}
|
2022-07-20 23:17:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (auto& pk : m_dPressedKeycodes) {
|
2022-07-25 14:06:49 +02:00
|
|
|
if (pk == k.keycode) {
|
2022-07-20 23:17:26 +02:00
|
|
|
shadow = true;
|
2022-07-24 12:16:26 +02:00
|
|
|
|
2022-07-25 16:12:06 +02:00
|
|
|
if (pk == doesntHaveCode && doesntHaveCode != 0 && doesntHaveCode != -1) {
|
|
|
|
shadow = false;
|
|
|
|
break;
|
|
|
|
}
|
2022-07-24 12:16:26 +02:00
|
|
|
}
|
2022-07-20 23:17:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
k.shadowed = shadow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-27 13:42:20 +02:00
|
|
|
bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
|
2022-03-27 19:32:50 +02:00
|
|
|
// Handles the CTRL+ALT+FX TTY keybinds
|
|
|
|
if (!(keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12))
|
|
|
|
return false;
|
|
|
|
|
2022-10-06 20:31:32 +02:00
|
|
|
// beyond this point, return true to not handle anything else.
|
|
|
|
// we'll avoid printing shit to active windows.
|
|
|
|
|
2022-10-05 22:41:27 +02:00
|
|
|
if (g_pCompositor->m_sWLRSession) {
|
2022-10-05 02:42:51 +02:00
|
|
|
const unsigned int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
|
2022-10-04 17:53:09 +02:00
|
|
|
|
2022-10-05 22:41:27 +02:00
|
|
|
// vtnr is bugged for some reason.
|
2022-12-20 03:18:47 +01:00
|
|
|
const std::string TTYSTR = execAndGet("head -n 1 /sys/devices/virtual/tty/tty0/active").substr(3);
|
|
|
|
unsigned int ttynum = 0;
|
2022-10-05 22:41:27 +02:00
|
|
|
try {
|
|
|
|
ttynum = std::stoll(TTYSTR);
|
2022-12-16 18:17:31 +01:00
|
|
|
} catch (std::exception& e) {
|
2022-10-05 22:41:27 +02:00
|
|
|
; // oops?
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ttynum == TTY)
|
2022-10-06 20:31:32 +02:00
|
|
|
return true;
|
2022-10-05 22:41:27 +02:00
|
|
|
|
|
|
|
Debug::log(LOG, "Switching from VT %i to VT %i", ttynum, TTY);
|
|
|
|
|
|
|
|
if (!wlr_session_change_vt(g_pCompositor->m_sWLRSession, TTY))
|
2022-10-06 20:31:32 +02:00
|
|
|
return true; // probably same session
|
2022-10-04 17:53:09 +02:00
|
|
|
|
2022-07-13 18:18:23 +02:00
|
|
|
g_pCompositor->m_bSessionActive = false;
|
2022-06-06 13:48:17 +02:00
|
|
|
|
2022-06-30 15:44:26 +02:00
|
|
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
|
|
|
m->noFrameSchedule = true;
|
2022-12-16 18:17:31 +01:00
|
|
|
m->framesToSkip = 1;
|
2022-06-06 13:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Debug::log(LOG, "Switched to VT %i, destroyed all render data, frames to skip for each: 2", TTY);
|
2022-06-27 13:42:20 +02:00
|
|
|
|
2022-03-27 19:32:50 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-10-06 20:31:32 +02:00
|
|
|
return true;
|
2022-03-27 19:32:50 +02:00
|
|
|
}
|
|
|
|
|
2022-06-27 13:42:20 +02:00
|
|
|
bool CKeybindManager::handleInternalKeybinds(xkb_keysym_t keysym) {
|
|
|
|
if (handleVT(keysym))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// handle ESC while in kill mode
|
|
|
|
if (g_pInputManager->getClickMode() == CLICKMODE_KILL) {
|
|
|
|
const auto KBKEY = xkb_keysym_from_name("ESCAPE", XKB_KEYSYM_CASE_INSENSITIVE);
|
|
|
|
|
|
|
|
if (keysym == KBKEY) {
|
|
|
|
g_pInputManager->setClickMode(CLICKMODE_DEFAULT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
// Dispatchers
|
|
|
|
|
|
|
|
void CKeybindManager::spawn(std::string args) {
|
2022-11-10 14:39:23 +01:00
|
|
|
|
|
|
|
args = removeBeginEndSpacesTabs(args);
|
|
|
|
|
|
|
|
std::string RULES = "";
|
|
|
|
|
|
|
|
if (args[0] == '[') {
|
|
|
|
// we have exec rules
|
|
|
|
RULES = args.substr(1, args.substr(1).find_first_of(']'));
|
2022-12-16 18:17:31 +01:00
|
|
|
args = args.substr(args.find_first_of(']') + 1);
|
2022-11-10 14:39:23 +01:00
|
|
|
}
|
|
|
|
|
2022-04-20 15:58:02 +02:00
|
|
|
if (g_pXWaylandManager->m_sWLRXWayland)
|
|
|
|
args = "WAYLAND_DISPLAY=" + std::string(g_pCompositor->m_szWLDisplaySocket) + " DISPLAY=" + std::string(g_pXWaylandManager->m_sWLRXWayland->display_name) + " " + args;
|
|
|
|
else
|
|
|
|
args = "WAYLAND_DISPLAY=" + std::string(g_pCompositor->m_szWLDisplaySocket) + " " + args;
|
2022-04-20 16:18:58 +02:00
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
Debug::log(LOG, "Executing %s", args.c_str());
|
|
|
|
|
2022-06-15 19:06:51 +02:00
|
|
|
int socket[2];
|
2022-06-16 21:19:36 +02:00
|
|
|
if (pipe(socket) != 0) {
|
|
|
|
Debug::log(LOG, "Unable to create pipe for fork");
|
|
|
|
}
|
2022-06-15 19:06:51 +02:00
|
|
|
|
2022-06-16 21:19:36 +02:00
|
|
|
pid_t child, grandchild;
|
2022-06-15 19:06:51 +02:00
|
|
|
child = fork();
|
2022-06-16 21:19:36 +02:00
|
|
|
if (child < 0) {
|
2022-06-15 19:06:51 +02:00
|
|
|
close(socket[0]);
|
|
|
|
close(socket[1]);
|
|
|
|
Debug::log(LOG, "Fail to create the first fork");
|
|
|
|
return;
|
|
|
|
}
|
2022-06-16 21:19:36 +02:00
|
|
|
if (child == 0) {
|
2022-06-15 19:06:51 +02:00
|
|
|
// run in child
|
2022-10-06 20:02:03 +02:00
|
|
|
|
|
|
|
sigset_t set;
|
|
|
|
sigemptyset(&set);
|
|
|
|
sigprocmask(SIG_SETMASK, &set, NULL);
|
|
|
|
|
2022-06-15 19:06:51 +02:00
|
|
|
grandchild = fork();
|
2022-06-16 21:19:36 +02:00
|
|
|
if (grandchild == 0) {
|
2022-06-15 19:06:51 +02:00
|
|
|
// run in grandchild
|
|
|
|
close(socket[0]);
|
|
|
|
close(socket[1]);
|
|
|
|
execl("/bin/sh", "/bin/sh", "-c", args.c_str(), nullptr);
|
|
|
|
// exit grandchild
|
|
|
|
_exit(0);
|
|
|
|
}
|
|
|
|
close(socket[0]);
|
2022-06-16 21:19:36 +02:00
|
|
|
write(socket[1], &grandchild, sizeof(grandchild));
|
2022-06-15 19:06:51 +02:00
|
|
|
close(socket[1]);
|
|
|
|
// exit child
|
2022-03-19 17:48:18 +01:00
|
|
|
_exit(0);
|
|
|
|
}
|
2022-06-15 19:06:51 +02:00
|
|
|
// run in parent
|
|
|
|
close(socket[1]);
|
2022-06-16 21:19:36 +02:00
|
|
|
read(socket[0], &grandchild, sizeof(grandchild));
|
2022-06-15 19:06:51 +02:00
|
|
|
close(socket[0]);
|
|
|
|
// clear child and leave child to init
|
|
|
|
waitpid(child, NULL, 0);
|
2022-06-16 21:19:36 +02:00
|
|
|
if (child < 0) {
|
2022-06-15 19:06:51 +02:00
|
|
|
Debug::log(LOG, "Fail to create the second fork");
|
|
|
|
return;
|
|
|
|
}
|
2022-11-10 14:39:23 +01:00
|
|
|
|
2022-06-16 21:19:36 +02:00
|
|
|
Debug::log(LOG, "Process Created with pid %d", grandchild);
|
2022-11-10 14:39:23 +01:00
|
|
|
|
|
|
|
if (!RULES.empty()) {
|
|
|
|
const auto RULESLIST = CVarList(RULES, 0, ';');
|
|
|
|
|
|
|
|
for (auto& r : RULESLIST) {
|
|
|
|
g_pConfigManager->addExecRule({r, (unsigned long)grandchild});
|
|
|
|
}
|
|
|
|
|
|
|
|
Debug::log(LOG, "Applied %i rule arguments for exec.", RULESLIST.size());
|
|
|
|
}
|
2022-03-19 17:48:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::killActive(std::string args) {
|
2022-08-06 20:57:38 +02:00
|
|
|
g_pCompositor->closeWindow(g_pCompositor->m_pLastWindow);
|
2022-03-19 21:48:24 +01:00
|
|
|
}
|
|
|
|
|
2022-08-30 21:35:27 +02:00
|
|
|
void CKeybindManager::kill(std::string args) {
|
|
|
|
const auto PWINDOW = g_pCompositor->getWindowByRegex(args);
|
|
|
|
|
|
|
|
if (!PWINDOW) {
|
|
|
|
Debug::log(ERR, "kill: no window found");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_pCompositor->closeWindow(PWINDOW);
|
|
|
|
}
|
|
|
|
|
2022-03-19 21:48:24 +01:00
|
|
|
void CKeybindManager::clearKeybinds() {
|
2022-04-21 17:06:43 +02:00
|
|
|
m_lKeybinds.clear();
|
2022-03-20 11:14:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::toggleActiveFloating(std::string args) {
|
2022-08-25 22:34:53 +02:00
|
|
|
CWindow* PWINDOW = nullptr;
|
2022-03-20 11:14:24 +01:00
|
|
|
|
2022-08-25 22:34:53 +02:00
|
|
|
if (args != "" && args != "active" && args.length() > 1) {
|
|
|
|
PWINDOW = g_pCompositor->getWindowByRegex(args);
|
|
|
|
} else {
|
|
|
|
PWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!PWINDOW)
|
|
|
|
return;
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
// remove drag status
|
|
|
|
g_pInputManager->currentlyDraggedWindow = nullptr;
|
2022-06-30 12:09:05 +02:00
|
|
|
|
2022-11-27 23:42:22 +01:00
|
|
|
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID))
|
2022-10-14 21:46:32 +02:00
|
|
|
return;
|
2022-03-20 13:37:07 +01:00
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
PWINDOW->m_bIsFloating = !PWINDOW->m_bIsFloating;
|
2022-05-31 14:01:00 +02:00
|
|
|
|
2022-11-15 11:21:26 +01:00
|
|
|
PWINDOW->updateDynamicRules();
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(PWINDOW);
|
2022-03-20 15:55:47 +01:00
|
|
|
}
|
|
|
|
|
2022-11-07 13:16:30 +01:00
|
|
|
void CKeybindManager::centerWindow(std::string args) {
|
|
|
|
const auto PWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
|
|
|
|
if (!PWINDOW || !PWINDOW->m_bIsFloating || PWINDOW->m_bIsFullscreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
|
|
|
|
|
|
|
PWINDOW->m_vRealPosition = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f - PWINDOW->m_vRealSize.goalv() / 2.f;
|
2022-12-16 18:17:31 +01:00
|
|
|
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goalv();
|
2022-11-07 13:16:30 +01:00
|
|
|
}
|
|
|
|
|
2022-04-02 20:04:32 +02:00
|
|
|
void CKeybindManager::toggleActivePseudo(std::string args) {
|
|
|
|
const auto ACTIVEWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!ACTIVEWINDOW)
|
2022-04-02 20:04:32 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
ACTIVEWINDOW->m_bIsPseudotiled = !ACTIVEWINDOW->m_bIsPseudotiled;
|
|
|
|
|
2022-09-22 21:57:09 +02:00
|
|
|
if (!ACTIVEWINDOW->m_bIsFullscreen)
|
|
|
|
g_pLayoutManager->getCurrentLayout()->recalculateWindow(ACTIVEWINDOW);
|
2022-04-02 20:04:32 +02:00
|
|
|
}
|
|
|
|
|
2022-04-21 17:21:55 +02:00
|
|
|
void CKeybindManager::changeworkspace(std::string args) {
|
2022-12-16 18:17:31 +01:00
|
|
|
int workspaceToChangeTo = 0;
|
|
|
|
std::string workspaceName = "";
|
2022-04-21 16:38:48 +02:00
|
|
|
|
2022-08-21 12:21:21 +02:00
|
|
|
// Flag needed so that the previous workspace is not recorded when switching
|
|
|
|
// to a previous workspace.
|
2022-12-20 03:18:47 +01:00
|
|
|
bool isSwitchingToPrevious = false;
|
2022-08-21 12:21:21 +02:00
|
|
|
|
2022-12-20 03:18:47 +01:00
|
|
|
bool internal = false;
|
2022-08-23 23:34:36 +02:00
|
|
|
|
2022-07-06 11:02:21 +02:00
|
|
|
if (args.find("[internal]") == 0) {
|
2022-12-16 18:17:31 +01:00
|
|
|
workspaceToChangeTo = std::stoi(args.substr(10));
|
2022-07-06 11:02:21 +02:00
|
|
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToChangeTo);
|
|
|
|
if (PWORKSPACE)
|
|
|
|
workspaceName = PWORKSPACE->m_szName;
|
2022-08-23 23:34:36 +02:00
|
|
|
|
|
|
|
internal = true;
|
2022-08-21 12:21:21 +02:00
|
|
|
} else if (args.find("previous") == 0) {
|
2022-10-13 16:16:39 +02:00
|
|
|
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
2022-08-21 12:21:21 +02:00
|
|
|
|
|
|
|
// Do nothing if there's no previous workspace, otherwise switch to it.
|
2022-08-21 13:58:46 +02:00
|
|
|
if (PCURRENTWORKSPACE->m_iPrevWorkspaceID == -1) {
|
2022-08-21 12:21:21 +02:00
|
|
|
Debug::log(LOG, "No previous workspace to change to");
|
|
|
|
return;
|
2022-10-13 16:16:39 +02:00
|
|
|
} else {
|
2022-08-21 13:58:46 +02:00
|
|
|
workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID;
|
2022-11-07 13:16:30 +01:00
|
|
|
|
2022-10-13 16:16:39 +02:00
|
|
|
if (const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); PWORKSPACETOCHANGETO)
|
|
|
|
workspaceName = PWORKSPACETOCHANGETO->m_szName;
|
|
|
|
else
|
|
|
|
workspaceName = std::to_string(workspaceToChangeTo);
|
|
|
|
|
2022-08-21 12:21:21 +02:00
|
|
|
isSwitchingToPrevious = true;
|
|
|
|
|
2022-08-21 12:47:56 +02:00
|
|
|
// If the previous workspace ID isn't reset, cycles can form when continually going
|
|
|
|
// to the previous workspace again and again.
|
2022-12-16 18:17:31 +01:00
|
|
|
static auto* const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue;
|
2022-08-21 13:58:46 +02:00
|
|
|
if (!*PALLOWWORKSPACECYCLES)
|
|
|
|
PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1;
|
2022-08-21 12:21:21 +02:00
|
|
|
}
|
2022-07-06 11:02:21 +02:00
|
|
|
} else {
|
|
|
|
workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName);
|
|
|
|
}
|
2022-04-14 23:02:10 +02:00
|
|
|
|
2022-04-20 16:53:41 +02:00
|
|
|
if (workspaceToChangeTo == INT_MAX) {
|
|
|
|
Debug::log(ERR, "Error in changeworkspace, invalid value");
|
|
|
|
return;
|
2022-03-20 15:55:47 +01:00
|
|
|
}
|
|
|
|
|
2022-09-25 20:07:48 +02:00
|
|
|
// Workspace_back_and_forth being enabled means that an attempt to switch to
|
2022-08-21 12:40:06 +02:00
|
|
|
// the current workspace will instead switch to the previous.
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
|
|
|
static auto* const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue;
|
2022-09-17 13:10:06 +02:00
|
|
|
|
2022-11-15 11:18:04 +01:00
|
|
|
if (*PBACKANDFORTH && PCURRENTWORKSPACE && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo && PCURRENTWORKSPACE->m_iPrevWorkspaceID != -1 && !internal) {
|
2022-10-06 21:40:58 +02:00
|
|
|
|
2022-10-06 21:18:49 +02:00
|
|
|
const auto PPREVWORKSPACE = g_pCompositor->getWorkspaceByID(PCURRENTWORKSPACE->m_iPrevWorkspaceID);
|
2022-08-21 12:40:06 +02:00
|
|
|
|
2022-10-06 21:40:58 +02:00
|
|
|
workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID;
|
2022-11-07 13:16:30 +01:00
|
|
|
|
2022-10-06 21:40:58 +02:00
|
|
|
if (PPREVWORKSPACE)
|
|
|
|
workspaceName = PPREVWORKSPACE->m_szName;
|
|
|
|
else
|
|
|
|
workspaceName = std::to_string(workspaceToChangeTo);
|
|
|
|
|
|
|
|
isSwitchingToPrevious = true;
|
|
|
|
|
|
|
|
// If the previous workspace ID isn't reset, cycles can form when continually going
|
|
|
|
// to the previous workspace again and again.
|
|
|
|
static auto* const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue;
|
|
|
|
if (!*PALLOWWORKSPACECYCLES)
|
|
|
|
PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1;
|
|
|
|
|
2022-11-15 11:18:04 +01:00
|
|
|
} else if (PCURRENTWORKSPACE && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo && !internal)
|
2022-09-17 13:10:06 +02:00
|
|
|
return;
|
2022-08-21 12:40:06 +02:00
|
|
|
|
2022-09-25 20:07:48 +02:00
|
|
|
// remove constraints
|
2022-08-09 20:36:21 +02:00
|
|
|
g_pInputManager->unconstrainMouse();
|
2022-05-18 14:57:08 +02:00
|
|
|
|
2022-11-25 12:34:29 +01:00
|
|
|
g_pInputManager->m_bEmptyFocusCursorSet = false;
|
|
|
|
|
2022-08-23 23:34:36 +02:00
|
|
|
// if it's not internal, we will unfocus to prevent stuck focus
|
|
|
|
if (!internal)
|
|
|
|
g_pCompositor->focusWindow(nullptr);
|
|
|
|
|
2022-03-20 15:55:47 +01:00
|
|
|
// if it exists, we warp to it
|
|
|
|
if (g_pCompositor->getWorkspaceByID(workspaceToChangeTo)) {
|
2022-04-11 19:51:37 +02:00
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->m_iMonitorID);
|
2022-03-20 15:55:47 +01:00
|
|
|
|
2022-05-24 19:42:43 +02:00
|
|
|
const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo);
|
|
|
|
|
2022-08-26 00:19:57 +02:00
|
|
|
if (!isSwitchingToPrevious && !internal)
|
2022-08-21 12:21:21 +02:00
|
|
|
// Remember previous workspace.
|
2022-08-21 13:58:46 +02:00
|
|
|
PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace;
|
2022-08-21 12:21:21 +02:00
|
|
|
|
2022-11-27 23:42:22 +01:00
|
|
|
if (g_pCompositor->isWorkspaceSpecial(workspaceToChangeTo))
|
2022-05-31 14:01:00 +02:00
|
|
|
PWORKSPACETOCHANGETO->m_iMonitorID = PMONITOR->ID;
|
|
|
|
|
2022-03-20 15:55:47 +01:00
|
|
|
// if it's not visible, make it visible.
|
2022-03-20 19:14:17 +01:00
|
|
|
if (!g_pCompositor->isWorkspaceVisible(workspaceToChangeTo)) {
|
|
|
|
const auto OLDWORKSPACEID = PMONITOR->activeWorkspace;
|
|
|
|
|
2022-09-10 13:11:02 +02:00
|
|
|
// fix pinned windows
|
|
|
|
for (auto& w : g_pCompositor->m_vWindows) {
|
|
|
|
if (w->m_iWorkspaceID == PMONITOR->activeWorkspace && w->m_bPinned) {
|
|
|
|
w->m_iWorkspaceID = workspaceToChangeTo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-20 19:14:17 +01:00
|
|
|
// change it
|
2022-11-27 23:42:22 +01:00
|
|
|
if (!g_pCompositor->isWorkspaceSpecial(workspaceToChangeTo))
|
2022-05-31 14:01:00 +02:00
|
|
|
PMONITOR->activeWorkspace = workspaceToChangeTo;
|
|
|
|
else
|
2022-11-27 23:42:22 +01:00
|
|
|
PMONITOR->specialWorkspaceID = workspaceToChangeTo;
|
2022-03-20 15:55:47 +01:00
|
|
|
|
2022-05-12 11:27:31 +02:00
|
|
|
// here and only here begin anim. we don't want to anim visible workspaces on other monitors.
|
2022-05-12 13:03:02 +02:00
|
|
|
// check if anim left or right
|
|
|
|
const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACEID;
|
|
|
|
|
2022-05-12 11:27:31 +02:00
|
|
|
// start anim on old workspace
|
2022-05-16 23:13:32 +02:00
|
|
|
g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->startAnim(false, ANIMTOLEFT);
|
2022-05-12 11:27:31 +02:00
|
|
|
|
|
|
|
// start anim on new workspace
|
2022-05-24 19:42:43 +02:00
|
|
|
PWORKSPACETOCHANGETO->startAnim(true, ANIMTOLEFT);
|
2022-05-24 22:21:31 +02:00
|
|
|
|
2022-07-20 18:39:08 +02:00
|
|
|
g_pEventManager->postEvent(SHyprIPCEvent{"workspace", PWORKSPACETOCHANGETO->m_szName});
|
2022-03-20 19:14:17 +01:00
|
|
|
}
|
|
|
|
|
2022-03-20 15:55:47 +01:00
|
|
|
// If the monitor is not the one our cursor's at, warp to it.
|
2022-11-17 22:58:22 +01:00
|
|
|
const bool anotherMonitor = PMONITOR != g_pCompositor->m_pLastMonitor;
|
2022-11-19 17:41:36 +01:00
|
|
|
if (anotherMonitor)
|
|
|
|
g_pCompositor->warpCursorTo(PMONITOR->vecPosition + PMONITOR->vecSize / 2.f);
|
2022-03-20 15:55:47 +01:00
|
|
|
|
2022-04-11 19:51:37 +02:00
|
|
|
// set active and deactivate all other in wlr
|
2022-05-24 19:42:43 +02:00
|
|
|
g_pCompositor->deactivateAllWLRWorkspaces(PWORKSPACETOCHANGETO->m_pWlrHandle);
|
2022-05-25 10:25:36 +02:00
|
|
|
PWORKSPACETOCHANGETO->setActive(true);
|
2022-04-11 19:51:37 +02:00
|
|
|
|
2022-05-30 20:05:38 +02:00
|
|
|
// recalc layout
|
|
|
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PWORKSPACETOCHANGETO->m_iMonitorID);
|
|
|
|
|
2022-04-11 19:51:37 +02:00
|
|
|
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
|
|
|
|
|
2022-04-14 23:02:10 +02:00
|
|
|
// focus
|
2022-09-01 11:46:36 +02:00
|
|
|
if (const auto PWINDOW = PWORKSPACETOCHANGETO->getLastFocusedWindow(); PWINDOW) {
|
2022-08-31 17:02:44 +02:00
|
|
|
// warp and focus
|
2022-08-31 21:39:27 +02:00
|
|
|
if (anotherMonitor)
|
|
|
|
g_pCompositor->warpCursorTo(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f);
|
2022-09-25 20:07:48 +02:00
|
|
|
|
2022-08-31 17:02:44 +02:00
|
|
|
g_pCompositor->focusWindow(PWINDOW, g_pXWaylandManager->getWindowSurface(PWINDOW));
|
2022-09-03 15:35:53 +02:00
|
|
|
|
|
|
|
if (g_pCompositor->cursorOnReservedArea()) // fix focus on bars etc
|
|
|
|
g_pInputManager->refocus();
|
2022-09-05 21:36:22 +02:00
|
|
|
} else if (g_pCompositor->getWindowsOnWorkspace(PWORKSPACETOCHANGETO->m_iID) > 0)
|
2022-08-31 17:02:44 +02:00
|
|
|
g_pInputManager->refocus();
|
2022-12-17 18:28:43 +01:00
|
|
|
else {
|
|
|
|
// if there are no windows on the workspace, just unfocus the window on the previous workspace
|
|
|
|
g_pCompositor->focusWindow(nullptr);
|
|
|
|
}
|
2022-04-14 23:02:10 +02:00
|
|
|
|
2022-09-05 21:36:22 +02:00
|
|
|
// set the new monitor as the last (no warps would bug otherwise)
|
2022-11-19 17:41:36 +01:00
|
|
|
g_pCompositor->setActiveMonitor(g_pCompositor->getMonitorFromID(PWORKSPACETOCHANGETO->m_iMonitorID));
|
2022-09-05 21:36:22 +02:00
|
|
|
|
2022-05-05 13:48:22 +02:00
|
|
|
// mark the monitor dirty
|
|
|
|
g_pHyprRenderer->damageMonitor(PMONITOR);
|
|
|
|
|
2022-03-20 15:55:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Workspace doesn't exist, create and switch
|
2022-09-12 21:05:52 +02:00
|
|
|
const auto BOUNDMON = g_pConfigManager->getBoundMonitorForWS(workspaceName);
|
|
|
|
|
|
|
|
const auto PMONITOR = BOUNDMON ? BOUNDMON : g_pCompositor->getMonitorFromCursor();
|
2022-03-20 15:55:47 +01:00
|
|
|
|
2022-03-20 19:28:57 +01:00
|
|
|
const auto OLDWORKSPACE = PMONITOR->activeWorkspace;
|
2022-03-20 19:27:47 +01:00
|
|
|
|
2022-05-12 13:03:02 +02:00
|
|
|
// get anim direction
|
|
|
|
const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACE;
|
|
|
|
|
2022-05-12 11:27:31 +02:00
|
|
|
// start anim on old workspace
|
2022-05-30 20:05:38 +02:00
|
|
|
if (const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); POLDWORKSPACE)
|
|
|
|
POLDWORKSPACE->startAnim(false, ANIMTOLEFT);
|
2022-05-12 11:27:31 +02:00
|
|
|
|
2022-10-24 19:36:31 +02:00
|
|
|
const auto PWORKSPACE = g_pCompositor->createNewWorkspace(workspaceToChangeTo, PMONITOR->ID, workspaceName);
|
2022-03-20 15:55:47 +01:00
|
|
|
|
2022-11-19 17:41:36 +01:00
|
|
|
const bool ANOTHERMONITOR = PMONITOR != g_pCompositor->m_pLastMonitor;
|
2022-11-17 22:58:22 +01:00
|
|
|
|
2022-08-21 12:21:21 +02:00
|
|
|
if (!isSwitchingToPrevious)
|
|
|
|
// Remember previous workspace.
|
|
|
|
PWORKSPACE->m_iPrevWorkspaceID = OLDWORKSPACE;
|
|
|
|
|
2022-05-12 11:27:31 +02:00
|
|
|
// start anim on new workspace
|
2022-05-16 23:13:32 +02:00
|
|
|
PWORKSPACE->startAnim(true, ANIMTOLEFT);
|
2022-05-12 11:27:31 +02:00
|
|
|
|
2022-11-27 23:42:22 +01:00
|
|
|
PMONITOR->specialWorkspaceID = 0;
|
2022-05-31 14:01:00 +02:00
|
|
|
|
2022-09-10 13:11:02 +02:00
|
|
|
// fix pinned windows
|
|
|
|
for (auto& w : g_pCompositor->m_vWindows) {
|
|
|
|
if (w->m_iWorkspaceID == PMONITOR->activeWorkspace && w->m_bPinned) {
|
|
|
|
w->m_iWorkspaceID = workspaceToChangeTo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-27 23:42:22 +01:00
|
|
|
if (!g_pCompositor->isWorkspaceSpecial(workspaceToChangeTo))
|
2022-05-31 14:01:00 +02:00
|
|
|
PMONITOR->activeWorkspace = workspaceToChangeTo;
|
|
|
|
else
|
2022-11-27 23:42:22 +01:00
|
|
|
PMONITOR->specialWorkspaceID = workspaceToChangeTo;
|
2022-03-20 19:28:57 +01:00
|
|
|
|
2022-04-11 19:51:37 +02:00
|
|
|
// set active and deactivate all other
|
2022-04-28 17:55:25 +02:00
|
|
|
g_pCompositor->deactivateAllWLRWorkspaces(PWORKSPACE->m_pWlrHandle);
|
2022-05-25 10:25:36 +02:00
|
|
|
PWORKSPACE->setActive(true);
|
2022-04-11 19:51:37 +02:00
|
|
|
|
2022-04-14 20:08:39 +02:00
|
|
|
// mark the monitor dirty
|
|
|
|
g_pHyprRenderer->damageMonitor(PMONITOR);
|
|
|
|
|
2022-09-12 21:05:52 +02:00
|
|
|
// some stuf with the cursor and focus
|
|
|
|
if (g_pCompositor->m_pLastMonitor != PMONITOR)
|
|
|
|
g_pCompositor->warpCursorTo(PMONITOR->vecPosition + PMONITOR->vecSize / 2.f);
|
|
|
|
|
2022-11-19 17:41:36 +01:00
|
|
|
g_pEventManager->postEvent(SHyprIPCEvent{"workspace", PWORKSPACE->m_szName});
|
|
|
|
|
|
|
|
g_pCompositor->setActiveMonitor(PMONITOR);
|
2022-09-12 21:05:52 +02:00
|
|
|
|
2022-04-14 23:02:10 +02:00
|
|
|
// focus (clears the last)
|
|
|
|
g_pInputManager->refocus();
|
|
|
|
|
2022-11-17 22:58:22 +01:00
|
|
|
// Events
|
2022-11-19 17:41:36 +01:00
|
|
|
if (ANOTHERMONITOR)
|
|
|
|
g_pCompositor->warpCursorTo(PMONITOR->vecPosition + PMONITOR->vecSize / 2.f);
|
2022-05-24 19:42:43 +02:00
|
|
|
|
2022-04-11 19:51:37 +02:00
|
|
|
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
|
2022-03-21 19:18:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::fullscreenActive(std::string args) {
|
2022-04-02 18:57:09 +02:00
|
|
|
const auto PWINDOW = g_pCompositor->m_pLastWindow;
|
2022-03-21 19:18:33 +01:00
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!PWINDOW)
|
2022-03-21 19:18:33 +01:00
|
|
|
return;
|
|
|
|
|
2022-11-27 23:42:22 +01:00
|
|
|
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID))
|
2022-08-29 14:55:11 +02:00
|
|
|
return;
|
|
|
|
|
2022-06-26 12:12:29 +02:00
|
|
|
g_pCompositor->setWindowFullscreen(PWINDOW, !PWINDOW->m_bIsFullscreen, args == "1" ? FULLSCREEN_MAXIMIZED : FULLSCREEN_FULL);
|
2022-03-23 16:51:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
2022-08-15 16:12:53 +02:00
|
|
|
|
|
|
|
CWindow* PWINDOW = nullptr;
|
|
|
|
|
|
|
|
if (args.contains(',')) {
|
|
|
|
PWINDOW = g_pCompositor->getWindowByRegex(args.substr(args.find_last_of(',') + 1));
|
2022-12-16 18:17:31 +01:00
|
|
|
args = args.substr(0, args.find_last_of(','));
|
2022-08-15 16:12:53 +02:00
|
|
|
} else {
|
|
|
|
PWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
}
|
2022-03-23 16:51:48 +01:00
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!PWINDOW)
|
2022-03-23 16:51:48 +01:00
|
|
|
return;
|
|
|
|
|
2022-12-20 03:18:47 +01:00
|
|
|
const auto OLDWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID);
|
2022-03-23 16:51:48 +01:00
|
|
|
|
|
|
|
// hack
|
2022-11-27 23:42:22 +01:00
|
|
|
std::string workspaceName;
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto WORKSPACEID = getWorkspaceIDFromString(args, workspaceName);
|
2022-05-30 15:28:23 +02:00
|
|
|
|
2022-12-14 19:42:48 +01:00
|
|
|
if (WORKSPACEID == INT_MAX) {
|
|
|
|
Debug::log(LOG, "Invalid workspace in moveActiveToWorkspace");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-03 11:19:17 +02:00
|
|
|
if (WORKSPACEID == PWINDOW->m_iWorkspaceID) {
|
|
|
|
Debug::log(LOG, "Not moving to workspace because it didn't change.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-17 13:15:56 +01:00
|
|
|
auto PSAVEDSIZE = PWINDOW->m_bIsFloating && PWINDOW->m_bIsFullscreen ? PWINDOW->m_vLastFloatingSize : PWINDOW->m_vRealSize.goalv();
|
|
|
|
auto PSAVEDPOS = PWINDOW->m_bIsFloating && PWINDOW->m_bIsFullscreen ? PWINDOW->m_vLastFloatingPosition : PWINDOW->m_vRealPosition.goalv();
|
2022-11-20 19:50:22 +01:00
|
|
|
const bool WASFULLSCREEN = PWINDOW->m_bIsFullscreen;
|
2022-07-18 20:53:29 +02:00
|
|
|
|
2022-06-03 11:19:17 +02:00
|
|
|
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW);
|
|
|
|
|
2022-12-06 21:20:37 +01:00
|
|
|
auto PWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID);
|
2022-03-23 16:51:48 +01:00
|
|
|
|
2022-04-21 16:38:48 +02:00
|
|
|
if (PWORKSPACE == OLDWORKSPACE) {
|
|
|
|
Debug::log(LOG, "Not moving to workspace because it didn't change.");
|
|
|
|
return;
|
|
|
|
}
|
2022-03-23 16:51:48 +01:00
|
|
|
|
2022-05-30 15:28:23 +02:00
|
|
|
if (!PWORKSPACE) {
|
2022-12-06 21:20:37 +01:00
|
|
|
// create
|
|
|
|
PWORKSPACE = g_pCompositor->createNewWorkspace(WORKSPACEID, OLDWORKSPACE->m_iMonitorID, workspaceName);
|
2022-05-30 15:28:23 +02:00
|
|
|
}
|
|
|
|
|
2022-08-21 17:01:26 +02:00
|
|
|
PWINDOW->moveToWorkspace(PWORKSPACE->m_iID);
|
2022-04-21 16:38:48 +02:00
|
|
|
PWINDOW->m_iMonitorID = PWORKSPACE->m_iMonitorID;
|
2022-03-23 16:51:48 +01:00
|
|
|
|
2022-09-20 11:16:58 +02:00
|
|
|
if (PWORKSPACE->m_bHasFullscreenWindow) {
|
|
|
|
g_pCompositor->setWindowFullscreen(g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID), false, FULLSCREEN_FULL);
|
2022-07-18 20:53:29 +02:00
|
|
|
}
|
|
|
|
|
2022-03-23 16:51:48 +01:00
|
|
|
// Hack: So that the layout doesnt find our window at the cursor
|
|
|
|
PWINDOW->m_vPosition = Vector2D(-42069, -42069);
|
2022-09-25 20:07:48 +02:00
|
|
|
|
2022-03-23 16:51:48 +01:00
|
|
|
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
|
|
|
|
|
2022-07-18 20:53:29 +02:00
|
|
|
// and restore it
|
2022-03-23 16:51:48 +01:00
|
|
|
if (PWINDOW->m_bIsFloating) {
|
2022-10-24 13:03:15 +02:00
|
|
|
PWINDOW->m_vRealSize.setValueAndWarp(PSAVEDSIZE);
|
2022-12-16 18:17:31 +01:00
|
|
|
PWINDOW->m_vRealPosition.setValueAndWarp(PSAVEDPOS - g_pCompositor->getMonitorFromID(OLDWORKSPACE->m_iMonitorID)->vecPosition +
|
|
|
|
g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID)->vecPosition);
|
2022-04-23 14:16:02 +02:00
|
|
|
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
|
2022-03-23 16:51:48 +01:00
|
|
|
}
|
2022-05-31 14:01:00 +02:00
|
|
|
|
2022-12-07 19:55:56 +01:00
|
|
|
if (WASFULLSCREEN)
|
2022-11-20 19:50:22 +01:00
|
|
|
g_pCompositor->setWindowFullscreen(PWINDOW, true, OLDWORKSPACE->m_efFullscreenMode);
|
|
|
|
|
2022-12-06 21:20:37 +01:00
|
|
|
if (!g_pCompositor->isWorkspaceSpecial(WORKSPACEID)) {
|
|
|
|
g_pKeybindManager->changeworkspace(args);
|
2022-09-19 17:01:42 +02:00
|
|
|
g_pCompositor->focusWindow(PWINDOW);
|
2022-12-06 21:31:44 +01:00
|
|
|
} else {
|
|
|
|
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID));
|
2022-12-19 15:49:19 +01:00
|
|
|
g_pInputManager->refocus();
|
2022-05-31 14:01:00 +02:00
|
|
|
}
|
2022-06-08 15:52:38 +02:00
|
|
|
|
2022-08-06 20:57:38 +02:00
|
|
|
PWINDOW->updateToplevel();
|
2023-01-13 12:31:24 +01:00
|
|
|
|
|
|
|
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID));
|
2022-03-27 19:32:50 +02:00
|
|
|
}
|
2022-04-09 13:26:55 +02:00
|
|
|
|
2022-05-18 12:18:58 +02:00
|
|
|
void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
|
|
|
// hacky, but works lol
|
2022-12-10 16:15:40 +01:00
|
|
|
// TODO: this sucks
|
2022-05-18 12:18:58 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
CWindow* PWINDOW = nullptr;
|
2022-08-15 16:12:53 +02:00
|
|
|
|
|
|
|
const auto ORIGINALARGS = args;
|
|
|
|
|
|
|
|
if (args.contains(',')) {
|
|
|
|
PWINDOW = g_pCompositor->getWindowByRegex(args.substr(args.find_last_of(',') + 1));
|
2022-12-16 18:17:31 +01:00
|
|
|
args = args.substr(0, args.find_last_of(','));
|
2022-08-15 16:12:53 +02:00
|
|
|
} else {
|
|
|
|
PWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
}
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!PWINDOW)
|
2022-08-15 16:12:53 +02:00
|
|
|
return;
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
int workspaceToMoveTo = 0;
|
|
|
|
std::string workspaceName = "";
|
2022-05-18 12:18:58 +02:00
|
|
|
|
|
|
|
workspaceToMoveTo = getWorkspaceIDFromString(args, workspaceName);
|
|
|
|
|
|
|
|
if (workspaceToMoveTo == INT_MAX) {
|
|
|
|
Debug::log(ERR, "Error in moveActiveToWorkspaceSilent, invalid value");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
|
|
|
|
2022-08-15 16:12:53 +02:00
|
|
|
if (workspaceToMoveTo == PWINDOW->m_iWorkspaceID)
|
2022-05-18 12:18:58 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
// may be null until later!
|
|
|
|
auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToMoveTo);
|
|
|
|
|
2022-09-12 21:05:52 +02:00
|
|
|
auto PMONITORNEW = PWORKSPACE ? g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID) : PMONITOR;
|
|
|
|
if (!PWORKSPACE) {
|
|
|
|
const auto BOUNDMON = g_pConfigManager->getBoundMonitorForWS(workspaceName);
|
|
|
|
if (BOUNDMON)
|
|
|
|
PMONITORNEW = BOUNDMON;
|
|
|
|
}
|
2022-05-18 12:18:58 +02:00
|
|
|
|
|
|
|
const auto OLDWORKSPACEIDONMONITOR = PMONITORNEW->activeWorkspace;
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto OLDWORKSPACEIDRETURN = PMONITOR->activeWorkspace;
|
2022-05-18 12:18:58 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto POLDWORKSPACEONMON = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDONMONITOR);
|
2022-05-18 12:18:58 +02:00
|
|
|
const auto POLDWORKSPACEIDRETURN = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDRETURN);
|
|
|
|
|
2022-06-21 22:17:30 +02:00
|
|
|
g_pEventManager->m_bIgnoreEvents = true;
|
2022-05-24 19:42:43 +02:00
|
|
|
|
2022-08-15 16:12:53 +02:00
|
|
|
moveActiveToWorkspace(ORIGINALARGS);
|
2022-05-18 12:18:58 +02:00
|
|
|
|
|
|
|
PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToMoveTo);
|
|
|
|
|
2022-07-06 11:02:21 +02:00
|
|
|
changeworkspace("[internal]" + std::to_string(OLDWORKSPACEIDONMONITOR));
|
|
|
|
changeworkspace("[internal]" + std::to_string(OLDWORKSPACEIDRETURN));
|
2022-05-18 12:18:58 +02:00
|
|
|
|
|
|
|
// revert animations
|
2022-12-16 18:17:31 +01:00
|
|
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
2022-05-18 12:18:58 +02:00
|
|
|
PWORKSPACE->m_fAlpha.setValueAndWarp(0.f);
|
|
|
|
|
|
|
|
POLDWORKSPACEIDRETURN->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
2023-01-05 19:25:45 +01:00
|
|
|
POLDWORKSPACEIDRETURN->m_fAlpha.setValueAndWarp(1.f);
|
2022-05-18 12:18:58 +02:00
|
|
|
|
|
|
|
POLDWORKSPACEONMON->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
2023-01-05 19:25:45 +01:00
|
|
|
POLDWORKSPACEONMON->m_fAlpha.setValueAndWarp(1.f);
|
2022-05-24 19:42:43 +02:00
|
|
|
|
2022-06-21 22:17:30 +02:00
|
|
|
g_pEventManager->m_bIgnoreEvents = false;
|
2022-06-08 15:52:38 +02:00
|
|
|
|
2022-09-29 20:33:43 +02:00
|
|
|
// manually post event cuz it got ignored above
|
|
|
|
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", PWINDOW, PWORKSPACE->m_szName.c_str())});
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
PWINDOW->m_iWorkspaceID = OLDWORKSPACEIDRETURN;
|
2022-12-10 16:15:40 +01:00
|
|
|
const auto PNEXTCANDIDATE = g_pLayoutManager->getCurrentLayout()->getNextWindowCandidate(PWINDOW);
|
2022-12-16 18:17:31 +01:00
|
|
|
PWINDOW->m_iWorkspaceID = workspaceToMoveTo;
|
2022-12-09 15:03:37 +01:00
|
|
|
|
2022-12-10 16:15:40 +01:00
|
|
|
g_pCompositor->focusWindow(PNEXTCANDIDATE);
|
2022-05-18 12:18:58 +02:00
|
|
|
}
|
|
|
|
|
2022-04-09 13:26:55 +02:00
|
|
|
void CKeybindManager::moveFocusTo(std::string args) {
|
|
|
|
char arg = args[0];
|
|
|
|
|
2022-05-05 12:50:25 +02:00
|
|
|
if (!isDirection(args)) {
|
2022-04-20 16:18:58 +02:00
|
|
|
Debug::log(ERR, "Cannot move focus in direction %c, unsupported direction. Supported: l,r,u/t,d/b", arg);
|
2022-04-09 13:26:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
|
2022-08-08 22:46:11 +02:00
|
|
|
if (!PLASTWINDOW)
|
|
|
|
return;
|
|
|
|
|
2022-05-18 14:57:08 +02:00
|
|
|
// remove constraints
|
2022-08-09 20:36:21 +02:00
|
|
|
g_pInputManager->unconstrainMouse();
|
2022-05-18 14:57:08 +02:00
|
|
|
|
2022-04-13 20:45:06 +02:00
|
|
|
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
|
2022-08-03 15:33:55 +02:00
|
|
|
if (PLASTWINDOW->m_iWorkspaceID == PWINDOWTOCHANGETO->m_iWorkspaceID && PLASTWINDOW->m_bIsFullscreen) {
|
|
|
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PLASTWINDOW->m_iWorkspaceID);
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto FSMODE = PWORKSPACE->m_efFullscreenMode;
|
2022-09-21 15:16:13 +02:00
|
|
|
|
|
|
|
if (!PWINDOWTOCHANGETO->m_bPinned)
|
|
|
|
g_pCompositor->setWindowFullscreen(PLASTWINDOW, false, FULLSCREEN_FULL);
|
2022-08-03 15:33:55 +02:00
|
|
|
|
|
|
|
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
|
|
|
|
2022-09-21 15:16:13 +02:00
|
|
|
if (!PWINDOWTOCHANGETO->m_bPinned)
|
|
|
|
g_pCompositor->setWindowFullscreen(PWINDOWTOCHANGETO, true, FSMODE);
|
2022-08-03 15:33:55 +02:00
|
|
|
} else {
|
|
|
|
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
|
|
|
Vector2D middle = PWINDOWTOCHANGETO->m_vRealPosition.goalv() + PWINDOWTOCHANGETO->m_vRealSize.goalv() / 2.f;
|
|
|
|
g_pCompositor->warpCursorTo(middle);
|
2022-10-01 11:38:43 +02:00
|
|
|
|
2022-10-04 07:19:14 +02:00
|
|
|
if (PLASTWINDOW->m_iMonitorID != PWINDOWTOCHANGETO->m_iMonitorID) {
|
2022-10-01 11:38:43 +02:00
|
|
|
// event
|
|
|
|
const auto PNEWMON = g_pCompositor->getMonitorFromID(PWINDOWTOCHANGETO->m_iMonitorID);
|
|
|
|
|
2022-11-19 17:41:36 +01:00
|
|
|
g_pCompositor->setActiveMonitor(PNEWMON);
|
2022-10-01 11:38:43 +02:00
|
|
|
}
|
2022-08-03 15:33:55 +02:00
|
|
|
}
|
2022-04-13 20:45:06 +02:00
|
|
|
};
|
|
|
|
|
2022-04-09 13:26:55 +02:00
|
|
|
const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
|
|
|
|
|
2022-04-09 13:33:44 +02:00
|
|
|
if (PWINDOWTOCHANGETO) {
|
2022-04-13 20:45:06 +02:00
|
|
|
switchToWindow(PWINDOWTOCHANGETO);
|
|
|
|
} else {
|
2022-09-29 17:53:31 +02:00
|
|
|
const auto PWINDOWNEXT = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true);
|
2022-04-13 20:45:06 +02:00
|
|
|
if (PWINDOWNEXT) {
|
|
|
|
switchToWindow(PWINDOWNEXT);
|
|
|
|
}
|
|
|
|
}
|
2022-04-12 16:44:18 +02:00
|
|
|
}
|
|
|
|
|
2022-04-20 16:18:58 +02:00
|
|
|
void CKeybindManager::moveActiveTo(std::string args) {
|
2022-12-16 18:17:31 +01:00
|
|
|
char arg = args[0];
|
2022-04-20 16:18:58 +02:00
|
|
|
|
2022-05-05 13:02:55 +02:00
|
|
|
const auto LASTMONITOR = g_pCompositor->m_pLastMonitor;
|
|
|
|
|
|
|
|
if (args.find("mon:") == 0) {
|
|
|
|
// hack: save the active window
|
|
|
|
const auto PACTIVE = g_pCompositor->m_pLastWindow;
|
|
|
|
|
|
|
|
// monitor
|
|
|
|
focusMonitor(args.substr(4));
|
|
|
|
|
|
|
|
if (LASTMONITOR == g_pCompositor->m_pLastMonitor) {
|
|
|
|
Debug::log(ERR, "moveActiveTo: moving to an invalid mon");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// restore the active
|
|
|
|
g_pCompositor->focusWindow(PACTIVE);
|
|
|
|
|
|
|
|
moveActiveToWorkspace(std::to_string(g_pCompositor->m_pLastMonitor->activeWorkspace));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-05 12:50:25 +02:00
|
|
|
if (!isDirection(args)) {
|
2022-04-20 16:18:58 +02:00
|
|
|
Debug::log(ERR, "Cannot move window in direction %c, unsupported direction. Supported: l,r,u/t,d/b", arg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!PLASTWINDOW || PLASTWINDOW->m_bIsFullscreen)
|
2022-04-20 16:18:58 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!PWINDOWTOCHANGETO)
|
2022-04-20 16:18:58 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, PWINDOWTOCHANGETO);
|
|
|
|
}
|
|
|
|
|
2022-04-12 16:44:18 +02:00
|
|
|
void CKeybindManager::toggleGroup(std::string args) {
|
2022-05-16 17:37:46 +02:00
|
|
|
SLayoutMessageHeader header;
|
|
|
|
header.pWindow = g_pCompositor->m_pLastWindow;
|
|
|
|
g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "togglegroup");
|
2022-04-12 16:44:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::changeGroupActive(std::string args) {
|
2022-05-16 17:37:46 +02:00
|
|
|
SLayoutMessageHeader header;
|
|
|
|
header.pWindow = g_pCompositor->m_pLastWindow;
|
2022-05-28 19:16:20 +02:00
|
|
|
if (args == "b")
|
|
|
|
g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "changegroupactiveb");
|
|
|
|
else
|
|
|
|
g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "changegroupactivef");
|
2022-05-16 17:37:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::toggleSplit(std::string args) {
|
|
|
|
SLayoutMessageHeader header;
|
|
|
|
header.pWindow = g_pCompositor->m_pLastWindow;
|
|
|
|
g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "togglesplit");
|
2022-04-20 16:53:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::alterSplitRatio(std::string args) {
|
|
|
|
float splitratio = 0;
|
2022-12-19 15:49:19 +01:00
|
|
|
bool exact = false;
|
2022-04-20 16:53:41 +02:00
|
|
|
|
|
|
|
if (args == "+" || args == "-") {
|
|
|
|
Debug::log(LOG, "alterSplitRatio: using LEGACY +/-, consider switching to the Hyprland syntax.");
|
|
|
|
splitratio = (args == "+" ? 0.05f : -0.05f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (splitratio == 0) {
|
2022-12-17 23:37:44 +01:00
|
|
|
if (args.find("exact") == 0) {
|
2022-12-19 15:49:19 +01:00
|
|
|
exact = true;
|
2022-12-17 23:37:44 +01:00
|
|
|
splitratio = getPlusMinusKeywordResult(args.substr(5), 0);
|
|
|
|
} else {
|
|
|
|
splitratio = getPlusMinusKeywordResult(args, 0);
|
|
|
|
}
|
2022-04-20 16:53:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (splitratio == INT_MAX) {
|
|
|
|
Debug::log(ERR, "Splitratio invalid in alterSplitRatio!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!PLASTWINDOW)
|
2022-04-20 16:53:41 +02:00
|
|
|
return;
|
|
|
|
|
2022-12-17 23:37:44 +01:00
|
|
|
g_pLayoutManager->getCurrentLayout()->alterSplitRatio(PLASTWINDOW, splitratio, exact);
|
2022-05-05 12:50:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::focusMonitor(std::string arg) {
|
2022-08-25 21:25:28 +02:00
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromString(arg);
|
2022-05-05 12:50:25 +02:00
|
|
|
|
2022-11-03 20:34:26 +01:00
|
|
|
if (!PMONITOR || PMONITOR == g_pCompositor->m_pLastMonitor)
|
2022-08-25 21:25:28 +02:00
|
|
|
return;
|
2022-05-05 12:50:25 +02:00
|
|
|
|
2022-08-25 21:25:28 +02:00
|
|
|
changeworkspace("[internal]" + std::to_string(PMONITOR->activeWorkspace));
|
2022-05-18 12:18:58 +02:00
|
|
|
}
|
2022-05-22 11:52:39 +02:00
|
|
|
|
|
|
|
void CKeybindManager::moveCursorToCorner(std::string arg) {
|
|
|
|
if (!isNumber(arg)) {
|
|
|
|
Debug::log(ERR, "moveCursorToCorner, arg has to be a number.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto CORNER = std::stoi(arg);
|
|
|
|
|
|
|
|
if (CORNER < 0 || CORNER > 3) {
|
|
|
|
Debug::log(ERR, "moveCursorToCorner, corner not 0 - 3.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto PWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!PWINDOW)
|
2022-05-22 11:52:39 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch (CORNER) {
|
|
|
|
case 0:
|
|
|
|
// bottom left
|
2022-12-16 18:17:31 +01:00
|
|
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x,
|
|
|
|
PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
|
2022-05-22 11:52:39 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
// bottom right
|
2022-12-16 18:17:31 +01:00
|
|
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x,
|
|
|
|
PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
|
2022-05-22 11:52:39 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// top right
|
2022-12-16 18:17:31 +01:00
|
|
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x,
|
|
|
|
PWINDOW->m_vRealPosition.vec().y);
|
2022-05-22 11:52:39 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
// top left
|
|
|
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y);
|
|
|
|
break;
|
|
|
|
}
|
2022-05-26 19:05:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::workspaceOpt(std::string args) {
|
2022-09-25 20:07:48 +02:00
|
|
|
|
2022-05-26 19:05:32 +02:00
|
|
|
// current workspace
|
|
|
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
|
|
|
|
|
|
|
if (!PWORKSPACE)
|
|
|
|
return; // ????
|
|
|
|
|
|
|
|
if (args == "allpseudo") {
|
|
|
|
PWORKSPACE->m_bDefaultPseudo = !PWORKSPACE->m_bDefaultPseudo;
|
|
|
|
|
|
|
|
// apply
|
2022-06-30 15:44:26 +02:00
|
|
|
for (auto& w : g_pCompositor->m_vWindows) {
|
|
|
|
if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID)
|
2022-05-26 19:05:32 +02:00
|
|
|
continue;
|
|
|
|
|
2022-06-30 15:44:26 +02:00
|
|
|
w->m_bIsPseudotiled = PWORKSPACE->m_bDefaultPseudo;
|
2022-05-26 19:05:32 +02:00
|
|
|
}
|
|
|
|
} else if (args == "allfloat") {
|
|
|
|
PWORKSPACE->m_bDefaultFloating = !PWORKSPACE->m_bDefaultFloating;
|
|
|
|
// apply
|
|
|
|
|
|
|
|
// we make a copy because changeWindowFloatingMode might invalidate the iterator
|
|
|
|
std::deque<CWindow*> ptrs;
|
2022-06-30 15:44:26 +02:00
|
|
|
for (auto& w : g_pCompositor->m_vWindows)
|
|
|
|
ptrs.push_back(w.get());
|
2022-05-26 19:05:32 +02:00
|
|
|
|
|
|
|
for (auto& w : ptrs) {
|
|
|
|
if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!w->m_bRequestsFloat && w->m_bIsFloating != PWORKSPACE->m_bDefaultFloating) {
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto SAVEDPOS = w->m_vRealPosition.vec();
|
2022-05-26 19:05:32 +02:00
|
|
|
const auto SAVEDSIZE = w->m_vRealSize.vec();
|
|
|
|
|
|
|
|
w->m_bIsFloating = PWORKSPACE->m_bDefaultFloating;
|
|
|
|
g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(w);
|
|
|
|
|
|
|
|
if (PWORKSPACE->m_bDefaultFloating) {
|
|
|
|
w->m_vRealPosition.setValueAndWarp(SAVEDPOS);
|
|
|
|
w->m_vRealSize.setValueAndWarp(SAVEDSIZE);
|
|
|
|
g_pXWaylandManager->setWindowSize(w, SAVEDSIZE);
|
2022-12-16 18:17:31 +01:00
|
|
|
w->m_vRealSize = w->m_vRealSize.vec() + Vector2D(4, 4);
|
|
|
|
w->m_vRealPosition = w->m_vRealPosition.vec() - Vector2D(2, 2);
|
2022-05-26 19:05:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Debug::log(ERR, "Invalid arg in workspaceOpt, opt \"%s\" doesn't exist.", args.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// recalc mon
|
|
|
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID);
|
2022-05-29 00:00:47 +02:00
|
|
|
}
|
|
|
|
|
2023-01-08 14:19:18 +01:00
|
|
|
void CKeybindManager::renameWorkspace(std::string args) {
|
|
|
|
try {
|
|
|
|
const auto FIRSTSPACEPOS = args.find_first_of(' ');
|
|
|
|
if (FIRSTSPACEPOS != std::string::npos) {
|
|
|
|
int workspace = std::stoi(args.substr(0, FIRSTSPACEPOS));
|
|
|
|
std::string name = args.substr(FIRSTSPACEPOS + 1);
|
|
|
|
g_pCompositor->renameWorkspace(workspace, name);
|
|
|
|
} else {
|
|
|
|
g_pCompositor->renameWorkspace(std::stoi(args), "");
|
|
|
|
}
|
|
|
|
} catch (std::exception& e) {
|
|
|
|
Debug::log(ERR, "Invalid arg in renameWorkspace, expected numeric id only or a numeric id and string name. \"%s\": \"%s\"", args.c_str(), e.what());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-29 00:00:47 +02:00
|
|
|
void CKeybindManager::exitHyprland(std::string argz) {
|
2022-07-13 18:18:23 +02:00
|
|
|
g_pCompositor->cleanup();
|
2022-05-30 20:05:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) {
|
2022-09-02 11:53:12 +02:00
|
|
|
CMonitor* PMONITOR = g_pCompositor->getMonitorFromString(args);
|
2022-05-30 20:05:38 +02:00
|
|
|
|
2022-07-29 16:59:31 +02:00
|
|
|
if (!PMONITOR)
|
|
|
|
return;
|
|
|
|
|
2022-05-30 20:05:38 +02:00
|
|
|
// get the current workspace
|
|
|
|
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
|
|
|
|
|
|
|
if (!PCURRENTWORKSPACE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_pCompositor->moveWorkspaceToMonitor(PCURRENTWORKSPACE, PMONITOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::moveWorkspaceToMonitor(std::string args) {
|
2022-07-06 16:50:11 +02:00
|
|
|
if (!args.contains(' '))
|
2022-06-06 19:32:14 +02:00
|
|
|
return;
|
2022-05-30 20:05:38 +02:00
|
|
|
|
|
|
|
std::string workspace = args.substr(0, args.find_first_of(' '));
|
2022-12-16 18:17:31 +01:00
|
|
|
std::string monitor = args.substr(args.find_first_of(' ') + 1);
|
2022-05-30 20:05:38 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromString(monitor);
|
2022-05-30 20:05:38 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
if (!PMONITOR) {
|
2022-05-30 20:05:38 +02:00
|
|
|
Debug::log(ERR, "Ignoring moveWorkspaceToMonitor: monitor doesnt exist");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string workspaceName;
|
2022-12-16 18:17:31 +01:00
|
|
|
const int WORKSPACEID = getWorkspaceIDFromString(workspace, workspaceName);
|
2022-05-30 20:05:38 +02:00
|
|
|
|
|
|
|
if (WORKSPACEID == INT_MAX) {
|
|
|
|
Debug::log(ERR, "moveWorkspaceToMonitor invalid workspace!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID);
|
|
|
|
|
2022-05-31 18:47:32 +02:00
|
|
|
if (!PWORKSPACE) {
|
|
|
|
Debug::log(ERR, "moveWorkspaceToMonitor workspace doesn't exist!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-30 20:05:38 +02:00
|
|
|
g_pCompositor->moveWorkspaceToMonitor(PWORKSPACE, PMONITOR);
|
2022-05-31 14:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
2022-12-06 21:31:44 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
std::string workspaceName = "";
|
|
|
|
int workspaceID = getWorkspaceIDFromString("special:" + args, workspaceName);
|
2022-11-27 23:42:22 +01:00
|
|
|
|
|
|
|
if (workspaceID == INT_MAX || !g_pCompositor->isWorkspaceSpecial(workspaceID)) {
|
|
|
|
Debug::log(ERR, "Invalid workspace passed to special");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_pCompositor->getWindowsOnWorkspace(workspaceID) == 0) {
|
2022-05-31 14:01:00 +02:00
|
|
|
Debug::log(LOG, "Can't open empty special workspace!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
bool requestedWorkspaceIsAlreadyOpen = false;
|
|
|
|
const auto PMONITOR = *PFOLLOWMOUSE == 1 ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->m_pLastMonitor;
|
|
|
|
int specialOpenOnMonitor = PMONITOR->specialWorkspaceID;
|
2022-05-31 14:01:00 +02:00
|
|
|
|
2022-06-30 15:44:26 +02:00
|
|
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
2022-11-27 23:42:22 +01:00
|
|
|
if (m->specialWorkspaceID == workspaceID) {
|
|
|
|
requestedWorkspaceIsAlreadyOpen = true;
|
2022-05-31 14:01:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-27 23:42:22 +01:00
|
|
|
if (requestedWorkspaceIsAlreadyOpen && specialOpenOnMonitor == workspaceID)
|
|
|
|
Debug::log(LOG, "Toggling special workspace %d to closed");
|
2022-05-31 14:01:00 +02:00
|
|
|
else
|
2022-11-27 23:42:22 +01:00
|
|
|
Debug::log(LOG, "Toggling special workspace %d to open");
|
2022-05-31 14:01:00 +02:00
|
|
|
|
2022-11-27 23:42:22 +01:00
|
|
|
if (requestedWorkspaceIsAlreadyOpen && specialOpenOnMonitor == workspaceID) {
|
|
|
|
// already open on this monitor
|
2022-05-31 14:01:00 +02:00
|
|
|
|
2022-12-06 21:31:44 +01:00
|
|
|
PMONITOR->specialWorkspaceID = 0;
|
|
|
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
|
2022-11-27 23:42:22 +01:00
|
|
|
|
|
|
|
g_pCompositor->getWorkspaceByID(workspaceID)->startAnim(false, false);
|
2022-08-31 17:02:44 +02:00
|
|
|
|
2022-12-06 21:31:44 +01:00
|
|
|
if (const auto PWINDOW = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace)->getLastFocusedWindow(); PWINDOW)
|
2022-08-31 17:02:44 +02:00
|
|
|
g_pCompositor->focusWindow(PWINDOW);
|
|
|
|
else
|
|
|
|
g_pInputManager->refocus();
|
2022-11-27 23:42:22 +01:00
|
|
|
} else if (requestedWorkspaceIsAlreadyOpen) {
|
|
|
|
// already open on another monitor
|
|
|
|
|
|
|
|
if (specialOpenOnMonitor) {
|
2022-12-06 21:31:44 +01:00
|
|
|
g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID)->startAnim(false, false);
|
|
|
|
PMONITOR->specialWorkspaceID = 0;
|
|
|
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
|
2022-11-27 23:42:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// move to current
|
|
|
|
const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto POLDMON = g_pCompositor->getMonitorFromID(PSPECIALWORKSPACE->m_iMonitorID);
|
2022-11-27 23:42:22 +01:00
|
|
|
|
|
|
|
POLDMON->specialWorkspaceID = 0;
|
|
|
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
|
2022-12-06 21:31:44 +01:00
|
|
|
PMONITOR->specialWorkspaceID = workspaceID;
|
|
|
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
|
|
|
|
PSPECIALWORKSPACE->m_iMonitorID = PMONITOR->ID;
|
2022-11-27 23:42:22 +01:00
|
|
|
|
|
|
|
if (const auto PWINDOW = PSPECIALWORKSPACE->getLastFocusedWindow(); PWINDOW)
|
|
|
|
g_pCompositor->focusWindow(PWINDOW);
|
|
|
|
else
|
|
|
|
g_pInputManager->refocus();
|
2022-05-31 14:01:00 +02:00
|
|
|
} else {
|
2022-11-27 23:42:22 +01:00
|
|
|
// not open anywhere
|
|
|
|
|
|
|
|
if (specialOpenOnMonitor) {
|
2022-12-06 21:31:44 +01:00
|
|
|
g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID)->startAnim(false, false);
|
|
|
|
PMONITOR->specialWorkspaceID = 0;
|
|
|
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
|
2022-11-27 23:42:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
|
2022-07-07 19:01:42 +02:00
|
|
|
|
|
|
|
if (!PSPECIALWORKSPACE) {
|
|
|
|
// ??? happens sometimes...?
|
2022-12-06 21:31:44 +01:00
|
|
|
PSPECIALWORKSPACE = g_pCompositor->createNewWorkspace(workspaceID, PMONITOR->ID, workspaceName);
|
2022-07-07 19:01:42 +02:00
|
|
|
}
|
|
|
|
|
2022-12-06 21:31:44 +01:00
|
|
|
PMONITOR->specialWorkspaceID = workspaceID;
|
|
|
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
|
2022-05-31 14:01:00 +02:00
|
|
|
|
2022-12-06 21:31:44 +01:00
|
|
|
PSPECIALWORKSPACE->m_iMonitorID = PMONITOR->ID;
|
2022-06-27 19:46:04 +02:00
|
|
|
PSPECIALWORKSPACE->startAnim(true, true);
|
2022-05-31 14:01:00 +02:00
|
|
|
|
2022-09-01 11:47:48 +02:00
|
|
|
if (const auto PWINDOW = PSPECIALWORKSPACE->getLastFocusedWindow(); PWINDOW)
|
2022-08-31 17:02:44 +02:00
|
|
|
g_pCompositor->focusWindow(PWINDOW);
|
|
|
|
else
|
|
|
|
g_pInputManager->refocus();
|
|
|
|
}
|
2022-06-06 13:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::forceRendererReload(std::string args) {
|
2022-06-30 23:55:28 +02:00
|
|
|
bool overAgain = false;
|
|
|
|
|
2022-06-30 15:44:26 +02:00
|
|
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
2022-10-05 11:22:33 +02:00
|
|
|
auto rule = g_pConfigManager->getMonitorRuleFor(m->szName, m->output->description ? m->output->description : "");
|
2022-06-30 23:55:28 +02:00
|
|
|
if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule, true)) {
|
|
|
|
overAgain = true;
|
|
|
|
break;
|
|
|
|
}
|
2022-06-06 13:48:17 +02:00
|
|
|
}
|
2022-06-30 23:55:28 +02:00
|
|
|
|
|
|
|
if (overAgain)
|
|
|
|
forceRendererReload(args);
|
2022-06-06 19:32:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::resizeActive(std::string args) {
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!g_pCompositor->m_pLastWindow || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
|
2022-08-15 15:59:07 +02:00
|
|
|
return;
|
2022-08-09 10:57:09 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealSize.goalv());
|
2022-06-06 19:32:14 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - g_pCompositor->m_pLastWindow->m_vRealSize.goalv());
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
if (g_pCompositor->m_pLastWindow->m_vRealSize.goalv().x > 1 && g_pCompositor->m_pLastWindow->m_vRealSize.goalv().y > 1)
|
2022-10-14 21:46:32 +02:00
|
|
|
g_pCompositor->m_pLastWindow->setHidden(false);
|
2022-08-15 15:59:07 +02:00
|
|
|
}
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
void CKeybindManager::moveActive(std::string args) {
|
2022-12-16 18:17:31 +01:00
|
|
|
if (!g_pCompositor->m_pLastWindow || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
|
|
|
|
return;
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
const auto POS = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealPosition.goalv());
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - g_pCompositor->m_pLastWindow->m_vRealPosition.goalv());
|
|
|
|
}
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
void CKeybindManager::moveWindow(std::string args) {
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto MOVECMD = args.substr(0, args.find_first_of(','));
|
2022-08-09 10:57:09 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
if (!PWINDOW) {
|
|
|
|
Debug::log(ERR, "moveWindow: no window");
|
2022-06-06 19:32:14 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-09-20 20:58:08 +02:00
|
|
|
if (PWINDOW->m_bIsFullscreen)
|
|
|
|
return;
|
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
const auto POS = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealPosition.goalv());
|
2022-06-06 19:32:14 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - PWINDOW->m_vRealPosition.goalv(), PWINDOW);
|
2022-06-10 11:39:06 +02:00
|
|
|
}
|
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
void CKeybindManager::resizeWindow(std::string args) {
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto MOVECMD = args.substr(0, args.find_first_of(','));
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
if (!PWINDOW) {
|
|
|
|
Debug::log(ERR, "resizeWindow: no window");
|
2022-06-23 10:14:59 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
if (PWINDOW->m_bIsFullscreen)
|
|
|
|
return;
|
2022-09-20 20:58:08 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealSize.goalv());
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - PWINDOW->m_vRealSize.goalv(), PWINDOW);
|
2022-06-23 10:14:59 +02:00
|
|
|
|
2022-08-15 15:59:07 +02:00
|
|
|
if (PWINDOW->m_vRealSize.goalv().x > 1 && PWINDOW->m_vRealSize.goalv().y > 1)
|
2022-10-14 21:46:32 +02:00
|
|
|
PWINDOW->setHidden(false);
|
2022-06-23 10:14:59 +02:00
|
|
|
}
|
|
|
|
|
2022-07-09 18:39:41 +02:00
|
|
|
void CKeybindManager::circleNext(std::string arg) {
|
2022-08-11 19:45:37 +02:00
|
|
|
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
|
2022-08-11 22:56:16 +02:00
|
|
|
if (PWINDOWTOCHANGETO == g_pCompositor->m_pLastWindow || !PWINDOWTOCHANGETO)
|
2022-08-11 20:21:55 +02:00
|
|
|
return;
|
|
|
|
|
2022-11-14 13:12:13 +01:00
|
|
|
if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_iWorkspaceID == PWINDOWTOCHANGETO->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsFullscreen) {
|
2022-08-11 19:45:37 +02:00
|
|
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastWindow->m_iWorkspaceID);
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto FSMODE = PWORKSPACE->m_efFullscreenMode;
|
2022-09-21 15:16:13 +02:00
|
|
|
|
|
|
|
if (!PWINDOWTOCHANGETO->m_bPinned)
|
|
|
|
g_pCompositor->setWindowFullscreen(g_pCompositor->m_pLastWindow, false, FULLSCREEN_FULL);
|
2022-06-10 11:39:06 +02:00
|
|
|
|
2022-08-11 19:45:37 +02:00
|
|
|
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
2022-06-10 11:39:06 +02:00
|
|
|
|
2022-09-21 15:16:13 +02:00
|
|
|
if (!PWINDOWTOCHANGETO->m_bPinned)
|
|
|
|
g_pCompositor->setWindowFullscreen(PWINDOWTOCHANGETO, true, FSMODE);
|
2022-08-11 19:45:37 +02:00
|
|
|
} else {
|
|
|
|
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
|
|
|
Vector2D middle = PWINDOWTOCHANGETO->m_vRealPosition.goalv() + PWINDOWTOCHANGETO->m_vRealSize.goalv() / 2.f;
|
|
|
|
g_pCompositor->warpCursorTo(middle);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-10-28 22:31:39 +02:00
|
|
|
if (!g_pCompositor->m_pLastWindow) {
|
|
|
|
// if we have a clear focus, find the first window and get the next focusable.
|
|
|
|
if (g_pCompositor->getWindowsOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace) > 0) {
|
|
|
|
const auto PWINDOW = g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace), true);
|
|
|
|
|
|
|
|
switchToWindow(PWINDOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-11 19:45:37 +02:00
|
|
|
if (arg == "last" || arg == "l" || arg == "prev" || arg == "p")
|
2022-09-29 17:53:31 +02:00
|
|
|
switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow, true));
|
2022-08-11 19:45:37 +02:00
|
|
|
else
|
2022-09-29 17:53:31 +02:00
|
|
|
switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow, true));
|
2022-06-10 11:39:06 +02:00
|
|
|
}
|
2022-06-10 12:06:27 +02:00
|
|
|
|
2022-07-01 16:24:37 +02:00
|
|
|
void CKeybindManager::focusWindow(std::string regexp) {
|
2022-07-26 17:30:30 +02:00
|
|
|
const auto PWINDOW = g_pCompositor->getWindowByRegex(regexp);
|
2022-07-18 01:00:12 +02:00
|
|
|
|
2022-07-26 17:30:30 +02:00
|
|
|
if (!PWINDOW)
|
|
|
|
return;
|
2022-06-10 12:06:27 +02:00
|
|
|
|
2022-07-26 17:30:30 +02:00
|
|
|
Debug::log(LOG, "Focusing to window name: %s", PWINDOW->m_szTitle.c_str());
|
2022-06-10 12:06:27 +02:00
|
|
|
|
2022-07-26 17:30:30 +02:00
|
|
|
g_pCompositor->focusWindow(PWINDOW);
|
2022-06-10 12:06:27 +02:00
|
|
|
|
2022-07-26 17:30:30 +02:00
|
|
|
const auto MIDPOINT = PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f;
|
2022-06-10 12:06:27 +02:00
|
|
|
|
2022-08-01 18:50:16 +02:00
|
|
|
g_pCompositor->warpCursorTo(MIDPOINT);
|
2022-06-10 12:06:27 +02:00
|
|
|
}
|
2022-06-22 20:23:20 +02:00
|
|
|
|
|
|
|
void CKeybindManager::setSubmap(std::string submap) {
|
|
|
|
if (submap == "reset" || submap == "") {
|
|
|
|
m_szCurrentSelectedSubmap = "";
|
|
|
|
Debug::log(LOG, "Reset active submap to the default one.");
|
2022-09-05 13:50:52 +02:00
|
|
|
g_pEventManager->postEvent(SHyprIPCEvent{"submap", ""});
|
2022-06-22 20:23:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto& k : g_pKeybindManager->m_lKeybinds) {
|
|
|
|
if (k.submap == submap) {
|
|
|
|
m_szCurrentSelectedSubmap = submap;
|
|
|
|
Debug::log(LOG, "Changed keybind submap to %s", submap.c_str());
|
2022-09-05 13:50:52 +02:00
|
|
|
g_pEventManager->postEvent(SHyprIPCEvent{"submap", submap});
|
2022-06-22 20:23:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Debug::log(ERR, "Cannot set submap %s, submap doesn't exist (wasn't registered!)", submap.c_str());
|
|
|
|
}
|
2022-07-26 17:30:30 +02:00
|
|
|
|
|
|
|
void CKeybindManager::pass(std::string regexp) {
|
|
|
|
|
|
|
|
// find the first window passing the regex
|
|
|
|
const auto PWINDOW = g_pCompositor->getWindowByRegex(regexp);
|
|
|
|
|
|
|
|
if (!PWINDOW) {
|
|
|
|
Debug::log(ERR, "pass: window not found");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto PLASTSRF = g_pCompositor->m_pLastFocus;
|
|
|
|
|
|
|
|
const auto KEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
if (!KEYBOARD) {
|
2022-07-26 17:30:30 +02:00
|
|
|
Debug::log(ERR, "No kb in pass?");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-28 16:43:15 +02:00
|
|
|
const auto XWTOXW = PWINDOW->m_bIsX11 && g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsX11;
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto SL = Vector2D(g_pCompositor->m_sSeat.seat->pointer_state.sx, g_pCompositor->m_sSeat.seat->pointer_state.sy);
|
2022-08-28 16:43:15 +02:00
|
|
|
|
2022-07-26 17:30:30 +02:00
|
|
|
// pass all mf shit
|
2022-08-28 17:01:48 +02:00
|
|
|
if (!XWTOXW) {
|
|
|
|
if (g_pKeybindManager->m_uLastCode != 0)
|
|
|
|
wlr_seat_keyboard_enter(g_pCompositor->m_sSeat.seat, g_pXWaylandManager->getWindowSurface(PWINDOW), KEYBOARD->keycodes, KEYBOARD->num_keycodes, &KEYBOARD->modifiers);
|
|
|
|
else
|
|
|
|
wlr_seat_pointer_enter(g_pCompositor->m_sSeat.seat, g_pXWaylandManager->getWindowSurface(PWINDOW), 1, 1);
|
|
|
|
}
|
2022-09-25 20:07:48 +02:00
|
|
|
|
2022-08-08 20:31:48 +02:00
|
|
|
wlr_keyboard_modifiers kbmods = {g_pInputManager->accumulateModsFromAllKBs(), 0, 0, 0};
|
|
|
|
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &kbmods);
|
|
|
|
|
2022-08-28 16:43:15 +02:00
|
|
|
if (g_pKeybindManager->m_iPassPressed == 1) {
|
2022-08-28 17:01:48 +02:00
|
|
|
if (g_pKeybindManager->m_uLastCode != 0)
|
|
|
|
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_PRESSED);
|
|
|
|
else
|
|
|
|
wlr_seat_pointer_notify_button(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastMouseCode, WLR_BUTTON_PRESSED);
|
2022-08-28 16:43:15 +02:00
|
|
|
} else if (g_pKeybindManager->m_iPassPressed == 0)
|
2022-08-28 17:01:48 +02:00
|
|
|
if (g_pKeybindManager->m_uLastCode != 0)
|
|
|
|
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_RELEASED);
|
|
|
|
else
|
|
|
|
wlr_seat_pointer_notify_button(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastMouseCode, WLR_BUTTON_RELEASED);
|
2022-08-27 19:29:28 +02:00
|
|
|
else {
|
|
|
|
// dynamic call of the dispatcher
|
2022-08-28 17:01:48 +02:00
|
|
|
if (g_pKeybindManager->m_uLastCode != 0) {
|
|
|
|
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_PRESSED);
|
|
|
|
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_RELEASED);
|
|
|
|
} else {
|
|
|
|
wlr_seat_pointer_notify_button(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastMouseCode, WLR_BUTTON_PRESSED);
|
|
|
|
wlr_seat_pointer_notify_button(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastMouseCode, WLR_BUTTON_RELEASED);
|
2022-09-25 20:07:48 +02:00
|
|
|
}
|
2022-08-27 19:29:28 +02:00
|
|
|
}
|
2022-07-26 17:30:30 +02:00
|
|
|
|
2022-08-28 16:43:15 +02:00
|
|
|
if (XWTOXW)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Massive hack:
|
|
|
|
// this will make wlroots NOT send the leave event to XWayland apps, provided we are not on an XWayland window already.
|
|
|
|
// please kill me
|
|
|
|
if (PWINDOW->m_bIsX11) {
|
2022-08-28 17:01:48 +02:00
|
|
|
if (g_pKeybindManager->m_uLastCode != 0) {
|
2022-12-16 18:17:31 +01:00
|
|
|
g_pCompositor->m_sSeat.seat->keyboard_state.focused_client = nullptr;
|
2022-08-28 17:01:48 +02:00
|
|
|
g_pCompositor->m_sSeat.seat->keyboard_state.focused_surface = nullptr;
|
|
|
|
} else {
|
2022-12-16 18:17:31 +01:00
|
|
|
g_pCompositor->m_sSeat.seat->pointer_state.focused_client = nullptr;
|
2022-08-28 17:01:48 +02:00
|
|
|
g_pCompositor->m_sSeat.seat->pointer_state.focused_surface = nullptr;
|
|
|
|
}
|
2022-08-28 16:43:15 +02:00
|
|
|
}
|
|
|
|
|
2022-08-28 17:01:48 +02:00
|
|
|
if (g_pKeybindManager->m_uLastCode != 0)
|
|
|
|
wlr_seat_keyboard_enter(g_pCompositor->m_sSeat.seat, PLASTSRF, KEYBOARD->keycodes, KEYBOARD->num_keycodes, &KEYBOARD->modifiers);
|
|
|
|
else
|
|
|
|
wlr_seat_pointer_enter(g_pCompositor->m_sSeat.seat, g_pXWaylandManager->getWindowSurface(PWINDOW), SL.x, SL.y);
|
2022-07-28 12:00:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::layoutmsg(std::string msg) {
|
|
|
|
SLayoutMessageHeader hd = {g_pCompositor->m_pLastWindow};
|
|
|
|
g_pLayoutManager->getCurrentLayout()->layoutMessage(hd, msg);
|
2022-07-28 12:07:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::toggleOpaque(std::string unused) {
|
|
|
|
const auto PWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!PWINDOW)
|
2022-07-28 12:07:41 +02:00
|
|
|
return;
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
PWINDOW->m_sAdditionalConfigData.forceOpaque = !PWINDOW->m_sAdditionalConfigData.forceOpaque;
|
2022-11-23 10:55:46 +01:00
|
|
|
PWINDOW->m_sAdditionalConfigData.forceOpaqueOverriden = true;
|
2022-07-28 12:07:41 +02:00
|
|
|
|
|
|
|
g_pHyprRenderer->damageWindow(PWINDOW);
|
2022-07-30 23:51:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKeybindManager::dpms(std::string arg) {
|
2022-12-16 18:17:31 +01:00
|
|
|
bool enable = arg.find("on") == 0;
|
|
|
|
std::string port = "";
|
2022-10-05 11:31:47 +02:00
|
|
|
|
|
|
|
if (arg.find_first_of(' ') != std::string::npos) {
|
|
|
|
port = arg.substr(arg.find_first_of(' ') + 1);
|
|
|
|
}
|
2022-07-30 23:51:13 +02:00
|
|
|
|
|
|
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
2022-10-05 11:31:47 +02:00
|
|
|
|
|
|
|
if (!port.empty() && m->szName != port)
|
|
|
|
continue;
|
|
|
|
|
2022-07-30 23:51:13 +02:00
|
|
|
wlr_output_enable(m->output, enable);
|
2022-09-25 20:07:48 +02:00
|
|
|
|
2022-10-05 19:14:11 +02:00
|
|
|
m->dpmsStatus = enable;
|
|
|
|
|
2022-07-30 23:51:13 +02:00
|
|
|
if (!wlr_output_commit(m->output)) {
|
|
|
|
Debug::log(ERR, "Couldn't commit output %s", m->szName.c_str());
|
|
|
|
}
|
2022-07-31 12:39:49 +02:00
|
|
|
|
|
|
|
if (enable)
|
|
|
|
g_pHyprRenderer->damageMonitor(m.get());
|
2022-07-30 23:51:13 +02:00
|
|
|
}
|
2022-07-31 15:46:42 +02:00
|
|
|
|
|
|
|
g_pCompositor->m_bDPMSStateON = enable;
|
2022-07-30 23:51:13 +02:00
|
|
|
}
|
2022-08-24 21:40:36 +02:00
|
|
|
|
|
|
|
void CKeybindManager::swapnext(std::string arg) {
|
|
|
|
|
|
|
|
CWindow* toSwap = nullptr;
|
|
|
|
|
2022-10-14 21:46:32 +02:00
|
|
|
if (!g_pCompositor->m_pLastWindow)
|
2022-08-24 21:40:36 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
const auto PLASTCYCLED = g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow->m_pLastCycledWindow) &&
|
|
|
|
g_pCompositor->m_pLastWindow->m_pLastCycledWindow->m_iWorkspaceID == PLASTWINDOW->m_iWorkspaceID ?
|
|
|
|
g_pCompositor->m_pLastWindow->m_pLastCycledWindow :
|
|
|
|
nullptr;
|
2022-08-24 22:01:25 +02:00
|
|
|
|
2022-08-24 21:40:36 +02:00
|
|
|
if (arg == "last" || arg == "l" || arg == "prev" || arg == "p")
|
2022-09-29 17:53:31 +02:00
|
|
|
toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW, true);
|
2022-08-24 21:40:36 +02:00
|
|
|
else
|
2022-09-29 17:53:31 +02:00
|
|
|
toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW, true);
|
2022-08-24 22:01:25 +02:00
|
|
|
|
|
|
|
// sometimes we may come back to ourselves.
|
|
|
|
if (toSwap == PLASTWINDOW) {
|
|
|
|
if (arg == "last" || arg == "l" || arg == "prev" || arg == "p")
|
2022-09-29 17:53:31 +02:00
|
|
|
toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW), true;
|
2022-08-24 22:01:25 +02:00
|
|
|
else
|
2022-09-29 17:53:31 +02:00
|
|
|
toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true);
|
2022-08-24 22:01:25 +02:00
|
|
|
}
|
2022-08-24 21:40:36 +02:00
|
|
|
|
|
|
|
g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, toSwap);
|
|
|
|
|
2022-08-24 22:01:25 +02:00
|
|
|
PLASTWINDOW->m_pLastCycledWindow = toSwap;
|
|
|
|
|
2022-08-24 21:40:36 +02:00
|
|
|
g_pCompositor->focusWindow(PLASTWINDOW);
|
|
|
|
}
|
2022-08-25 21:25:28 +02:00
|
|
|
|
|
|
|
void CKeybindManager::swapActiveWorkspaces(std::string args) {
|
|
|
|
const auto MON1 = args.substr(0, args.find_first_of(' '));
|
|
|
|
const auto MON2 = args.substr(args.find_first_of(' ') + 1);
|
|
|
|
|
|
|
|
const auto PMON1 = g_pCompositor->getMonitorFromString(MON1);
|
|
|
|
const auto PMON2 = g_pCompositor->getMonitorFromString(MON2);
|
|
|
|
|
|
|
|
if (!PMON1 || !PMON2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_pCompositor->swapActiveWorkspaces(PMON1, PMON2);
|
|
|
|
}
|
2022-09-10 13:11:02 +02:00
|
|
|
|
|
|
|
void CKeybindManager::pinActive(std::string args) {
|
2023-01-08 18:37:24 +01:00
|
|
|
|
|
|
|
CWindow* PWINDOW = nullptr;
|
|
|
|
|
|
|
|
if (args != "" && args != "active" && args.length() > 1) {
|
|
|
|
PWINDOW = g_pCompositor->getWindowByRegex(args);
|
|
|
|
} else {
|
|
|
|
PWINDOW = g_pCompositor->m_pLastWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!PWINDOW) {
|
|
|
|
Debug::log(ERR, "pin: window not found");
|
2022-09-10 13:11:02 +02:00
|
|
|
return;
|
2023-01-08 18:37:24 +01:00
|
|
|
}
|
2022-09-10 13:11:02 +02:00
|
|
|
|
2023-01-08 18:37:24 +01:00
|
|
|
if (!PWINDOW->m_bIsFloating || PWINDOW->m_bIsFullscreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
PWINDOW->m_bPinned = !PWINDOW->m_bPinned;
|
|
|
|
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace;
|
2022-09-10 13:11:02 +02:00
|
|
|
|
2023-01-08 18:37:24 +01:00
|
|
|
PWINDOW->updateDynamicRules();
|
|
|
|
g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW);
|
2022-11-15 11:21:26 +01:00
|
|
|
|
2023-01-08 18:37:24 +01:00
|
|
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID);
|
2022-09-10 13:11:02 +02:00
|
|
|
|
|
|
|
PWORKSPACE->m_pLastFocusedWindow = g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal());
|
|
|
|
}
|
2022-09-19 20:04:48 +02:00
|
|
|
|
|
|
|
void CKeybindManager::mouse(std::string args) {
|
|
|
|
const auto TRUEARG = args.substr(1);
|
|
|
|
const auto PRESSED = args[0] == '1';
|
|
|
|
|
|
|
|
if (TRUEARG == "movewindow") {
|
|
|
|
if (PRESSED) {
|
2022-09-20 11:02:20 +02:00
|
|
|
g_pKeybindManager->m_bIsMouseBindActive = true;
|
|
|
|
|
2022-10-04 17:08:49 +02:00
|
|
|
g_pInputManager->currentlyDraggedWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
|
2022-12-16 18:17:31 +01:00
|
|
|
g_pInputManager->dragMode = MBIND_MOVE;
|
2022-09-19 20:04:48 +02:00
|
|
|
|
|
|
|
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
|
|
|
} else {
|
2022-09-20 11:02:20 +02:00
|
|
|
g_pKeybindManager->m_bIsMouseBindActive = false;
|
|
|
|
|
2022-09-19 20:04:48 +02:00
|
|
|
if (g_pInputManager->currentlyDraggedWindow) {
|
|
|
|
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
|
|
|
g_pInputManager->currentlyDraggedWindow = nullptr;
|
2022-12-16 18:17:31 +01:00
|
|
|
g_pInputManager->dragMode = MBIND_INVALID;
|
2022-09-19 20:04:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (TRUEARG == "resizewindow") {
|
|
|
|
if (PRESSED) {
|
2022-09-20 11:02:20 +02:00
|
|
|
g_pKeybindManager->m_bIsMouseBindActive = true;
|
|
|
|
|
2022-10-04 17:08:49 +02:00
|
|
|
g_pInputManager->currentlyDraggedWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
|
2022-12-16 18:17:31 +01:00
|
|
|
g_pInputManager->dragMode = MBIND_RESIZE;
|
2022-09-19 20:04:48 +02:00
|
|
|
|
|
|
|
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
|
|
|
} else {
|
2022-09-20 11:02:20 +02:00
|
|
|
g_pKeybindManager->m_bIsMouseBindActive = false;
|
|
|
|
|
2022-09-19 20:04:48 +02:00
|
|
|
if (g_pInputManager->currentlyDraggedWindow) {
|
|
|
|
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
|
|
|
g_pInputManager->currentlyDraggedWindow = nullptr;
|
2022-12-16 18:17:31 +01:00
|
|
|
g_pInputManager->dragMode = MBIND_INVALID;
|
2022-09-19 20:04:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-14 15:22:20 +02:00
|
|
|
|
|
|
|
void CKeybindManager::bringActiveToTop(std::string args) {
|
2022-10-14 21:46:32 +02:00
|
|
|
if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsFloating)
|
2022-10-14 15:22:20 +02:00
|
|
|
g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow);
|
|
|
|
}
|
2023-01-01 16:54:13 +01:00
|
|
|
|
|
|
|
void CKeybindManager::fakeFullscreenActive(std::string args) {
|
|
|
|
if (g_pCompositor->m_pLastWindow) {
|
|
|
|
// will also set the flag
|
2023-01-06 13:29:43 +01:00
|
|
|
g_pCompositor->m_pLastWindow->m_bFakeFullscreenState = !g_pCompositor->m_pLastWindow->m_bFakeFullscreenState;
|
|
|
|
g_pXWaylandManager->setWindowFullscreen(g_pCompositor->m_pLastWindow,
|
|
|
|
g_pCompositor->m_pLastWindow->m_bFakeFullscreenState || g_pCompositor->m_pLastWindow->m_bIsFullscreen);
|
2023-01-01 16:54:13 +01:00
|
|
|
}
|
|
|
|
}
|