Skip to content

Commit 4e4e9b0

Browse files
authored
Merge pull request #74 from levnikmyskin/fix-moveto
Fix `movtodesk` dispatchers
2 parents 45001c5 + b6b944c commit 4e4e9b0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/VirtualDeskManager.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,25 @@ int VirtualDeskManager::moveToDesk(std::string& arg, int vdeskId) {
114114

115115
auto vdesk = getOrCreateVdesk(vdeskId);
116116

117-
PHLWINDOW window = g_pCompositor->getWindowByRegex(arg);
118-
if (!window) {
119-
printLog(std::format("Window {} does not exist???", arg), eLogLevel::ERR);
120-
return vdeskId;
117+
// monitor of the target window
118+
// if no arg is provided, it's the currently focussed monitor and otherwise
119+
// it's the monitor of the window matched by the arg regex
120+
PHLMONITORREF monitor = g_pCompositor->m_pLastMonitor;
121+
if (arg != "") {
122+
PHLWINDOW window = g_pCompositor->getWindowByRegex(arg);
123+
if (!window) {
124+
printLog(std::format("Window {} does not exist???", arg), eLogLevel::ERR);
125+
} else {
126+
monitor = window->m_pMonitor;
127+
}
121128
}
122129

123130
// take the first workspace wherever in the layout
124131
// and later go for the workspace which is on the same monitor
125132
// of the window
126133
auto wid = vdesk->activeLayout(conf).begin()->second;
127134
for (auto const& [mon, workspace] : vdesk->activeLayout(conf)) {
128-
if (mon == window->m_pMonitor) {
135+
if (mon == monitor) {
129136
wid = workspace;
130137
}
131138
}

0 commit comments

Comments
 (0)