summaryrefslogtreecommitdiff
path: root/launcher
diff options
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2013-10-24 16:06:39 +0000
committerTarmac <>2013-10-24 16:06:39 +0000
commit1d5ca8149248462612d6aed3ab9946bff1d76254 (patch)
tree750ce5aa096aabb12954759a4f6f7d0632d4915f /launcher
parent7f1af67ad33383066c1b5d739f5a68a8cb199756 (diff)
parentf213711534d5560eb237f2b6bfb523860b283326 (diff)
Invalidate the Icon Centers when the monitor layout changes, so we make sure that if an icon center is set, then the icon is available on that monitor.
Added GetCenterForMonitor that allows to retrieve the nearest valid icon center for a given monitor, and in this way we can get the best icon that can handle a window minimization. Fixes: https://bugs.launchpad.net/bugs/767752. Approved by Brandon Schaefer, PS Jenkins bot. (bzr r3584)
Diffstat (limited to 'launcher')
-rw-r--r--launcher/AbstractLauncherIcon.h2
-rw-r--r--launcher/ApplicationLauncherIcon.cpp29
-rw-r--r--launcher/ApplicationLauncherIcon.h4
-rw-r--r--launcher/LauncherController.cpp4
-rw-r--r--launcher/LauncherIcon.cpp62
-rw-r--r--launcher/LauncherIcon.h11
-rw-r--r--launcher/MockLauncherIcon.h6
7 files changed, 81 insertions, 37 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/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp
index 6e13360be..b5b5c8836 100644
--- a/launcher/ApplicationLauncherIcon.cpp
+++ b/launcher/ApplicationLauncherIcon.cpp
@@ -495,8 +495,14 @@ void ApplicationLauncherIcon::OnWindowMinimized(guint32 xid)
{
if (xid == window->window_id())
{
- Present(0.5f, 600, window->monitor());
- FullyAnimateQuirkDelayed(300, Quirk::SHIMMER, window->monitor());
+ int monitor = GetCenterForMonitor(window->monitor()).first;
+
+ if (monitor >= 0)
+ {
+ Present(0.5f, 600, monitor);
+ FullyAnimateQuirkDelayed(300, Quirk::SHIMMER, monitor);
+ }
+
break;
}
}
@@ -1078,7 +1084,7 @@ AbstractLauncherIcon::MenuItemsVector ApplicationLauncherIcon::GetMenus()
return result;
}
-void ApplicationLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> center)
+void ApplicationLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> const& centers)
{
if (app_->type() == "webapp")
return;
@@ -1088,18 +1094,23 @@ void ApplicationLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> cent
for (auto& window : app_->GetWindows())
{
Window xid = window->window_id();
- int monitor = window->monitor();
- monitor = std::max<int>(0, std::min<int>(center.size() - 1, monitor));
+ int monitor = GetCenterForMonitor(window->monitor()).first;
+
+ if (monitor < 0)
+ {
+ WindowManager::Default().SetWindowIconGeometry(xid, nux::Geometry());
+ continue;
+ }
- geo.x = center[monitor].x - icon_size / 2;
- geo.y = center[monitor].y - icon_size / 2;
+ geo.x = centers[monitor].x - icon_size / 2;
+ geo.y = centers[monitor].y - icon_size / 2;
WindowManager::Default().SetWindowIconGeometry(xid, geo);
}
}
-void ApplicationLauncherIcon::OnCenterStabilized(std::vector<nux::Point3> center)
+void ApplicationLauncherIcon::OnCenterStabilized(std::vector<nux::Point3> const& centers)
{
- UpdateIconGeometries(center);
+ UpdateIconGeometries(centers);
}
void ApplicationLauncherIcon::UpdateRemoteUri()
diff --git a/launcher/ApplicationLauncherIcon.h b/launcher/ApplicationLauncherIcon.h
index 60f811ef8..4aed11e48 100644
--- a/launcher/ApplicationLauncherIcon.h
+++ b/launcher/ApplicationLauncherIcon.h
@@ -77,8 +77,8 @@ protected:
ApplicationPtr GetApplication() const;
void Remove();
- void UpdateIconGeometries(std::vector<nux::Point3> center);
- void OnCenterStabilized(std::vector<nux::Point3> center);
+ void UpdateIconGeometries(std::vector<nux::Point3> const& centers);
+ void OnCenterStabilized(std::vector<nux::Point3> const& centers);
void AddProperties(GVariantBuilder* builder);
void OnAcceptDrop(DndData const& dnd_data);
void OnDndEnter();
diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp
index de345c4f4..e4df86642 100644
--- a/launcher/LauncherController.cpp
+++ b/launcher/LauncherController.cpp
@@ -199,6 +199,10 @@ void Controller::Impl::EnsureLaunchers(int primary, std::vector<nux::Geometry> c
unsigned int launchers_size = launchers.size();
unsigned int last_launcher = 0;
+ // Reset the icon centers: only the used icon centers must contain valid values
+ for (auto const& icon : *model_)
+ icon->ResetCenters();
+
for (unsigned int i = 0; i < num_launchers; ++i, ++last_launcher)
{
if (i >= launchers_size)
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..779eb709e 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);
@@ -207,6 +209,8 @@ public:
protected:
std::vector<nux::Point3> GetCenters();
+ std::pair<int, nux::Point3> GetCenterForMonitor(int monitor) const;
+
std::string GetName() const;
void AddProperties(GVariantBuilder* builder);
@@ -292,7 +296,8 @@ protected:
bool IsActionArgValid(ActionArg const&);
- inline nux::animation::AnimateValue<float>& GetQuirkAnimation(Quirk quirk, int monitor) const
+ typedef nux::animation::AnimateValue<float> Animation;
+ inline Animation& GetQuirkAnimation(Quirk quirk, int monitor) const
{
return *_quirk_animations[monitor][unsigned(quirk)];
}
@@ -301,8 +306,6 @@ protected:
static int _current_theme_is_mono;
private:
- typedef nux::animation::AnimateValue<float> Animation;
-
IconType _icon_type;
nux::ObjectPtr<Tooltip> _tooltip;
@@ -330,7 +333,7 @@ private:
bool _allow_quicklist_to_show;
std::vector<nux::Point3> _center;
- std::bitset<std::size_t(monitors::MAX)> _has_visible_window;
+ std::bitset<monitors::MAX> _has_visible_window;
std::vector<std::bitset<std::size_t(Quirk::LAST)>> _quirks;
std::vector<std::vector<std::shared_ptr<Animation>>> _quirk_animations;
std::vector<nux::Point3> _last_stable;
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];