diff --git a/README.md b/README.md index d213efe6..b4854b2a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ Hyprland needs testers! Try it out and report bugs or suggestions! # Installation I do not maintain any packages, but some kind people have made them for me. If I missed any, please let me know. +**Warning:** since I am not the maintainer, I cannot guarantee that those packages will always work and be up to date. Use at your own disclosure. If they don't, try building manually. + _Arch (AUR, -git)_ ``` yay -S hyprland-git diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 2f1746c9..95e2ac48 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -54,6 +54,7 @@ CCompositor::CCompositor() { m_sWLRSubCompositor = wlr_subcompositor_create(m_sWLDisplay); m_sWLRDataDevMgr = wlr_data_device_manager_create(m_sWLDisplay); + m_sWLRDmabuf = wlr_linux_dmabuf_v1_create(m_sWLDisplay, m_sWLRRenderer); wlr_export_dmabuf_manager_v1_create(m_sWLDisplay); wlr_screencopy_manager_v1_create(m_sWLDisplay); wlr_data_control_manager_v1_create(m_sWLDisplay); @@ -366,7 +367,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { return; } - if (m_pLastWindow == pWindow) + if (m_pLastWindow == pWindow && m_sSeat.seat->keyboard_state.focused_surface == pSurface) return; if (windowValidMapped(m_pLastWindow) && m_pLastWindow->m_bIsX11) { @@ -380,8 +381,9 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { g_pXWaylandManager->activateWindow(pWindow, true); - // do pointer focus too - wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, 0, 0); + // do pointer focus too + const auto POINTERLOCAL = g_pInputManager->getMouseCoordsInternal() - pWindow->m_vRealPosition; + wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, POINTERLOCAL.x, POINTERLOCAL.y); m_pLastWindow = pWindow; } diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 9f1fdc87..2435b972 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -50,6 +50,7 @@ public: wlr_egl* m_sWLREGL; int m_iDRMFD; wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr; + wlr_linux_dmabuf_v1* m_sWLRDmabuf; // ------------------------------------------------- // diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index d2c97158..3a093a29 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -145,6 +145,14 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string nextItem(); + if (curitem == "disable" || curitem == "disabled") { + newrule.disabled = true; + + m_dMonitorRules.push_back(newrule); + + return; + } + newrule.resolution.x = stoi(curitem.substr(0, curitem.find_first_of('x'))); newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1, curitem.find_first_of('@'))); diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 45946b93..e1e21dd2 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -26,6 +26,7 @@ struct SMonitorRule { float scale = 1; float refreshRate = 60; int defaultWorkspaceID = -1; + bool disabled = false; }; struct SWindowRule { diff --git a/src/events/Layers.cpp b/src/events/Layers.cpp index db21ae68..2b55ece2 100644 --- a/src/events/Layers.cpp +++ b/src/events/Layers.cpp @@ -145,16 +145,18 @@ void Events::listener_commitLayerSurface(void* owner, void* data) { g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID); } - g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID); + if (layersurface->layerSurface->current.committed != 0) { + g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID); - if (layersurface->layer != layersurface->layerSurface->current.layer) { - PMONITOR->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface); - PMONITOR->m_aLayerSurfaceLists[layersurface->layerSurface->current.layer].push_back(layersurface); - layersurface->layer = layersurface->layerSurface->current.layer; + if (layersurface->layer != layersurface->layerSurface->current.layer) { + PMONITOR->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface); + PMONITOR->m_aLayerSurfaceLists[layersurface->layerSurface->current.layer].push_back(layersurface); + layersurface->layer = layersurface->layerSurface->current.layer; + } + + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID); } - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID); - layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y); g_pHyprRenderer->damageBox(&layersurface->geometry); diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index a6315a68..90a8b3e9 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -45,6 +45,16 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { // new monitor added, let's accomodate for that. const auto OUTPUT = (wlr_output*)data; + // get monitor rule that matches + SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(OUTPUT->name); + + // if it's disabled, disable and ignore + if (monitorRule.disabled) { + wlr_output_enable(OUTPUT, 0); + wlr_output_commit(OUTPUT); + return; + } + SMonitor newMonitor; newMonitor.output = OUTPUT; newMonitor.ID = g_pCompositor->m_lMonitors.size(); @@ -52,9 +62,6 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { wlr_output_init_render(OUTPUT, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer); - // get monitor rule that matches - SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(OUTPUT->name); - wlr_output_set_scale(OUTPUT, monitorRule.scale); wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, monitorRule.scale); wlr_output_set_transform(OUTPUT, WL_OUTPUT_TRANSFORM_NORMAL); // TODO: support other transforms @@ -138,7 +145,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { PNEWMONITOR->damage = wlr_output_damage_create(OUTPUT); // Workspace - const auto WORKSPACEID = monitorRule.defaultWorkspaceID == -1 ? g_pCompositor->m_lWorkspaces.size() : monitorRule.defaultWorkspaceID; + const auto WORKSPACEID = monitorRule.defaultWorkspaceID == -1 ? g_pCompositor->m_lWorkspaces.size() + 1 /* Cuz workspaces doesnt have the new one yet and we start with 1 */ : monitorRule.defaultWorkspaceID; g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); const auto PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back(); diff --git a/src/includes.hpp b/src/includes.hpp index 54893af7..45347672 100644 --- a/src/includes.hpp +++ b/src/includes.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #if true @@ -42,6 +43,7 @@ extern "C" { #include #include #include +#include #include #include #include diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 1d3379c3..4a5cce5a 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -56,6 +56,9 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t else if (k.handler == "movefocus") { moveFocusTo(k.arg); } else if (k.handler == "togglegroup") { toggleGroup(k.arg); } else if (k.handler == "changegroupactive") { changeGroupActive(k.arg); } + else { + Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str()); + } found = true; } @@ -130,10 +133,28 @@ void CKeybindManager::toggleActivePseudo(std::string args) { void CKeybindManager::changeworkspace(std::string args) { int workspaceToChangeTo = 0; - try { - workspaceToChangeTo = stoi(args); - } catch (...) { - Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str()); + + if (args.find_first_of("+") == 0) { + try { + workspaceToChangeTo = g_pCompositor->m_pLastMonitor->activeWorkspace + std::stoi(args.substr(1)); + } catch (...) { + Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str()); + return; + } + } else if (args.find_first_of("-") == 0) { + try { + workspaceToChangeTo = std::clamp(g_pCompositor->m_pLastMonitor->activeWorkspace - std::stoi(args.substr(1)), 1, INT_MAX); + } catch (...) { + Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str()); + return; + } + } else { + try { + workspaceToChangeTo = stoi(args); + } catch (...) { + Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str()); + return; + } } // if it exists, we warp to it @@ -171,6 +192,9 @@ void CKeybindManager::changeworkspace(std::string args) { Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); + // focus + g_pInputManager->refocus(); + return; } @@ -201,6 +225,9 @@ void CKeybindManager::changeworkspace(std::string args) { // mark the monitor dirty g_pHyprRenderer->damageMonitor(PMONITOR); + // focus (clears the last) + g_pInputManager->refocus(); + Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); }