diff options
| -rw-r--r-- | tests/mock-application.h | 4 | ||||
| -rw-r--r-- | unity-shared/ApplicationManager.h | 1 | ||||
| -rw-r--r-- | unity-shared/BamfApplicationManager.cpp | 20 | ||||
| -rw-r--r-- | unity-shared/BamfApplicationManager.h | 1 |
4 files changed, 26 insertions, 0 deletions
diff --git a/tests/mock-application.h b/tests/mock-application.h index 7070f1086..bd00908dc 100644 --- a/tests/mock-application.h +++ b/tests/mock-application.h @@ -321,6 +321,9 @@ struct MockApplicationManager : public unity::ApplicationManager ON_CALL(*this, GetActiveApplication()).WillByDefault(Invoke([this] { return unity::ApplicationPtr(); } )); ON_CALL(*this, GetWindowsForMonitor(_)).WillByDefault(Invoke([this] (Window) { return unity::WindowList(); } )); ON_CALL(*this, GetWindowForId(_)).WillByDefault(Invoke([this] (int) { return unity::ApplicationWindowPtr(); } )); + ON_CALL(*this, GetWindowForProperty(_, _)).WillByDefault(Invoke([this] (std::string const&, std::string const&) { + return unity::ApplicationWindowPtr(); + })); } static void StartApp(std::string const& desktop_file) @@ -340,6 +343,7 @@ struct MockApplicationManager : public unity::ApplicationManager MOCK_CONST_METHOD0(GetActiveApplication, unity::ApplicationPtr()); MOCK_CONST_METHOD1(GetWindowsForMonitor, unity::WindowList(int)); MOCK_CONST_METHOD1(GetWindowForId, unity::ApplicationWindowPtr(Window)); + MOCK_CONST_METHOD2(GetWindowForProperty, unity::ApplicationWindowPtr(std::string const&, std::string const&)); MOCK_CONST_METHOD3(FocusWindowGroup, void(unity::WindowList const&, bool, int)); unity::ApplicationPtr LocalGetApplicationForDesktopFile(std::string const& desktop_file) diff --git a/unity-shared/ApplicationManager.h b/unity-shared/ApplicationManager.h index 36a4959f7..e60a56fb5 100644 --- a/unity-shared/ApplicationManager.h +++ b/unity-shared/ApplicationManager.h @@ -227,6 +227,7 @@ public: virtual WindowList GetWindowsForMonitor(int monitor = -1) const = 0; virtual ApplicationPtr GetApplicationForWindow(Window xid) const = 0; virtual ApplicationWindowPtr GetWindowForId(Window xid) const = 0; + virtual ApplicationWindowPtr GetWindowForProperty(const std::string& name, const std::string& value) const = 0; virtual void FocusWindowGroup(WindowList const&, bool show_on_visible, int monitor) const = 0; sigc::signal<void, ApplicationPtr const&> application_started; diff --git a/unity-shared/BamfApplicationManager.cpp b/unity-shared/BamfApplicationManager.cpp index 5973bd031..fb580ef75 100644 --- a/unity-shared/BamfApplicationManager.cpp +++ b/unity-shared/BamfApplicationManager.cpp @@ -730,6 +730,26 @@ ApplicationWindowPtr Manager::GetWindowForId(Window xid) const return nullptr; } +ApplicationWindowPtr Manager::GetWindowForProperty(std::string const& name, std::string const& value) const +{ + if (name.empty()) + return nullptr; + + for (auto const& win_pair : pool::wins_) + { + if (win_pair.second->property(name) == value) + return win_pair.second; + } + + for (auto const& win : GetWindowsForMonitor()) + { + if (win->property(name) == value) + return win; + } + + return nullptr; +} + ApplicationList Manager::GetRunningApplications() const { ApplicationList result; diff --git a/unity-shared/BamfApplicationManager.h b/unity-shared/BamfApplicationManager.h index 822a3b0b2..eac6d2508 100644 --- a/unity-shared/BamfApplicationManager.h +++ b/unity-shared/BamfApplicationManager.h @@ -173,6 +173,7 @@ public: WindowList GetWindowsForMonitor(int monitor = -1) const override; ApplicationPtr GetApplicationForWindow(Window xid) const override; ApplicationWindowPtr GetWindowForId(Window xid) const override; + ApplicationWindowPtr GetWindowForProperty(const std::string& name, const std::string& value) const override; ApplicationPtr EnsureApplication(BamfView*) const; ApplicationWindowPtr EnsureWindow(BamfView*) const; |
