diff options
| -rw-r--r-- | launcher/AbstractLauncherIcon.h | 5 | ||||
| -rw-r--r-- | launcher/ApplicationLauncherIcon.cpp | 35 | ||||
| -rw-r--r-- | launcher/ApplicationLauncherIcon.h | 9 | ||||
| -rw-r--r-- | launcher/LauncherController.cpp | 32 | ||||
| -rw-r--r-- | launcher/LauncherIcon.cpp | 2 | ||||
| -rw-r--r-- | launcher/LauncherIcon.h | 4 | ||||
| -rw-r--r-- | launcher/MockLauncherIcon.h | 5 | ||||
| -rw-r--r-- | launcher/VolumeLauncherIcon.cpp | 8 | ||||
| -rw-r--r-- | launcher/VolumeLauncherIcon.h | 2 | ||||
| -rw-r--r-- | unity-shared/PluginAdapter.cpp | 23 | 
10 files changed, 43 insertions, 82 deletions
| diff --git a/launcher/AbstractLauncherIcon.h b/launcher/AbstractLauncherIcon.h index b0cb5f11b..495317a87 100644 --- a/launcher/AbstractLauncherIcon.h +++ b/launcher/AbstractLauncherIcon.h @@ -30,10 +30,11 @@  #include "DndData.h"  #include "unity-shared/Introspectable.h" -#include "LauncherEntryRemote.h"  #include "unity-shared/IconTextureSource.h"  #include "unity-shared/WindowManager.h" +#include "LauncherEntryRemote.h" +  namespace unity  {  namespace launcher @@ -161,8 +162,6 @@ public:  virtual std::vector<Window> WindowsOnViewport() = 0; - virtual std::string NameForWindow(Window window) = 0; -  virtual const bool WindowVisibleOnMonitor(int monitor) = 0;  virtual const bool WindowVisibleOnViewport() = 0; diff --git a/launcher/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp index 8fabbb8b5..b3782e256 100644 --- a/launcher/ApplicationLauncherIcon.cpp +++ b/launcher/ApplicationLauncherIcon.cpp @@ -326,7 +326,7 @@ void ApplicationLauncherIcon::ActivateLauncherIcon(ActionArg arg)  }  SetQuirk(Quirk::STARTING, true); - OpenInstanceLauncherIcon(ActionArg()); + OpenInstanceLauncherIcon();  }  else // app is running  { @@ -437,29 +437,6 @@ std::vector<Window> ApplicationLauncherIcon::WindowsForMonitor(int monitor)  return GetWindows(filter, monitor);  } -std::string ApplicationLauncherIcon::NameForWindow(Window window) -{ - std::string result; - GList* children, *l; - - children = bamf_view_get_children(BAMF_VIEW(_bamf_app.RawPtr())); - for (l = children; l; l = l->next) - { - if (!BAMF_IS_WINDOW(l->data)) - continue; - - if (bamf_window_get_xid(static_cast<BamfWindow*>(l->data)) == window) - { - auto view = static_cast<BamfView*>(l->data); - result = glib::String(bamf_view_get_name(view)).Str(); - break; - } - } - - g_list_free(children); - return result; -} -  void ApplicationLauncherIcon::OnWindowMinimized(guint32 xid)  {  if (!OwnsWindow(xid)) @@ -624,7 +601,7 @@ void ApplicationLauncherIcon::OpenInstanceWithUris(std::set<std::string> uris)  UpdateQuirkTime(Quirk::STARTING);  } -void ApplicationLauncherIcon::OpenInstanceLauncherIcon(ActionArg arg) +void ApplicationLauncherIcon::OpenInstanceLauncherIcon()  {  std::set<std::string> empty;  OpenInstanceWithUris(empty); @@ -665,7 +642,7 @@ std::vector<Window> ApplicationLauncherIcon::GetFocusableWindows(ActionArg arg,  {  if (g_strcmp0(bamf_application_get_application_type(_bamf_app.RawPtr()), "webapp") == 0)  { - OpenInstanceLauncherIcon(arg); + OpenInstanceLauncherIcon();  return windows;  } @@ -940,6 +917,12 @@ void ApplicationLauncherIcon::Quit()  g_list_free(children);  } +void ApplicationLauncherIcon::AboutToRemove() +{ + UnStick(); + Quit(); +} +  void ApplicationLauncherIcon::Stick(bool save)  {  if (IsSticky()) diff --git a/launcher/ApplicationLauncherIcon.h b/launcher/ApplicationLauncherIcon.h index 3481bd85e..7e64df53f 100644 --- a/launcher/ApplicationLauncherIcon.h +++ b/launcher/ApplicationLauncherIcon.h @@ -18,8 +18,8 @@  * Marco Trevisan (TreviƱo) <3v1n0@ubuntu.com>  */ -#ifndef BAMFLAUNCHERICON_H -#define BAMFLAUNCHERICON_H +#ifndef APPLICATIONLAUNCHERICON_H +#define APPLICATIONLAUNCHERICON_H  #include <UnityCore/GLibSignal.h>  #include <UnityCore/GLibWrapper.h> @@ -53,6 +53,8 @@ public:  bool IsUrgent() const;  virtual void Quit(); + virtual void AboutToRemove(); +  virtual void Stick(bool save = true);  virtual void UnStick(); @@ -64,7 +66,6 @@ public:  std::vector<Window> Windows();  std::vector<Window> WindowsOnViewport();  std::vector<Window> WindowsForMonitor(int monitor); - std::string NameForWindow(Window window);  protected:  void Remove(); @@ -75,7 +76,7 @@ protected:  void OnDndEnter();  void OnDndHovered();  void OnDndLeave(); - void OpenInstanceLauncherIcon(ActionArg arg); + void OpenInstanceLauncherIcon();  void ToggleSticky();  bool OnShouldHighlightOnDrag(DndData const& dnd_data); diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp index a257b2dff..380026dcb 100644 --- a/launcher/LauncherController.cpp +++ b/launcher/LauncherController.cpp @@ -486,37 +486,7 @@ void Controller::Impl::OnIconRemoved(AbstractLauncherIcon::Ptr const& icon)  void Controller::Impl::OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr const& icon)  { - switch (icon->GetIconType()) - { - case AbstractLauncherIcon::IconType::APPLICATION: - { - ApplicationLauncherIcon* bamf_icon = dynamic_cast<ApplicationLauncherIcon*>(icon.GetPointer()); - - if (bamf_icon) - { - bamf_icon->UnStick(); - bamf_icon->Quit(); - } - - break; - } - case AbstractLauncherIcon::IconType::DEVICE: - { - auto device_icon = dynamic_cast<VolumeLauncherIcon*>(icon.GetPointer()); - - if (device_icon) - { - if (device_icon->CanEject()) - device_icon->EjectAndShowNotification(); - else if (device_icon->CanStop()) - device_icon->StopDrive(); - } - - break; - } - default: - break; - } + icon->AboutToRemove();  }  void Controller::Impl::OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry) diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp index d893a7458..46d689f94 100644 --- a/launcher/LauncherIcon.cpp +++ b/launcher/LauncherIcon.cpp @@ -233,7 +233,7 @@ LauncherIcon::OpenInstance(ActionArg arg)  if (wm.IsScaleActive())  wm.TerminateScale(); - OpenInstanceLauncherIcon(arg); + OpenInstanceLauncherIcon();  UpdateQuirkTime(Quirk::LAST_ACTION);  } diff --git a/launcher/LauncherIcon.h b/launcher/LauncherIcon.h index 47bf18df5..0971dc3bc 100644 --- a/launcher/LauncherIcon.h +++ b/launcher/LauncherIcon.h @@ -103,8 +103,6 @@ public:  virtual std::vector<Window> WindowsForMonitor(int monitor) { return std::vector<Window> (); } - virtual std::string NameForWindow(Window window) { return std::string(); } -  const bool WindowVisibleOnMonitor(int monitor);  const bool WindowVisibleOnViewport(); @@ -252,7 +250,7 @@ protected:  virtual void ActivateLauncherIcon(ActionArg arg) {} - virtual void OpenInstanceLauncherIcon(ActionArg arg) {} + virtual void OpenInstanceLauncherIcon() {}  virtual bool HandlesSpread () { return false; } diff --git a/launcher/MockLauncherIcon.h b/launcher/MockLauncherIcon.h index d201f7251..d00c6c569 100644 --- a/launcher/MockLauncherIcon.h +++ b/launcher/MockLauncherIcon.h @@ -118,11 +118,6 @@ public:  return result;  } - std::string NameForWindow (Window window) - { - return std::string(); - } -  void SetSortPriority(int priority) { sort_priority_ = priority; }  bool OpenQuicklist(bool select_first_item = false, int monitor = -1) diff --git a/launcher/VolumeLauncherIcon.cpp b/launcher/VolumeLauncherIcon.cpp index 2976cbb28..5a6aaaa28 100644 --- a/launcher/VolumeLauncherIcon.cpp +++ b/launcher/VolumeLauncherIcon.cpp @@ -303,6 +303,14 @@ VolumeLauncherIcon::VolumeLauncherIcon(Volume::Ptr const& volume,  VolumeLauncherIcon::~VolumeLauncherIcon()  {} +void VolumeLauncherIcon::AboutToRemove() +{ + if (CanEject()) + EjectAndShowNotification(); + else if (CanStop()) + StopDrive(); +} +  bool VolumeLauncherIcon::CanEject() const  {  return pimpl_->CanEject(); diff --git a/launcher/VolumeLauncherIcon.h b/launcher/VolumeLauncherIcon.h index a8bfb1ec1..aa9afd63c 100644 --- a/launcher/VolumeLauncherIcon.h +++ b/launcher/VolumeLauncherIcon.h @@ -39,6 +39,8 @@ public:  DevicesSettings::Ptr const& devices_settings);  virtual ~VolumeLauncherIcon(); + virtual void AboutToRemove(); +  bool CanEject() const; // TODO: rename to public virtual bool IsTrashable();  void EjectAndShowNotification(); // TODO: rename to private virtual void DoDropToTrash();  bool CanStop() const; diff --git a/unity-shared/PluginAdapter.cpp b/unity-shared/PluginAdapter.cpp index 42adc10dd..5e83ddf45 100644 --- a/unity-shared/PluginAdapter.cpp +++ b/unity-shared/PluginAdapter.cpp @@ -734,12 +734,13 @@ void PluginAdapter::FocusWindowGroup(std::vector<Window> const& window_ids,  CompWindow* top_window = nullptr;  CompWindow* top_monitor_win = nullptr; + // mapped windows are visible windows (non-minimised)  bool any_on_current = false;  bool any_mapped = false;  bool any_mapped_on_current = false;  bool forced_unminimize = false; - /* sort the list */ + // Get the compiz windows for the window_ids passed in.  CompWindowList windows;  for (auto win : m_Screen->clientList())  { @@ -748,30 +749,34 @@ void PluginAdapter::FocusWindowGroup(std::vector<Window> const& window_ids,  windows.push_back(win);  } - /* filter based on workspace */ + // Work out if there are any visible windows on the current view port.  for (CompWindow* &win : windows)  { - if (win->defaultViewport() == m_Screen->vp()) + if (win->defaultViewport() == target_vp)  {  any_on_current = true; -  if (!win->minimized()) - {  any_mapped_on_current = true; - }  }  if (!win->minimized()) - {  any_mapped = true; - } - if (any_on_current && any_mapped) + // If there is a visible window on the current view port, then don't + // bother looking for others, as we will end up focusing the one on the + // current view port, so we don't care if there are other windows on other + // view ports. + if (any_mapped_on_current)  break;  } + // If we don't find any windows on the current view port, we need to look + // for the view port of the maooed window. Or if there are not any mapped + // windows, then just choosing any view port is fine.  if (!any_on_current)  { + // By iterating backwards, we stop at the top most window in the stack + // that is either visible, or the top most minimised window.  for (auto it = windows.rbegin(); it != windows.rend(); ++it)  {  CompWindow* win = *it; | 
