aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2023-03-20 02:01:23 +0000
committerGitHub <[email protected]>2023-03-20 02:01:23 +0000
commit200fa3d677cde939ca2f4d7165458f07345d1cfc (patch)
tree75d379197fc96200a6ce187ebb62a48301559a3e
parentdcae72e153e915ad8b4355f6f981aed15b6766d4 (diff)
parentd23bbd1687a5413fb7f2c08b67692d4e64f8efef (diff)
downloadHyprland-200fa3d677cde939ca2f4d7165458f07345d1cfc.tar.gz
Hyprland-200fa3d677cde939ca2f4d7165458f07345d1cfc.zip
Merge branch 'main' into wrap-surfaces
-rw-r--r--src/Compositor.cpp26
-rw-r--r--src/Window.cpp37
-rw-r--r--src/Window.hpp1
-rw-r--r--src/config/ConfigManager.cpp20
-rw-r--r--src/config/ConfigManager.hpp21
-rw-r--r--src/events/Windows.cpp6
-rw-r--r--src/helpers/Monitor.cpp6
-rw-r--r--src/layout/IHyprLayout.cpp2
-rw-r--r--src/managers/KeybindManager.cpp5
-rw-r--r--src/meson.build1
-rw-r--r--src/render/OpenGL.cpp12
11 files changed, 97 insertions, 40 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 497f26d8..924de252 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -1714,6 +1714,11 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == PWORKSPACEA->m_iID) {
+ if (w->m_bPinned) {
+ w->m_iWorkspaceID = PWORKSPACEB->m_iID;
+ continue;
+ }
+
w->m_iMonitorID = pMonitorB->ID;
// additionally, move floating and fs windows manually
@@ -1734,6 +1739,11 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == PWORKSPACEB->m_iID) {
+ if (w->m_bPinned) {
+ w->m_iWorkspaceID = PWORKSPACEA->m_iID;
+ continue;
+ }
+
w->m_iMonitorID = pMonitorA->ID;
// additionally, move floating and fs windows manually
@@ -1749,17 +1759,6 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
}
}
- // fix pinned windows
- for (auto& w : g_pCompositor->m_vWindows) {
- if (w->m_iWorkspaceID == pMonitorA->activeWorkspace && w->m_bPinned) {
- w->m_iWorkspaceID = PWORKSPACEB->m_iID;
- }
-
- if (w->m_iWorkspaceID == pMonitorB->activeWorkspace && w->m_bPinned) {
- w->m_iWorkspaceID = PWORKSPACEA->m_iID;
- }
- }
-
pMonitorA->activeWorkspace = PWORKSPACEB->m_iID;
pMonitorB->activeWorkspace = PWORKSPACEA->m_iID;
@@ -1909,6 +1908,11 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == pWorkspace->m_iID) {
+ if (w->m_bPinned) {
+ w->m_iWorkspaceID = nextWorkspaceOnMonitorID;
+ continue;
+ }
+
w->m_iMonitorID = pMonitor->ID;
// additionally, move floating and fs windows manually
diff --git a/src/Window.cpp b/src/Window.cpp
index 747bc787..b390d2e6 100644
--- a/src/Window.cpp
+++ b/src/Window.cpp
@@ -271,17 +271,21 @@ void CWindow::updateSurfaceOutputs() {
}
void CWindow::moveToWorkspace(int workspaceID) {
- if (m_iWorkspaceID != workspaceID) {
- m_iWorkspaceID = workspaceID;
+ if (m_iWorkspaceID == workspaceID)
+ return;
- if (const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID); PWORKSPACE) {
- g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", this, PWORKSPACE->m_szName.c_str())});
- EMIT_HOOK_EVENT("moveWindow", (std::vector<void*>{this, PWORKSPACE}));
- }
+ m_iWorkspaceID = workspaceID;
- if (const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); PMONITOR)
- g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(m_pWLSurface.wlr(), PMONITOR->scale);
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
+
+ if (PWORKSPACE) {
+ g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", this, PWORKSPACE->m_szName.c_str())});
+ EMIT_HOOK_EVENT("moveWindow", (std::vector<void*>{this, PWORKSPACE}));
}
+
+ if (PMONITOR)
+ g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(g_pXWaylandManager->getWindowSurface(m_pWLSurface.wlr()), PMONITOR->scale);
}
CWindow* CWindow::X11TransientFor() {
@@ -617,4 +621,21 @@ void CWindow::insertWindowToGroup(CWindow* pWindow) {
pWindow->m_sGroupData.pNextWindow = PHEAD;
setGroupCurrent(pWindow);
+}
+
+void CWindow::updateGroupOutputs() {
+ if (!m_sGroupData.pNextWindow)
+ return;
+
+ CWindow* curr = m_sGroupData.pNextWindow;
+
+ while (curr != this) {
+ curr->m_iMonitorID = m_iMonitorID;
+ curr->moveToWorkspace(m_iWorkspaceID);
+
+ curr->m_vRealPosition = m_vRealPosition.goalv();
+ curr->m_vRealSize = m_vRealSize.goalv();
+
+ curr = curr->m_sGroupData.pNextWindow;
+ }
} \ No newline at end of file
diff --git a/src/Window.hpp b/src/Window.hpp
index 42e48e42..6cada8c8 100644
--- a/src/Window.hpp
+++ b/src/Window.hpp
@@ -321,6 +321,7 @@ class CWindow {
CWindow* getGroupCurrent();
void setGroupCurrent(CWindow* pWindow);
void insertWindowToGroup(CWindow* pWindow);
+ void updateGroupOutputs();
private:
// For hidden windows and stuff
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index a157a108..4abe858c 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -558,6 +558,12 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
} else if (ARGS[argno] == "bitdepth") {
newrule.enable10bit = ARGS[argno + 1] == "10";
argno++;
+ } else if (ARGS[argno] == "transform") {
+ newrule.transform = (wl_output_transform)std::stoi(ARGS[argno + 1]);
+ argno++;
+ } else if (ARGS[argno] == "workspace") {
+ m_mDefaultWorkspaces[newrule.name] = ARGS[argno + 1];
+ argno++;
} else {
Debug::log(ERR, "Config error: invalid monitor syntax");
parseError = "invalid syntax at \"" + ARGS[argno] + "\"";
@@ -982,12 +988,7 @@ void CConfigManager::handleBlurLS(const std::string& command, const std::string&
void CConfigManager::handleDefaultWorkspace(const std::string& command, const std::string& value) {
const auto ARGS = CVarList(value);
- for (auto& mr : m_dMonitorRules) {
- if (mr.name == ARGS[0]) {
- mr.defaultWorkspace = ARGS[1];
- break;
- }
- }
+ m_mDefaultWorkspaces[ARGS[0]] = ARGS[1];
}
void CConfigManager::handleSubmap(const std::string& command, const std::string& submap) {
@@ -1926,3 +1927,10 @@ void CConfigManager::addPluginConfigVar(HANDLE handle, const std::string& name,
void CConfigManager::removePluginConfig(HANDLE handle) {
std::erase_if(pluginConfigs, [&](const auto& other) { return other.first == handle; });
}
+
+std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) {
+ const auto IT = std::find_if(m_mDefaultWorkspaces.begin(), m_mDefaultWorkspaces.end(), [&](const auto& other) { return other.first == name; });
+ if (IT == m_mDefaultWorkspaces.end())
+ return "";
+ return IT->second;
+} \ No newline at end of file
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index f09241f8..e5a5749d 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -34,16 +34,15 @@ struct SConfigValue {
};
struct SMonitorRule {
- std::string name = "";
- Vector2D resolution = Vector2D(1280, 720);
- Vector2D offset = Vector2D(0, 0);
- float scale = 1;
- float refreshRate = 60;
- std::string defaultWorkspace = "";
- bool disabled = false;
- wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
- std::string mirrorOf = "";
- bool enable10bit = false;
+ std::string name = "";
+ Vector2D resolution = Vector2D(1280, 720);
+ Vector2D offset = Vector2D(0, 0);
+ float scale = 1;
+ float refreshRate = 60;
+ bool disabled = false;
+ wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
+ std::string mirrorOf = "";
+ bool enable10bit = false;
};
struct SMonitorAdditionalReservedArea {
@@ -150,6 +149,7 @@ class CConfigManager {
SConfigValue* getConfigValuePtrSafe(const std::string&);
SMonitorRule getMonitorRuleFor(const std::string&, const std::string& displayName = "");
+ std::string getDefaultWorkspaceFor(const std::string&);
CMonitor* getBoundMonitorForWS(const std::string&);
std::string getBoundMonitorStringForWS(const std::string&);
@@ -208,6 +208,7 @@ class CConfigManager {
bool isFirstLaunch = true; // For exec-once
std::deque<SMonitorRule> m_dMonitorRules;
+ std::unordered_map<std::string, std::string> m_mDefaultWorkspaces;
std::deque<SWindowRule> m_dWindowRules;
std::deque<SLayerRule> m_dLayerRules;
std::deque<std::string> m_dBlurLSNamespaces;
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index 0274b75f..adbd2118 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -675,8 +675,10 @@ void Events::listener_unmapWindow(void* owner, void* data) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
// do the animation thing
- PWINDOW->m_vOriginalClosedPos = PWINDOW->m_vRealPosition.vec() - PMONITOR->vecPosition;
- PWINDOW->m_vOriginalClosedSize = PWINDOW->m_vRealSize.vec();
+ if (PMONITOR) {
+ PWINDOW->m_vOriginalClosedPos = PWINDOW->m_vRealPosition.vec() - PMONITOR->vecPosition;
+ PWINDOW->m_vOriginalClosedSize = PWINDOW->m_vRealSize.vec();
+ }
if (!PWINDOW->m_bX11DoesntWantBorders) // don't animate out if they weren't animated in.
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.vec() + Vector2D(0.01f, 0.01f); // it has to be animated, otherwise onWindowPostCreateClose will ignore it
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index f97c386d..6ad60dfa 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -297,13 +297,15 @@ int CMonitor::findAvailableDefaultWS() {
void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
// Workspace
std::string newDefaultWorkspaceName = "";
- int64_t WORKSPACEID = monitorRule.defaultWorkspace == "" ? findAvailableDefaultWS() : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName);
+ int64_t WORKSPACEID = g_pConfigManager->getDefaultWorkspaceFor(szName).empty() ?
+ findAvailableDefaultWS() :
+ getWorkspaceIDFromString(g_pConfigManager->getDefaultWorkspaceFor(szName), newDefaultWorkspaceName);
if (WORKSPACEID == INT_MAX || (WORKSPACEID >= SPECIAL_WORKSPACE_START && WORKSPACEID <= -2)) {
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
- Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace.c_str());
+ Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", g_pConfigManager->getDefaultWorkspaceFor(szName).c_str());
}
auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID);
diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp
index 06dd159a..c9260f19 100644
--- a/src/layout/IHyprLayout.cpp
+++ b/src/layout/IHyprLayout.cpp
@@ -343,6 +343,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
if (PMONITOR && !SPECIAL) {
DRAGGINGWINDOW->m_iMonitorID = PMONITOR->ID;
DRAGGINGWINDOW->moveToWorkspace(PMONITOR->activeWorkspace);
+ DRAGGINGWINDOW->updateGroupOutputs();
DRAGGINGWINDOW->updateToplevel();
}
@@ -374,6 +375,7 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.vec() + pWindow->m_vRealSize.vec() / 2.f);
pWindow->m_iMonitorID = PNEWMON->ID;
pWindow->moveToWorkspace(PNEWMON->activeWorkspace);
+ pWindow->updateGroupOutputs();
// save real pos cuz the func applies the default 5,5 mid
const auto PSAVEDPOS = pWindow->m_vRealPosition.goalv();
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 075a5d57..0ace08d3 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -986,8 +986,9 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
PWORKSPACE = g_pCompositor->createNewWorkspace(WORKSPACEID, OLDWORKSPACE->m_iMonitorID, workspaceName);
}
- PWINDOW->moveToWorkspace(PWORKSPACE->m_iID);
PWINDOW->m_iMonitorID = PWORKSPACE->m_iMonitorID;
+ PWINDOW->moveToWorkspace(PWORKSPACE->m_iID);
+ PWINDOW->updateGroupOutputs();
if (PWORKSPACE->m_bHasFullscreenWindow) {
g_pCompositor->setWindowFullscreen(g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID), false, FULLSCREEN_FULL);
@@ -1273,6 +1274,8 @@ void CKeybindManager::moveActiveTo(std::string args) {
return;
g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, PWINDOWTOCHANGETO);
+
+ g_pCompositor->warpCursorTo(PLASTWINDOW->m_vRealPosition.vec() + PLASTWINDOW->m_vRealSize.vec() / 2.0);
}
void CKeybindManager::toggleGroup(std::string args) {
diff --git a/src/meson.build b/src/meson.build
index 7b658d31..32a7a127 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -3,6 +3,7 @@ src = globber.stdout().strip().split('\n')
executable('Hyprland', src,
cpp_args: ['-DWLR_USE_UNSTABLE'],
+ link_args: '-rdynamic',
dependencies: [
server_protos,
dependency('wayland-server'),
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 1455c1da..ea36b2da 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -1074,6 +1074,10 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad,
void CHyprOpenGLImpl::makeRawWindowSnapshot(CWindow* pWindow, CFramebuffer* pFramebuffer) {
// we trust the window is valid.
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+
+ if (!PMONITOR || !PMONITOR->output)
+ return;
+
wlr_output_attach_render(PMONITOR->output, nullptr);
// we need to "damage" the entire monitor
@@ -1129,6 +1133,10 @@ void CHyprOpenGLImpl::makeRawWindowSnapshot(CWindow* pWindow, CFramebuffer* pFra
void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) {
// we trust the window is valid.
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+
+ if (!PMONITOR || !PMONITOR->output)
+ return;
+
wlr_output_attach_render(PMONITOR->output, nullptr);
// we need to "damage" the entire monitor
@@ -1189,6 +1197,10 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) {
void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) {
// we trust the window is valid.
const auto PMONITOR = g_pCompositor->getMonitorFromID(pLayer->monitorID);
+
+ if (!PMONITOR || !PMONITOR->output)
+ return;
+
wlr_output_attach_render(PMONITOR->output, nullptr);
// we need to "damage" the entire monitor