Skip to content

Commit

Permalink
Merge pull request #74 from levnikmyskin/fix-moveto
Browse files Browse the repository at this point in the history
Fix `movtodesk` dispatchers
  • Loading branch information
levnikmyskin authored Dec 19, 2024
2 parents 45001c5 + b6b944c commit 4e4e9b0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/VirtualDeskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,25 @@ int VirtualDeskManager::moveToDesk(std::string& arg, int vdeskId) {

auto vdesk = getOrCreateVdesk(vdeskId);

PHLWINDOW window = g_pCompositor->getWindowByRegex(arg);
if (!window) {
printLog(std::format("Window {} does not exist???", arg), eLogLevel::ERR);
return vdeskId;
// monitor of the target window
// if no arg is provided, it's the currently focussed monitor and otherwise
// it's the monitor of the window matched by the arg regex
PHLMONITORREF monitor = g_pCompositor->m_pLastMonitor;
if (arg != "") {
PHLWINDOW window = g_pCompositor->getWindowByRegex(arg);
if (!window) {
printLog(std::format("Window {} does not exist???", arg), eLogLevel::ERR);
} else {
monitor = window->m_pMonitor;
}
}

// take the first workspace wherever in the layout
// and later go for the workspace which is on the same monitor
// of the window
auto wid = vdesk->activeLayout(conf).begin()->second;
for (auto const& [mon, workspace] : vdesk->activeLayout(conf)) {
if (mon == window->m_pMonitor) {
if (mon == monitor) {
wid = workspace;
}
}
Expand Down

0 comments on commit 4e4e9b0

Please sign in to comment.