mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-12-26 03:09:49 +01:00
dock autodetect monitor based on position
This commit is contained in:
parent
8d499c62ab
commit
6c02b3947a
3 changed files with 20 additions and 0 deletions
|
@ -307,6 +307,16 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
|
|||
+ ", " + std::to_string(PWINDOWINARR->getDefaultSize().x) + ", " + std::to_string(PWINDOWINARR->getDefaultSize().y));
|
||||
|
||||
PWINDOWINARR->setDock(true);
|
||||
|
||||
// since it's a dock get its monitor from the coords
|
||||
const auto CENTERVEC = PWINDOWINARR->getDefaultPosition() + (PWINDOWINARR->getDefaultSize() / 2.f);
|
||||
const auto MONITOR = g_pWindowManager->getMonitorFromCoord(CENTERVEC);
|
||||
if (MONITOR) {
|
||||
PWINDOWINARR->setMonitor(MONITOR->ID);
|
||||
Debug::log(LOG, "Guessed dock's monitor to be " + std::to_string(MONITOR->ID) + ".");
|
||||
} else {
|
||||
Debug::log(LOG, "Couldn't guess dock's monitor. Leaving at " + std::to_string(PWINDOWINARR->getMonitor()) + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2390,4 +2390,13 @@ bool CWindowManager::shouldBeManaged(const int& window) {
|
|||
|
||||
int CWindowManager::getBarHeightForMonitor(const int& mon) {
|
||||
return (mon == ConfigManager::getInt("bar:monitor") ? (ConfigManager::getInt("bar:enabled") == 1 ? ConfigManager::getInt("bar:height") : ConfigManager::parseError == "" ? 0 : ConfigManager::getInt("bar:height")) : 0);
|
||||
}
|
||||
|
||||
SMonitor* CWindowManager::getMonitorFromCoord(const Vector2D coord) {
|
||||
for (auto& m : monitors) {
|
||||
if (VECINRECT(coord, m.vecPosition.x, m.vecPosition.y, m.vecPosition.x + m.vecSize.x, m.vecPosition.y + m.vecSize.y))
|
||||
return &m;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
|
@ -107,6 +107,7 @@ public:
|
|||
|
||||
SMonitor* getMonitorFromWindow(CWindow*);
|
||||
SMonitor* getMonitorFromCursor();
|
||||
SMonitor* getMonitorFromCoord(const Vector2D);
|
||||
|
||||
Vector2D getCursorPos();
|
||||
|
||||
|
|
Loading…
Reference in a new issue