diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-10-22 01:16:49 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-10-22 01:16:49 +0200 |
| commit | 4b05976bb9d9fd74559c49728906a9d4eab1632e (patch) | |
| tree | ddd02a1dc44f66fc92d50adceec3fafc72a8660a /launcher | |
| parent | 554f41bac8f170ff62a2125d48f95bdcfff698be (diff) | |
LauncherIcon: add ResetCenters and GetCenterForMonitor functions
ResetCenters sets the center values to the default (null) value. GetCenterForMonitor gives the nearest valid {monitor, center} pair for a given monitor id. It allows to know which is the center that handles an icon children (such as a window) that is on the provided monitor. (bzr r3566.5.1)
Diffstat (limited to 'launcher')
| -rw-r--r-- | launcher/AbstractLauncherIcon.h | 2 | ||||
| -rw-r--r-- | launcher/LauncherIcon.cpp | 62 | ||||
| -rw-r--r-- | launcher/LauncherIcon.h | 4 | ||||
| -rw-r--r-- | launcher/MockLauncherIcon.h | 6 |
4 files changed, 52 insertions, 22 deletions
diff --git a/launcher/AbstractLauncherIcon.h b/launcher/AbstractLauncherIcon.h index 5527c29b1..0b586ec90 100644 --- a/launcher/AbstractLauncherIcon.h +++ b/launcher/AbstractLauncherIcon.h @@ -153,6 +153,8 @@ public: virtual void SetCenter(nux::Point3 const& center, int monitor) = 0; + virtual void ResetCenters(int monitor = -1) = 0; + virtual nux::Point3 GetCenter(int monitor) = 0; virtual nux::Point3 GetSavedCenter(int monitor) = 0; diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp index 06ace3a91..171b7b20a 100644 --- a/launcher/LauncherIcon.cpp +++ b/launcher/LauncherIcon.cpp @@ -670,14 +670,25 @@ void LauncherIcon::SetCenter(nux::Point3 const& new_center, int monitor) }, CENTER_STABILIZE_TIMEOUT + std::to_string(monitor)); } -nux::Point3 -LauncherIcon::GetCenter(int monitor) +void LauncherIcon::ResetCenters(int monitor) +{ + if (monitor < 0) + { + for (unsigned i = 0; i < monitors::MAX; ++i) + _center[i].Set(0, 0, 0); + } + else + { + _center[monitor].Set(0, 0, 0); + } +} + +nux::Point3 LauncherIcon::GetCenter(int monitor) { return _center[monitor]; } -nux::Point3 -LauncherIcon::GetSavedCenter(int monitor) +nux::Point3 LauncherIcon::GetSavedCenter(int monitor) { return _saved_center[monitor]; } @@ -687,15 +698,29 @@ std::vector<nux::Point3> LauncherIcon::GetCenters() return _center; } -void -LauncherIcon::SaveCenter() +void LauncherIcon::SaveCenter() { _saved_center = _center; FullyAnimateQuirk(Quirk::CENTER_SAVED, 0); } -void -LauncherIcon::SetWindowVisibleOnMonitor(bool val, int monitor) +std::pair<int, nux::Point3> LauncherIcon::GetCenterForMonitor(int monitor) const +{ + monitor = CLAMP(monitor, 0, static_cast<int>(_center.size() - 1)); + + if (_center[monitor].x && _center[monitor].y) + return {monitor, _center[monitor]}; + + for (unsigned i = 0; i < _center.size(); ++i) + { + if (_center[i].x && _center[i].y) + return {i, _center[i]}; + } + + return {-1, nux::Point3()}; +} + +void LauncherIcon::SetWindowVisibleOnMonitor(bool val, int monitor) { if (_has_visible_window[monitor] == val) return; @@ -704,14 +729,12 @@ LauncherIcon::SetWindowVisibleOnMonitor(bool val, int monitor) EmitNeedsRedraw(monitor); } -void -LauncherIcon::SetVisibleOnMonitor(int monitor, bool visible) +void LauncherIcon::SetVisibleOnMonitor(int monitor, bool visible) { SetQuirk(Quirk::VISIBLE, visible, monitor); } -bool -LauncherIcon::IsVisibleOnMonitor(int monitor) const +bool LauncherIcon::IsVisibleOnMonitor(int monitor) const { return GetQuirk(Quirk::VISIBLE, monitor); } @@ -721,8 +744,7 @@ float LauncherIcon::PresentUrgency() return _present_urgency; } -void -LauncherIcon::Present(float present_urgency, int length, int monitor) +void LauncherIcon::Present(float present_urgency, int length, int monitor) { if (GetQuirk(Quirk::PRESENTED, monitor)) return; @@ -743,8 +765,7 @@ LauncherIcon::Present(float present_urgency, int length, int monitor) SetQuirk(Quirk::UNFOLDED, true, monitor); } -void -LauncherIcon::Unpresent(int monitor) +void LauncherIcon::Unpresent(int monitor) { if (!GetQuirk(Quirk::PRESENTED, monitor)) return; @@ -754,8 +775,7 @@ LauncherIcon::Unpresent(int monitor) SetQuirk(Quirk::UNFOLDED, false, monitor); } -void -LauncherIcon::Remove() +void LauncherIcon::Remove() { if (_quicklist && _quicklist->IsVisible()) _quicklist->Hide(); @@ -773,14 +793,12 @@ LauncherIcon::Remove() removed = true; } -void -LauncherIcon::SetSortPriority(int priority) +void LauncherIcon::SetSortPriority(int priority) { _sort_priority = priority; } -int -LauncherIcon::SortPriority() +int LauncherIcon::SortPriority() { return _sort_priority; } diff --git a/launcher/LauncherIcon.h b/launcher/LauncherIcon.h index 9b18edb23..b5f57a5ba 100644 --- a/launcher/LauncherIcon.h +++ b/launcher/LauncherIcon.h @@ -80,6 +80,8 @@ public: void SetCenter(nux::Point3 const& center, int parent_monitor); + void ResetCenters(int monitor = -1); + nux::Point3 GetCenter(int monitor); virtual void Activate(ActionArg arg); @@ -90,6 +92,8 @@ public: nux::Point3 GetSavedCenter(int monitor); + std::pair<int, nux::Point3> GetCenterForMonitor(int monitor) const; + int SortPriority(); virtual WindowList Windows() { return WindowList(); } diff --git a/launcher/MockLauncherIcon.h b/launcher/MockLauncherIcon.h index 2157d33d6..2b375c9b6 100644 --- a/launcher/MockLauncherIcon.h +++ b/launcher/MockLauncherIcon.h @@ -160,6 +160,12 @@ public: center_[monitor] = center; } + void ResetCenters(int monitor = -1) + { + for (auto& pair : center_) + pair.second.Set(0, 0, 0); + } + nux::Point3 GetCenter(int monitor) { return center_[monitor]; |
