From 2506b2908ba5541f622d58c5ce5e2ba4505f62e8 Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Thu, 12 Jan 2012 22:55:34 -0800 Subject: Couldn't find a signal in nux to handle this anymore, so using a property bool instead (bzr r1827.2.1) --- plugins/unityshell/src/DashSearchBar.cpp | 2 ++ plugins/unityshell/src/DashSearchBar.h | 1 + plugins/unityshell/src/DashView.cpp | 2 ++ plugins/unityshell/src/IMTextEntry.h | 5 +++-- 4 files changed, 8 insertions(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashSearchBar.cpp b/plugins/unityshell/src/DashSearchBar.cpp index 1719c5504..50f50f5d6 100644 --- a/plugins/unityshell/src/DashSearchBar.cpp +++ b/plugins/unityshell/src/DashSearchBar.cpp @@ -55,6 +55,7 @@ SearchBar::SearchBar(NUX_FILE_LINE_DECL) , search_hint("") , showing_filters(false) , can_refine_search(false) + , im_focus(false) , search_bar_width_(642) , live_search_timeout_(0) { @@ -122,6 +123,7 @@ SearchBar::SearchBar(NUX_FILE_LINE_DECL) im_active.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_active)); showing_filters.changed.connect(sigc::mem_fun(this, &SearchBar::OnShowingFiltersChanged)); can_refine_search.changed.connect([&] (bool can_refine) { show_filters_->SetVisible(can_refine); }); + im_focus.changed.connect([&] (bool focus) { focus ? pango_entry_->OnFocusIn() : pango_entry_->OnFocusOut();}); } SearchBar::~SearchBar() diff --git a/plugins/unityshell/src/DashSearchBar.h b/plugins/unityshell/src/DashSearchBar.h index c41b4fb8a..656d9b9e3 100644 --- a/plugins/unityshell/src/DashSearchBar.h +++ b/plugins/unityshell/src/DashSearchBar.h @@ -58,6 +58,7 @@ public: nux::Property search_hint; nux::Property showing_filters; nux::Property can_refine_search; + nux::Property im_focus; nux::ROProperty im_active; sigc::signal activated; diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index 9d6d0d111..e2e94cda1 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -84,12 +84,14 @@ void DashView::AboutToShow() visible_ = true; bg_effect_helper_.enabled = true; search_bar_->text_entry()->SelectAll(); + search_bar_->im_focus = true; } void DashView::AboutToHide() { visible_ = false; bg_effect_helper_.enabled = false; + search_bar_->im_focus = false; } void DashView::SetupBackground() diff --git a/plugins/unityshell/src/IMTextEntry.h b/plugins/unityshell/src/IMTextEntry.h index d36d5b68d..6d2ba30e3 100644 --- a/plugins/unityshell/src/IMTextEntry.h +++ b/plugins/unityshell/src/IMTextEntry.h @@ -46,6 +46,9 @@ public: nux::Property im_enabled; nux::Property im_active; + void OnFocusIn(); + void OnFocusOut(); + private: void CheckIMEnabled(); void SetupSimpleIM(); @@ -65,8 +68,6 @@ private: void OnPreeditStart(GtkIMContext* context); void OnPreeditEnd(GtkIMContext* context); - void OnFocusIn(); - void OnFocusOut(); void UpdateCursorLocation(); void OnMouseButtonUp(int x, int y, unsigned long bflags, unsigned long kflags); -- cgit v1.2.3 From 1cc995ed9e95085fb6f0455d4795c0231abc0694 Mon Sep 17 00:00:00 2001 From: smspillaz Date: Fri, 20 Jan 2012 15:59:04 +0800 Subject: Remove virtual function (bzr r1853.2.2) --- plugins/unityshell/src/compizminimizedwindowhandler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/compizminimizedwindowhandler.h b/plugins/unityshell/src/compizminimizedwindowhandler.h index 8125a036f..28f01b70d 100644 --- a/plugins/unityshell/src/compizminimizedwindowhandler.h +++ b/plugins/unityshell/src/compizminimizedwindowhandler.h @@ -67,7 +67,7 @@ public: typedef std::list List; protected: - virtual std::vector getTransients (); + std::vector getTransients (); private: -- cgit v1.2.3 From 9d44765f436a98f17a095471991d4c76cfcba49a Mon Sep 17 00:00:00 2001 From: smspillaz Date: Fri, 20 Jan 2012 16:14:07 +0800 Subject: Move the unminimize / minimize dance to the minimize window handler destructor, don't care about transients on windows that are destroyed. Fixes LP #881190 (bzr r1853.2.3) --- plugins/unityshell/src/compizminimizedwindowhandler.h | 9 +++++++++ plugins/unityshell/src/comptransientfor.cpp | 7 ++++++- plugins/unityshell/src/transientfor.cpp | 15 +++++++++++---- plugins/unityshell/src/unityshell.cpp | 13 +------------ 4 files changed, 27 insertions(+), 17 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/compizminimizedwindowhandler.h b/plugins/unityshell/src/compizminimizedwindowhandler.h index 28f01b70d..7448855dc 100644 --- a/plugins/unityshell/src/compizminimizedwindowhandler.h +++ b/plugins/unityshell/src/compizminimizedwindowhandler.h @@ -103,6 +103,15 @@ compiz::CompizMinimizedWindowHandler::CompizMinimizedWindowHandl template compiz::CompizMinimizedWindowHandler::~CompizMinimizedWindowHandler () { + if (!priv->mWindow->destroyed ()) + { + priv->mWindow->unminimize (); + priv->mWindow->focusSetEnabled (Window::get (priv->mWindow), false); + priv->mWindow->minimizeSetEnabled (Window::get (priv->mWindow), false); + priv->mWindow->unminimizeSetEnabled (Window::get (priv->mWindow), false); + priv->mWindow->minimize (); + } + minimizedWindows.remove (this); } diff --git a/plugins/unityshell/src/comptransientfor.cpp b/plugins/unityshell/src/comptransientfor.cpp index 356e88638..8901fd4bb 100644 --- a/plugins/unityshell/src/comptransientfor.cpp +++ b/plugins/unityshell/src/comptransientfor.cpp @@ -55,13 +55,18 @@ compiz::CompTransientForReader::getAncestor () bool compiz::CompTransientForReader::isTransientFor (unsigned int ancestor) { + if (!ancestor || + !priv->mWindow->id ()) + return false; + return priv->mWindow->transientFor () == ancestor; } bool compiz::CompTransientForReader::isGroupTransientFor (unsigned int clientLeader) { - if (!clientLeader) + if (!clientLeader || + !priv->mWindow->id ()) return false; if (priv->mWindow->transientFor () == None || priv->mWindow->transientFor () == screen->root ()) diff --git a/plugins/unityshell/src/transientfor.cpp b/plugins/unityshell/src/transientfor.cpp index 321ade6dd..6db032742 100644 --- a/plugins/unityshell/src/transientfor.cpp +++ b/plugins/unityshell/src/transientfor.cpp @@ -51,9 +51,9 @@ compiz::X11TransientForReader::getAncestor () { if (actualType == XA_WINDOW && actualFormat == 32 && nLeft == 0 && nItems == 1) { - Window *data = (Window *) prop; + Window *data = (Window *) prop; - serverAncestor = *data; + serverAncestor = *data; } XFree (prop); @@ -65,6 +65,10 @@ compiz::X11TransientForReader::getAncestor () bool compiz::X11TransientForReader::isTransientFor (unsigned int ancestor) { + if (!ancestor || + !priv->mXid) + return false; + return ancestor == getAncestor (); } @@ -80,14 +84,17 @@ compiz::X11TransientForReader::isGroupTransientFor (unsigned int clientLeader) std::vector strings; std::list atoms; + if (!clientLeader || + !priv->mXid) + if (XGetWindowProperty (priv->mDpy, priv->mXid, wmClientLeader, 0L, 2L, false, XA_WINDOW, &actualType, &actualFormat, &nItems, &nLeft, (unsigned char **)&prop) == Success) { if (actualType == XA_WINDOW && actualFormat == 32 && nLeft == 0 && nItems == 1) { - Window *data = (Window *) prop; + Window *data = (Window *) prop; - serverClientLeader = *data; + serverClientLeader = *data; } XFree (prop); diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 168049cbb..226f0bdc7 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -2500,18 +2500,7 @@ UnityWindow::~UnityWindow() UnityShowdesktopHandler::animating_windows.remove (window); - if (mMinimizeHandler) - { - unminimize (); - window->focusSetEnabled (this, false); - window->minimizeSetEnabled (this, false); - window->unminimizeSetEnabled (this, false); - window->minimizedSetEnabled (this, false); - window->minimize (); - - delete mMinimizeHandler; - mMinimizeHandler = nullptr; - } + delete mMinimizeHandler; if (mShowdesktopHandler) delete mShowdesktopHandler; -- cgit v1.2.3 From e70fab4fe24bf23975791df85becc5955efbfff7 Mon Sep 17 00:00:00 2001 From: smspillaz Date: Thu, 2 Feb 2012 09:49:48 +0800 Subject: Use std::unique_ptr, nullptr (bzr r1853.2.4) --- plugins/unityshell/src/compizminimizedwindowhandler.h | 8 ++++---- plugins/unityshell/src/unityshell.cpp | 11 ++++------- plugins/unityshell/src/unityshell.h | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/compizminimizedwindowhandler.h b/plugins/unityshell/src/compizminimizedwindowhandler.h index 7448855dc..67368bd5c 100644 --- a/plugins/unityshell/src/compizminimizedwindowhandler.h +++ b/plugins/unityshell/src/compizminimizedwindowhandler.h @@ -26,6 +26,7 @@ #include #include "minimizedwindowhandler.h" #include "comptransientfor.h" +#include // Will be merged back into compiz namespace compiz { @@ -167,7 +168,7 @@ compiz::CompizMinimizedWindowHandler::minimize () { Window *w = Window::get (win); if (!w->mMinimizeHandler) - w->mMinimizeHandler = new Type (win); + w->mMinimizeHandler = std::unique_ptr (new Type (win)); w->mMinimizeHandler->minimize (); } } @@ -250,8 +251,7 @@ compiz::CompizMinimizedWindowHandler::unminimize () if (w && w->mMinimizeHandler) { w->mMinimizeHandler->unminimize (); - delete w->mMinimizeHandler; - w->mMinimizeHandler = NULL; + w->mMinimizeHandler.release (); } } } @@ -333,7 +333,7 @@ compiz::CompizMinimizedWindowHandler::handleEvent (XEvent *event if (w) { Window *pw = Window::get (w); - Type *compizMinimizeHandler = pw->mMinimizeHandler; + Type *compizMinimizeHandler = pw->mMinimizeHandler.get (); /* Restore and re-save input shape and remove */ if (compizMinimizeHandler) diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 226f0bdc7..84f0fe3e4 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -1811,7 +1811,7 @@ UnityWindow::minimize () if (!mMinimizeHandler) { - mMinimizeHandler = new UnityMinimizedHandler (window); + mMinimizeHandler = std::unique_ptr (new UnityMinimizedHandler (window)); mMinimizeHandler->minimize (); } } @@ -1822,8 +1822,7 @@ UnityWindow::unminimize () if (mMinimizeHandler) { mMinimizeHandler->unminimize (); - delete mMinimizeHandler; - mMinimizeHandler = nullptr; + mMinimizeHandler.release (); } } @@ -1862,7 +1861,7 @@ UnityWindow::focus () bool UnityWindow::minimized () { - return mMinimizeHandler != nullptr; + return mMinimizeHandler.get () != nullptr; } gboolean @@ -2442,7 +2441,7 @@ UnityWindow::UnityWindow(CompWindow* window) , PluginClassHandler(window) , window(window) , gWindow(GLWindow::get(window)) - , mMinimizeHandler(nullptr) + , mMinimizeHandler() , mShowdesktopHandler(nullptr) , focusdesktop_handle_(0) { @@ -2500,8 +2499,6 @@ UnityWindow::~UnityWindow() UnityShowdesktopHandler::animating_windows.remove (window); - delete mMinimizeHandler; - if (mShowdesktopHandler) delete mShowdesktopHandler; diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index d81b1de29..628996c61 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -378,7 +378,7 @@ public: typedef compiz::CompizMinimizedWindowHandler UnityMinimizedHandler; - UnityMinimizedHandler *mMinimizeHandler; + std::unique_ptr mMinimizeHandler; UnityShowdesktopHandler *mShowdesktopHandler; -- cgit v1.2.3 From 1c2a58355899bb8df46dc25d601750e23bcb4be6 Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Wed, 1 Feb 2012 20:01:30 -0800 Subject: Changed to use a signal. (bzr r1827.2.2) --- plugins/unityshell/src/DashSearchBar.cpp | 2 -- plugins/unityshell/src/DashSearchBar.h | 1 - plugins/unityshell/src/DashView.cpp | 2 -- plugins/unityshell/src/IMTextEntry.cpp | 1 + plugins/unityshell/src/IMTextEntry.h | 6 +++--- 5 files changed, 4 insertions(+), 8 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashSearchBar.cpp b/plugins/unityshell/src/DashSearchBar.cpp index 50f50f5d6..1719c5504 100644 --- a/plugins/unityshell/src/DashSearchBar.cpp +++ b/plugins/unityshell/src/DashSearchBar.cpp @@ -55,7 +55,6 @@ SearchBar::SearchBar(NUX_FILE_LINE_DECL) , search_hint("") , showing_filters(false) , can_refine_search(false) - , im_focus(false) , search_bar_width_(642) , live_search_timeout_(0) { @@ -123,7 +122,6 @@ SearchBar::SearchBar(NUX_FILE_LINE_DECL) im_active.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_active)); showing_filters.changed.connect(sigc::mem_fun(this, &SearchBar::OnShowingFiltersChanged)); can_refine_search.changed.connect([&] (bool can_refine) { show_filters_->SetVisible(can_refine); }); - im_focus.changed.connect([&] (bool focus) { focus ? pango_entry_->OnFocusIn() : pango_entry_->OnFocusOut();}); } SearchBar::~SearchBar() diff --git a/plugins/unityshell/src/DashSearchBar.h b/plugins/unityshell/src/DashSearchBar.h index 656d9b9e3..c41b4fb8a 100644 --- a/plugins/unityshell/src/DashSearchBar.h +++ b/plugins/unityshell/src/DashSearchBar.h @@ -58,7 +58,6 @@ public: nux::Property search_hint; nux::Property showing_filters; nux::Property can_refine_search; - nux::Property im_focus; nux::ROProperty im_active; sigc::signal activated; diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index e2e94cda1..9d6d0d111 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -84,14 +84,12 @@ void DashView::AboutToShow() visible_ = true; bg_effect_helper_.enabled = true; search_bar_->text_entry()->SelectAll(); - search_bar_->im_focus = true; } void DashView::AboutToHide() { visible_ = false; bg_effect_helper_.enabled = false; - search_bar_->im_focus = false; } void DashView::SetupBackground() diff --git a/plugins/unityshell/src/IMTextEntry.cpp b/plugins/unityshell/src/IMTextEntry.cpp index 6732c0a7d..061844ea9 100644 --- a/plugins/unityshell/src/IMTextEntry.cpp +++ b/plugins/unityshell/src/IMTextEntry.cpp @@ -50,6 +50,7 @@ IMTextEntry::IMTextEntry() CheckIMEnabled(); im_enabled ? SetupMultiIM() : SetupSimpleIM(); + OnKeyNavFocusChange.connect([&] (nux::Area*) { HasKeyFocus() ? OnFocusIn() : OnFocusOut(); }); mouse_up.connect(sigc::mem_fun(this, &IMTextEntry::OnMouseButtonUp)); } diff --git a/plugins/unityshell/src/IMTextEntry.h b/plugins/unityshell/src/IMTextEntry.h index 6d2ba30e3..97bae264c 100644 --- a/plugins/unityshell/src/IMTextEntry.h +++ b/plugins/unityshell/src/IMTextEntry.h @@ -46,9 +46,6 @@ public: nux::Property im_enabled; nux::Property im_active; - void OnFocusIn(); - void OnFocusOut(); - private: void CheckIMEnabled(); void SetupSimpleIM(); @@ -68,6 +65,9 @@ private: void OnPreeditStart(GtkIMContext* context); void OnPreeditEnd(GtkIMContext* context); + void OnFocusIn(); + void OnFocusOut(); + void UpdateCursorLocation(); void OnMouseButtonUp(int x, int y, unsigned long bflags, unsigned long kflags); -- cgit v1.2.3 From e16abbb47f30e94c86e9ddb092790ad671e739de Mon Sep 17 00:00:00 2001 From: Michal Hruby Date: Thu, 2 Feb 2012 11:00:47 +0100 Subject: Make sure we don't load the same icon multiple times Fixes LP: #922074 (bzr r1886.4.1) --- plugins/unityshell/src/IconLoader.cpp | 54 ++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/IconLoader.cpp b/plugins/unityshell/src/IconLoader.cpp index 423a3d6bd..e8d4be723 100644 --- a/plugins/unityshell/src/IconLoader.cpp +++ b/plugins/unityshell/src/IconLoader.cpp @@ -76,6 +76,9 @@ private: REQUEST_TYPE_URI, }; + struct IconLoaderTask; + typedef std::list TaskList; + struct IconLoaderTask { IconLoaderRequestType type; @@ -88,6 +91,7 @@ private: GtkIconInfo* icon_info; GdkPixbuf* result; glib::Error error; + TaskList shadow_tasks; IconLoaderTask(IconLoaderRequestType type_, std::string const& data_, @@ -100,6 +104,22 @@ private: , slot(slot_), handle(handle_), self(self_) , icon_info(NULL), result(NULL) {} + + void InvokeSlot(GdkPixbuf* pixbuf) + { + slot(data, size, pixbuf); + + // notify shadow tasks + for (auto shadow_task : shadow_tasks) + { + shadow_task->slot(shadow_task->data, shadow_task->size, pixbuf); + + self->task_map_.erase(shadow_task->handle); + delete shadow_task; + } + + shadow_tasks.clear(); + } }; Handle ReturnCachedOrQueue(std::string const& data, @@ -139,6 +159,8 @@ private: private: typedef std::map> ImageCache; ImageCache cache_; + typedef std::map CacheQueue; + CacheQueue queued_tasks_; typedef std::queue TaskQueue; TaskQueue tasks_; typedef std::map TaskMap; @@ -260,6 +282,28 @@ int IconLoader::Impl::QueueTask(std::string const& key, { IconLoaderTask* task = new IconLoaderTask(type, data, size, key, slot, ++handle_counter_, this); + + auto iter = queued_tasks_.find(key); + bool already_queued = iter != queued_tasks_.end(); + IconLoaderTask* running_task = already_queued ? iter->second : NULL; + + if (running_task != NULL) + { + running_task->shadow_tasks.push_back(task); + // do NOT push the task into the tasks queue, + // the parent task (which is in the queue) will handle it + task_map_[task->handle] = task; + + LOG_DEBUG(logger) << "Appending shadow task " << data + << ", queue size now at " << tasks_.size(); + + return task->handle; + } + else + { + queued_tasks_[key] = task; + } + tasks_.push(task); task_map_[task->handle] = task; @@ -317,7 +361,7 @@ bool IconLoader::Impl::ProcessTask(IconLoaderTask* task) LOG_WARNING(logger) << "Request type " << task->type << " is not supported (" << task->data << " " << task->size << ")"; - task->slot(task->data, task->size, nullptr); + task->InvokeSlot(nullptr); return true; } @@ -341,7 +385,7 @@ bool IconLoader::Impl::ProcessIconNameTask(IconLoaderTask* task) << " at size " << task->size; } - task->slot(task->data, task->size, nullptr); + task->InvokeSlot(nullptr); return true; } @@ -402,7 +446,7 @@ bool IconLoader::Impl::ProcessGIconTask(IconLoaderTask* task) << " at size " << task->size << ": " << error; } - task->slot(task->data, task->size, nullptr); + task->InvokeSlot(nullptr); return true; } @@ -493,10 +537,11 @@ gboolean IconLoader::Impl::CoalesceTasksCb(IconLoader::Impl* self) << " at size " << task->size << ": " << task->error; } - task->slot(task->data, task->size, task->result); + task->InvokeSlot(task->result); // this was all async, we need to erase the task from the task_map self->task_map_.erase(task->handle); + self->queued_tasks_.erase(task->key); delete task; } @@ -521,6 +566,7 @@ bool IconLoader::Impl::Iteration() if (ProcessTask(task)) { task_map_.erase(task->handle); + queued_tasks_.erase(task->key); delete task; } -- cgit v1.2.3 From 4b48e8eca33d7d56308ff1c879321bdd23922d2a Mon Sep 17 00:00:00 2001 From: smspillaz Date: Tue, 7 Feb 2012 11:55:40 +0800 Subject: Cleanup (bzr r1853.2.5) --- plugins/unityshell/src/compizminimizedwindowhandler.h | 4 ++-- plugins/unityshell/src/transientfor.cpp | 8 ++++---- plugins/unityshell/src/unityshell.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/compizminimizedwindowhandler.h b/plugins/unityshell/src/compizminimizedwindowhandler.h index 67368bd5c..f9da351ff 100644 --- a/plugins/unityshell/src/compizminimizedwindowhandler.h +++ b/plugins/unityshell/src/compizminimizedwindowhandler.h @@ -168,7 +168,7 @@ compiz::CompizMinimizedWindowHandler::minimize () { Window *w = Window::get (win); if (!w->mMinimizeHandler) - w->mMinimizeHandler = std::unique_ptr (new Type (win)); + w->mMinimizeHandle.reset (new Type (win)); w->mMinimizeHandler->minimize (); } } @@ -251,7 +251,7 @@ compiz::CompizMinimizedWindowHandler::unminimize () if (w && w->mMinimizeHandler) { w->mMinimizeHandler->unminimize (); - w->mMinimizeHandler.release (); + w->mMinimizeHandler.release (); } } } diff --git a/plugins/unityshell/src/transientfor.cpp b/plugins/unityshell/src/transientfor.cpp index 6db032742..66536fc1a 100644 --- a/plugins/unityshell/src/transientfor.cpp +++ b/plugins/unityshell/src/transientfor.cpp @@ -51,7 +51,7 @@ compiz::X11TransientForReader::getAncestor () { if (actualType == XA_WINDOW && actualFormat == 32 && nLeft == 0 && nItems == 1) { - Window *data = (Window *) prop; + Window *data = static_cast (prop); serverAncestor = *data; } @@ -92,7 +92,7 @@ compiz::X11TransientForReader::isGroupTransientFor (unsigned int clientLeader) { if (actualType == XA_WINDOW && actualFormat == 32 && nLeft == 0 && nItems == 1) { - Window *data = (Window *) prop; + Window *data = static_cast (prop); serverClientLeader = *data; } @@ -130,7 +130,7 @@ compiz::X11TransientForReader::isGroupTransientFor (unsigned int clientLeader) { if (actualType == XA_ATOM && actualFormat == 32 && nLeft == 0 && nItems) { - Atom *data = (Atom *) prop; + Atom *data = static_cast (prop); while (nItems--) { @@ -167,7 +167,7 @@ compiz::X11TransientForReader::getTransients () { if (actualType == XA_WINDOW && actualFormat == 32 && nItems && !nLeft) { - Window *data = (Window *) prop; + Window *data = static_cast (prop); while (nItems--) { diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 84f0fe3e4..99fc04088 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -1822,7 +1822,7 @@ UnityWindow::unminimize () if (mMinimizeHandler) { mMinimizeHandler->unminimize (); - mMinimizeHandler.release (); + mMinimizeHandler.reset (); } } @@ -1861,7 +1861,7 @@ UnityWindow::focus () bool UnityWindow::minimized () { - return mMinimizeHandler.get () != nullptr; + return mMinimizeHandler; } gboolean -- cgit v1.2.3 From 0ee370342f0b8f225d07b99d84a0e08da715a0fc Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Tue, 7 Feb 2012 18:45:03 +0000 Subject: dash resizing active (bzr r1900.1.1) --- plugins/unityshell/src/DashView.cpp | 98 +++++++++++++++++++++++++++++--- plugins/unityshell/src/DashView.h | 8 +++ plugins/unityshell/src/HudController.cpp | 5 ++ plugins/unityshell/src/HudView.cpp | 1 + plugins/unityshell/src/LensView.cpp | 46 ++++++++++++++- plugins/unityshell/src/LensView.h | 2 + 6 files changed, 151 insertions(+), 9 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index bde256eee..3719f5614 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -41,6 +41,7 @@ namespace dash namespace { nux::logging::Logger logger("unity.dash.view"); +const int grow_anim_length = 90 * 1000; } NUX_IMPLEMENT_OBJECT_TYPE(DashView); @@ -54,6 +55,11 @@ DashView::DashView() , search_in_progress_(false) , activate_on_finish_(false) , visible_(false) + , timeline_id_(0) + , start_time_(0) + , last_known_height_(0) + , current_height_(0) + , timeline_need_more_draw_(false) { renderer_.SetOwner(this); renderer_.need_redraw.connect([this] () { @@ -85,6 +91,39 @@ void DashView::SetMonitorOffset(int x, int y) renderer_.y_offset = y; } +void DashView::ProcessGrowShrink() +{ + float diff = g_get_monotonic_time() - start_time_; + float progress = diff / grow_anim_length; + int last_height = last_known_height_; + int new_height = 0; + int target_height = content_layout_->GetGeometry().height; + + if (last_height < target_height) + { + // grow + new_height = last_height + ((target_height - last_height) * progress); + } + else + { + //shrink + new_height = last_height - ((last_height - target_height) * progress); + } + + LOG_DEBUG(logger) << "resizing to " << target_height << " (" << new_height << ")"; + + current_height_ = new_height; + QueueDraw(); + + if (diff > grow_anim_length) + { + // ensure we are at our final location and update last known height + current_height_ = target_height; + last_known_height_ = target_height; + timeline_need_more_draw_ = false; + } +} + void DashView::AboutToShow() { ubus_manager_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT); @@ -136,7 +175,7 @@ void DashView::SetupViews() content_layout_->SetHorizontalExternalMargin(0); content_layout_->SetVerticalExternalMargin(0); - layout_->AddLayout(content_layout_, 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL); + layout_->AddLayout(content_layout_, 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL); search_bar_ = new SearchBar(); AddChild(search_bar_); search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated)); @@ -146,7 +185,7 @@ void DashView::SetupViews() content_layout_->AddView(search_bar_, 0, nux::MINOR_POSITION_LEFT); lenses_layout_ = new nux::VLayout(); - content_layout_->AddView(lenses_layout_, 1, nux::MINOR_POSITION_LEFT); + content_layout_->AddView(lenses_layout_, 0, nux::MINOR_POSITION_LEFT); home_view_ = new LensView(home_lens_); active_lens_view_ = home_view_; @@ -167,6 +206,22 @@ void DashView::SetupUBusConnections() long DashView::PostLayoutManagement (long LayoutResult) { Relayout(); + if (content_layout_->GetGeometry().height != last_known_height_) + { + // Start the timeline of drawing the dash resize + if (timeline_need_more_draw_) + { + // already started, just reset the last known height + last_known_height_ = current_height_; + } + else + { + timeline_need_more_draw_ = true; + QueueDraw(); + } + start_time_ = g_get_monotonic_time(); + } + return LayoutResult; } @@ -184,10 +239,13 @@ void DashView::Relayout() // kinda hacky, but it makes sure the content isn't so big that it throws // the bottom of the dash off the screen // not hugely happy with this, so FIXME - lenses_layout_->SetMaximumHeight (content_geo_.height - search_bar_->GetGeometry().height - lens_bar_->GetGeometry().height); - lenses_layout_->SetMinimumHeight (content_geo_.height - search_bar_->GetGeometry().height - lens_bar_->GetGeometry().height); + lenses_layout_->SetMaximumHeight(content_geo_.height - search_bar_->GetGeometry().height - lens_bar_->GetGeometry().height); + lenses_layout_->SetMinimumWidth(content_geo_.width); + lenses_layout_->SetMaximumWidth(content_geo_.width); + layout_->SetMaximumWidth(content_geo_.width); + //lenses_layout_->SetMinimumHeight (content_geo_.height - search_bar_->GetGeometry().height - lens_bar_->GetGeometry().height); - layout_->SetMinMaxSize(content_geo_.width, content_geo_.height); + //layout_->SetMinMaxSize(content_geo_.width, content_geo_.height); dash::Style& style = dash::Style::Instance(); @@ -237,13 +295,24 @@ nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo) void DashView::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) { - renderer_.DrawFull(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry()); + nux::Geometry draw_content_geo = content_geo_; + draw_content_geo.height = current_height_; + renderer_.DrawFull(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); } void DashView::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) { - renderer_.DrawInner(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry()); + if (timeline_need_more_draw_) + { + // process our animation + ProcessGrowShrink(); + } + + nux::Geometry draw_content_geo = content_geo_; + draw_content_geo.height = current_height_; + renderer_.DrawInner(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); + gfx_context.PushClippingRectangle(draw_content_geo); if (IsFullRedraw()) { nux::GetPainter().PushBackgroundStack(); @@ -254,8 +323,21 @@ void DashView::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) { layout_->ProcessDraw(gfx_context, force_draw); } + gfx_context.PopClippingRectangle(); - renderer_.DrawInnerCleanup(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry()); + renderer_.DrawInnerCleanup(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); + + + if (timeline_need_more_draw_ && !timeline_id_) + { + // timeline is still running, queue up another draw + timeline_id_ = g_timeout_add(0, [] (gpointer data) -> gboolean { + DashView* self = static_cast(data); + self->QueueDraw(); + self->timeline_id_ = 0; + return FALSE; + }, this); + } } void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) diff --git a/plugins/unityshell/src/DashView.h b/plugins/unityshell/src/DashView.h index 80b64ada5..1602c84f4 100644 --- a/plugins/unityshell/src/DashView.h +++ b/plugins/unityshell/src/DashView.h @@ -97,6 +97,8 @@ private: void UpdateLensFilter(std::string lens, std::string filter, std::string value); void UpdateLensFilterValue(Filter::Ptr filter, std::string value); void EnsureLensesInitialized(); + + void ProcessGrowShrink(); bool AcceptKeyNavFocus(); bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character); @@ -135,6 +137,12 @@ private: bool activate_on_finish_; bool visible_; + + guint timeline_id_; + gint64 start_time_; + int last_known_height_; + int current_height_; + bool timeline_need_more_draw_; }; diff --git a/plugins/unityshell/src/HudController.cpp b/plugins/unityshell/src/HudController.cpp index bf02375f2..616ee26c5 100644 --- a/plugins/unityshell/src/HudController.cpp +++ b/plugins/unityshell/src/HudController.cpp @@ -214,8 +214,13 @@ bool Controller::IsVisible() void Controller::ShowHud() { + PluginAdapter* adaptor = PluginAdapter::Default(); LOG_DEBUG(logger) << "Showing the hud"; EnsureHud(); + + if (visible_ || adaptor->IsExpoActive() || adaptor->IsScaleActive()) + return; + view_->AboutToShow(); window_->ShowWindow(true); diff --git a/plugins/unityshell/src/HudView.cpp b/plugins/unityshell/src/HudView.cpp index 3abbd01c8..b4a824c05 100644 --- a/plugins/unityshell/src/HudView.cpp +++ b/plugins/unityshell/src/HudView.cpp @@ -88,6 +88,7 @@ View::~View() } } + void View::ResetToDefault() { search_bar_->search_string = ""; diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index b3ddda08d..f6383bb1f 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -86,6 +86,7 @@ LensView::LensView() , filters_expanded(false) , can_refine_search(false) , fix_renderering_id_(0) + , ensure_size_id_(0) {} LensView::LensView(Lens::Ptr lens) @@ -96,6 +97,7 @@ LensView::LensView(Lens::Ptr lens) , lens_(lens) , initial_activation_(true) , fix_renderering_id_(0) + , ensure_size_id_(0) { SetupViews(); SetupCategories(); @@ -208,7 +210,8 @@ void LensView::OnCategoryAdded(Category const& category) std::string renderer_name = category.renderer_name; int index = category.index; - LOG_DEBUG(logger) << "Category added: " << name + LOG_DEBUG(logger) << "(" << this << " - " << lens_->name() << ")" + << "Category added: " << name << "(" << icon_hint << ", " << renderer_name << ", " << boost::lexical_cast(index) << ")"; @@ -242,6 +245,7 @@ void LensView::OnCategoryAdded(Category const& category) scroll_layout_->AddView(group, 0, nux::MinorDimensionPosition::eAbove, nux::MinorDimensionSize::eFull, 100.0f, (nux::LayoutPosition)index); + EnsureSize(); } void LensView::OnResultAdded(Result const& result) @@ -261,6 +265,8 @@ void LensView::OnResultAdded(Result const& result) << boost::lexical_cast(result.category_index) << ". Is out of range."; } + + EnsureSize(); } void LensView::OnResultRemoved(Result const& result) @@ -280,6 +286,43 @@ void LensView::OnResultRemoved(Result const& result) << boost::lexical_cast(result.category_index) << ". Is out of range."; } + + EnsureSize(); +} + +void LensView::EnsureSize() +{ + // actually queue this method + if (ensure_size_id_) + return; + + auto queued_lambda = [] (gpointer data) -> gboolean + { + LensView* self = static_cast(data); + int height = 0; + + for (auto category = self->categories_.begin(); category != self->categories_.end(); category++) + { + PlacesGroup* group = (*category); + if (group->IsVisible()) + { + height += group->GetMinimumHeight(); + height += group->GetChildView()->GetMinimumHeight(); + height += 24; + LOG_DEBUG(logger) << "got category (" << group->GetMinimumHeight() + group->GetChildView()->GetMinimumHeight()<< ")"; + } + + } + self->SetMinimumHeight(height); + + LOG_DEBUG(logger) << "Maximum height for lens: " + << self->lens_->name() + << " (" << height << ")"; + self->ensure_size_id_ = 0; + return FALSE; + }; + + ensure_size_id_ = g_idle_add_full (G_PRIORITY_DEFAULT, queued_lambda, this, NULL); } void LensView::UpdateCounts(PlacesGroup* group) @@ -325,6 +368,7 @@ void LensView::OnGroupExpanded(PlacesGroup* group) { ResultViewGrid* grid = static_cast(group->GetChildView()); grid->expanded = group->GetExpanded(); + EnsureSize(); ubus_manager_.SendMessage(UBUS_PLACE_VIEW_QUEUE_DRAW); } diff --git a/plugins/unityshell/src/LensView.h b/plugins/unityshell/src/LensView.h index 9176f13d4..5d75af394 100644 --- a/plugins/unityshell/src/LensView.h +++ b/plugins/unityshell/src/LensView.h @@ -79,6 +79,7 @@ private: void OnFilterAdded(Filter::Ptr filter); void OnFilterRemoved(Filter::Ptr filter); void OnViewTypeChanged(ViewType view_type); + void EnsureSize(); void QueueFixRenderering(); static gboolean FixRenderering(LensView* self); @@ -105,6 +106,7 @@ private: FilterBar* filter_bar_; guint fix_renderering_id_; + guint ensure_size_id_; UBusManager ubus_; }; -- cgit v1.2.3 From cb19072b4b6ac7fe77f2c872259419d035464ef9 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Tue, 7 Feb 2012 18:50:06 +0000 Subject: dash resizing active (bzr r1900.1.2) --- plugins/unityshell/src/DashView.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index 3719f5614..27698212d 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -295,6 +295,12 @@ nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo) void DashView::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) { + if (timeline_need_more_draw_) + { + // process our animation + ProcessGrowShrink(); + } + nux::Geometry draw_content_geo = content_geo_; draw_content_geo.height = current_height_; renderer_.DrawFull(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); @@ -302,12 +308,6 @@ void DashView::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) void DashView::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) { - if (timeline_need_more_draw_) - { - // process our animation - ProcessGrowShrink(); - } - nux::Geometry draw_content_geo = content_geo_; draw_content_geo.height = current_height_; renderer_.DrawInner(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); -- cgit v1.2.3 From e2e526cb62215957a34f4395596d2793b20d214a Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Tue, 7 Feb 2012 19:43:57 +0000 Subject: fixed a few sizing issues, redraw issues (bzr r1900.1.3) --- plugins/unityshell/src/LensView.cpp | 20 +++++++++++++++----- plugins/unityshell/src/LensView.h | 3 +++ 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index f6383bb1f..87dba1159 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -290,6 +290,12 @@ void LensView::OnResultRemoved(Result const& result) EnsureSize(); } +long LensView::PostLayoutManagement (long LayoutResult) +{ + EnsureSize(); + return View::PostLayoutManagement(LayoutResult); +} + void LensView::EnsureSize() { // actually queue this method @@ -313,11 +319,15 @@ void LensView::EnsureSize() } } - self->SetMinimumHeight(height); - - LOG_DEBUG(logger) << "Maximum height for lens: " - << self->lens_->name() - << " (" << height << ")"; + + if (self->GetMinimumHeight() != height) + { + self->SetMinimumHeight(height); + LOG_DEBUG(logger) << "Maximum height for lens: " + << self->lens_->name() + << " (" << height << ")"; + } + self->ensure_size_id_ = 0; return FALSE; }; diff --git a/plugins/unityshell/src/LensView.h b/plugins/unityshell/src/LensView.h index 5d75af394..8e133cc3b 100644 --- a/plugins/unityshell/src/LensView.h +++ b/plugins/unityshell/src/LensView.h @@ -64,6 +64,9 @@ public: sigc::signal uri_activated; +protected: + virtual long PostLayoutManagement(long LayoutResult); + private: void SetupViews(); void SetupCategories(); -- cgit v1.2.3 From 2eeeef6c4f16d063f2351b58000c6f8d9feaa238 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Wed, 8 Feb 2012 11:24:57 +0000 Subject: implimented a pause before resizing (bzr r1900.1.4) --- plugins/unityshell/src/DashView.cpp | 87 +++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 37 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index 27698212d..fab22bad5 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -42,6 +42,7 @@ namespace { nux::logging::Logger logger("unity.dash.view"); const int grow_anim_length = 90 * 1000; +const int pause_before_grow_length = 32 * 1000; } NUX_IMPLEMENT_OBJECT_TYPE(DashView); @@ -94,28 +95,33 @@ void DashView::SetMonitorOffset(int x, int y) void DashView::ProcessGrowShrink() { float diff = g_get_monotonic_time() - start_time_; - float progress = diff / grow_anim_length; - int last_height = last_known_height_; - int new_height = 0; int target_height = content_layout_->GetGeometry().height; - - if (last_height < target_height) - { - // grow - new_height = last_height + ((target_height - last_height) * progress); - } - else - { - //shrink - new_height = last_height - ((last_height - target_height) * progress); + // only animate if we are after our defined pause time + if (diff > pause_before_grow_length) + { + float progress = (diff - pause_before_grow_length) / grow_anim_length; + int last_height = last_known_height_; + int new_height = 0; + + if (last_height < target_height) + { + // grow + new_height = last_height + ((target_height - last_height) * progress); + } + else + { + //shrink + new_height = last_height - ((last_height - target_height) * progress); + } + + LOG_DEBUG(logger) << "resizing to " << target_height << " (" << new_height << ")"; + + current_height_ = new_height; } - LOG_DEBUG(logger) << "resizing to " << target_height << " (" << new_height << ")"; - - current_height_ = new_height; QueueDraw(); - if (diff > grow_anim_length) + if (diff > grow_anim_length + pause_before_grow_length) { // ensure we are at our final location and update last known height current_height_ = target_height; @@ -170,31 +176,38 @@ void DashView::SetupViews() { layout_ = new nux::VLayout(); SetLayout(layout_); - + content_layout_ = new nux::VLayout(); content_layout_->SetHorizontalExternalMargin(0); content_layout_->SetVerticalExternalMargin(0); + + { + // Add layouts/views to content_layout_ + search_bar_ = new SearchBar(); + AddChild(search_bar_); + search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated)); + search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged)); + search_bar_->live_search_reached.connect(sigc::mem_fun(this, &DashView::OnLiveSearchReached)); + search_bar_->showing_filters.changed.connect([&] (bool showing) { if (active_lens_view_) active_lens_view_->filters_expanded = showing; QueueDraw(); }); + content_layout_->AddView(search_bar_, 0, nux::MINOR_POSITION_LEFT); + lenses_layout_ = new nux::VLayout(); + { + // Add layouts/views to lenses_layout_ + home_view_ = new LensView(home_lens_); + active_lens_view_ = home_view_; + lens_views_[home_lens_->id] = home_view_; + lenses_layout_->AddView(home_view_); + } + + content_layout_->AddView(lenses_layout_, 0, nux::MINOR_POSITION_LEFT); + + lens_bar_ = new LensBar(); + lens_bar_->lens_activated.connect(sigc::mem_fun(this, &DashView::OnLensBarActivated)); + content_layout_->AddView(lens_bar_, 0, nux::MINOR_POSITION_CENTER); + } + layout_->AddLayout(content_layout_, 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL); - search_bar_ = new SearchBar(); - AddChild(search_bar_); - search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated)); - search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged)); - search_bar_->live_search_reached.connect(sigc::mem_fun(this, &DashView::OnLiveSearchReached)); - search_bar_->showing_filters.changed.connect([&] (bool showing) { if (active_lens_view_) active_lens_view_->filters_expanded = showing; QueueDraw(); }); - content_layout_->AddView(search_bar_, 0, nux::MINOR_POSITION_LEFT); - - lenses_layout_ = new nux::VLayout(); - content_layout_->AddView(lenses_layout_, 0, nux::MINOR_POSITION_LEFT); - - home_view_ = new LensView(home_lens_); - active_lens_view_ = home_view_; - lens_views_[home_lens_->id] = home_view_; - lenses_layout_->AddView(home_view_); - - lens_bar_ = new LensBar(); - lens_bar_->lens_activated.connect(sigc::mem_fun(this, &DashView::OnLensBarActivated)); - content_layout_->AddView(lens_bar_, 0, nux::MINOR_POSITION_CENTER); } void DashView::SetupUBusConnections() -- cgit v1.2.3 From 53a978d7fb832c6c9e46e41a3d4ffb97fbc2996d Mon Sep 17 00:00:00 2001 From: smspillaz Date: Wed, 8 Feb 2012 20:59:20 +0800 Subject: Fix typo (bzr r1905.1.3) --- plugins/unityshell/src/compizminimizedwindowhandler.h | 2 +- plugins/unityshell/src/unityshell.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/compizminimizedwindowhandler.h b/plugins/unityshell/src/compizminimizedwindowhandler.h index f9da351ff..bdd583ee1 100644 --- a/plugins/unityshell/src/compizminimizedwindowhandler.h +++ b/plugins/unityshell/src/compizminimizedwindowhandler.h @@ -168,7 +168,7 @@ compiz::CompizMinimizedWindowHandler::minimize () { Window *w = Window::get (win); if (!w->mMinimizeHandler) - w->mMinimizeHandle.reset (new Type (win)); + w->mMinimizeHandler.reset (new Type (win)); w->mMinimizeHandler->minimize (); } } diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 3149fbc93..2863a8b37 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -2054,7 +2054,7 @@ UnityWindow::focus () bool UnityWindow::minimized () { - return mMinimizeHandler; + return mMinimizeHandler.get () != nullptr; } gboolean -- cgit v1.2.3 From 36a12baa6477c568f921d77692c6434b93a429e0 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Wed, 8 Feb 2012 17:17:15 +0000 Subject: fixed a stupid bug that caused the dash to constantly relayout whenever there were 0 results (bzr r1900.1.5) --- plugins/unityshell/src/DashView.cpp | 25 +++++++++++++++---------- plugins/unityshell/src/LensView.cpp | 11 ++++------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index fab22bad5..92bebe404 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -115,7 +115,6 @@ void DashView::ProcessGrowShrink() } LOG_DEBUG(logger) << "resizing to " << target_height << " (" << new_height << ")"; - current_height_ = new_height; } @@ -218,22 +217,21 @@ void DashView::SetupUBusConnections() long DashView::PostLayoutManagement (long LayoutResult) { + LOG_DEBUG(logger) << "got post layout management " << content_layout_->GetGeometry().height; Relayout(); - if (content_layout_->GetGeometry().height != last_known_height_) - { + //if (content_layout_->GetGeometry().height != last_known_height_) + //{ // Start the timeline of drawing the dash resize if (timeline_need_more_draw_) { // already started, just reset the last known height last_known_height_ = current_height_; } - else - { - timeline_need_more_draw_ = true; - QueueDraw(); - } + + timeline_need_more_draw_ = true; start_time_ = g_get_monotonic_time(); - } + QueueDraw(); + //} return LayoutResult; } @@ -248,7 +246,6 @@ void DashView::Relayout() if (geo.width >= content_geo_.width && geo.height > content_geo_.height) content_geo_ = geo; } - // kinda hacky, but it makes sure the content isn't so big that it throws // the bottom of the dash off the screen // not hugely happy with this, so FIXME @@ -256,6 +253,7 @@ void DashView::Relayout() lenses_layout_->SetMinimumWidth(content_geo_.width); lenses_layout_->SetMaximumWidth(content_geo_.width); layout_->SetMaximumWidth(content_geo_.width); + //lenses_layout_->SetMinimumHeight (content_geo_.height - search_bar_->GetGeometry().height - lens_bar_->GetGeometry().height); //layout_->SetMinMaxSize(content_geo_.width, content_geo_.height); @@ -269,6 +267,10 @@ void DashView::Relayout() ubus_manager_.SendMessage(UBUS_DASH_SIZE_CHANGED, g_variant_new("(ii)", content_geo_.width, content_geo_.height)); QueueDraw(); + + //LOG_DEBUG(logger) << "Layout size: " << layout_->GetGeometry().height; + //LOG_DEBUG(logger) << "lenses_layout size: " << layout_->GetGeometry().height; + } // Gives us the width and height of the contents that will give us the best "fit", @@ -522,6 +524,9 @@ void DashView::OnSearchFinished(Lens::Hints const& hints) if (it != hints.end()) { LOG_DEBUG(logger) << "We have no-results-hint: " << g_variant_get_string (it->second, NULL); + // force relayout + QueueRelayout(); + } std::string search_string = search_bar_->search_string; diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index 87dba1159..556e7bdaf 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -265,7 +265,6 @@ void LensView::OnResultAdded(Result const& result) << boost::lexical_cast(result.category_index) << ". Is out of range."; } - EnsureSize(); } @@ -286,7 +285,7 @@ void LensView::OnResultRemoved(Result const& result) << boost::lexical_cast(result.category_index) << ". Is out of range."; } - + EnsureSize(); } @@ -315,17 +314,15 @@ void LensView::EnsureSize() height += group->GetMinimumHeight(); height += group->GetChildView()->GetMinimumHeight(); height += 24; - LOG_DEBUG(logger) << "got category (" << group->GetMinimumHeight() + group->GetChildView()->GetMinimumHeight()<< ")"; } } - + + height = std::max(height, 1); // hack because nux does not like heights < 1 + if (self->GetMinimumHeight() != height) { self->SetMinimumHeight(height); - LOG_DEBUG(logger) << "Maximum height for lens: " - << self->lens_->name() - << " (" << height << ")"; } self->ensure_size_id_ = 0; -- cgit v1.2.3 From 281a6408d547d5bf84abcb1b8958ed147c17438d Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Wed, 8 Feb 2012 17:22:33 +0000 Subject: fixed a stupid bug that caused the dash to constantly relayout whenever there were 0 results (bzr r1900.1.6) --- plugins/unityshell/src/LensView.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index 556e7bdaf..ce001c468 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -292,6 +292,10 @@ void LensView::OnResultRemoved(Result const& result) long LensView::PostLayoutManagement (long LayoutResult) { EnsureSize(); + + LOG_DEBUG(logger) << "lens: " << lens_->name() + << " - size: " << scroll_view_->GetGeometry().height; + return View::PostLayoutManagement(LayoutResult); } -- cgit v1.2.3 From 27d585fef2bdd4f36b74e5e096a0d660cae5e7f8 Mon Sep 17 00:00:00 2001 From: Sven Baars Date: Wed, 8 Feb 2012 19:18:37 +0100 Subject: Initialize _is_grabbed before use Also remove some comparisons to true and false (bzr r1932.3.1) --- plugins/unityshell/src/PanelMenuView.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/PanelMenuView.cpp b/plugins/unityshell/src/PanelMenuView.cpp index f1be2ea1f..90ba22e1e 100644 --- a/plugins/unityshell/src/PanelMenuView.cpp +++ b/plugins/unityshell/src/PanelMenuView.cpp @@ -63,6 +63,7 @@ PanelMenuView::PanelMenuView(int padding) _is_inside(false), _is_maximized(false), _is_own_window(false), + _is_grabbed(false), _last_active_view(nullptr), _new_application(nullptr), _last_width(0), @@ -258,7 +259,7 @@ PanelMenuView::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEven { bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type); - if (mouse_inside == false) + if (!mouse_inside) return nullptr; Area* found_area = nullptr; @@ -1644,7 +1645,7 @@ PanelMenuView::HasOurWindowFocused() void PanelMenuView::OnPanelViewMouseEnter(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state) { - if (_is_inside != true) + if (!_is_inside) { if (_is_grabbed) _is_grabbed = false; @@ -1658,7 +1659,7 @@ PanelMenuView::OnPanelViewMouseEnter(int x, int y, unsigned long mouse_button_st void PanelMenuView::OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state) { - if (_is_inside != false) + if (_is_inside) { _is_inside = false; FullRedraw(); -- cgit v1.2.3 From cc9dc596e2c648d4d9222430c1aa4684c42a5928 Mon Sep 17 00:00:00 2001 From: Sven Baars Date: Thu, 9 Feb 2012 10:19:14 +0100 Subject: Release introspection_data upon return (Valgrind) (bzr r1932.2.1) --- plugins/unityshell/src/DebugDBusInterface.cpp | 1 + plugins/unityshell/src/Launcher.cpp | 2 ++ 2 files changed, 3 insertions(+) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DebugDBusInterface.cpp b/plugins/unityshell/src/DebugDBusInterface.cpp index edeb4e311..6a4b88cb9 100644 --- a/plugins/unityshell/src/DebugDBusInterface.cpp +++ b/plugins/unityshell/src/DebugDBusInterface.cpp @@ -117,6 +117,7 @@ DebugDBusInterface::OnBusAcquired(GDBusConnection* connection, const gchar* name } i++; } + g_dbus_node_info_unref(introspection_data); } void diff --git a/plugins/unityshell/src/Launcher.cpp b/plugins/unityshell/src/Launcher.cpp index 455d0db46..681935bc4 100644 --- a/plugins/unityshell/src/Launcher.cpp +++ b/plugins/unityshell/src/Launcher.cpp @@ -2958,6 +2958,8 @@ Launcher::OnBusAcquired(GDBusConnection* connection, { LOG_WARNING(logger) << "Object registration failed. Won't get dynamic launcher addition."; } + + g_dbus_node_info_unref(introspection_data); } void -- cgit v1.2.3 From 8772ef30ed753b244bef72d8e74a498293f474de Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Thu, 9 Feb 2012 15:22:46 +0000 Subject: resizing hud (bzr r1900.1.7) --- plugins/unityshell/src/HudController.cpp | 2 +- plugins/unityshell/src/HudView.cpp | 168 ++++++++++++++++++++++++------- plugins/unityshell/src/HudView.h | 8 ++ plugins/unityshell/src/LensView.cpp | 5 +- 4 files changed, 145 insertions(+), 38 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/HudController.cpp b/plugins/unityshell/src/HudController.cpp index 616ee26c5..16119ff7c 100644 --- a/plugins/unityshell/src/HudController.cpp +++ b/plugins/unityshell/src/HudController.cpp @@ -97,7 +97,7 @@ void Controller::SetupHudView() view_ = new View(); layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - layout_->AddView(view_, 1); + layout_->AddView(view_, 0); window_->SetLayout(layout_); view_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow)); diff --git a/plugins/unityshell/src/HudView.cpp b/plugins/unityshell/src/HudView.cpp index b4a824c05..840e635ab 100644 --- a/plugins/unityshell/src/HudView.cpp +++ b/plugins/unityshell/src/HudView.cpp @@ -48,6 +48,8 @@ namespace nux::logging::Logger logger("unity.hud.view"); int icon_size = 42; const std::string default_text = _("Type your command"); +const int grow_anim_length = 90 * 1000; +const int pause_before_grow_length = 32 * 1000; } NUX_IMPLEMENT_OBJECT_TYPE(View); @@ -55,6 +57,12 @@ NUX_IMPLEMENT_OBJECT_TYPE(View); View::View() : nux::View(NUX_TRACKER_LOCATION) , button_views_(NULL) + , timeline_id_(0) + , start_time_(0) + , last_known_height_(0) + , current_height_(0) + , timeline_need_more_draw_(false) + { renderer_.SetOwner(this); renderer_.need_redraw.connect([this] () { @@ -76,7 +84,6 @@ View::View() mouse_down.connect(sigc::mem_fun(this, &View::OnMouseButtonDown)); Relayout(); - } View::~View() @@ -88,6 +95,44 @@ View::~View() } } +void View::ProcessGrowShrink() +{ + float diff = g_get_monotonic_time() - start_time_; + int target_height = content_layout_->GetGeometry().height; + // only animate if we are after our defined pause time + if (diff > pause_before_grow_length) + { + float progress = (diff - pause_before_grow_length) / grow_anim_length; + int last_height = last_known_height_; + int new_height = 0; + + if (last_height < target_height) + { + // grow + new_height = last_height + ((target_height - last_height) * progress); + } + else + { + //shrink + new_height = last_height - ((last_height - target_height) * progress); + } + + LOG_DEBUG(logger) << "resizing to " << target_height << " (" << new_height << ")" + << "View height: " << GetGeometry().height; + current_height_ = new_height; + } + + QueueDraw(); + + if (diff > grow_anim_length + pause_before_grow_length) + { + // ensure we are at our final location and update last known height + current_height_ = target_height; + last_known_height_ = target_height; + timeline_need_more_draw_ = false; + } +} + void View::ResetToDefault() { @@ -101,7 +146,10 @@ void View::Relayout() content_geo_ = GetBestFitGeometry(geo); LOG_DEBUG(logger) << "content_geo: " << content_geo_.width << "x" << content_geo_.height; - layout_->SetMinMaxSize(content_geo_.width, content_geo_.height); + layout_->SetMinimumWidth(content_geo_.width); + layout_->SetMaximumWidth(content_geo_.width); + layout_->SetMaximumHeight(content_geo_.height); + //layout_->SetMinMaxSize(content_geo_.width, content_geo_.height); QueueDraw(); } @@ -109,6 +157,20 @@ void View::Relayout() long View::PostLayoutManagement(long LayoutResult) { Relayout(); + if (GetGeometry().height != last_known_height_) + { + // Start the timeline of drawing the dash resize + if (timeline_need_more_draw_) + { + // already started, just reset the last known height + last_known_height_ = current_height_; + } + + timeline_need_more_draw_ = true; + start_time_ = g_get_monotonic_time(); + QueueDraw(); + } + return LayoutResult; } @@ -209,42 +271,55 @@ namespace const int content_width = 941; const int icon_vertical_margin = 5; const int spacing_between_icon_and_content = 8; + const int bottom_padding = 10; } void View::SetupViews() { layout_ = new nux::HLayout(); - - icon_ = new Icon("", icon_size, true); - nux::Layout* icon_layout = new nux::VLayout(); - icon_layout->SetVerticalExternalMargin(icon_vertical_margin); - icon_layout->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL); - layout_->AddLayout(icon_layout, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_MATCHCONTENT); - layout_->AddLayout(new nux::SpaceLayout(spacing_between_icon_and_content, - spacing_between_icon_and_content, - spacing_between_icon_and_content, - spacing_between_icon_and_content), 0); - - - content_layout_ = new nux::VLayout(); - layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP); - SetLayout(layout_.GetPointer()); - - // add the top spacing - content_layout_->AddLayout(new nux::SpaceLayout(top_spacing,top_spacing,top_spacing,top_spacing), 0); + { + // fill icon layout with icon + icon_ = new Icon("", icon_size, true); + nux::Layout* icon_layout = new nux::VLayout(); + { + icon_layout->SetVerticalExternalMargin(icon_vertical_margin); + icon_layout->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL); + layout_->AddLayout(icon_layout, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_MATCHCONTENT); + } - // add the search bar to the composite - search_bar_ = new unity::SearchBar(content_width, true); - search_bar_->disable_glow = true; - search_bar_->search_hint = default_text; - search_bar_->search_changed.connect(sigc::mem_fun(this, &View::OnSearchChanged)); - AddChild(search_bar_.GetPointer()); - content_layout_->AddView(search_bar_.GetPointer(), 0, nux::MINOR_POSITION_LEFT); - - button_views_ = new nux::VLayout(); - button_views_->SetMaximumWidth(content_width); + // add padding to layout between icon and content + layout_->AddLayout(new nux::SpaceLayout(spacing_between_icon_and_content, + spacing_between_icon_and_content, + spacing_between_icon_and_content, + spacing_between_icon_and_content), 0); + + // fill the content layout + content_layout_ = new nux::VLayout(); + { + // add the top spacing + content_layout_->AddLayout(new nux::SpaceLayout(top_spacing,top_spacing,top_spacing,top_spacing), 0); - content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_LEFT); + // add the search bar to the composite + search_bar_ = new unity::SearchBar(content_width, true); + search_bar_->disable_glow = true; + search_bar_->search_hint = default_text; + search_bar_->search_changed.connect(sigc::mem_fun(this, &View::OnSearchChanged)); + AddChild(search_bar_.GetPointer()); + content_layout_->AddView(search_bar_.GetPointer(), 0, nux::MINOR_POSITION_LEFT); + + button_views_ = new nux::VLayout(); + button_views_->SetMaximumWidth(content_width); + + content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_LEFT); + content_layout_->AddLayout(new nux::SpaceLayout(bottom_padding, + bottom_padding, + bottom_padding, + bottom_padding), 0); + } + layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP); + } + + SetLayout(layout_.GetPointer()); } void View::OnSearchChanged(std::string const& search_string) @@ -283,13 +358,24 @@ void View::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long k void View::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) { - renderer_.DrawFull(gfx_context, layout_->GetGeometry(), absolute_window_geometry_, window_geometry_, true); + if (timeline_need_more_draw_) + { + ProcessGrowShrink(); + } + + nux::Geometry draw_content_geo = layout_->GetGeometry(); + draw_content_geo.height = current_height_; + renderer_.DrawFull(gfx_context, draw_content_geo, absolute_window_geometry_, window_geometry_, true); } void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) { - renderer_.DrawInner(gfx_context, layout_->GetGeometry(), absolute_window_geometry_, window_geometry_); - + nux::Geometry draw_content_geo = layout_->GetGeometry(); + draw_content_geo.height = current_height_; + + renderer_.DrawInner(gfx_context, draw_content_geo, absolute_window_geometry_, window_geometry_); + + gfx_context.PushClippingRectangle(draw_content_geo); if (IsFullRedraw()) { nux::GetPainter().PushBackgroundStack(); @@ -300,8 +386,20 @@ void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) { layout_->ProcessDraw(gfx_context, force_draw); } + gfx_context.PopClippingRectangle(); + + renderer_.DrawInnerCleanup(gfx_context, draw_content_geo, absolute_window_geometry_, window_geometry_); - renderer_.DrawInnerCleanup(gfx_context, layout_->GetGeometry(), absolute_window_geometry_, window_geometry_); + if (timeline_need_more_draw_ && !timeline_id_) + { + timeline_id_ = g_timeout_add(0, [] (gpointer data) -> gboolean + { + View *self = static_cast(data); + self->QueueDraw(); + self->timeline_id_ = 0; + return FALSE; + }, this); + } } // Keyboard navigation diff --git a/plugins/unityshell/src/HudView.h b/plugins/unityshell/src/HudView.h index b0a54d740..79d87840c 100644 --- a/plugins/unityshell/src/HudView.h +++ b/plugins/unityshell/src/HudView.h @@ -89,6 +89,8 @@ private: bool AcceptKeyNavFocus(); nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo); + void ProcessGrowShrink(); + std::string GetName() const; void AddProperties(GVariantBuilder* builder); @@ -109,6 +111,12 @@ private: OverlayRenderer renderer_; nux::Geometry window_geometry_; nux::Geometry absolute_window_geometry_; + + guint timeline_id_; + guint64 start_time_; + int last_known_height_; + int current_height_; + bool timeline_need_more_draw_; }; diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index ce001c468..0340673e6 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -324,9 +324,10 @@ void LensView::EnsureSize() height = std::max(height, 1); // hack because nux does not like heights < 1 - if (self->GetMinimumHeight() != height) + LOG_DEBUG(logger) << "wuh: " << self->GetBaseHeight() << " - " << height; + if (self->GetBaseHeight() != height) { - self->SetMinimumHeight(height); + self->SetBaseHeight(height); } self->ensure_size_id_ = 0; -- cgit v1.2.3 From c86ea6e30da605e14967ac78b2b1ceeeb3856a92 Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Thu, 9 Feb 2012 21:19:30 +0100 Subject: Update the design of the mouse over state for the filters expander. This design will be used for the focus state too. (bzr r1935.1.1) --- plugins/unityshell/src/DashStyle.h | 2 +- plugins/unityshell/src/DashView.cpp | 2 +- plugins/unityshell/src/FilterBar.cpp | 4 +- plugins/unityshell/src/FilterExpanderLabel.cpp | 113 ++++++++++++++++++---- plugins/unityshell/src/FilterExpanderLabel.h | 11 +++ plugins/unityshell/src/FilterGenreWidget.cpp | 16 --- plugins/unityshell/src/FilterGenreWidget.h | 3 - plugins/unityshell/src/FilterMultiRangeWidget.cpp | 17 +--- plugins/unityshell/src/FilterMultiRangeWidget.h | 3 - plugins/unityshell/src/FilterRatingsWidget.cpp | 16 --- plugins/unityshell/src/FilterRatingsWidget.h | 5 +- plugins/unityshell/src/LensView.cpp | 8 +- 12 files changed, 115 insertions(+), 85 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashStyle.h b/plugins/unityshell/src/DashStyle.h index ae57c2c7e..5c29a7680 100644 --- a/plugins/unityshell/src/DashStyle.h +++ b/plugins/unityshell/src/DashStyle.h @@ -194,7 +194,7 @@ public: // Paddings static const int FILTERS_LEFT_PADDING = 0; - static const int FILTERS_RIGHT_PADDING = 8; + static const int FILTERS_RIGHT_PADDING = 0; sigc::signal changed; diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index 67713ceb3..12a3e8b6c 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -220,7 +220,7 @@ nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo) width = MAX(width, tile_width * 6); - width += 19 + 32 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING; // add the left padding and the group plugin padding + width += 19 + 32 + 8 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING; // add the left padding and the group plugin padding height = search_bar_->GetGeometry().height; height += tile_height * 3; diff --git a/plugins/unityshell/src/FilterBar.cpp b/plugins/unityshell/src/FilterBar.cpp index c1aedfdd9..ecfc3241b 100644 --- a/plugins/unityshell/src/FilterBar.cpp +++ b/plugins/unityshell/src/FilterBar.cpp @@ -126,8 +126,8 @@ void FilterBar::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); GfxContext.GetRenderStates().SetColorMask(true, true, true, false); nux::GetPainter().Draw2DLine(GfxContext, - geom.x , geom.y + geom.height - 1, - geom.x + geom.width, geom.y + geom.height - 1, + geom.x + 5, geom.y + geom.height - 1, + geom.x + geom.width - 9, geom.y + geom.height - 1, col); GfxContext.GetRenderStates().SetBlend(alpha, src, dest); } diff --git a/plugins/unityshell/src/FilterExpanderLabel.cpp b/plugins/unityshell/src/FilterExpanderLabel.cpp index 35543bd7c..7d6ff2564 100644 --- a/plugins/unityshell/src/FilterExpanderLabel.cpp +++ b/plugins/unityshell/src/FilterExpanderLabel.cpp @@ -34,6 +34,30 @@ namespace unity namespace dash { +class ExpanderView : public nux::View +{ +public: + ExpanderView(NUX_FILE_LINE_DECL) + : nux::View(NUX_FILE_LINE_PARAM) + { + } + +protected: + void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) + { + }; + + void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) + { + if (GetLayout()) + GetLayout()->ProcessDraw(graphics_engine, force_draw); + } + + bool AcceptKeyNavFocus() + { + return false; + } +}; NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel); @@ -43,6 +67,8 @@ FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE , expanded(true) , layout_(nullptr) , top_bar_layout_(nullptr) + , expander_view_(nullptr) + , expander_layout_(nullptr) , right_hand_contents_(nullptr) , cairo_label_(nullptr) , raw_label_(label) @@ -68,7 +94,7 @@ void FilterExpanderLabel::SetLabel(std::string const& label) void FilterExpanderLabel::SetRightHandView(nux::View* view) { - view->SetMaximumHeight(30); + view->SetMinimumHeight(33); right_hand_contents_ = view; top_bar_layout_->AddView(right_hand_contents_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); @@ -87,20 +113,24 @@ void FilterExpanderLabel::SetContents(nux::Layout* contents) void FilterExpanderLabel::BuildLayout() { layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); + layout_->SetLeftAndRightPadding(3, 1); + top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - top_bar_layout_->SetHorizontalInternalMargin(8); + top_bar_layout_->SetLeftAndRightPadding(2, 0); + + expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); + expander_layout_->SetSpaceBetweenChildren(8); + + + expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION); + expander_view_->SetLayout(expander_layout_); + top_bar_layout_->AddView(expander_view_, 0); cairo_label_ = new nux::StaticText(label_.c_str(), NUX_TRACKER_LOCATION); cairo_label_->SetFontName("Ubuntu 10"); cairo_label_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); cairo_label_->SetAcceptKeyNavFocusOnMouseDown(false); - cairo_label_->mouse_down.connect( - [&](int x, int y, unsigned long button_flags, unsigned long key_flag) - { - expanded = !expanded; - }); - nux::BaseTexture* arrow; arrow = dash::Style::Instance().GetGroupUnexpandIcon(); expand_icon_ = new IconTexture(arrow, @@ -109,11 +139,6 @@ void FilterExpanderLabel::BuildLayout() expand_icon_->SetOpacity(kExpandDefaultIconOpacity); expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight()); expand_icon_->SetVisible(true); - expand_icon_->mouse_click.connect( - [&] (int x, int y, unsigned long b, unsigned long k) - { - expanded = !expanded; - }); arrow_layout_ = new nux::VLayout(); arrow_top_space_ = new nux::SpaceLayout(2, 2, 11, 11); arrow_bottom_space_ = new nux::SpaceLayout(2, 2, 9, 9); @@ -121,17 +146,39 @@ void FilterExpanderLabel::BuildLayout() arrow_layout_->AddView(expand_icon_, 0, nux::MINOR_POSITION_CENTER); arrow_layout_->AddView(arrow_bottom_space_, 0, nux::MINOR_POSITION_CENTER); - top_bar_layout_->AddView(cairo_label_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); - top_bar_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER); + expander_layout_->AddView(cairo_label_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); + expander_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER); top_bar_layout_->AddSpace(1, 1); - top_bar_layout_->SetMaximumWidth((Style::Instance().GetTileWidth() - 12) * 2 + 20); + top_bar_layout_->SetMaximumWidth((Style::Instance().GetTileWidth() - 12) * 2 + 19); layout_->AddLayout(top_bar_layout_, 0, nux::MINOR_POSITION_LEFT); layout_->SetVerticalInternalMargin(0); SetLayout(layout_); + // Lambda functions + auto mouse_redraw = [&](int x, int y, unsigned long b, unsigned long k) + { + QueueDraw(); + }; + + auto mouse_expand = [&](int x, int y, unsigned long b, unsigned long k) + { + expanded = !expanded; + }; + + // Signals + expander_view_->mouse_click.connect(mouse_expand); + expander_view_->mouse_enter.connect(mouse_redraw); + expander_view_->mouse_leave.connect(mouse_redraw); + cairo_label_->mouse_click.connect(mouse_expand); + cairo_label_->mouse_enter.connect(mouse_redraw); + cairo_label_->mouse_leave.connect(mouse_redraw); + expand_icon_->mouse_click.connect(mouse_expand); + expand_icon_->mouse_enter.connect(mouse_redraw); + expand_icon_->mouse_leave.connect(mouse_redraw); + QueueRelayout(); NeedRedraw(); } @@ -159,18 +206,46 @@ void FilterExpanderLabel::DoExpandChange(bool change) QueueDraw(); } +bool FilterExpanderLabel::ShouldBeHighlighted() +{ + return ((expander_view_ && expander_view_->IsMouseInside()) || + (cairo_label_ && cairo_label_->IsMouseInside()) || + (expand_icon_ && expand_icon_->IsMouseInside())); +} + void FilterExpanderLabel::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { - nux::Geometry const& geo = GetGeometry(); + nux::Geometry const& base = GetGeometry(); + + GfxContext.PushClippingRectangle(base); + nux::GetPainter().PaintBackground(GfxContext, base); + + if (ShouldBeHighlighted()) + { + nux::Geometry geo(top_bar_layout_->GetGeometry()); + geo.x = base.x; + geo.height = 34; + geo.width = base.width - 5; + + if (!highlight_layer_) + highlight_layer_.reset(dash::Style::Instance().FocusOverlay(geo.width, geo.height)); + + highlight_layer_->SetGeometry(geo); + highlight_layer_->Renderlayer(GfxContext); + } - GfxContext.PushClippingRectangle(geo); - nux::GetPainter().PaintBackground(GfxContext, geo); GfxContext.PopClippingRectangle(); } void FilterExpanderLabel::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) { GfxContext.PushClippingRectangle(GetGeometry()); + + if (ShouldBeHighlighted() && highlight_layer_ && !IsFullRedraw()) + { + nux::GetPainter().PushLayer(GfxContext, highlight_layer_->GetGeometry(), highlight_layer_.get()); + } + GetLayout()->ProcessDraw(GfxContext, force_draw); GfxContext.PopClippingRectangle(); } diff --git a/plugins/unityshell/src/FilterExpanderLabel.h b/plugins/unityshell/src/FilterExpanderLabel.h index ed409241b..5acc1cc2b 100644 --- a/plugins/unityshell/src/FilterExpanderLabel.h +++ b/plugins/unityshell/src/FilterExpanderLabel.h @@ -23,6 +23,8 @@ #ifndef UNITYSHELL_FILTEREXPANDERLABEL_H #define UNITYSHELL_FILTEREXPANDERLABEL_H +#include + #include #include #include @@ -32,6 +34,11 @@ #include "FilterWidget.h" #include "IconTexture.h" +namespace nux +{ +class AbstractPaintLayer; +} + namespace unity { namespace dash @@ -57,9 +64,12 @@ protected: private: void BuildLayout(); void DoExpandChange(bool change); + bool ShouldBeHighlighted(); nux::LinearLayout* layout_; nux::LinearLayout* top_bar_layout_; + nux::View* expander_view_; + nux::LinearLayout* expander_layout_; nux::View* right_hand_contents_; nux::StaticText* cairo_label_; std::string raw_label_; @@ -70,6 +80,7 @@ private: IconTexture* expand_icon_; nux::ObjectPtr contents_; + std::unique_ptr highlight_layer_; }; } // namespace dash diff --git a/plugins/unityshell/src/FilterGenreWidget.cpp b/plugins/unityshell/src/FilterGenreWidget.cpp index 9ab2277eb..378718201 100644 --- a/plugins/unityshell/src/FilterGenreWidget.cpp +++ b/plugins/unityshell/src/FilterGenreWidget.cpp @@ -119,21 +119,5 @@ void FilterGenre::InitTheme() //FIXME - build theme here - store images, cache them, fun fun fun } -void FilterGenre::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) -{ - nux::Geometry const& geo = GetGeometry(); - - GfxContext.PushClippingRectangle(geo); - nux::GetPainter().PaintBackground(GfxContext, geo); - GfxContext.PopClippingRectangle(); -} - -void FilterGenre::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) -{ - GfxContext.PushClippingRectangle(GetGeometry()); - GetLayout()->ProcessDraw(GfxContext, force_draw); - GfxContext.PopClippingRectangle(); -} - } // namespace dash } // namespace unity diff --git a/plugins/unityshell/src/FilterGenreWidget.h b/plugins/unityshell/src/FilterGenreWidget.h index 9e344f4f3..84baa0ae0 100644 --- a/plugins/unityshell/src/FilterGenreWidget.h +++ b/plugins/unityshell/src/FilterGenreWidget.h @@ -52,9 +52,6 @@ public: std::string GetFilterType(); protected: - virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); - virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); - void InitTheme(); private: diff --git a/plugins/unityshell/src/FilterMultiRangeWidget.cpp b/plugins/unityshell/src/FilterMultiRangeWidget.cpp index ef552d2ce..fe5448f6b 100644 --- a/plugins/unityshell/src/FilterMultiRangeWidget.cpp +++ b/plugins/unityshell/src/FilterMultiRangeWidget.cpp @@ -44,6 +44,7 @@ FilterMultiRange::FilterMultiRange(NUX_FILE_LINE_DECL) all_button_ = new FilterAllButton(NUX_TRACKER_LOCATION); layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); + layout_->SetLeftAndRightPadding(0, 8); layout_->SetTopAndBottomPadding(9, 12); SetRightHandView(all_button_); @@ -155,21 +156,5 @@ void FilterMultiRange::InitTheme() //FIXME - build theme here - store images, cache them, fun fun fun } -void FilterMultiRange::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) -{ - nux::Geometry const& geo = GetGeometry(); - - GfxContext.PushClippingRectangle(geo); - nux::GetPainter().PaintBackground(GfxContext, geo); - GfxContext.PopClippingRectangle(); -} - -void FilterMultiRange::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) -{ - GfxContext.PushClippingRectangle(GetGeometry()); - GetLayout()->ProcessDraw(GfxContext, force_draw); - GfxContext.PopClippingRectangle(); -} - } // namespace dash } // namespace unity diff --git a/plugins/unityshell/src/FilterMultiRangeWidget.h b/plugins/unityshell/src/FilterMultiRangeWidget.h index 638dd9649..1d4b9b8ca 100644 --- a/plugins/unityshell/src/FilterMultiRangeWidget.h +++ b/plugins/unityshell/src/FilterMultiRangeWidget.h @@ -50,9 +50,6 @@ public: std::string GetFilterType(); protected: - virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); - virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); - void InitTheme(); private: diff --git a/plugins/unityshell/src/FilterRatingsWidget.cpp b/plugins/unityshell/src/FilterRatingsWidget.cpp index 0b9129cc1..9c9749548 100644 --- a/plugins/unityshell/src/FilterRatingsWidget.cpp +++ b/plugins/unityshell/src/FilterRatingsWidget.cpp @@ -73,21 +73,5 @@ std::string FilterRatingsWidget::GetFilterType() return "FilterRatingsWidget"; } -void FilterRatingsWidget::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) -{ - nux::Geometry const& geo = GetGeometry(); - - GfxContext.PushClippingRectangle(geo); - nux::GetPainter().PaintBackground(GfxContext, geo); - GfxContext.PopClippingRectangle(); -} - -void FilterRatingsWidget::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) -{ - GfxContext.PushClippingRectangle(GetGeometry()); - GetLayout()->ProcessDraw(GfxContext, force_draw); - GfxContext.PopClippingRectangle(); -} - } // namespace dash } // namespace unity diff --git a/plugins/unityshell/src/FilterRatingsWidget.h b/plugins/unityshell/src/FilterRatingsWidget.h index 9db1c3d38..6d002eb7d 100644 --- a/plugins/unityshell/src/FilterRatingsWidget.h +++ b/plugins/unityshell/src/FilterRatingsWidget.h @@ -50,10 +50,7 @@ public: void SetFilter(Filter::Ptr const& filter); std::string GetFilterType(); -protected: - virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); - virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); - +private: FilterAllButton* all_button_; FilterRatingsButton* ratings_; RatingsFilter::Ptr filter_; diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index 4e74d798f..6fb2657ff 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -346,8 +346,8 @@ void LensView::OnFilterAdded(Filter::Ptr filter) filter_bar_->AddFilter(filter); int width = dash::Style::Instance().GetTileWidth(); - fscroll_view_->SetMinimumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING); - fscroll_view_->SetMaximumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING); + fscroll_view_->SetMinimumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING + 3 + 8); + fscroll_view_->SetMaximumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING + 3 + 8); can_refine_search = true; } @@ -371,7 +371,7 @@ void LensView::OnViewTypeChanged(ViewType view_type) void LensView::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) { - nux::Geometry geo = GetGeometry(); + nux::Geometry const& geo = GetGeometry(); gfx_context.PushClippingRectangle(geo); nux::GetPainter().PaintBackground(gfx_context, geo); @@ -393,7 +393,7 @@ Lens::Ptr LensView::lens() const } int LensView::GetNumRows() -{ +{ unsigned int columns = dash::Style::Instance().GetDefaultNColumns(); columns -= filters_expanded ? 2 : 0; -- cgit v1.2.3 From 16a829a95d092b7cb4a758671d3d1d85a6c065dc Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Fri, 10 Feb 2012 01:28:11 +0100 Subject: Removes magic numbers. (bzr r1935.1.3) --- plugins/unityshell/src/DashStyle.h | 4 --- plugins/unityshell/src/DashView.cpp | 3 +- plugins/unityshell/src/FilterExpanderLabel.cpp | 43 +++++++++++++++++------ plugins/unityshell/src/FilterMultiRangeWidget.cpp | 13 +++++-- plugins/unityshell/src/LensView.cpp | 6 ++-- 5 files changed, 48 insertions(+), 21 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashStyle.h b/plugins/unityshell/src/DashStyle.h index 5c29a7680..98f604f2f 100644 --- a/plugins/unityshell/src/DashStyle.h +++ b/plugins/unityshell/src/DashStyle.h @@ -192,10 +192,6 @@ public: nux::BaseTexture* GetGroupUnexpandIcon(); nux::BaseTexture* GetGroupExpandIcon(); - // Paddings - static const int FILTERS_LEFT_PADDING = 0; - static const int FILTERS_RIGHT_PADDING = 0; - sigc::signal changed; private: diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index 12a3e8b6c..0f101e38e 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -41,6 +41,7 @@ namespace dash namespace { nux::logging::Logger logger("unity.dash.view"); + } NUX_IMPLEMENT_OBJECT_TYPE(DashView); @@ -220,7 +221,7 @@ nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo) width = MAX(width, tile_width * 6); - width += 19 + 32 + 8 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING; // add the left padding and the group plugin padding + width += 19 + 40; // add the left padding and the group plugin padding height = search_bar_->GetGeometry().height; height += tile_height * 3; diff --git a/plugins/unityshell/src/FilterExpanderLabel.cpp b/plugins/unityshell/src/FilterExpanderLabel.cpp index ecffa2112..54e8295b1 100644 --- a/plugins/unityshell/src/FilterExpanderLabel.cpp +++ b/plugins/unityshell/src/FilterExpanderLabel.cpp @@ -26,7 +26,28 @@ namespace { -const float kExpandDefaultIconOpacity = 1.0f; + +const float EXPAND_DEFAULT_ICON_OPACITY = 1.0f; + +// right_hand_contents_ +const int RIGHT_HAND_CONTENTS_HEIGHT = 33; + +// layout_ +const int LAYOUT_LEFT_PADDING = 3; +const int LAYOUT_RIGHT_PADDING = 1; + +// top_bar_layout_ +const int TOP_BAR_LAYOUT_LEFT_PADDING = 2; +const int TOP_BAR_LAYOUT_RIGHT_PADDING = 0; +const int TOP_BAR_LAYOUT_WIDTH_ADDER = 19; + +// expander_layout_ +const int EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN = 8; + +// highlight +const int HIGHLIGHT_HEIGHT = 34; +const int HIGHLIGHT_WIDTH_SUBTRACTOR = 5; + } namespace unity @@ -94,7 +115,8 @@ void FilterExpanderLabel::SetLabel(std::string const& label) void FilterExpanderLabel::SetRightHandView(nux::View* view) { - view->SetMinimumHeight(33); + view->SetMinimumHeight(RIGHT_HAND_CONTENTS_HEIGHT); + view->SetMaximumHeight(RIGHT_HAND_CONTENTS_HEIGHT); right_hand_contents_ = view; top_bar_layout_->AddView(right_hand_contents_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); @@ -114,14 +136,13 @@ void FilterExpanderLabel::SetContents(nux::Layout* contents) void FilterExpanderLabel::BuildLayout() { layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); - layout_->SetLeftAndRightPadding(3, 1); + layout_->SetLeftAndRightPadding(LAYOUT_LEFT_PADDING, LAYOUT_RIGHT_PADDING); top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - top_bar_layout_->SetLeftAndRightPadding(2, 0); + top_bar_layout_->SetLeftAndRightPadding(TOP_BAR_LAYOUT_LEFT_PADDING, TOP_BAR_LAYOUT_RIGHT_PADDING); expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - expander_layout_->SetSpaceBetweenChildren(8); - + expander_layout_->SetSpaceBetweenChildren(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN); expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION); expander_view_->SetLayout(expander_layout_); @@ -129,7 +150,7 @@ void FilterExpanderLabel::BuildLayout() cairo_label_ = new nux::StaticText(label_.c_str(), NUX_TRACKER_LOCATION); cairo_label_->SetFontName("Ubuntu 10"); - cairo_label_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); + cairo_label_->SetTextColor(nux::color::White); cairo_label_->SetAcceptKeyNavFocusOnMouseDown(false); nux::BaseTexture* arrow; @@ -137,7 +158,7 @@ void FilterExpanderLabel::BuildLayout() expand_icon_ = new IconTexture(arrow, arrow->GetWidth(), arrow->GetHeight()); - expand_icon_->SetOpacity(kExpandDefaultIconOpacity); + expand_icon_->SetOpacity(EXPAND_DEFAULT_ICON_OPACITY); expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight()); expand_icon_->SetVisible(true); arrow_layout_ = new nux::VLayout(); @@ -151,7 +172,7 @@ void FilterExpanderLabel::BuildLayout() expander_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER); top_bar_layout_->AddSpace(1, 1); - top_bar_layout_->SetMaximumWidth((Style::Instance().GetTileWidth() - 12) * 2 + 19); + top_bar_layout_->SetMaximumWidth((Style::Instance().GetTileWidth() - 12) * 2 + TOP_BAR_LAYOUT_WIDTH_ADDER); layout_->AddLayout(top_bar_layout_, 0, nux::MINOR_POSITION_LEFT); layout_->SetVerticalInternalMargin(0); @@ -225,8 +246,8 @@ void FilterExpanderLabel::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { nux::Geometry geo(top_bar_layout_->GetGeometry()); geo.x = base.x; - geo.height = 34; - geo.width = base.width - 5; + geo.height = HIGHLIGHT_HEIGHT; + geo.width = base.width - HIGHLIGHT_WIDTH_SUBTRACTOR;; if (!highlight_layer_) highlight_layer_.reset(dash::Style::Instance().FocusOverlay(geo.width, geo.height)); diff --git a/plugins/unityshell/src/FilterMultiRangeWidget.cpp b/plugins/unityshell/src/FilterMultiRangeWidget.cpp index fe5448f6b..18fc9452a 100644 --- a/plugins/unityshell/src/FilterMultiRangeWidget.cpp +++ b/plugins/unityshell/src/FilterMultiRangeWidget.cpp @@ -33,6 +33,15 @@ namespace unity { namespace dash { +namespace +{ + +const int TOP_PADDING = 9; +const int RIGHT_PADDING = 8; +const int BOTTOM_PADDING = 12; +const int LEFT_PADDING = 0; + +} NUX_IMPLEMENT_OBJECT_TYPE(FilterMultiRange); @@ -44,8 +53,8 @@ FilterMultiRange::FilterMultiRange(NUX_FILE_LINE_DECL) all_button_ = new FilterAllButton(NUX_TRACKER_LOCATION); layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - layout_->SetLeftAndRightPadding(0, 8); - layout_->SetTopAndBottomPadding(9, 12); + layout_->SetLeftAndRightPadding(LEFT_PADDING, RIGHT_PADDING); + layout_->SetTopAndBottomPadding(TOP_PADDING, BOTTOM_PADDING); SetRightHandView(all_button_); SetContents(layout_); diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index 6fb2657ff..486e33939 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -39,6 +39,7 @@ namespace { nux::logging::Logger logger("unity.dash.lensview"); +const int FSCROLL_VIEW_WIDTH_ADDER = 11; } // This is so we can access some protected members in scrollview. @@ -163,7 +164,6 @@ void LensView::SetupViews() layout_->AddView(fscroll_view_, 1); fscroll_layout_ = new nux::VLayout(); - fscroll_layout_->SetLeftAndRightPadding(dash::Style::FILTERS_LEFT_PADDING, dash::Style::FILTERS_RIGHT_PADDING); fscroll_view_->SetLayout(fscroll_layout_); filter_bar_ = new FilterBar(); @@ -346,8 +346,8 @@ void LensView::OnFilterAdded(Filter::Ptr filter) filter_bar_->AddFilter(filter); int width = dash::Style::Instance().GetTileWidth(); - fscroll_view_->SetMinimumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING + 3 + 8); - fscroll_view_->SetMaximumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING + 3 + 8); + fscroll_view_->SetMinimumWidth(width * 2 + FSCROLL_VIEW_WIDTH_ADDER); + fscroll_view_->SetMaximumWidth(width * 2 + FSCROLL_VIEW_WIDTH_ADDER); can_refine_search = true; } -- cgit v1.2.3 From b3b8e84ece50b69d2cbfc5482672f48d20a46864 Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Fri, 10 Feb 2012 01:46:52 +0100 Subject: Removes magic numbers. (bzr r1935.1.4) --- plugins/unityshell/src/FilterBar.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/FilterBar.cpp b/plugins/unityshell/src/FilterBar.cpp index ecfc3241b..e56c28634 100644 --- a/plugins/unityshell/src/FilterBar.cpp +++ b/plugins/unityshell/src/FilterBar.cpp @@ -35,6 +35,9 @@ namespace nux::logging::Logger logger("unity.dash.filterbar"); +const int SEPARATOR_LEFT_PADDING = 5; +const int SEPARATOR_WIDTH_SOTTRACTOR = 9; + } NUX_IMPLEMENT_OBJECT_TYPE(FilterBar); @@ -126,8 +129,8 @@ void FilterBar::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); GfxContext.GetRenderStates().SetColorMask(true, true, true, false); nux::GetPainter().Draw2DLine(GfxContext, - geom.x + 5, geom.y + geom.height - 1, - geom.x + geom.width - 9, geom.y + geom.height - 1, + geom.x + SEPARATOR_LEFT_PADDING, geom.y + geom.height - 1, + geom.x + geom.width - SEPARATOR_WIDTH_SOTTRACTOR, geom.y + geom.height - 1, col); GfxContext.GetRenderStates().SetBlend(alpha, src, dest); } -- cgit v1.2.3 From ae40301afd544e88a25a004060c3bc6b30e9ca8c Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Fri, 10 Feb 2012 11:35:35 +0000 Subject: reverted out lensview change, it was programmer error (bzr r1900.1.9) --- plugins/unityshell/src/LensView.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index 0340673e6..ce001c468 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -324,10 +324,9 @@ void LensView::EnsureSize() height = std::max(height, 1); // hack because nux does not like heights < 1 - LOG_DEBUG(logger) << "wuh: " << self->GetBaseHeight() << " - " << height; - if (self->GetBaseHeight() != height) + if (self->GetMinimumHeight() != height) { - self->SetBaseHeight(height); + self->SetMinimumHeight(height); } self->ensure_size_id_ = 0; -- cgit v1.2.3 From 52fc31a9bcf115687debf512ad249d73555b90a4 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Fri, 10 Feb 2012 12:20:32 +0000 Subject: working hud resize but strange redrawing (bzr r1900.1.10) --- plugins/unityshell/src/HudController.cpp | 4 ++-- plugins/unityshell/src/HudView.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/HudController.cpp b/plugins/unityshell/src/HudController.cpp index 16119ff7c..f6b39b615 100644 --- a/plugins/unityshell/src/HudController.cpp +++ b/plugins/unityshell/src/HudController.cpp @@ -96,8 +96,8 @@ void Controller::SetupHudView() LOG_DEBUG(logger) << "SetupHudView called"; view_ = new View(); - layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - layout_->AddView(view_, 0); + layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); + layout_->AddView(view_, 1, nux::MINOR_POSITION_TOP); window_->SetLayout(layout_); view_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow)); diff --git a/plugins/unityshell/src/HudView.cpp b/plugins/unityshell/src/HudView.cpp index 840e635ab..15e25c037 100644 --- a/plugins/unityshell/src/HudView.cpp +++ b/plugins/unityshell/src/HudView.cpp @@ -276,6 +276,7 @@ namespace void View::SetupViews() { + nux::VLayout* super_layout = new nux::VLayout(); layout_ = new nux::HLayout(); { // fill icon layout with icon @@ -316,10 +317,12 @@ void View::SetupViews() bottom_padding, bottom_padding), 0); } + layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP); } - SetLayout(layout_.GetPointer()); + super_layout->AddLayout(layout_.GetPointer(), 0); + SetLayout(super_layout); } void View::OnSearchChanged(std::string const& search_string) -- cgit v1.2.3 From fe29f454bf715e5581b29105a9058968c4b1157f Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Fri, 10 Feb 2012 12:22:27 +0000 Subject: fixed weird redrawing issue (bzr r1900.1.11) --- plugins/unityshell/src/HudView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/HudView.cpp b/plugins/unityshell/src/HudView.cpp index 15e25c037..a135992bf 100644 --- a/plugins/unityshell/src/HudView.cpp +++ b/plugins/unityshell/src/HudView.cpp @@ -382,7 +382,7 @@ void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) if (IsFullRedraw()) { nux::GetPainter().PushBackgroundStack(); - layout_->ProcessDraw(gfx_context, force_draw); + GetLayout()->ProcessDraw(gfx_context, force_draw); nux::GetPainter().PopBackgroundStack(); } else -- cgit v1.2.3 From 97a5977a6f42a98e240af1d297f8146530981040 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Fri, 10 Feb 2012 12:22:39 +0000 Subject: fixed weird redrawing issue (bzr r1900.1.12) --- plugins/unityshell/src/HudView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/HudView.cpp b/plugins/unityshell/src/HudView.cpp index a135992bf..34fc847a4 100644 --- a/plugins/unityshell/src/HudView.cpp +++ b/plugins/unityshell/src/HudView.cpp @@ -387,7 +387,7 @@ void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) } else { - layout_->ProcessDraw(gfx_context, force_draw); + GetLayout()->ProcessDraw(gfx_context, force_draw); } gfx_context.PopClippingRectangle(); -- cgit v1.2.3 From d2b6b193361c64f0ab1b6499d33b3dc3d2159b1c Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Fri, 10 Feb 2012 12:53:36 +0000 Subject: dash optimization (bzr r1900.1.13) --- plugins/unityshell/src/DashView.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index 92bebe404..b388e744c 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -42,7 +42,7 @@ namespace { nux::logging::Logger logger("unity.dash.view"); const int grow_anim_length = 90 * 1000; -const int pause_before_grow_length = 32 * 1000; +const int pause_before_grow_length = 50 * 1000; } NUX_IMPLEMENT_OBJECT_TYPE(DashView); @@ -219,8 +219,8 @@ long DashView::PostLayoutManagement (long LayoutResult) { LOG_DEBUG(logger) << "got post layout management " << content_layout_->GetGeometry().height; Relayout(); - //if (content_layout_->GetGeometry().height != last_known_height_) - //{ + if (content_layout_->GetGeometry().height != last_known_height_) + { // Start the timeline of drawing the dash resize if (timeline_need_more_draw_) { @@ -231,7 +231,7 @@ long DashView::PostLayoutManagement (long LayoutResult) timeline_need_more_draw_ = true; start_time_ = g_get_monotonic_time(); QueueDraw(); - //} + } return LayoutResult; } -- cgit v1.2.3 From 9df0c3f757b72803304155c9b0cf78c116eab371 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Fri, 10 Feb 2012 17:05:24 +0000 Subject: reverted out dash changes so its just a hud branch (bzr r1900.1.14) --- plugins/unityshell/src/DashView.cpp | 156 +++++++----------------------------- plugins/unityshell/src/DashView.h | 8 -- plugins/unityshell/src/LensView.cpp | 57 +------------ plugins/unityshell/src/LensView.h | 5 -- 4 files changed, 29 insertions(+), 197 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp index b388e744c..bde256eee 100644 --- a/plugins/unityshell/src/DashView.cpp +++ b/plugins/unityshell/src/DashView.cpp @@ -41,8 +41,6 @@ namespace dash namespace { nux::logging::Logger logger("unity.dash.view"); -const int grow_anim_length = 90 * 1000; -const int pause_before_grow_length = 50 * 1000; } NUX_IMPLEMENT_OBJECT_TYPE(DashView); @@ -56,11 +54,6 @@ DashView::DashView() , search_in_progress_(false) , activate_on_finish_(false) , visible_(false) - , timeline_id_(0) - , start_time_(0) - , last_known_height_(0) - , current_height_(0) - , timeline_need_more_draw_(false) { renderer_.SetOwner(this); renderer_.need_redraw.connect([this] () { @@ -92,43 +85,6 @@ void DashView::SetMonitorOffset(int x, int y) renderer_.y_offset = y; } -void DashView::ProcessGrowShrink() -{ - float diff = g_get_monotonic_time() - start_time_; - int target_height = content_layout_->GetGeometry().height; - // only animate if we are after our defined pause time - if (diff > pause_before_grow_length) - { - float progress = (diff - pause_before_grow_length) / grow_anim_length; - int last_height = last_known_height_; - int new_height = 0; - - if (last_height < target_height) - { - // grow - new_height = last_height + ((target_height - last_height) * progress); - } - else - { - //shrink - new_height = last_height - ((last_height - target_height) * progress); - } - - LOG_DEBUG(logger) << "resizing to " << target_height << " (" << new_height << ")"; - current_height_ = new_height; - } - - QueueDraw(); - - if (diff > grow_anim_length + pause_before_grow_length) - { - // ensure we are at our final location and update last known height - current_height_ = target_height; - last_known_height_ = target_height; - timeline_need_more_draw_ = false; - } -} - void DashView::AboutToShow() { ubus_manager_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT); @@ -175,38 +131,31 @@ void DashView::SetupViews() { layout_ = new nux::VLayout(); SetLayout(layout_); - + content_layout_ = new nux::VLayout(); content_layout_->SetHorizontalExternalMargin(0); content_layout_->SetVerticalExternalMargin(0); - - { - // Add layouts/views to content_layout_ - search_bar_ = new SearchBar(); - AddChild(search_bar_); - search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated)); - search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged)); - search_bar_->live_search_reached.connect(sigc::mem_fun(this, &DashView::OnLiveSearchReached)); - search_bar_->showing_filters.changed.connect([&] (bool showing) { if (active_lens_view_) active_lens_view_->filters_expanded = showing; QueueDraw(); }); - content_layout_->AddView(search_bar_, 0, nux::MINOR_POSITION_LEFT); - - lenses_layout_ = new nux::VLayout(); - { - // Add layouts/views to lenses_layout_ - home_view_ = new LensView(home_lens_); - active_lens_view_ = home_view_; - lens_views_[home_lens_->id] = home_view_; - lenses_layout_->AddView(home_view_); - } - - content_layout_->AddView(lenses_layout_, 0, nux::MINOR_POSITION_LEFT); - lens_bar_ = new LensBar(); - lens_bar_->lens_activated.connect(sigc::mem_fun(this, &DashView::OnLensBarActivated)); - content_layout_->AddView(lens_bar_, 0, nux::MINOR_POSITION_CENTER); - } - - layout_->AddLayout(content_layout_, 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL); + layout_->AddLayout(content_layout_, 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL); + search_bar_ = new SearchBar(); + AddChild(search_bar_); + search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated)); + search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged)); + search_bar_->live_search_reached.connect(sigc::mem_fun(this, &DashView::OnLiveSearchReached)); + search_bar_->showing_filters.changed.connect([&] (bool showing) { if (active_lens_view_) active_lens_view_->filters_expanded = showing; QueueDraw(); }); + content_layout_->AddView(search_bar_, 0, nux::MINOR_POSITION_LEFT); + + lenses_layout_ = new nux::VLayout(); + content_layout_->AddView(lenses_layout_, 1, nux::MINOR_POSITION_LEFT); + + home_view_ = new LensView(home_lens_); + active_lens_view_ = home_view_; + lens_views_[home_lens_->id] = home_view_; + lenses_layout_->AddView(home_view_); + + lens_bar_ = new LensBar(); + lens_bar_->lens_activated.connect(sigc::mem_fun(this, &DashView::OnLensBarActivated)); + content_layout_->AddView(lens_bar_, 0, nux::MINOR_POSITION_CENTER); } void DashView::SetupUBusConnections() @@ -217,22 +166,7 @@ void DashView::SetupUBusConnections() long DashView::PostLayoutManagement (long LayoutResult) { - LOG_DEBUG(logger) << "got post layout management " << content_layout_->GetGeometry().height; Relayout(); - if (content_layout_->GetGeometry().height != last_known_height_) - { - // Start the timeline of drawing the dash resize - if (timeline_need_more_draw_) - { - // already started, just reset the last known height - last_known_height_ = current_height_; - } - - timeline_need_more_draw_ = true; - start_time_ = g_get_monotonic_time(); - QueueDraw(); - } - return LayoutResult; } @@ -246,17 +180,14 @@ void DashView::Relayout() if (geo.width >= content_geo_.width && geo.height > content_geo_.height) content_geo_ = geo; } + // kinda hacky, but it makes sure the content isn't so big that it throws // the bottom of the dash off the screen // not hugely happy with this, so FIXME - lenses_layout_->SetMaximumHeight(content_geo_.height - search_bar_->GetGeometry().height - lens_bar_->GetGeometry().height); - lenses_layout_->SetMinimumWidth(content_geo_.width); - lenses_layout_->SetMaximumWidth(content_geo_.width); - layout_->SetMaximumWidth(content_geo_.width); - - //lenses_layout_->SetMinimumHeight (content_geo_.height - search_bar_->GetGeometry().height - lens_bar_->GetGeometry().height); + lenses_layout_->SetMaximumHeight (content_geo_.height - search_bar_->GetGeometry().height - lens_bar_->GetGeometry().height); + lenses_layout_->SetMinimumHeight (content_geo_.height - search_bar_->GetGeometry().height - lens_bar_->GetGeometry().height); - //layout_->SetMinMaxSize(content_geo_.width, content_geo_.height); + layout_->SetMinMaxSize(content_geo_.width, content_geo_.height); dash::Style& style = dash::Style::Instance(); @@ -267,10 +198,6 @@ void DashView::Relayout() ubus_manager_.SendMessage(UBUS_DASH_SIZE_CHANGED, g_variant_new("(ii)", content_geo_.width, content_geo_.height)); QueueDraw(); - - //LOG_DEBUG(logger) << "Layout size: " << layout_->GetGeometry().height; - //LOG_DEBUG(logger) << "lenses_layout size: " << layout_->GetGeometry().height; - } // Gives us the width and height of the contents that will give us the best "fit", @@ -310,24 +237,13 @@ nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo) void DashView::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) { - if (timeline_need_more_draw_) - { - // process our animation - ProcessGrowShrink(); - } - - nux::Geometry draw_content_geo = content_geo_; - draw_content_geo.height = current_height_; - renderer_.DrawFull(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); + renderer_.DrawFull(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry()); } void DashView::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) { - nux::Geometry draw_content_geo = content_geo_; - draw_content_geo.height = current_height_; - renderer_.DrawInner(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); + renderer_.DrawInner(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry()); - gfx_context.PushClippingRectangle(draw_content_geo); if (IsFullRedraw()) { nux::GetPainter().PushBackgroundStack(); @@ -338,21 +254,8 @@ void DashView::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) { layout_->ProcessDraw(gfx_context, force_draw); } - gfx_context.PopClippingRectangle(); - renderer_.DrawInnerCleanup(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); - - - if (timeline_need_more_draw_ && !timeline_id_) - { - // timeline is still running, queue up another draw - timeline_id_ = g_timeout_add(0, [] (gpointer data) -> gboolean { - DashView* self = static_cast(data); - self->QueueDraw(); - self->timeline_id_ = 0; - return FALSE; - }, this); - } + renderer_.DrawInnerCleanup(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry()); } void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) @@ -524,9 +427,6 @@ void DashView::OnSearchFinished(Lens::Hints const& hints) if (it != hints.end()) { LOG_DEBUG(logger) << "We have no-results-hint: " << g_variant_get_string (it->second, NULL); - // force relayout - QueueRelayout(); - } std::string search_string = search_bar_->search_string; diff --git a/plugins/unityshell/src/DashView.h b/plugins/unityshell/src/DashView.h index 1602c84f4..80b64ada5 100644 --- a/plugins/unityshell/src/DashView.h +++ b/plugins/unityshell/src/DashView.h @@ -97,8 +97,6 @@ private: void UpdateLensFilter(std::string lens, std::string filter, std::string value); void UpdateLensFilterValue(Filter::Ptr filter, std::string value); void EnsureLensesInitialized(); - - void ProcessGrowShrink(); bool AcceptKeyNavFocus(); bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character); @@ -137,12 +135,6 @@ private: bool activate_on_finish_; bool visible_; - - guint timeline_id_; - gint64 start_time_; - int last_known_height_; - int current_height_; - bool timeline_need_more_draw_; }; diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index ce001c468..b3ddda08d 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -86,7 +86,6 @@ LensView::LensView() , filters_expanded(false) , can_refine_search(false) , fix_renderering_id_(0) - , ensure_size_id_(0) {} LensView::LensView(Lens::Ptr lens) @@ -97,7 +96,6 @@ LensView::LensView(Lens::Ptr lens) , lens_(lens) , initial_activation_(true) , fix_renderering_id_(0) - , ensure_size_id_(0) { SetupViews(); SetupCategories(); @@ -210,8 +208,7 @@ void LensView::OnCategoryAdded(Category const& category) std::string renderer_name = category.renderer_name; int index = category.index; - LOG_DEBUG(logger) << "(" << this << " - " << lens_->name() << ")" - << "Category added: " << name + LOG_DEBUG(logger) << "Category added: " << name << "(" << icon_hint << ", " << renderer_name << ", " << boost::lexical_cast(index) << ")"; @@ -245,7 +242,6 @@ void LensView::OnCategoryAdded(Category const& category) scroll_layout_->AddView(group, 0, nux::MinorDimensionPosition::eAbove, nux::MinorDimensionSize::eFull, 100.0f, (nux::LayoutPosition)index); - EnsureSize(); } void LensView::OnResultAdded(Result const& result) @@ -265,7 +261,6 @@ void LensView::OnResultAdded(Result const& result) << boost::lexical_cast(result.category_index) << ". Is out of range."; } - EnsureSize(); } void LensView::OnResultRemoved(Result const& result) @@ -285,55 +280,6 @@ void LensView::OnResultRemoved(Result const& result) << boost::lexical_cast(result.category_index) << ". Is out of range."; } - - EnsureSize(); -} - -long LensView::PostLayoutManagement (long LayoutResult) -{ - EnsureSize(); - - LOG_DEBUG(logger) << "lens: " << lens_->name() - << " - size: " << scroll_view_->GetGeometry().height; - - return View::PostLayoutManagement(LayoutResult); -} - -void LensView::EnsureSize() -{ - // actually queue this method - if (ensure_size_id_) - return; - - auto queued_lambda = [] (gpointer data) -> gboolean - { - LensView* self = static_cast(data); - int height = 0; - - for (auto category = self->categories_.begin(); category != self->categories_.end(); category++) - { - PlacesGroup* group = (*category); - if (group->IsVisible()) - { - height += group->GetMinimumHeight(); - height += group->GetChildView()->GetMinimumHeight(); - height += 24; - } - - } - - height = std::max(height, 1); // hack because nux does not like heights < 1 - - if (self->GetMinimumHeight() != height) - { - self->SetMinimumHeight(height); - } - - self->ensure_size_id_ = 0; - return FALSE; - }; - - ensure_size_id_ = g_idle_add_full (G_PRIORITY_DEFAULT, queued_lambda, this, NULL); } void LensView::UpdateCounts(PlacesGroup* group) @@ -379,7 +325,6 @@ void LensView::OnGroupExpanded(PlacesGroup* group) { ResultViewGrid* grid = static_cast(group->GetChildView()); grid->expanded = group->GetExpanded(); - EnsureSize(); ubus_manager_.SendMessage(UBUS_PLACE_VIEW_QUEUE_DRAW); } diff --git a/plugins/unityshell/src/LensView.h b/plugins/unityshell/src/LensView.h index 8e133cc3b..9176f13d4 100644 --- a/plugins/unityshell/src/LensView.h +++ b/plugins/unityshell/src/LensView.h @@ -64,9 +64,6 @@ public: sigc::signal uri_activated; -protected: - virtual long PostLayoutManagement(long LayoutResult); - private: void SetupViews(); void SetupCategories(); @@ -82,7 +79,6 @@ private: void OnFilterAdded(Filter::Ptr filter); void OnFilterRemoved(Filter::Ptr filter); void OnViewTypeChanged(ViewType view_type); - void EnsureSize(); void QueueFixRenderering(); static gboolean FixRenderering(LensView* self); @@ -109,7 +105,6 @@ private: FilterBar* filter_bar_; guint fix_renderering_id_; - guint ensure_size_id_; UBusManager ubus_; }; -- cgit v1.2.3 From bd574c5b92265064f019c66883509cc310aff688 Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Fri, 10 Feb 2012 23:36:52 +0100 Subject: Implements "Filter results" highlight. (bzr r1946.2.1) --- plugins/unityshell/src/FilterExpanderLabel.cpp | 13 ++- plugins/unityshell/src/SearchBar.cpp | 127 +++++++++++++++++++++---- plugins/unityshell/src/SearchBar.h | 14 ++- 3 files changed, 128 insertions(+), 26 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/FilterExpanderLabel.cpp b/plugins/unityshell/src/FilterExpanderLabel.cpp index 54e8295b1..68e325c2d 100644 --- a/plugins/unityshell/src/FilterExpanderLabel.cpp +++ b/plugins/unityshell/src/FilterExpanderLabel.cpp @@ -48,13 +48,6 @@ const int EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN = 8; const int HIGHLIGHT_HEIGHT = 34; const int HIGHLIGHT_WIDTH_SUBTRACTOR = 5; -} - -namespace unity -{ -namespace dash -{ - class ExpanderView : public nux::View { public: @@ -80,6 +73,12 @@ protected: } }; +} + +namespace unity +{ +namespace dash +{ NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel); diff --git a/plugins/unityshell/src/SearchBar.cpp b/plugins/unityshell/src/SearchBar.cpp index 55bb79b4b..b946358bc 100644 --- a/plugins/unityshell/src/SearchBar.cpp +++ b/plugins/unityshell/src/SearchBar.cpp @@ -50,11 +50,44 @@ const int external_margin_vertical = 8; const int external_margin_horizontal = 7; const int LIVE_SEARCH_TIMEOUT = 40; const int SPINNER_TIMEOUT = 100; + +// Highlight +const int HIGHLIGHT_HEIGHT = 24; +const int HIGHLIGHT_WIDTH = 292; +const int HIGHLIGHT_LEFT_PADDING = 5; +const int HIGHLIGHT_RIGHT_PADDING = 4; } namespace { - nux::logging::Logger logger("unity"); + +nux::logging::Logger logger("unity"); + +class ExpanderView : public nux::View +{ +public: + ExpanderView(NUX_FILE_LINE_DECL) + : nux::View(NUX_FILE_LINE_PARAM) + { + } + +protected: + void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) + { + }; + + void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) + { + if (GetLayout()) + GetLayout()->ProcessDraw(graphics_engine, force_draw); + } + + bool AcceptKeyNavFocus() + { + return false; + } +}; + } namespace unity @@ -69,6 +102,7 @@ SearchBar::SearchBar(NUX_FILE_LINE_DECL) , can_refine_search(false) , disable_glow(false) , show_filter_hint_(true) + , expander_view_(nullptr) , search_bar_width_(642) , live_search_timeout_(0) , start_spinner_timeout_(0) @@ -83,6 +117,7 @@ SearchBar::SearchBar(int search_bar_width, bool show_filter_hint_, NUX_FILE_LINE , can_refine_search(false) , disable_glow(false) , show_filter_hint_(show_filter_hint_) + , expander_view_(nullptr) , search_bar_width_(search_bar_width) , live_search_timeout_(0) , start_spinner_timeout_(0) @@ -97,6 +132,7 @@ SearchBar::SearchBar(int search_bar_width, NUX_FILE_LINE_DECL) , can_refine_search(false) , disable_glow(false) , show_filter_hint_(true) + , expander_view_(nullptr) , search_bar_width_(search_bar_width) , live_search_timeout_(0) , start_spinner_timeout_(0) @@ -144,13 +180,12 @@ void SearchBar::Init() if (show_filter_hint_) { - std::string filter_str = _("Filter results"); + std::string filter_str(_("Filter results")); show_filters_ = new nux::StaticCairoText(filter_str.c_str()); show_filters_->SetVisible(false); show_filters_->SetFont("Ubuntu 10"); show_filters_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); show_filters_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_LEFT); - show_filters_->mouse_click.connect([&] (int x, int y, unsigned long b, unsigned long k) { showing_filters = !showing_filters; }); nux::BaseTexture* arrow; arrow = dash::Style::Instance().GetGroupExpandIcon(); @@ -160,13 +195,10 @@ void SearchBar::Init() expand_icon_->SetOpacity(kExpandDefaultIconOpacity); expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight()); expand_icon_->SetVisible(false); - expand_icon_->mouse_click.connect([&] (int x, int y, unsigned long b, unsigned long k) { showing_filters = !showing_filters; }); filter_layout_ = new nux::HLayout(); filter_layout_->SetHorizontalInternalMargin(8); filter_layout_->SetHorizontalExternalMargin(6); - filter_space_ = new nux::SpaceLayout(1, 10000, 0, 1); - filter_layout_->AddLayout(filter_space_, 1); filter_layout_->AddView(show_filters_, 0, nux::MINOR_POSITION_CENTER); arrow_layout_ = new nux::VLayout(); @@ -178,8 +210,34 @@ void SearchBar::Init() filter_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER); - layout_->AddView(filter_layout_, 1, nux::MINOR_POSITION_RIGHT, nux::MINOR_SIZE_FULL); - } + layout_->AddLayout(new nux::SpaceLayout(1, 10000, 0, 1), 1); + + expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION); + expander_view_->SetLayout(filter_layout_); + layout_->AddView(expander_view_, 0, nux::MINOR_POSITION_RIGHT, nux::MINOR_SIZE_FULL); + + // Lambda functions + auto mouse_redraw = [&](int x, int y, unsigned long b, unsigned long k) + { + QueueDraw(); + }; + + auto mouse_expand = [&](int x, int y, unsigned long b, unsigned long k) + { + showing_filters = !showing_filters; + }; + + // Signals + expander_view_->mouse_click.connect(mouse_expand); + expander_view_->mouse_enter.connect(mouse_redraw); + expander_view_->mouse_leave.connect(mouse_redraw); + show_filters_->mouse_click.connect(mouse_expand); + show_filters_->mouse_enter.connect(mouse_redraw); + show_filters_->mouse_leave.connect(mouse_redraw); + expand_icon_->mouse_click.connect(mouse_expand); + expand_icon_->mouse_enter.connect(mouse_redraw); + expand_icon_->mouse_leave.connect(mouse_redraw); + } sig_manager_.Add(new Signal (gtk_settings_get_default(), @@ -326,28 +384,50 @@ void SearchBar::OnShowingFiltersChanged(bool is_showing) void SearchBar::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { - nux::Geometry geo = GetGeometry(); + nux::Geometry const& base = GetGeometry(); UpdateBackground(false); - GfxContext.PushClippingRectangle(geo); - - nux::GetPainter().PaintBackground(GfxContext, geo); + GfxContext.PushClippingRectangle(base); + nux::GetPainter().PaintBackground(GfxContext, base); - bg_layer_->SetGeometry(nux::Geometry(geo.x, geo.y, last_width_, geo.height)); + bg_layer_->SetGeometry(nux::Geometry(base.x, base.y, last_width_, base.height)); nux::GetPainter().RenderSinglePaintLayer(GfxContext, bg_layer_->GetGeometry(), bg_layer_); + if (ShouldBeHighlighted()) + { + nux::Geometry geo(show_filters_->GetGeometry()); + nux::Geometry const& geo_arrow = arrow_layout_->GetGeometry(); + + geo.y -= (HIGHLIGHT_HEIGHT- geo.height) / 2; + geo.height = HIGHLIGHT_HEIGHT; + geo.width = HIGHLIGHT_WIDTH + HIGHLIGHT_LEFT_PADDING + HIGHLIGHT_RIGHT_PADDING; + geo.x = geo_arrow.x + (geo_arrow.width - 1) - geo.width + HIGHLIGHT_RIGHT_PADDING; + + if (!highlight_layer_) + highlight_layer_.reset(dash::Style::Instance().FocusOverlay(geo.width, geo.height)); + + highlight_layer_->SetGeometry(geo); + highlight_layer_->Renderlayer(GfxContext); + } + GfxContext.PopClippingRectangle(); } void SearchBar::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) { - nux::Geometry geo = GetGeometry(); + nux::Geometry const& geo = GetGeometry(); GfxContext.PushClippingRectangle(geo); + if (highlight_layer_ && !IsFullRedraw()) + { + nux::GetPainter().PushLayer(GfxContext, highlight_layer_->GetGeometry(), highlight_layer_.get()); + } + + if (!IsFullRedraw()) { gPainter.PushLayer(GfxContext, bg_layer_->GetGeometry(), bg_layer_); @@ -407,7 +487,7 @@ void SearchBar::UpdateBackground(bool force) int PADDING = 12; int RADIUS = 5; int x, y, width, height; - nux::Geometry geo = GetGeometry(); + nux::Geometry geo(GetGeometry()); geo.width = layered_layout_->GetGeometry().width; LOG_DEBUG(logger) << "height: " @@ -426,7 +506,6 @@ void SearchBar::UpdateBackground(bool force) if (disable_glow) PADDING = 2; - x = y = PADDING - 1; width = last_width_ - (2 * PADDING); @@ -526,15 +605,27 @@ bool SearchBar::get_im_active() const return pango_entry_->im_active(); } +// +// Highlight +// +bool SearchBar::ShouldBeHighlighted() +{ + return ((expander_view_ && expander_view_->IsMouseInside()) || + (show_filters_ && show_filters_->IsMouseInside()) || + (expand_icon_ && expand_icon_->IsMouseInside())); +} + // // Key navigation // -bool -SearchBar::AcceptKeyNavFocus() +bool SearchBar::AcceptKeyNavFocus() { return false; } +// +// Introspection +// std::string SearchBar::GetName() const { return "SearchBar"; diff --git a/plugins/unityshell/src/SearchBar.h b/plugins/unityshell/src/SearchBar.h index bb2d2fe86..923925a1e 100644 --- a/plugins/unityshell/src/SearchBar.h +++ b/plugins/unityshell/src/SearchBar.h @@ -20,6 +20,8 @@ #ifndef SEARCH_BAR_H #define SEARCH_BAR_H +#include + #include #include @@ -38,6 +40,12 @@ #include "Introspectable.h" #include "StaticCairoText.h" +namespace nux +{ +class AbstractPaintLayer; +class LinearLayout; +} + namespace unity { @@ -99,15 +107,19 @@ private: bool AcceptKeyNavFocus(); private: + bool ShouldBeHighlighted(); + glib::SignalManager sig_manager_; nux::AbstractPaintLayer* bg_layer_; + std::unique_ptr highlight_layer_; nux::HLayout* layout_; nux::LayeredLayout* layered_layout_; nux::StaticCairoText* hint_; + nux::LinearLayout* expander_layout_; IMTextEntry* pango_entry_; + nux::View* expander_view_; nux::HLayout* filter_layout_; - nux::SpaceLayout* filter_space_; nux::StaticCairoText* show_filters_; nux::VLayout* arrow_layout_; nux::SpaceLayout* arrow_top_space_; -- cgit v1.2.3 From 65b67fa28a87d80b88a83f6676f0046a8533c028 Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Fri, 10 Feb 2012 23:50:29 +0100 Subject: Fix. (bzr r1946.2.2) --- plugins/unityshell/src/SearchBar.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/SearchBar.cpp b/plugins/unityshell/src/SearchBar.cpp index b946358bc..6a52f47f0 100644 --- a/plugins/unityshell/src/SearchBar.cpp +++ b/plugins/unityshell/src/SearchBar.cpp @@ -213,6 +213,7 @@ void SearchBar::Init() layout_->AddLayout(new nux::SpaceLayout(1, 10000, 0, 1), 1); expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION); + expander_view_->SetVisible(false); expander_view_->SetLayout(filter_layout_); layout_->AddView(expander_view_, 0, nux::MINOR_POSITION_RIGHT, nux::MINOR_SIZE_FULL); @@ -254,6 +255,7 @@ void SearchBar::Init() { if (show_filter_hint_) { + expander_view_->SetVisible(can_refine); show_filters_->SetVisible(can_refine); expand_icon_->SetVisible(can_refine); } @@ -610,9 +612,9 @@ bool SearchBar::get_im_active() const // bool SearchBar::ShouldBeHighlighted() { - return ((expander_view_ && expander_view_->IsMouseInside()) || - (show_filters_ && show_filters_->IsMouseInside()) || - (expand_icon_ && expand_icon_->IsMouseInside())); + return ((expander_view_ && expander_view_->IsVisible() && expander_view_->IsMouseInside()) || + (show_filters_ && show_filters_->IsVisible() && show_filters_->IsMouseInside()) || + (expand_icon_ && expand_icon_->IsVisible() && expand_icon_->IsMouseInside())); } // -- cgit v1.2.3 From ec7cbc80bbfae3dbfb36e261767dbfe5756dc78c Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sat, 11 Feb 2012 02:17:26 -0500 Subject: make HUD popup on correct monitor make Icon drag out animation return to the correct monitor (bzr r1946.1.1) --- plugins/unityshell/src/HudController.cpp | 4 ++-- plugins/unityshell/src/Launcher.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/HudController.cpp b/plugins/unityshell/src/HudController.cpp index 55aba0bc7..c1c8c724e 100644 --- a/plugins/unityshell/src/HudController.cpp +++ b/plugins/unityshell/src/HudController.cpp @@ -148,7 +148,7 @@ void Controller::OnWindowConfigure(int window_width, int window_height, nux::Geometry Controller::GetIdealWindowGeometry() { UScreen *uscreen = UScreen::GetDefault(); - int primary_monitor = uscreen->GetPrimaryMonitor(); + int primary_monitor = uscreen->GetMonitorWithMouse(); auto monitor_geo = uscreen->GetMonitorGeometry(primary_monitor); // We want to cover as much of the screen as possible to grab any mouse events outside @@ -242,7 +242,7 @@ void Controller::ShowHud() GVariant* message_data = g_variant_new("(b)", TRUE); ubus.SendMessage(UBUS_LAUNCHER_LOCK_HIDE, message_data); - GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "hud", FALSE, 0); + GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "hud", FALSE, UScreen::GetDefault()->GetMonitorWithMouse()); ubus.SendMessage(UBUS_OVERLAY_SHOWN, info); } void Controller::HideHud(bool restore) diff --git a/plugins/unityshell/src/Launcher.cpp b/plugins/unityshell/src/Launcher.cpp index e4852b558..33811708a 100644 --- a/plugins/unityshell/src/Launcher.cpp +++ b/plugins/unityshell/src/Launcher.cpp @@ -1026,7 +1026,8 @@ void Launcher::FillRenderArg(AbstractLauncherIcon* icon, // FIXME: this is a hack, we should have a look why SetAnimationTarget is necessary in SetAnimationTarget // we should ideally just need it at start to set the target if (!_initial_drag_animation && icon == _drag_icon && _drag_window && _drag_window->Animating()) - _drag_window->SetAnimationTarget((int) center.x, (int) center.y + _parent->GetGeometry().y); + _drag_window->SetAnimationTarget((int)(_drag_icon->GetCenter(monitor).x) + parent_abs_geo.x, + (int)(_drag_icon->GetCenter(monitor).y) + parent_abs_geo.y); center.y += (half_size * size_modifier) + spacing; // move to end } @@ -2078,9 +2079,11 @@ void Launcher::EndIconDrag() } else { + auto abs_geo = GetAbsoluteGeometry(); _model->Save(); - _drag_window->SetAnimationTarget((int)(_drag_icon->GetCenter(monitor).x), (int)(_drag_icon->GetCenter(monitor).y)); + _drag_window->SetAnimationTarget((int)(_drag_icon->GetCenter(monitor).x) + abs_geo.x, + (int)(_drag_icon->GetCenter(monitor).y) + abs_geo.y); _drag_window->StartAnimation(); if (_drag_window->on_anim_completed.connected()) -- cgit v1.2.3 From 21e6667ab626f3c8361a5eb62c9527f8a5fa6910 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sat, 11 Feb 2012 02:34:27 -0500 Subject: ensure that windows minimize to the correct launcher (bzr r1946.1.2) --- plugins/unityshell/src/BamfLauncherIcon.cpp | 8 ++++++-- plugins/unityshell/src/Launcher.cpp | 9 ++++----- plugins/unityshell/src/LauncherIcon.cpp | 8 +++++--- 3 files changed, 15 insertions(+), 10 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/BamfLauncherIcon.cpp b/plugins/unityshell/src/BamfLauncherIcon.cpp index de4467ec6..5550b80af 100644 --- a/plugins/unityshell/src/BamfLauncherIcon.cpp +++ b/plugins/unityshell/src/BamfLauncherIcon.cpp @@ -379,6 +379,7 @@ void BamfLauncherIcon::OnWindowMoved(guint32 moved_win) { BamfLauncherIcon* self = static_cast(data); self->EnsureWindowState(); + self->UpdateIconGeometries(self->GetCenters()); self->_window_moved_id = 0; return FALSE; }, this); @@ -1016,8 +1017,6 @@ void BamfLauncherIcon::UpdateIconGeometries(std::vector center) GList* children, *l; nux::Geometry geo; - geo.x = center[0].x - 24; - geo.y = center[0].y - 24; geo.width = 48; geo.height = 48; @@ -1029,6 +1028,11 @@ void BamfLauncherIcon::UpdateIconGeometries(std::vector center) continue; Window xid = bamf_window_get_xid(static_cast(l->data)); + int monitor = bamf_window_get_monitor(static_cast(l->data)); + monitor = std::max(0, std::min(center.size() - 1, monitor)); + + geo.x = center[monitor].x - 24; + geo.y = center[monitor].y - 24; WindowManager::Default()->SetWindowIconGeometry(xid, geo); } diff --git a/plugins/unityshell/src/Launcher.cpp b/plugins/unityshell/src/Launcher.cpp index 33811708a..1a18b8b23 100644 --- a/plugins/unityshell/src/Launcher.cpp +++ b/plugins/unityshell/src/Launcher.cpp @@ -1026,8 +1026,8 @@ void Launcher::FillRenderArg(AbstractLauncherIcon* icon, // FIXME: this is a hack, we should have a look why SetAnimationTarget is necessary in SetAnimationTarget // we should ideally just need it at start to set the target if (!_initial_drag_animation && icon == _drag_icon && _drag_window && _drag_window->Animating()) - _drag_window->SetAnimationTarget((int)(_drag_icon->GetCenter(monitor).x) + parent_abs_geo.x, - (int)(_drag_icon->GetCenter(monitor).y) + parent_abs_geo.y); + _drag_window->SetAnimationTarget((int)(_drag_icon->GetCenter(monitor).x), + (int)(_drag_icon->GetCenter(monitor).y)); center.y += (half_size * size_modifier) + spacing; // move to end } @@ -1744,7 +1744,6 @@ LauncherModel* Launcher::GetModel() const void Launcher::EnsureIconOnScreen(AbstractLauncherIcon* selection) { - nux::Point3 center = selection->GetCenter(monitor); nux::Geometry geo = GetGeometry(); int natural_y = 0; @@ -2082,8 +2081,8 @@ void Launcher::EndIconDrag() auto abs_geo = GetAbsoluteGeometry(); _model->Save(); - _drag_window->SetAnimationTarget((int)(_drag_icon->GetCenter(monitor).x) + abs_geo.x, - (int)(_drag_icon->GetCenter(monitor).y) + abs_geo.y); + _drag_window->SetAnimationTarget((int)(_drag_icon->GetCenter(monitor).x), + (int)(_drag_icon->GetCenter(monitor).y)); _drag_window->StartAnimation(); if (_drag_window->on_anim_completed.connected()) diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp index d68410604..de7081072 100644 --- a/plugins/unityshell/src/LauncherIcon.cpp +++ b/plugins/unityshell/src/LauncherIcon.cpp @@ -489,7 +489,7 @@ LauncherIcon::ShowTooltip() { nux::Geometry geo = _parent_geo[_last_monitor]; tip_x = geo.x + geo.width - 4 * geo.width / 48; - tip_y = geo.y + _center[_last_monitor].y; + tip_y = _center[_last_monitor].y; } if (!_tooltip) @@ -578,7 +578,7 @@ bool LauncherIcon::OpenQuicklist(bool default_to_first_item, int monitor) nux::Geometry geo = _parent_geo[monitor]; int tip_x = geo.x + geo.width - 4 * geo.width / 48; - int tip_y = geo.y + _center[monitor].y; + int tip_y = _center[monitor].y; auto win_manager = WindowManager::Default(); @@ -652,6 +652,8 @@ LauncherIcon::OnCenterTimeout(gpointer data) void LauncherIcon::SetCenter(nux::Point3 center, int monitor, nux::Geometry geo) { + center.x += geo.x; + center.y += geo.y; _center[monitor] = center; _parent_geo[monitor] = geo; @@ -659,7 +661,7 @@ LauncherIcon::SetCenter(nux::Point3 center, int monitor, nux::Geometry geo) { int tip_x, tip_y; tip_x = geo.x + geo.width - 4 * geo.width / 48; - tip_y = geo.y + _center[monitor].y; + tip_y = _center[monitor].y; if (_quicklist && _quicklist->IsVisible()) QuicklistManager::Default()->ShowQuicklist(_quicklist.GetPointer(), tip_x, tip_y); -- cgit v1.2.3 From 8cf989079c08e62e4f27583ae0c0b299d31985b7 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sat, 11 Feb 2012 03:11:04 -0500 Subject: remove stray call (bzr r1946.1.3) --- plugins/unityshell/src/Launcher.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/Launcher.cpp b/plugins/unityshell/src/Launcher.cpp index 1a18b8b23..5fd8882ca 100644 --- a/plugins/unityshell/src/Launcher.cpp +++ b/plugins/unityshell/src/Launcher.cpp @@ -2078,7 +2078,6 @@ void Launcher::EndIconDrag() } else { - auto abs_geo = GetAbsoluteGeometry(); _model->Save(); _drag_window->SetAnimationTarget((int)(_drag_icon->GetCenter(monitor).x), -- cgit v1.2.3 From 9b0079dcdbdf34ca9013cbdcd7330c31762efd2d Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Sat, 11 Feb 2012 10:46:45 +0100 Subject: Fix. (bzr r1946.2.3) --- plugins/unityshell/src/SearchBar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/SearchBar.cpp b/plugins/unityshell/src/SearchBar.cpp index 6a52f47f0..651ee36eb 100644 --- a/plugins/unityshell/src/SearchBar.cpp +++ b/plugins/unityshell/src/SearchBar.cpp @@ -424,7 +424,7 @@ void SearchBar::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) GfxContext.PushClippingRectangle(geo); - if (highlight_layer_ && !IsFullRedraw()) + if (highlight_layer_ && ShouldBeHighlighted() && !IsFullRedraw()) { nux::GetPainter().PushLayer(GfxContext, highlight_layer_->GetGeometry(), highlight_layer_.get()); } -- cgit v1.2.3 From 89573162094546aae7768d2b0fb12999450358b4 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sun, 12 Feb 2012 00:21:59 -0500 Subject: fix panel shadow corruption (bzr r1947.1.1) --- plugins/unityshell/src/unityshell.cpp | 13 +++++++++++-- plugins/unityshell/src/unityshell.h | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index bc2ee10fb..977a587f7 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -495,6 +495,11 @@ void UnityScreen::nuxEpilogue() glDisable(GL_SCISSOR_TEST); } +void UnityScreen::setPanelShadowMatrix(const GLMatrix& matrix) +{ + panel_shadow_matrix_ = matrix; +} + void UnityScreen::paintPanelShadow(const GLMatrix& matrix) { #ifndef USE_GLES @@ -514,9 +519,9 @@ void UnityScreen::paintPanelShadow(const GLMatrix& matrix) float y1 = output->y() + panel_h; float x2 = x1 + output->width(); float y2 = y1 + h; - GLMatrix sTransform = GLMatrix (); - sTransform.toScreenSpace(output, -DEFAULT_Z_CAMERA); + glPushMatrix (); + glLoadMatrixf (panel_shadow_matrix_.getMatrix ()); vc[0] = x1; vc[1] = x2; @@ -572,6 +577,7 @@ void UnityScreen::paintPanelShadow(const GLMatrix& matrix) glDisable(GL_BLEND); } } + glPopMatrix(); #else #warning Panel shadow not properly implemented for GLES2 return; @@ -1980,6 +1986,9 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, } } + if (window->type() == CompWindowTypeDesktopMask) + uScreen->setPanelShadowMatrix(matrix); + Window active_window = screen->activeWindow(); if (window->id() == active_window && window->type() != CompWindowTypeDesktopMask) { diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 337be3636..faf8f1b3a 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -141,6 +141,7 @@ public: void paintDisplay(const CompRegion& region, const GLMatrix& transform, unsigned int mask); #endif void paintPanelShadow(const GLMatrix& matrix); + void setPanelShadowMatrix(const GLMatrix& matrix); void preparePaint (int ms); void paintFboForOutput (CompOutput *output); @@ -331,6 +332,8 @@ private: unsigned int tray_paint_mask_; gint64 last_hud_show_time_; + GLMatrix panel_shadow_matrix_; + #ifndef USE_GLES ScreenEffectFramebufferObject::GLXGetProcAddressProc glXGetProcAddressP; #endif -- cgit v1.2.3 From 1a93f8a3feac0768cd9eb05a711d3c5414c866af Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sun, 12 Feb 2012 05:43:11 -0500 Subject: port to AbstractLauncherIcon::Ptr from AbstractLauncherIcon* (bzr r1948.8.1) --- plugins/unityshell/src/AbstractLauncherIcon.cpp | 27 ++++ plugins/unityshell/src/AbstractLauncherIcon.h | 23 +++- plugins/unityshell/src/BamfLauncherIcon.cpp | 6 +- plugins/unityshell/src/BamfLauncherIcon.h | 1 + plugins/unityshell/src/DesktopLauncherIcon.cpp | 3 +- plugins/unityshell/src/DeviceLauncherSection.cpp | 4 +- plugins/unityshell/src/DeviceLauncherSection.h | 2 +- plugins/unityshell/src/IconTextureSource.cpp | 1 + plugins/unityshell/src/IconTextureSource.h | 1 + plugins/unityshell/src/Launcher.cpp | 107 ++++++++------- plugins/unityshell/src/Launcher.h | 68 +++++----- plugins/unityshell/src/LauncherController.cpp | 148 ++++++++++----------- plugins/unityshell/src/LauncherController.h | 2 +- plugins/unityshell/src/LauncherIcon.cpp | 31 +++-- plugins/unityshell/src/LauncherIcon.h | 17 ++- plugins/unityshell/src/LauncherModel.cpp | 44 +++--- plugins/unityshell/src/LauncherModel.h | 36 ++--- plugins/unityshell/src/MockLauncherIcon.h | 17 ++- plugins/unityshell/src/SimpleLauncherIcon.cpp | 4 +- plugins/unityshell/src/SimpleLauncherIcon.h | 1 + .../unityshell/src/SoftwareCenterLauncherIcon.cpp | 1 + plugins/unityshell/src/SwitcherController.cpp | 18 +-- plugins/unityshell/src/SwitcherController.h | 6 +- plugins/unityshell/src/SwitcherModel.cpp | 18 ++- plugins/unityshell/src/SwitcherModel.h | 14 +- plugins/unityshell/src/SwitcherView.cpp | 8 +- plugins/unityshell/src/SwitcherView.h | 4 +- .../unityshell/src/unity-launcher-accessible.cpp | 32 ++--- .../unityshell/src/unity-switcher-accessible.cpp | 14 +- plugins/unityshell/src/unityshell.cpp | 4 +- 30 files changed, 368 insertions(+), 294 deletions(-) create mode 100644 plugins/unityshell/src/AbstractLauncherIcon.cpp (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/AbstractLauncherIcon.cpp b/plugins/unityshell/src/AbstractLauncherIcon.cpp new file mode 100644 index 000000000..0c647ac54 --- /dev/null +++ b/plugins/unityshell/src/AbstractLauncherIcon.cpp @@ -0,0 +1,27 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2012 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Jason Smith + */ + +#include "AbstractLauncherIcon.h" + +namespace unity { +namespace launcher { + // needed for ungodly stupid reasons + NUX_IMPLEMENT_OBJECT_TYPE(AbstractLauncherIcon); +} +} \ No newline at end of file diff --git a/plugins/unityshell/src/AbstractLauncherIcon.h b/plugins/unityshell/src/AbstractLauncherIcon.h index 527edbfba..033a70784 100644 --- a/plugins/unityshell/src/AbstractLauncherIcon.h +++ b/plugins/unityshell/src/AbstractLauncherIcon.h @@ -75,8 +75,9 @@ public: class AbstractLauncherIcon : public ui::IconTextureSource, public debug::Introspectable { + NUX_DECLARE_OBJECT_TYPE(AbstractLauncherIcon, ui::IconTextureSource); public: - + typedef nux::ObjectPtr Ptr; typedef std::vector TransformVector; typedef enum @@ -168,7 +169,7 @@ public: virtual void ResetQuirkTime(Quirk quirk) = 0; - virtual IconType Type() = 0; + virtual IconType GetIconType() = 0; virtual const gchar* RemoteUri() = 0; @@ -186,16 +187,26 @@ public: virtual void RemoveEntryRemote(LauncherEntryRemote* remote) = 0; + virtual std::string DesktopFile() = 0; + + virtual bool IsSticky() const = 0; + + virtual bool IsVisible() const = 0; + + virtual void AboutToRemove() = 0; + + virtual void Stick(bool save = true) = 0; + + virtual void UnStick() = 0; + sigc::signal mouse_down; sigc::signal mouse_up; sigc::signal mouse_click; sigc::signal mouse_enter; sigc::signal mouse_leave; - sigc::signal show; - sigc::signal hide; - sigc::signal needs_redraw; - sigc::signal remove; + sigc::signal needs_redraw; + sigc::signal remove; sigc::connection needs_redraw_connection; sigc::connection on_icon_added_connection; diff --git a/plugins/unityshell/src/BamfLauncherIcon.cpp b/plugins/unityshell/src/BamfLauncherIcon.cpp index 5550b80af..5695a0340 100644 --- a/plugins/unityshell/src/BamfLauncherIcon.cpp +++ b/plugins/unityshell/src/BamfLauncherIcon.cpp @@ -39,6 +39,8 @@ namespace unity namespace launcher { +NUX_IMPLEMENT_OBJECT_TYPE(BamfLauncherIcon); + BamfLauncherIcon::BamfLauncherIcon(BamfApplication* app) : SimpleLauncherIcon() , _bamf_app(app, glib::AddRef()) @@ -120,7 +122,7 @@ BamfLauncherIcon::BamfLauncherIcon(BamfApplication* app) WindowManager::Default()->compiz_screen_viewport_switch_ended.connect(sigc::mem_fun(this, &BamfLauncherIcon::EnsureWindowState)); WindowManager::Default()->terminate_expo.connect(sigc::mem_fun(this, &BamfLauncherIcon::EnsureWindowState)); - EnsureWindowState(); + //EnsureWindowState(); UpdateMenus(); UpdateDesktopFile(); @@ -653,7 +655,7 @@ void BamfLauncherIcon::EnsureWindowState() for (int i = 0; i < max_num_monitors; i++) SetWindowVisibleOnMonitor(monitors[i], i); - needs_redraw.emit(this); + EmitNeedsRedraw(); g_list_free(children); } diff --git a/plugins/unityshell/src/BamfLauncherIcon.h b/plugins/unityshell/src/BamfLauncherIcon.h index c222f4268..fcafaf1b8 100644 --- a/plugins/unityshell/src/BamfLauncherIcon.h +++ b/plugins/unityshell/src/BamfLauncherIcon.h @@ -38,6 +38,7 @@ class Launcher; class BamfLauncherIcon : public SimpleLauncherIcon { + NUX_DECLARE_OBJECT_TYPE(BamfLauncherIcon, SimpleLauncherIcon); public: BamfLauncherIcon(BamfApplication* app); virtual ~BamfLauncherIcon(); diff --git a/plugins/unityshell/src/DesktopLauncherIcon.cpp b/plugins/unityshell/src/DesktopLauncherIcon.cpp index b974b7233..8e1f7b1ae 100644 --- a/plugins/unityshell/src/DesktopLauncherIcon.cpp +++ b/plugins/unityshell/src/DesktopLauncherIcon.cpp @@ -35,7 +35,8 @@ DesktopLauncherIcon::DesktopLauncherIcon() icon_name = "desktop"; SetQuirk(QUIRK_VISIBLE, true); SetQuirk(QUIRK_RUNNING, false); - SetIconType(TYPE_BEGIN); + SetIconType(TYPE_DESKTOP); + SetShowInSwitcher(false); } DesktopLauncherIcon::~DesktopLauncherIcon() diff --git a/plugins/unityshell/src/DeviceLauncherSection.cpp b/plugins/unityshell/src/DeviceLauncherSection.cpp index 6958f0a12..2d9fed667 100644 --- a/plugins/unityshell/src/DeviceLauncherSection.cpp +++ b/plugins/unityshell/src/DeviceLauncherSection.cpp @@ -81,7 +81,7 @@ bool DeviceLauncherSection::PopulateEntries(DeviceLauncherSection* self) DeviceLauncherIcon* icon = new DeviceLauncherIcon(volume); self->map_[volume] = icon; - self->IconAdded.emit(icon); + self->IconAdded.emit(AbstractLauncherIcon::Ptr(icon)); } g_list_free(volumes); @@ -102,7 +102,7 @@ void DeviceLauncherSection::OnVolumeAdded(GVolumeMonitor* monitor, DeviceLauncherIcon* icon = new DeviceLauncherIcon(volume); self->map_[volume] = icon; - self->IconAdded.emit(icon); + self->IconAdded.emit(AbstractLauncherIcon::Ptr(icon)); } void DeviceLauncherSection::OnVolumeRemoved(GVolumeMonitor* monitor, diff --git a/plugins/unityshell/src/DeviceLauncherSection.h b/plugins/unityshell/src/DeviceLauncherSection.h index 6cc770d9f..9870f37e4 100644 --- a/plugins/unityshell/src/DeviceLauncherSection.h +++ b/plugins/unityshell/src/DeviceLauncherSection.h @@ -42,7 +42,7 @@ public: DeviceLauncherSection(); ~DeviceLauncherSection(); - sigc::signal IconAdded; + sigc::signal IconAdded; private: static bool PopulateEntries(DeviceLauncherSection* self); diff --git a/plugins/unityshell/src/IconTextureSource.cpp b/plugins/unityshell/src/IconTextureSource.cpp index 7cfcd8ac1..8ee725287 100644 --- a/plugins/unityshell/src/IconTextureSource.cpp +++ b/plugins/unityshell/src/IconTextureSource.cpp @@ -24,6 +24,7 @@ namespace unity { namespace ui { +NUX_IMPLEMENT_OBJECT_TYPE(IconTextureSource); IconTextureSource::IconTextureSource() { diff --git a/plugins/unityshell/src/IconTextureSource.h b/plugins/unityshell/src/IconTextureSource.h index 7ae6ef202..e38dcbf40 100644 --- a/plugins/unityshell/src/IconTextureSource.h +++ b/plugins/unityshell/src/IconTextureSource.h @@ -32,6 +32,7 @@ namespace ui class IconTextureSource : public nux::InitiallyUnownedObject { + NUX_DECLARE_OBJECT_TYPE(IconTextureSource, nux::InitiallyUnownedObject); public: typedef nux::ObjectPtr Ptr; diff --git a/plugins/unityshell/src/Launcher.cpp b/plugins/unityshell/src/Launcher.cpp index 5fd8882ca..0fbdb1ece 100644 --- a/plugins/unityshell/src/Launcher.cpp +++ b/plugins/unityshell/src/Launcher.cpp @@ -498,7 +498,7 @@ void Launcher::EnsureAnimation() NeedRedraw(); } -bool Launcher::IconNeedsAnimation(AbstractLauncherIcon* icon, struct timespec const& current) const +bool Launcher::IconNeedsAnimation(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_VISIBLE); if (unity::TimeUtil::TimeDelta(¤t, &time) < ANIM_DURATION_SHORT) @@ -618,7 +618,7 @@ float Launcher::GetAutohidePositionMax() const } -float Launcher::IconVisibleProgress(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconVisibleProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE)) { @@ -636,16 +636,15 @@ float Launcher::IconVisibleProgress(AbstractLauncherIcon* icon, struct timespec void Launcher::SetDndDelta(float x, float y, nux::Geometry const& geo, timespec const& current) { - AbstractLauncherIcon* anchor = nullptr; - LauncherModel::iterator it; + AbstractLauncherIcon::Ptr anchor; anchor = MouseIconIntersection(x, _enter_y); if (anchor) { float position = y; - for (it = _model->begin(); it != _model->end(); it++) + for (AbstractLauncherIcon::Ptr model_icon : *_model) { - if (*it == anchor) + if (model_icon == anchor) { position += _icon_size / 2; _launcher_drag_delta = _enter_y - position; @@ -655,12 +654,12 @@ void Launcher::SetDndDelta(float x, float y, nux::Geometry const& geo, timespec break; } - position += (_icon_size + _space_between_icons) * IconVisibleProgress(*it, current); + position += (_icon_size + _space_between_icons) * IconVisibleProgress(model_icon, current); } } } -float Launcher::IconPresentProgress(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconPresentProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec icon_present_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PRESENTED); int ms = unity::TimeUtil::TimeDelta(¤t, &icon_present_time); @@ -672,7 +671,7 @@ float Launcher::IconPresentProgress(AbstractLauncherIcon* icon, struct timespec return 1.0f - result; } -float Launcher::IconUrgentProgress(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconUrgentProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec urgent_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_URGENT); int urgent_ms = unity::TimeUtil::TimeDelta(¤t, &urgent_time); @@ -689,7 +688,7 @@ float Launcher::IconUrgentProgress(AbstractLauncherIcon* icon, struct timespec c return 1.0f - result; } -float Launcher::IconDropDimValue(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconDropDimValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_DROP_DIM); int dim_ms = unity::TimeUtil::TimeDelta(¤t, &dim_time); @@ -701,7 +700,7 @@ float Launcher::IconDropDimValue(AbstractLauncherIcon* icon, struct timespec con return result; } -float Launcher::IconDesatValue(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconDesatValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_DESAT); int ms = unity::TimeUtil::TimeDelta(¤t, &dim_time); @@ -713,21 +712,21 @@ float Launcher::IconDesatValue(AbstractLauncherIcon* icon, struct timespec const return result; } -float Launcher::IconShimmerProgress(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconShimmerProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec shimmer_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_SHIMMER); int shimmer_ms = unity::TimeUtil::TimeDelta(¤t, &shimmer_time); return CLAMP((float) shimmer_ms / (float) ANIM_DURATION_LONG, 0.0f, 1.0f); } -float Launcher::IconCenterTransitionProgress(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconCenterTransitionProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec save_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_CENTER_SAVED); int save_ms = unity::TimeUtil::TimeDelta(¤t, &save_time); return CLAMP((float) save_ms / (float) ANIM_DURATION, 0.0f, 1.0f); } -float Launcher::IconUrgentPulseValue(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconUrgentPulseValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { if (!icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT)) return 1.0f; // we are full on in a normal condition @@ -736,7 +735,7 @@ float Launcher::IconUrgentPulseValue(AbstractLauncherIcon* icon, struct timespec return 0.5f + (float)(std::cos(M_PI * (float)(URGENT_BLINKS * 2) * urgent_progress)) * 0.5f; } -float Launcher::IconPulseOnceValue(AbstractLauncherIcon *icon, struct timespec const ¤t) const +float Launcher::IconPulseOnceValue(AbstractLauncherIcon::Ptr icon, struct timespec const ¤t) const { struct timespec pulse_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PULSE_ONCE); int pulse_ms = unity::TimeUtil::TimeDelta(¤t, &pulse_time); @@ -748,7 +747,7 @@ float Launcher::IconPulseOnceValue(AbstractLauncherIcon *icon, struct timespec c return 0.5f + (float) (std::cos(M_PI * 2.0 * pulse_progress)) * 0.5f; } -float Launcher::IconUrgentWiggleValue(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconUrgentWiggleValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { if (!icon->GetQuirk(AbstractLauncherIcon::QUIRK_URGENT)) return 0.0f; // we are full on in a normal condition @@ -757,7 +756,7 @@ float Launcher::IconUrgentWiggleValue(AbstractLauncherIcon* icon, struct timespe return 0.3f * (float)(std::sin(M_PI * (float)(WIGGLE_CYCLES * 2) * urgent_progress)) * 0.5f; } -float Launcher::IconStartingBlinkValue(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconStartingBlinkValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_STARTING); int starting_ms = unity::TimeUtil::TimeDelta(¤t, &starting_time); @@ -766,7 +765,7 @@ float Launcher::IconStartingBlinkValue(AbstractLauncherIcon* icon, struct timesp return 0.5f + (float)(std::cos(M_PI * val * starting_progress)) * 0.5f; } -float Launcher::IconStartingPulseValue(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconStartingPulseValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_STARTING); int starting_ms = unity::TimeUtil::TimeDelta(¤t, &starting_time); @@ -781,7 +780,7 @@ float Launcher::IconStartingPulseValue(AbstractLauncherIcon* icon, struct timesp return 0.5f + (float)(std::cos(M_PI * (float)(MAX_STARTING_BLINKS * 2) * starting_progress)) * 0.5f; } -float Launcher::IconBackgroundIntensity(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconBackgroundIntensity(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { float result = 0.0f; @@ -848,7 +847,7 @@ float Launcher::IconBackgroundIntensity(AbstractLauncherIcon* icon, struct times return result; } -float Launcher::IconProgressBias(AbstractLauncherIcon* icon, struct timespec const& current) const +float Launcher::IconProgressBias(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const { struct timespec icon_progress_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PROGRESS); int ms = unity::TimeUtil::TimeDelta(¤t, &icon_progress_time); @@ -860,7 +859,7 @@ float Launcher::IconProgressBias(AbstractLauncherIcon* icon, struct timespec con return result; } -bool Launcher::IconDrawEdgeOnly(AbstractLauncherIcon* icon) const +bool Launcher::IconDrawEdgeOnly(AbstractLauncherIcon::Ptr icon) const { if (options()->backlight_mode() == BACKLIGHT_EDGE_TOGGLE) return true; @@ -871,10 +870,10 @@ bool Launcher::IconDrawEdgeOnly(AbstractLauncherIcon* icon) const return false; } -void Launcher::SetupRenderArg(AbstractLauncherIcon* icon, struct timespec const& current, RenderArg& arg) +void Launcher::SetupRenderArg(AbstractLauncherIcon::Ptr icon, struct timespec const& current, RenderArg& arg) { float desat_value = IconDesatValue(icon, current); - arg.icon = icon; + arg.icon = icon.GetPointer(); arg.alpha = 0.5f + 0.5f * desat_value; arg.saturation = desat_value; arg.colorify = nux::color::White; @@ -892,13 +891,13 @@ void Launcher::SetupRenderArg(AbstractLauncherIcon* icon, struct timespec const& arg.progress_bias = IconProgressBias(icon, current); arg.progress = CLAMP(icon->GetProgress(), 0.0f, 1.0f); arg.draw_shortcut = _shortcuts_shown && !_hide_machine->GetQuirk(LauncherHideMachine::PLACES_VISIBLE); - arg.system_item = icon->Type() == AbstractLauncherIcon::TYPE_HOME; - arg.colorify_background = icon->Type() == AbstractLauncherIcon::TYPE_HOME || - icon->Type() == AbstractLauncherIcon::TYPE_TRASH || - icon->Type() == AbstractLauncherIcon::TYPE_EXPO; + arg.system_item = icon->GetIconType() == AbstractLauncherIcon::TYPE_HOME; + arg.colorify_background = icon->GetIconType() == AbstractLauncherIcon::TYPE_HOME || + icon->GetIconType() == AbstractLauncherIcon::TYPE_TRASH || + icon->GetIconType() == AbstractLauncherIcon::TYPE_EXPO; if (_dash_is_open) - arg.active_arrow = icon->Type() == AbstractLauncherIcon::TYPE_HOME; + arg.active_arrow = icon->GetIconType() == AbstractLauncherIcon::TYPE_HOME; else arg.active_arrow = icon->GetQuirk(AbstractLauncherIcon::QUIRK_ACTIVE); @@ -947,7 +946,7 @@ void Launcher::SetupRenderArg(AbstractLauncherIcon* icon, struct timespec const& } } -void Launcher::FillRenderArg(AbstractLauncherIcon* icon, +void Launcher::FillRenderArg(AbstractLauncherIcon::Ptr icon, RenderArg& arg, nux::Point3& center, nux::Geometry const& parent_abs_geo, @@ -1190,7 +1189,7 @@ void Launcher::RenderArgs(std::list &launcher_args, for (it = _model->main_begin(); it != _model->main_end(); it++) { RenderArg arg; - AbstractLauncherIcon* icon = *it; + AbstractLauncherIcon::Ptr icon = *it; FillRenderArg(icon, arg, center, parent_abs_geo, folding_threshold, folded_size, folded_spacing, autohide_offset, folded_z_distance, animation_neg_rads, current); @@ -1218,7 +1217,7 @@ void Launcher::RenderArgs(std::list &launcher_args, for (it = _model->shelf_begin(); it != _model->shelf_end(); it++) { RenderArg arg; - AbstractLauncherIcon* icon = *it; + AbstractLauncherIcon::Ptr icon = *it; FillRenderArg(icon, arg, center, parent_abs_geo, folding_threshold, folded_size, folded_spacing, autohide_offset, folded_z_distance, animation_neg_rads, current); @@ -1268,7 +1267,7 @@ void Launcher::DesaturateIcons() { for (auto icon : *_model) { - if (icon->Type () != AbstractLauncherIcon::TYPE_HOME) + if (icon->GetIconType () != AbstractLauncherIcon::TYPE_HOME) icon->SetQuirk(AbstractLauncherIcon::QUIRK_DESAT, true); icon->HideTooltip(); } @@ -1700,14 +1699,14 @@ void Launcher::Resize() } -void Launcher::OnIconAdded(AbstractLauncherIcon* icon) +void Launcher::OnIconAdded(AbstractLauncherIcon::Ptr icon) { EnsureAnimation(); icon->needs_redraw.connect(sigc::mem_fun(this, &Launcher::OnIconNeedsRedraw)); } -void Launcher::OnIconRemoved(AbstractLauncherIcon* icon) +void Launcher::OnIconRemoved(AbstractLauncherIcon::Ptr icon) { if (icon->needs_redraw_connection.connected()) icon->needs_redraw_connection.disconnect(); @@ -1742,7 +1741,7 @@ LauncherModel* Launcher::GetModel() const return _model; } -void Launcher::EnsureIconOnScreen(AbstractLauncherIcon* selection) +void Launcher::EnsureIconOnScreen(AbstractLauncherIcon::Ptr selection) { nux::Geometry geo = GetGeometry(); @@ -1764,7 +1763,7 @@ void Launcher::EnsureIconOnScreen(AbstractLauncherIcon* selection) _launcher_drag_delta = std::max(min_drag_delta, std::min(max_drag_delta, _launcher_drag_delta)); } -void Launcher::OnSelectionChanged(AbstractLauncherIcon* selection) +void Launcher::OnSelectionChanged(AbstractLauncherIcon::Ptr selection) { if (IsInKeyNavMode()) { @@ -1773,7 +1772,7 @@ void Launcher::OnSelectionChanged(AbstractLauncherIcon* selection) } } -void Launcher::OnIconNeedsRedraw(AbstractLauncherIcon* icon) +void Launcher::OnIconNeedsRedraw(AbstractLauncherIcon::Ptr icon) { EnsureAnimation(); } @@ -2007,7 +2006,7 @@ gboolean Launcher::StartIconDragTimeout(gpointer data) void Launcher::StartIconDragRequest(int x, int y) { - AbstractLauncherIcon* drag_icon = MouseIconIntersection((int)(GetGeometry().x / 2.0f), y); + AbstractLauncherIcon::Ptr drag_icon = MouseIconIntersection((int)(GetGeometry().x / 2.0f), y); // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying // on an internal Launcher property then @@ -2036,7 +2035,7 @@ void Launcher::StartIconDragRequest(int x, int y) } } -void Launcher::StartIconDrag(AbstractLauncherIcon* icon) +void Launcher::StartIconDrag(AbstractLauncherIcon::Ptr icon) { if (!icon) return; @@ -2065,9 +2064,9 @@ void Launcher::EndIconDrag() { if (_drag_window) { - AbstractLauncherIcon* hovered_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y); + AbstractLauncherIcon::Ptr hovered_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y); - if (hovered_icon && hovered_icon->Type() == AbstractLauncherIcon::TYPE_TRASH) + if (hovered_icon && hovered_icon->GetIconType() == AbstractLauncherIcon::TYPE_TRASH) { hovered_icon->SetQuirk(AbstractLauncherIcon::QUIRK_PULSE_ONCE, true); @@ -2107,7 +2106,7 @@ void Launcher::UpdateDragWindowPosition(int x, int y) nux::Geometry geo = _drag_window->GetGeometry(); _drag_window->SetBaseXY(x - geo.width / 2 + _parent->GetGeometry().x, y - geo.height / 2 + _parent->GetGeometry().y); - AbstractLauncherIcon* hovered_icon = MouseIconIntersection((int)(GetGeometry().x / 2.0f), y); + AbstractLauncherIcon::Ptr hovered_icon = MouseIconIntersection((int)(GetGeometry().x / 2.0f), y); struct timespec current; clock_gettime(CLOCK_MONOTONIC, ¤t); @@ -2355,7 +2354,7 @@ void Launcher::EventLogic() GetActionState() == ACTION_DRAG_LAUNCHER) return; - AbstractLauncherIcon* launcher_icon = nullptr; + AbstractLauncherIcon::Ptr launcher_icon; if (!_hidden && !IsInKeyNavMode() && _hovered) { @@ -2380,7 +2379,7 @@ void Launcher::EventLogic() void Launcher::MouseDownLogic(int x, int y, unsigned long button_flags, unsigned long key_flags) { - AbstractLauncherIcon* launcher_icon = nullptr; + AbstractLauncherIcon::Ptr launcher_icon; launcher_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y); _hide_machine->SetQuirk(LauncherHideMachine::LAST_ACTION_ACTIVATE, false); @@ -2399,7 +2398,7 @@ void Launcher::MouseDownLogic(int x, int y, unsigned long button_flags, unsigned void Launcher::MouseUpLogic(int x, int y, unsigned long button_flags, unsigned long key_flags) { - AbstractLauncherIcon* launcher_icon = nullptr; + AbstractLauncherIcon::Ptr launcher_icon; launcher_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y); @@ -2430,7 +2429,7 @@ void Launcher::MouseUpLogic(int x, int y, unsigned long button_flags, unsigned l _icon_mouse_down = nullptr; } -AbstractLauncherIcon* Launcher::MouseIconIntersection(int x, int y) +AbstractLauncherIcon::Ptr Launcher::MouseIconIntersection(int x, int y) { LauncherModel::iterator it; // We are looking for the icon at screen coordinates x, y; @@ -2454,11 +2453,11 @@ AbstractLauncherIcon* Launcher::MouseIconIntersection(int x, int y) return (*it); } - return 0; + return AbstractLauncherIcon::Ptr(); } void -Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon* icon, nux::ObjectPtr texture) +Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr icon, nux::ObjectPtr texture) { RenderArg arg; struct timespec current; @@ -2671,15 +2670,15 @@ Launcher::ProcessDndMove(int x, int y, std::list mimes) } EventLogic(); - AbstractLauncherIcon* hovered_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y); + AbstractLauncherIcon::Ptr hovered_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y); bool hovered_icon_is_appropriate = false; if (hovered_icon) { - if (hovered_icon->Type() == AbstractLauncherIcon::TYPE_TRASH) + if (hovered_icon->GetIconType() == AbstractLauncherIcon::TYPE_TRASH) _steal_drag = false; - if (hovered_icon->Type() == AbstractLauncherIcon::TYPE_APPLICATION || hovered_icon->Type() == AbstractLauncherIcon::TYPE_EXPO) + if (hovered_icon->GetIconType() == AbstractLauncherIcon::TYPE_APPLICATION || hovered_icon->GetIconType() == AbstractLauncherIcon::TYPE_EXPO) hovered_icon_is_appropriate = true; } @@ -2788,11 +2787,11 @@ Launcher::ProcessDndDrop(int x, int y) * Returns the current selected icon if it is in keynavmode * It will return NULL if it is not on keynavmode */ -AbstractLauncherIcon* +AbstractLauncherIcon::Ptr Launcher::GetSelectedMenuIcon() const { if (!IsInKeyNavMode()) - return NULL; + return AbstractLauncherIcon::Ptr(); return _model->Selection(); } @@ -2822,7 +2821,7 @@ Launcher::handle_dbus_method_call(GDBusConnection* connection, g_variant_get(parameters, "(ssiiiss)", &title, &icon, &icon_x, &icon_y, &icon_size, &desktop_file, &aptdaemon_task, NULL); Launcher* self = (Launcher*)user_data; - self->launcher_addrequest_special.emit(desktop_file, nullptr, aptdaemon_task, icon); + self->launcher_addrequest_special.emit(desktop_file, AbstractLauncherIcon::Ptr(), aptdaemon_task, icon); g_dbus_method_invocation_return_value(invocation, nullptr); g_free(icon); diff --git a/plugins/unityshell/src/Launcher.h b/plugins/unityshell/src/Launcher.h index 8b4fa65fa..501f19ff4 100644 --- a/plugins/unityshell/src/Launcher.h +++ b/plugins/unityshell/src/Launcher.h @@ -65,7 +65,7 @@ public: virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw); - AbstractLauncherIcon* GetSelectedMenuIcon() const; + AbstractLauncherIcon::Ptr GetSelectedMenuIcon() const; void SetIconSize(int tile_size, int icon_size); @@ -85,7 +85,7 @@ public: void StartKeyShowLauncher(); void EndKeyShowLauncher(); - void EnsureIconOnScreen(AbstractLauncherIcon* icon); + void EnsureIconOnScreen(AbstractLauncherIcon::Ptr icon); void SetBacklightMode(BacklightMode mode); BacklightMode GetBacklightMode() const; @@ -112,9 +112,9 @@ public: void Resize(); - sigc::signal launcher_addrequest; - sigc::signal launcher_addrequest_special; - sigc::signal launcher_removerequest; + sigc::signal launcher_addrequest; + sigc::signal launcher_addrequest_special; + sigc::signal launcher_removerequest; sigc::signal selection_change; sigc::signal hidden_changed; @@ -181,7 +181,7 @@ private: void OnPluginStateChanged(); - void OnSelectionChanged(AbstractLauncherIcon* selection); + void OnSelectionChanged(AbstractLauncherIcon::Ptr selection); static gboolean AnimationTimeout(gpointer data); static gboolean StrutHack(gpointer data); @@ -195,8 +195,8 @@ private: void OnDragWindowAnimCompleted(); - bool IconNeedsAnimation(AbstractLauncherIcon* icon, struct timespec const& current) const; - bool IconDrawEdgeOnly(AbstractLauncherIcon* icon) const; + bool IconNeedsAnimation(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + bool IconDrawEdgeOnly(AbstractLauncherIcon::Ptr icon) const; bool AnimationInProgress() const; void SetActionState(LauncherActionState actionstate); @@ -221,20 +221,20 @@ private: float DragThresholdProgress(struct timespec const& current) const; float DragHideProgress(struct timespec const& current) const; float DragOutProgress(struct timespec const& current) const; - float IconDesatValue(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconPresentProgress(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconUrgentProgress(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconShimmerProgress(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconUrgentPulseValue(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconPulseOnceValue(AbstractLauncherIcon *icon, struct timespec const ¤t) const; - float IconUrgentWiggleValue(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconStartingBlinkValue(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconStartingPulseValue(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconBackgroundIntensity(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconProgressBias(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconDropDimValue(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconCenterTransitionProgress(AbstractLauncherIcon* icon, struct timespec const& current) const; - float IconVisibleProgress(AbstractLauncherIcon* icon, struct timespec const& current) const; + float IconDesatValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconPresentProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconUrgentProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconShimmerProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconUrgentPulseValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconPulseOnceValue(AbstractLauncherIcon::Ptr icon, struct timespec const ¤t) const; + float IconUrgentWiggleValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconStartingBlinkValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconStartingPulseValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconBackgroundIntensity(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconProgressBias(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconDropDimValue(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconCenterTransitionProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; + float IconVisibleProgress(AbstractLauncherIcon::Ptr icon, struct timespec const& current) const; void SetHover(bool hovered); void SetHidden(bool hidden); @@ -242,8 +242,8 @@ private: void SetDndDelta(float x, float y, nux::Geometry const& geo, timespec const& current); float DragLimiter(float x); - void SetupRenderArg(AbstractLauncherIcon* icon, struct timespec const& current, ui::RenderArg& arg); - void FillRenderArg(AbstractLauncherIcon* icon, + void SetupRenderArg(AbstractLauncherIcon::Ptr icon, struct timespec const& current, ui::RenderArg& arg); + void FillRenderArg(AbstractLauncherIcon::Ptr icon, ui::RenderArg& arg, nux::Point3& center, nux::Geometry const& parent_abs_geo, @@ -258,11 +258,11 @@ private: void RenderArgs(std::list &launcher_args, nux::Geometry& box_geo, float* launcher_alpha, nux::Geometry const& parent_abs_geo); - void OnIconAdded(AbstractLauncherIcon* icon); - void OnIconRemoved(AbstractLauncherIcon* icon); + void OnIconAdded(AbstractLauncherIcon::Ptr icon); + void OnIconRemoved(AbstractLauncherIcon::Ptr icon); void OnOrderChanged(); - void OnIconNeedsRedraw(AbstractLauncherIcon* icon); + void OnIconNeedsRedraw(AbstractLauncherIcon::Ptr icon); void OnOverlayHidden(GVariant* data); void OnOverlayShown(GVariant* data); @@ -276,15 +276,15 @@ private: void OnActionDone(GVariant* data); - void RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon* icon, nux::ObjectPtr texture); + void RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr icon, nux::ObjectPtr texture); - AbstractLauncherIcon* MouseIconIntersection(int x, int y); + AbstractLauncherIcon::Ptr MouseIconIntersection(int x, int y); void EventLogic(); void MouseDownLogic(int x, int y, unsigned long button_flags, unsigned long key_flags); void MouseUpLogic(int x, int y, unsigned long button_flags, unsigned long key_flags); void StartIconDragRequest(int x, int y); - void StartIconDrag(AbstractLauncherIcon* icon); + void StartIconDrag(AbstractLauncherIcon::Ptr icon); void EndIconDrag(); void UpdateDragWindowPosition(int x, int y); @@ -305,9 +305,9 @@ private: nux::HLayout* m_Layout; // used by keyboard/a11y-navigation - AbstractLauncherIcon* _icon_under_mouse; - AbstractLauncherIcon* _icon_mouse_down; - AbstractLauncherIcon* _drag_icon; + AbstractLauncherIcon::Ptr _icon_under_mouse; + AbstractLauncherIcon::Ptr _icon_mouse_down; + AbstractLauncherIcon::Ptr _drag_icon; QuicklistView* _active_quicklist; @@ -368,7 +368,7 @@ private: bool _data_checked; bool _steal_drag; bool _drag_edge_touching; - AbstractLauncherIcon* _dnd_hovered_icon; + AbstractLauncherIcon::Ptr _dnd_hovered_icon; unity::DNDCollectionWindow* _collection_window; sigc::connection _on_data_collected_connection; diff --git a/plugins/unityshell/src/LauncherController.cpp b/plugins/unityshell/src/LauncherController.cpp index 9898f3dd0..06d278845 100644 --- a/plugins/unityshell/src/LauncherController.cpp +++ b/plugins/unityshell/src/LauncherController.cpp @@ -80,12 +80,12 @@ public: void Save(); void SortAndUpdate(); - void OnIconAdded(AbstractLauncherIcon* icon); - void OnIconRemoved(AbstractLauncherIcon* icon); + void OnIconAdded(AbstractLauncherIcon::Ptr icon); + void OnIconRemoved(AbstractLauncherIcon::Ptr icon); - void OnLauncherAddRequest(char* path, AbstractLauncherIcon* before); - void OnLauncherAddRequestSpecial(std::string const& path, AbstractLauncherIcon* before, std::string const& aptdaemon_trans_id, std::string const& icon_path); - void OnLauncherRemoveRequest(AbstractLauncherIcon* icon); + void OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before); + void OnLauncherAddRequestSpecial(std::string const& path, AbstractLauncherIcon::Ptr before, std::string const& aptdaemon_trans_id, std::string const& icon_path); + void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr icon); void OnLauncherEntryRemoteAdded(LauncherEntryRemote* entry); void OnLauncherEntryRemoteRemoved(LauncherEntryRemote* entry); @@ -111,11 +111,11 @@ public: void InsertTrash(); - void RegisterIcon(AbstractLauncherIcon* icon); + void RegisterIcon(AbstractLauncherIcon::Ptr icon); - AbstractLauncherIcon* CreateFavorite(const char* file_path); + AbstractLauncherIcon::Ptr CreateFavorite(const char* file_path); - SoftwareCenterLauncherIcon* CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); + AbstractLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); void SetupBamf(); @@ -145,9 +145,9 @@ public: int sort_priority_; DeviceLauncherSection* device_section_; LauncherEntryRemoteModel remote_model_; - SimpleLauncherIcon* expo_icon_; - DesktopLauncherIcon* desktop_launcher_icon_; - nux::ObjectPtr desktop_icon_; + AbstractLauncherIcon::Ptr expo_icon_; + AbstractLauncherIcon::Ptr desktop_launcher_icon_; + AbstractLauncherIcon::Ptr desktop_icon_; int num_workspaces_; bool show_desktop_icon_; Display* display_; @@ -234,8 +234,8 @@ Controller::Impl::Impl(Display* display, Controller* parent) FavoriteStore::GetDefault().favorite_removed.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteRemoved)); FavoriteStore::GetDefault().reordered.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreReordered)); - RegisterIcon(new BFBLauncherIcon()); - desktop_icon_ = new DesktopLauncherIcon(); + RegisterIcon(AbstractLauncherIcon::Ptr(new BFBLauncherIcon())); + desktop_icon_ = AbstractLauncherIcon::Ptr(new DesktopLauncherIcon()); uscreen->changed.connect(sigc::mem_fun(this, &Controller::Impl::OnScreenChanged)); @@ -333,7 +333,7 @@ Launcher* Controller::Impl::CreateLauncher(int monitor) return launcher; } -void Controller::Impl::OnLauncherAddRequest(char* path, AbstractLauncherIcon* before) +void Controller::Impl::OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before) { for (auto it : model_->GetSublist ()) { @@ -346,7 +346,7 @@ void Controller::Impl::OnLauncherAddRequest(char* path, AbstractLauncherIcon* be } } - AbstractLauncherIcon* result = CreateFavorite(path); + AbstractLauncherIcon::Ptr result = CreateFavorite(path); if (result) { RegisterIcon(result); @@ -362,7 +362,7 @@ void Controller::Impl::Save() unity::FavoriteList desktop_paths; // Updates gsettings favorites. - std::list launchers = model_->GetSublist (); + auto launchers = model_->GetSublist (); for (auto icon : launchers) { if (!icon->IsSticky()) @@ -379,20 +379,18 @@ void Controller::Impl::Save() void Controller::Impl::OnLauncherAddRequestSpecial(std::string const& path, - AbstractLauncherIcon* before, + AbstractLauncherIcon::Ptr before, std::string const& aptdaemon_trans_id, std::string const& icon_path) { - std::list launchers; - - launchers = model_->GetSublist(); + auto launchers = model_->GetSublist(); for (auto icon : launchers) { if (icon->DesktopFile() == path) return; } - SoftwareCenterLauncherIcon* result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path); + AbstractLauncherIcon::Ptr result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path); if (result) { RegisterIcon(result); @@ -407,7 +405,7 @@ void Controller::Impl::SortAndUpdate() { gint shortcut = 1; - std::list launchers = model_->GetSublist (); + auto launchers = model_->GetSublist (); for (auto icon : launchers) { if (shortcut <= 10 && icon->IsVisible()) @@ -425,23 +423,23 @@ void Controller::Impl::SortAndUpdate() } } -void Controller::Impl::OnIconAdded(AbstractLauncherIcon* icon) +void Controller::Impl::OnIconAdded(AbstractLauncherIcon::Ptr icon) { this->RegisterIcon(icon); } -void Controller::Impl::OnIconRemoved(AbstractLauncherIcon* icon) +void Controller::Impl::OnIconRemoved(AbstractLauncherIcon::Ptr icon) { SortAndUpdate(); } -void Controller::Impl::OnLauncherRemoveRequest(AbstractLauncherIcon* icon) +void Controller::Impl::OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr icon) { - switch (icon->Type()) + switch (icon->GetIconType()) { case AbstractLauncherIcon::TYPE_APPLICATION: { - BamfLauncherIcon* bamf_icon = dynamic_cast(icon); + BamfLauncherIcon* bamf_icon = dynamic_cast(icon.GetPointer()); if (bamf_icon) { @@ -453,7 +451,7 @@ void Controller::Impl::OnLauncherRemoveRequest(AbstractLauncherIcon* icon) } case AbstractLauncherIcon::TYPE_DEVICE: { - DeviceLauncherIcon* device_icon = dynamic_cast(icon); + DeviceLauncherIcon* device_icon = dynamic_cast(icon.GetPointer()); if (device_icon && device_icon->CanEject()) device_icon->Eject(); @@ -490,7 +488,9 @@ void Controller::Impl::OnLauncherEntryRemoteRemoved(LauncherEntryRemote* entry) void Controller::Impl::OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before) { auto bamf_list = model_->GetSublist(); - AbstractLauncherIcon* other = (bamf_list.size() > 0) ? *(bamf_list.begin()) : nullptr; + AbstractLauncherIcon::Ptr other; + if (bamf_list.size() > 0) + other = *(bamf_list.begin()); if (!pos.empty()) { @@ -514,7 +514,7 @@ void Controller::Impl::OnFavoriteStoreFavoriteAdded(std::string const& entry, st } } - AbstractLauncherIcon* result = CreateFavorite(entry.c_str()); + AbstractLauncherIcon::Ptr result = CreateFavorite(entry.c_str()); if (result) { RegisterIcon(result); @@ -546,7 +546,7 @@ void Controller::Impl::OnFavoriteStoreReordered() for (auto it : favs) { auto icon = std::find_if(bamf_list.begin(), bamf_list.end(), - [&it](BamfLauncherIcon* x) { return (x->DesktopFile() == it); }); + [&it](AbstractLauncherIcon::Ptr x) { return (x->DesktopFile() == it); }); if (icon != bamf_list.end()) { @@ -570,8 +570,7 @@ void Controller::Impl::OnExpoActivated() void Controller::Impl::InsertTrash() { - TrashLauncherIcon* icon; - icon = new TrashLauncherIcon(); + AbstractLauncherIcon::Ptr icon(new TrashLauncherIcon()); RegisterIcon(icon); } @@ -591,17 +590,19 @@ void Controller::Impl::UpdateNumWorkspaces(int workspaces) void Controller::Impl::InsertExpoAction() { - expo_icon_ = new SimpleLauncherIcon(); + expo_icon_ = AbstractLauncherIcon::Ptr(new SimpleLauncherIcon()); - expo_icon_->tooltip_text = _("Workspace Switcher"); - expo_icon_->icon_name = "workspace-switcher"; - expo_icon_->SetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE, true); - expo_icon_->SetQuirk(AbstractLauncherIcon::QUIRK_RUNNING, false); - expo_icon_->SetIconType(AbstractLauncherIcon::TYPE_EXPO); - expo_icon_->SetShortcut('s'); + SimpleLauncherIcon* icon = static_cast(expo_icon_.GetPointer()); + icon->tooltip_text = _("Workspace Switcher"); + icon->icon_name = "workspace-switcher"; + icon->SetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE, true); + icon->SetQuirk(AbstractLauncherIcon::QUIRK_RUNNING, false); + icon->SetIconType(AbstractLauncherIcon::TYPE_EXPO); + icon->SetShortcut('s'); - on_expoicon_activate_connection_ = expo_icon_->activate.connect(sigc::mem_fun(this, &Impl::OnExpoActivated)); + on_expoicon_activate_connection_ = icon->activate.connect(sigc::mem_fun(this, &Impl::OnExpoActivated)); + RegisterIcon(expo_icon_); } @@ -614,10 +615,7 @@ void Controller::Impl::RemoveExpoAction() void Controller::Impl::InsertDesktopIcon() { - desktop_launcher_icon_ = new DesktopLauncherIcon(); - desktop_launcher_icon_->SetIconType(AbstractLauncherIcon::TYPE_DESKTOP); - desktop_launcher_icon_->SetShowInSwitcher(false); - + desktop_launcher_icon_ = AbstractLauncherIcon::Ptr(new DesktopLauncherIcon()); RegisterIcon(desktop_launcher_icon_); } @@ -626,20 +624,16 @@ void Controller::Impl::RemoveDesktopIcon() model_->RemoveIcon(desktop_launcher_icon_); } -void Controller::Impl::RegisterIcon(AbstractLauncherIcon* icon) +void Controller::Impl::RegisterIcon(AbstractLauncherIcon::Ptr icon) { model_->AddIcon(icon); - BamfLauncherIcon* bamf_icon = dynamic_cast(icon); - if (bamf_icon) - { - LauncherEntryRemote* entry = NULL; - std::string const& path = bamf_icon->DesktopFile(); - if (!path.empty()) - entry = remote_model_.LookupByDesktopFile(path.c_str()); - if (entry) - icon->InsertEntryRemote(entry); - } + LauncherEntryRemote* entry = NULL; + std::string const& path = icon->DesktopFile(); + if (!path.empty()) + entry = remote_model_.LookupByDesktopFile(path.c_str()); + if (entry) + icon->InsertEntryRemote(entry); } /* static private */ @@ -659,71 +653,69 @@ void Controller::Impl::OnViewOpened(BamfMatcher* matcher, BamfView* view, gpoint return; } - BamfLauncherIcon* icon = new BamfLauncherIcon(app); - icon->SetIconType(AbstractLauncherIcon::TYPE_APPLICATION); + AbstractLauncherIcon::Ptr icon (new BamfLauncherIcon(app)); icon->SetSortPriority(self->sort_priority_++); self->RegisterIcon(icon); } -AbstractLauncherIcon* Controller::Impl::CreateFavorite(const char* file_path) +AbstractLauncherIcon::Ptr Controller::Impl::CreateFavorite(const char* file_path) { BamfApplication* app; - BamfLauncherIcon* icon; + AbstractLauncherIcon::Ptr result; app = bamf_matcher_get_application_for_desktop_file(matcher_, file_path, true); if (!app) - return NULL; + return result; if (g_object_get_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"))) { bamf_view_set_sticky(BAMF_VIEW(app), true); - return 0; + return result; } g_object_set_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"), GINT_TO_POINTER(1)); bamf_view_set_sticky(BAMF_VIEW(app), true); - icon = new BamfLauncherIcon(app); - icon->SetIconType(AbstractLauncherIcon::TYPE_APPLICATION); + AbstractLauncherIcon::Ptr icon (new BamfLauncherIcon(app)); icon->SetSortPriority(sort_priority_++); + result = icon; - return icon; + return result; } -SoftwareCenterLauncherIcon* +AbstractLauncherIcon::Ptr Controller::Impl::CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path) { BamfApplication* app; - SoftwareCenterLauncherIcon* icon; + AbstractLauncherIcon::Ptr result; app = bamf_matcher_get_application_for_desktop_file(matcher_, file_path.c_str(), true); if (!BAMF_IS_APPLICATION(app)) - return NULL; + return result; if (g_object_get_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"))) { bamf_view_set_sticky(BAMF_VIEW(app), true); - return 0; + return result; } g_object_set_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"), GINT_TO_POINTER(1)); bamf_view_set_sticky(BAMF_VIEW(app), true); - icon = new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path); - icon->SetIconType(LauncherIcon::TYPE_APPLICATION); + AbstractLauncherIcon::Ptr icon(new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path)); icon->SetSortPriority(sort_priority_++); - return icon; + result = icon; + return result; } void Controller::Impl::SetupBamf() { GList* apps, *l; BamfApplication* app; - BamfLauncherIcon* icon; // Sufficiently large number such that we ensure proper sorting // (avoids case where first item gets tacked onto end rather than start) @@ -736,7 +728,7 @@ void Controller::Impl::SetupBamf() for (FavoriteList::const_iterator i = favs.begin(), end = favs.end(); i != end; ++i) { - AbstractLauncherIcon* fav = CreateFavorite(i->c_str()); + AbstractLauncherIcon::Ptr fav = CreateFavorite(i->c_str()); if (fav) { @@ -757,7 +749,7 @@ void Controller::Impl::SetupBamf() continue; g_object_set_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"), GINT_TO_POINTER(1)); - icon = new BamfLauncherIcon(app); + AbstractLauncherIcon::Ptr icon(new BamfLauncherIcon(app)); icon->SetSortPriority(sort_priority_++); RegisterIcon(icon); } @@ -827,11 +819,11 @@ std::vector Controller::GetAllShortcuts() const return shortcuts; } -std::vector Controller::GetAltTabIcons(bool current) const +std::vector Controller::GetAltTabIcons(bool current) const { - std::vector results; + std::vector results; - results.push_back(pimpl->desktop_icon_.GetPointer()); + results.push_back(pimpl->desktop_icon_); for (auto icon : *(pimpl->model_)) if (icon->ShowInSwitcher(current)) diff --git a/plugins/unityshell/src/LauncherController.h b/plugins/unityshell/src/LauncherController.h index b9cb20601..06cd7e66d 100644 --- a/plugins/unityshell/src/LauncherController.h +++ b/plugins/unityshell/src/LauncherController.h @@ -53,7 +53,7 @@ public: void UpdateNumWorkspaces(int workspaces); std::vector GetAllShortcuts() const; - std::vector GetAltTabIcons(bool current) const; + std::vector GetAltTabIcons(bool current) const; void PushToFront(); diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp index de7081072..48dd20a07 100644 --- a/plugins/unityshell/src/LauncherIcon.cpp +++ b/plugins/unityshell/src/LauncherIcon.cpp @@ -706,7 +706,7 @@ LauncherIcon::SetWindowVisibleOnMonitor(bool val, int monitor) return; _has_visible_window[monitor] = val; - needs_redraw.emit(this); + EmitNeedsRedraw(); } gboolean @@ -760,7 +760,7 @@ LauncherIcon::Remove() _quicklist->Hide(); SetQuirk(QUIRK_VISIBLE, false); - remove.emit(this); + EmitRemove(); } void @@ -782,7 +782,7 @@ LauncherIcon::SortPriority() } LauncherIcon::IconType -LauncherIcon::Type() +LauncherIcon::GetIconType() { return _icon_type; } @@ -804,7 +804,7 @@ LauncherIcon::SetQuirk(LauncherIcon::Quirk quirk, bool value) TimeUtil::SetTimeStruct(&(_quirk_times[quirk]), &(_quirk_times[quirk]), Launcher::ANIM_DURATION_SHORT); else clock_gettime(CLOCK_MONOTONIC, &(_quirk_times[quirk])); - needs_redraw.emit(this); + EmitNeedsRedraw(); // Present on urgent as a general policy if (quirk == QUIRK_VISIBLE && value) @@ -828,7 +828,7 @@ LauncherIcon::OnDelayedUpdateTimeout(gpointer data) LauncherIcon* self = arg->self; clock_gettime(CLOCK_MONOTONIC, &(self->_quirk_times[arg->quirk])); - self->needs_redraw.emit(self); + self->EmitNeedsRedraw(); self->_time_delay_handle = 0; @@ -849,7 +849,7 @@ void LauncherIcon::UpdateQuirkTime(LauncherIcon::Quirk quirk) { clock_gettime(CLOCK_MONOTONIC, &(_quirk_times[quirk])); - needs_redraw.emit(this); + EmitNeedsRedraw(); } void @@ -872,7 +872,7 @@ LauncherIcon::SetProgress(float progress) return; _progress = progress; - needs_redraw.emit(this); + EmitNeedsRedraw(); } float @@ -902,7 +902,7 @@ void LauncherIcon::SetEmblem(LauncherIcon::BaseTexturePtr const& emblem) { _emblem = emblem; - needs_redraw.emit(this); + EmitNeedsRedraw(); } void @@ -1135,5 +1135,20 @@ LauncherIcon::OnRemoteProgressVisibleChanged(LauncherEntryRemote* remote) SetProgress((float) remote->Progress()); } +void LauncherIcon::EmitNeedsRedraw() +{ + auto slots = needs_redraw.slots(); + if (slots.begin() != slots.end()) + needs_redraw.emit(AbstractLauncherIcon::Ptr(this)); +} + +void LauncherIcon::EmitRemove() +{ + auto slots = remove.slots(); + if (slots.begin() != slots.end()) + remove.emit(AbstractLauncherIcon::Ptr(this)); +} + + } // namespace launcher } // namespace unity diff --git a/plugins/unityshell/src/LauncherIcon.h b/plugins/unityshell/src/LauncherIcon.h index 6d45c8d39..1574a7994 100644 --- a/plugins/unityshell/src/LauncherIcon.h +++ b/plugins/unityshell/src/LauncherIcon.h @@ -141,7 +141,7 @@ public: struct timespec GetQuirkTime(Quirk quirk); - IconType Type(); + IconType GetIconType(); virtual nux::Color BackgroundColor(); @@ -184,6 +184,18 @@ public: void SetIconType(IconType type); + virtual std::string DesktopFile() { return std::string(""); } + + virtual bool IsSticky() const { return false; } + + virtual bool IsVisible() const { return false; } + + virtual void AboutToRemove() {} + + virtual void Stick(bool save = true) {} + + virtual void UnStick() {} + protected: std::vector GetCenters(); @@ -263,6 +275,9 @@ protected: void OnRemoteProgressVisibleChanged(LauncherEntryRemote* remote); + void EmitNeedsRedraw(); + + void EmitRemove(); // This looks like a case for boost::logical::tribool static int _current_theme_is_mono; diff --git a/plugins/unityshell/src/LauncherModel.cpp b/plugins/unityshell/src/LauncherModel.cpp index ae613b0ae..879a0b9b2 100644 --- a/plugins/unityshell/src/LauncherModel.cpp +++ b/plugins/unityshell/src/LauncherModel.cpp @@ -30,7 +30,7 @@ namespace launcher typedef struct { - AbstractLauncherIcon* icon; + AbstractLauncherIcon::Ptr icon; LauncherModel* self; } RemoveArg; @@ -41,11 +41,6 @@ LauncherModel::LauncherModel() LauncherModel::~LauncherModel() { - for (auto icon : _inner_shelf) - icon->UnReference(); - - for (auto icon : _inner_main) - icon->UnReference(); } std::string LauncherModel::GetName() const @@ -64,21 +59,21 @@ unity::debug::Introspectable::IntrospectableList const& LauncherModel::GetIntros introspection_results_.clear(); for (auto icon : _inner) - introspection_results_.push_back(icon); + introspection_results_.push_back(icon.GetPointer()); return introspection_results_; } -bool LauncherModel::IconShouldShelf(AbstractLauncherIcon* icon) const +bool LauncherModel::IconShouldShelf(AbstractLauncherIcon::Ptr icon) const { - return icon->Type() == AbstractLauncherIcon::TYPE_TRASH; + return icon->GetIconType() == AbstractLauncherIcon::TYPE_TRASH; } -bool LauncherModel::CompareIcons(AbstractLauncherIcon* first, AbstractLauncherIcon* second) +bool LauncherModel::CompareIcons(AbstractLauncherIcon::Ptr first, AbstractLauncherIcon::Ptr second) { - if (first->Type() < second->Type()) + if (first->GetIconType() < second->GetIconType()) return true; - else if (first->Type() > second->Type()) + else if (first->GetIconType() > second->GetIconType()) return false; return first->SortPriority() < second->SortPriority(); @@ -112,10 +107,8 @@ LauncherModel::Populate() } void -LauncherModel::AddIcon(AbstractLauncherIcon* icon) +LauncherModel::AddIcon(AbstractLauncherIcon::Ptr icon) { - icon->SinkReference(); - if (IconShouldShelf(icon)) _inner_shelf.push_back(icon); else @@ -131,7 +124,7 @@ LauncherModel::AddIcon(AbstractLauncherIcon* icon) } void -LauncherModel::RemoveIcon(AbstractLauncherIcon* icon) +LauncherModel::RemoveIcon(AbstractLauncherIcon::Ptr icon) { size_t size; @@ -144,7 +137,6 @@ LauncherModel::RemoveIcon(AbstractLauncherIcon* icon) if (size != _inner.size()) { icon_removed.emit(icon); - icon->UnReference(); } } @@ -160,7 +152,7 @@ LauncherModel::RemoveCallback(gpointer data) } void -LauncherModel::OnIconRemove(AbstractLauncherIcon* icon) +LauncherModel::OnIconRemove(AbstractLauncherIcon::Ptr icon) { RemoveArg* arg = (RemoveArg*) g_malloc0(sizeof(RemoveArg)); arg->icon = icon; @@ -186,12 +178,12 @@ LauncherModel::Sort() } bool -LauncherModel::IconHasSister(AbstractLauncherIcon* icon) const +LauncherModel::IconHasSister(AbstractLauncherIcon::Ptr icon) const { const_iterator it; const_iterator end; - if (icon && icon->Type() == AbstractLauncherIcon::TYPE_DEVICE) + if (icon && icon->GetIconType() == AbstractLauncherIcon::TYPE_DEVICE) return true; if (IconShouldShelf(icon)) @@ -207,9 +199,9 @@ LauncherModel::IconHasSister(AbstractLauncherIcon* icon) const for (; it != end; ++it) { - AbstractLauncherIcon* iter_icon = *it; + AbstractLauncherIcon::Ptr iter_icon = *it; if ((iter_icon != icon) - && iter_icon->Type() == icon->Type()) + && iter_icon->GetIconType() == icon->GetIconType()) return true; } @@ -217,7 +209,7 @@ LauncherModel::IconHasSister(AbstractLauncherIcon* icon) const } void -LauncherModel::ReorderAfter(AbstractLauncherIcon* icon, AbstractLauncherIcon* other) +LauncherModel::ReorderAfter(AbstractLauncherIcon::Ptr icon, AbstractLauncherIcon::Ptr other) { if (icon == other) return; @@ -247,7 +239,7 @@ LauncherModel::ReorderAfter(AbstractLauncherIcon* icon, AbstractLauncherIcon* ot } void -LauncherModel::ReorderBefore(AbstractLauncherIcon* icon, AbstractLauncherIcon* other, bool save) +LauncherModel::ReorderBefore(AbstractLauncherIcon::Ptr icon, AbstractLauncherIcon::Ptr other, bool save) { if (icon == other) return; @@ -288,7 +280,7 @@ LauncherModel::ReorderBefore(AbstractLauncherIcon* icon, AbstractLauncherIcon* o } void -LauncherModel::ReorderSmart(AbstractLauncherIcon* icon, AbstractLauncherIcon* other, bool save) +LauncherModel::ReorderSmart(AbstractLauncherIcon::Ptr icon, AbstractLauncherIcon::Ptr other, bool save) { if (icon == other) return; @@ -347,7 +339,7 @@ LauncherModel::Size() const return _inner.size(); } -AbstractLauncherIcon* LauncherModel::Selection () const +AbstractLauncherIcon::Ptr LauncherModel::Selection () const { return _inner[selection_]; } diff --git a/plugins/unityshell/src/LauncherModel.h b/plugins/unityshell/src/LauncherModel.h index 5fb48f984..23f8b321d 100644 --- a/plugins/unityshell/src/LauncherModel.h +++ b/plugins/unityshell/src/LauncherModel.h @@ -35,7 +35,7 @@ class LauncherModel : public unity::debug::Introspectable, public sigc::trackabl { public: typedef std::shared_ptr Ptr; - typedef std::vector Base; + typedef std::vector Base; typedef Base::iterator iterator; typedef Base::const_iterator const_iterator; typedef Base::reverse_iterator reverse_iterator; @@ -44,22 +44,22 @@ public: LauncherModel(); ~LauncherModel(); - void AddIcon(AbstractLauncherIcon* icon); - void RemoveIcon(AbstractLauncherIcon* icon); + void AddIcon(AbstractLauncherIcon::Ptr icon); + void RemoveIcon(AbstractLauncherIcon::Ptr icon); void Save(); void Sort(); int Size() const; - void OnIconRemove(AbstractLauncherIcon* icon); + void OnIconRemove(AbstractLauncherIcon::Ptr icon); - bool IconHasSister(AbstractLauncherIcon* icon) const; + bool IconHasSister(AbstractLauncherIcon::Ptr icon) const; - void ReorderAfter(AbstractLauncherIcon* icon, AbstractLauncherIcon* other); - void ReorderBefore(AbstractLauncherIcon* icon, AbstractLauncherIcon* other, bool save); + void ReorderAfter(AbstractLauncherIcon::Ptr icon, AbstractLauncherIcon::Ptr other); + void ReorderBefore(AbstractLauncherIcon::Ptr icon, AbstractLauncherIcon::Ptr other, bool save); - void ReorderSmart(AbstractLauncherIcon* icon, AbstractLauncherIcon* other, bool save); + void ReorderSmart(AbstractLauncherIcon::Ptr icon, AbstractLauncherIcon::Ptr other, bool save); - AbstractLauncherIcon* Selection() const; + AbstractLauncherIcon::Ptr Selection() const; int SelectionIndex() const; void SetSelection(int selection); void SelectNext(); @@ -81,11 +81,11 @@ public: reverse_iterator shelf_rbegin(); reverse_iterator shelf_rend(); - sigc::signal icon_added; - sigc::signal icon_removed; + sigc::signal icon_added; + sigc::signal icon_removed; sigc::signal order_changed; sigc::signal saved; - sigc::signal selection_changed; + sigc::signal selection_changed; IntrospectableList const& GetIntrospectableChildren(); protected: @@ -102,26 +102,26 @@ private: bool Populate(); - bool IconShouldShelf(AbstractLauncherIcon* icon) const; + bool IconShouldShelf(AbstractLauncherIcon::Ptr icon) const; static gboolean RemoveCallback(gpointer data); - static bool CompareIcons(AbstractLauncherIcon* first, AbstractLauncherIcon* second); + static bool CompareIcons(AbstractLauncherIcon::Ptr first, AbstractLauncherIcon::Ptr second); /* Template Methods */ public: template - std::list GetSublist() + std::list GetSublist() { - std::list result; + std::list result; iterator it; for (it = begin(); it != end(); it++) { - T* var = dynamic_cast(*it); + T* var = dynamic_cast((*it).GetPointer()); if (var) - result.push_back(var); + result.push_back(*it); } return result; diff --git a/plugins/unityshell/src/MockLauncherIcon.h b/plugins/unityshell/src/MockLauncherIcon.h index eddce171a..db577e200 100644 --- a/plugins/unityshell/src/MockLauncherIcon.h +++ b/plugins/unityshell/src/MockLauncherIcon.h @@ -42,6 +42,7 @@ namespace launcher class MockLauncherIcon : public AbstractLauncherIcon { + NUX_DECLARE_OBJECT_TYPE(MockLauncherIcon, AbstractLauncherIcon); public: MockLauncherIcon() : icon_(0) @@ -185,7 +186,7 @@ public: return tv; } - IconType Type() + IconType GetIconType() { return type_; } @@ -239,6 +240,18 @@ public: void SendDndLeave() {} + std::string DesktopFile() { return std::string(""); } + + bool IsSticky() const { return false; } + + bool IsVisible() const { return false; } + + void AboutToRemove() {} + + void Stick(bool save = true) {} + + void UnStick() {} + private: nux::BaseTexture* TextureFromGtkTheme(const char* icon_name, int size) { @@ -292,6 +305,8 @@ private: IconType type_; }; +NUX_IMPLEMENT_OBJECT_TYPE(MockLauncherIcon); + } } diff --git a/plugins/unityshell/src/SimpleLauncherIcon.cpp b/plugins/unityshell/src/SimpleLauncherIcon.cpp index 9d0a4ac9c..3b29267c7 100644 --- a/plugins/unityshell/src/SimpleLauncherIcon.cpp +++ b/plugins/unityshell/src/SimpleLauncherIcon.cpp @@ -40,6 +40,8 @@ namespace nux::logging::Logger logger("unity.dash.CategoryViewGrid"); } +NUX_IMPLEMENT_OBJECT_TYPE(SimpleLauncherIcon); + SimpleLauncherIcon::SimpleLauncherIcon() : LauncherIcon() , icon_name("", sigc::mem_fun(this, &SimpleLauncherIcon::SetIconName)) @@ -130,7 +132,7 @@ void SimpleLauncherIcon::ReloadIcon() element.second->UnReference(); texture_map.clear (); - needs_redraw.emit(this); + EmitNeedsRedraw(); } void SimpleLauncherIcon::OnIconThemeChanged(GtkIconTheme* icon_theme, gpointer data) diff --git a/plugins/unityshell/src/SimpleLauncherIcon.h b/plugins/unityshell/src/SimpleLauncherIcon.h index 2d2a8faee..271bdd98c 100644 --- a/plugins/unityshell/src/SimpleLauncherIcon.h +++ b/plugins/unityshell/src/SimpleLauncherIcon.h @@ -31,6 +31,7 @@ class Launcher; class SimpleLauncherIcon : public LauncherIcon { + NUX_DECLARE_OBJECT_TYPE(SimpleLauncherIcon, LauncherIcon); public: SimpleLauncherIcon(); virtual ~SimpleLauncherIcon(); diff --git a/plugins/unityshell/src/SoftwareCenterLauncherIcon.cpp b/plugins/unityshell/src/SoftwareCenterLauncherIcon.cpp index babbce605..adb7d1194 100644 --- a/plugins/unityshell/src/SoftwareCenterLauncherIcon.cpp +++ b/plugins/unityshell/src/SoftwareCenterLauncherIcon.cpp @@ -43,6 +43,7 @@ SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(BamfApplication* app, SetProgress(0.0f); }); + SetIconType(TYPE_APPLICATION); icon_name = icon_path.c_str(); tooltip_text = _("Waiting to install"); } diff --git a/plugins/unityshell/src/SwitcherController.cpp b/plugins/unityshell/src/SwitcherController.cpp index 0a4e5a46e..88ff49f22 100644 --- a/plugins/unityshell/src/SwitcherController.cpp +++ b/plugins/unityshell/src/SwitcherController.cpp @@ -74,7 +74,7 @@ void Controller::OnBackgroundUpdate(GVariant* data, Controller* self) } void Controller::Show(ShowMode show, SortMode sort, bool reverse, - std::vector results) + std::vector results) { if (sort == SortMode::FOCUS_ORDER) { @@ -147,7 +147,7 @@ gboolean Controller::OnDetailTimer(gpointer data) return FALSE; } -void Controller::OnModelSelectionChanged(AbstractLauncherIcon *icon) +void Controller::OnModelSelectionChanged(AbstractLauncherIcon::Ptr icon) { if (detail_on_timeout) { @@ -205,7 +205,7 @@ void Controller::Hide(bool accept_state) if (accept_state) { - AbstractLauncherIcon* selection = model_->Selection(); + AbstractLauncherIcon::Ptr selection = model_->Selection(); if (selection) { if (model_->detail_selection) @@ -374,12 +374,12 @@ LayoutWindowList Controller::ExternalRenderTargets() return view_->ExternalTargets(); } -bool Controller::CompareSwitcherItemsPriority(AbstractLauncherIcon* first, - AbstractLauncherIcon* second) +bool Controller::CompareSwitcherItemsPriority(AbstractLauncherIcon::Ptr first, + AbstractLauncherIcon::Ptr second) { - if (first->Type() == second->Type()) + if (first->GetIconType() == second->GetIconType()) return first->SwitcherPriority() > second->SwitcherPriority(); - return first->Type() < second->Type(); + return first->GetIconType() < second->GetIconType(); } void Controller::SelectFirstItem() @@ -387,8 +387,8 @@ void Controller::SelectFirstItem() if (!model_) return; - AbstractLauncherIcon* first = model_->at(1); - AbstractLauncherIcon* second = model_->at(2); + AbstractLauncherIcon::Ptr first = model_->at(1); + AbstractLauncherIcon::Ptr second = model_->at(2); if (!first) { diff --git a/plugins/unityshell/src/SwitcherController.h b/plugins/unityshell/src/SwitcherController.h index 1c1afe134..75a768e5e 100644 --- a/plugins/unityshell/src/SwitcherController.h +++ b/plugins/unityshell/src/SwitcherController.h @@ -70,7 +70,7 @@ public: nux::Property detail_on_timeout; nux::Property detail_timeout_length; - void Show(ShowMode show, SortMode sort, bool reverse, std::vector results); + void Show(ShowMode show, SortMode sort, bool reverse, std::vector results); void Hide(bool accept_state=true); bool Visible(); @@ -108,7 +108,7 @@ private: void ConstructView(); - void OnModelSelectionChanged(launcher::AbstractLauncherIcon *icon); + void OnModelSelectionChanged(launcher::AbstractLauncherIcon::Ptr icon); static void OnBackgroundUpdate(GVariant* data, Controller* self); @@ -131,7 +131,7 @@ private: static gboolean OnShowTimer(gpointer data); static gboolean OnDetailTimer(gpointer data); - static bool CompareSwitcherItemsPriority(launcher::AbstractLauncherIcon* first, launcher::AbstractLauncherIcon* second); + static bool CompareSwitcherItemsPriority(launcher::AbstractLauncherIcon::Ptr first, launcher::AbstractLauncherIcon::Ptr second); }; } diff --git a/plugins/unityshell/src/SwitcherModel.cpp b/plugins/unityshell/src/SwitcherModel.cpp index 37f63991f..bedaa1dc7 100644 --- a/plugins/unityshell/src/SwitcherModel.cpp +++ b/plugins/unityshell/src/SwitcherModel.cpp @@ -30,7 +30,7 @@ using launcher::AbstractLauncherIcon; namespace switcher { -SwitcherModel::SwitcherModel(std::vector icons) +SwitcherModel::SwitcherModel(std::vector icons) : _inner(icons) , _index(0) , _last_index(0) @@ -41,8 +41,7 @@ SwitcherModel::SwitcherModel(std::vector icons) for (auto icon : _inner) { - AddChild(icon); - icon->Reference(); + AddChild(icon.GetPointer()); } } @@ -50,8 +49,7 @@ SwitcherModel::~SwitcherModel() { for (auto icon : _inner) { - RemoveChild(icon); - icon->UnReference(); + RemoveChild(icon.GetPointer()); } } @@ -94,11 +92,11 @@ SwitcherModel::rend() return _inner.rend(); } -AbstractLauncherIcon* +AbstractLauncherIcon::Ptr SwitcherModel::at(unsigned int index) { if ((int) index >= Size ()) - return 0; + return AbstractLauncherIcon::Ptr(); return _inner[index]; } @@ -108,7 +106,7 @@ SwitcherModel::Size() return _inner.size(); } -AbstractLauncherIcon* +AbstractLauncherIcon::Ptr SwitcherModel::Selection() { return _inner.at(_index); @@ -120,7 +118,7 @@ SwitcherModel::SelectionIndex() return _index; } -AbstractLauncherIcon* +AbstractLauncherIcon::Ptr SwitcherModel::LastSelection() { return _inner.at(_last_index); @@ -229,7 +227,7 @@ void SwitcherModel::PrevDetail () } void -SwitcherModel::Select(AbstractLauncherIcon* selection) +SwitcherModel::Select(AbstractLauncherIcon::Ptr selection) { int i = 0; for (iterator it = begin(), e = end(); it != e; ++it) diff --git a/plugins/unityshell/src/SwitcherModel.h b/plugins/unityshell/src/SwitcherModel.h index d70077867..309d51389 100644 --- a/plugins/unityshell/src/SwitcherModel.h +++ b/plugins/unityshell/src/SwitcherModel.h @@ -41,7 +41,7 @@ class SwitcherModel : public debug::Introspectable, public sigc::trackable public: typedef boost::shared_ptr Ptr; - typedef std::vector Base; + typedef std::vector Base; typedef Base::iterator iterator; typedef Base::reverse_iterator reverse_iterator; @@ -52,7 +52,7 @@ public: // Icons are owned externally and assumed valid for life of switcher. // When AbstractLauncherIcon is complete, it will be passed as a shared pointer and this // will no longer be a worry. - SwitcherModel(std::vector icons); + SwitcherModel(std::vector icons); virtual ~SwitcherModel(); iterator begin(); @@ -61,14 +61,14 @@ public: reverse_iterator rbegin(); reverse_iterator rend(); - launcher::AbstractLauncherIcon* at(unsigned int index); + launcher::AbstractLauncherIcon::Ptr at(unsigned int index); int Size(); - launcher::AbstractLauncherIcon* Selection(); + launcher::AbstractLauncherIcon::Ptr Selection(); int SelectionIndex(); - launcher::AbstractLauncherIcon* LastSelection(); + launcher::AbstractLauncherIcon::Ptr LastSelection(); int LastSelectionIndex(); std::vector DetailXids (); @@ -80,10 +80,10 @@ public: void NextDetail(); void PrevDetail(); - void Select(launcher::AbstractLauncherIcon* selection); + void Select(launcher::AbstractLauncherIcon::Ptr selection); void Select(int index); - sigc::signal selection_changed; + sigc::signal selection_changed; protected: // Introspectable methods diff --git a/plugins/unityshell/src/SwitcherView.cpp b/plugins/unityshell/src/SwitcherView.cpp index a75ee16bb..1ffa95251 100644 --- a/plugins/unityshell/src/SwitcherView.cpp +++ b/plugins/unityshell/src/SwitcherView.cpp @@ -172,7 +172,7 @@ void SwitcherView::OnDetailSelectionChanged (bool detail) QueueDraw (); } -void SwitcherView::OnSelectionChanged(AbstractLauncherIcon* selection) +void SwitcherView::OnSelectionChanged(AbstractLauncherIcon::Ptr selection) { if (selection) text_view_->SetText(selection->tooltip_text().c_str()); @@ -185,10 +185,10 @@ SwitcherModel::Ptr SwitcherView::GetModel() return model_; } -RenderArg SwitcherView::CreateBaseArgForIcon(AbstractLauncherIcon* icon) +RenderArg SwitcherView::CreateBaseArgForIcon(AbstractLauncherIcon::Ptr icon) { RenderArg arg; - arg.icon = icon; + arg.icon = icon.GetPointer(); arg.alpha = 0.95f; // tells the renderer to render arrows by number @@ -569,7 +569,7 @@ void SwitcherView::DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, std::list::iterator it; for (it = last_args_.begin(); it != last_args_.end(); ++it) { - if (it->icon == model_->Selection()) + if (model_->Selection() == it->icon) { int view_width = text_view_->GetBaseWidth(); int start_x = it->render_center.x - view_width / 2; diff --git a/plugins/unityshell/src/SwitcherView.h b/plugins/unityshell/src/SwitcherView.h index f0e460fcd..7f4273902 100644 --- a/plugins/unityshell/src/SwitcherView.h +++ b/plugins/unityshell/src/SwitcherView.h @@ -88,9 +88,9 @@ protected: std::list RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current); - ui::RenderArg CreateBaseArgForIcon(launcher::AbstractLauncherIcon* icon); + ui::RenderArg CreateBaseArgForIcon(launcher::AbstractLauncherIcon::Ptr icon); private: - void OnSelectionChanged(launcher::AbstractLauncherIcon* selection); + void OnSelectionChanged(launcher::AbstractLauncherIcon::Ptr selection); void OnDetailSelectionChanged (bool detail); void OnDetailSelectionIndexChanged (unsigned int index); diff --git a/plugins/unityshell/src/unity-launcher-accessible.cpp b/plugins/unityshell/src/unity-launcher-accessible.cpp index 7f9eacb52..5b7f29ab4 100644 --- a/plugins/unityshell/src/unity-launcher-accessible.cpp +++ b/plugins/unityshell/src/unity-launcher-accessible.cpp @@ -64,8 +64,8 @@ static gboolean unity_launcher_accessible_is_child_selected(AtkSelection* sele /* private */ static void on_selection_change_cb(UnityLauncherAccessible* launcher_accessible); -static void on_icon_added_cb(AbstractLauncherIcon* icon, UnityLauncherAccessible* self); -static void on_icon_removed_cb(AbstractLauncherIcon* icon, UnityLauncherAccessible* self); +static void on_icon_added_cb(AbstractLauncherIcon::Ptr icon, UnityLauncherAccessible* self); +static void on_icon_removed_cb(AbstractLauncherIcon::Ptr icon, UnityLauncherAccessible* self); static void on_order_change_cb(UnityLauncherAccessible* self); static void update_children_index(UnityLauncherAccessible* self); @@ -227,7 +227,7 @@ unity_launcher_accessible_ref_child(AtkObject* obj, it = launcher_model->begin(); std::advance(it, i); - child = dynamic_cast(*it); + child = dynamic_cast((*it).GetPointer()); child_accessible = unity_a11y_get_accessible(child); parent = atk_object_get_parent(child_accessible); @@ -287,7 +287,7 @@ unity_launcher_accessible_ref_selection(AtkSelection* selection, gint i) { Launcher* launcher = NULL; - AbstractLauncherIcon* selected_icon = NULL; + AbstractLauncherIcon::Ptr selected_icon; nux::Object* nux_object = NULL; AtkObject* accessible_selected = NULL; @@ -302,9 +302,9 @@ unity_launcher_accessible_ref_selection(AtkSelection* selection, launcher = dynamic_cast(nux_object); selected_icon = launcher->GetSelectedMenuIcon(); - if (selected_icon != 0) + if (selected_icon) { - accessible_selected = unity_a11y_get_accessible(selected_icon); + accessible_selected = unity_a11y_get_accessible(selected_icon.GetPointer()); g_object_ref(accessible_selected); } @@ -315,7 +315,7 @@ static gint unity_launcher_accessible_get_selection_count(AtkSelection* selection) { Launcher* launcher = NULL; - AbstractLauncherIcon* selected_icon = NULL; + AbstractLauncherIcon::Ptr selected_icon; nux::Object* nux_object = NULL; g_return_val_if_fail(UNITY_IS_LAUNCHER_ACCESSIBLE(selection), 0); @@ -327,7 +327,7 @@ unity_launcher_accessible_get_selection_count(AtkSelection* selection) launcher = dynamic_cast(nux_object); selected_icon = launcher->GetSelectedMenuIcon(); - if (selected_icon == 0) + if (!selected_icon) return 0; else return 1; @@ -338,8 +338,8 @@ unity_launcher_accessible_is_child_selected(AtkSelection* selection, gint i) { Launcher* launcher = NULL; - AbstractLauncherIcon* icon = NULL; - AbstractLauncherIcon* selected_icon = NULL; + AbstractLauncherIcon::Ptr icon; + AbstractLauncherIcon::Ptr selected_icon; LauncherModel* launcher_model = NULL; LauncherModel::iterator it; nux::Object* nux_object = NULL; @@ -354,7 +354,7 @@ unity_launcher_accessible_is_child_selected(AtkSelection* selection, launcher_model = launcher->GetModel(); it = launcher_model->begin(); std::advance(it, i); - icon = dynamic_cast(*it); + icon = *it; selected_icon = launcher->GetSelectedMenuIcon(); @@ -372,7 +372,7 @@ static void on_selection_change_cb(UnityLauncherAccessible* launcher_accessible) static void -on_icon_added_cb(AbstractLauncherIcon* icon, +on_icon_added_cb(AbstractLauncherIcon::Ptr icon, UnityLauncherAccessible* self) { AtkObject* icon_accessible = NULL; @@ -385,7 +385,7 @@ on_icon_added_cb(AbstractLauncherIcon* icon, if (nux_object == NULL) /* state is defunct */ return; - icon_accessible = unity_a11y_get_accessible(icon); + icon_accessible = unity_a11y_get_accessible(icon.GetPointer()); update_children_index(self); @@ -396,7 +396,7 @@ on_icon_added_cb(AbstractLauncherIcon* icon, } static void -on_icon_removed_cb(AbstractLauncherIcon* icon, +on_icon_removed_cb(AbstractLauncherIcon::Ptr icon, UnityLauncherAccessible* self) { AtkObject* icon_accessible = NULL; @@ -409,7 +409,7 @@ on_icon_removed_cb(AbstractLauncherIcon* icon, if (nux_object == NULL) /* state is defunct */ return; - icon_accessible = unity_a11y_get_accessible(icon); + icon_accessible = unity_a11y_get_accessible(icon.GetPointer()); index = atk_object_get_index_in_parent(icon_accessible); @@ -442,7 +442,7 @@ update_children_index(UnityLauncherAccessible* self) for (it = launcher_model->begin(); it != launcher_model->end(); it++) { - child = dynamic_cast(*it); + child = dynamic_cast((*it).GetPointer()); child_accessible = unity_a11y_get_accessible(child); unity_launcher_icon_accessible_set_index(UNITY_LAUNCHER_ICON_ACCESSIBLE(child_accessible), diff --git a/plugins/unityshell/src/unity-switcher-accessible.cpp b/plugins/unityshell/src/unity-switcher-accessible.cpp index a61fcfbd7..e4e2a968f 100644 --- a/plugins/unityshell/src/unity-switcher-accessible.cpp +++ b/plugins/unityshell/src/unity-switcher-accessible.cpp @@ -64,7 +64,7 @@ static gboolean unity_switcher_accessible_is_child_selected(AtkSelection* sele static gboolean unity_switcher_accessible_check_pending_notification(NuxAreaAccessible* self); /* private */ -static void on_selection_changed_cb(AbstractLauncherIcon* icon, +static void on_selection_changed_cb(AbstractLauncherIcon::Ptr icon, UnitySwitcherAccessible* switcher_accessible); static void create_children(UnitySwitcherAccessible* self); @@ -311,7 +311,7 @@ unity_switcher_accessible_get_selection_count(AtkSelection* selection) { SwitcherView* switcher = NULL; SwitcherModel::Ptr switcher_model; - AbstractLauncherIcon* selected_icon = NULL; + AbstractLauncherIcon::Ptr selected_icon; nux::Object* nux_object = NULL; g_return_val_if_fail(UNITY_IS_SWITCHER_ACCESSIBLE(selection), 0); @@ -325,7 +325,7 @@ unity_switcher_accessible_get_selection_count(AtkSelection* selection) selected_icon = switcher_model->Selection(); - if (selected_icon == 0) + if (!selected_icon) return 0; else return 1; @@ -377,7 +377,7 @@ unity_switcher_accessible_check_pending_notification(NuxAreaAccessible* self) /* private */ static void -on_selection_changed_cb(AbstractLauncherIcon* icon, +on_selection_changed_cb(AbstractLauncherIcon::Ptr icon, UnitySwitcherAccessible* switcher_accessible) { g_signal_emit_by_name(ATK_OBJECT(switcher_accessible), "selection-changed"); @@ -391,7 +391,7 @@ create_children(UnitySwitcherAccessible* self) SwitcherView* switcher = NULL; SwitcherModel::Ptr switcher_model; SwitcherModel::iterator it; - AbstractLauncherIcon* child = NULL; + AbstractLauncherIcon::Ptr child; AtkObject* child_accessible = NULL; nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(self)); @@ -406,8 +406,8 @@ create_children(UnitySwitcherAccessible* self) for (it = switcher_model->begin(); it != switcher_model->end(); it++) { - child = dynamic_cast(*it); - child_accessible = unity_launcher_icon_accessible_new(child); + child = *it; + child_accessible = unity_launcher_icon_accessible_new(child.GetPointer()); atk_object_set_parent(child_accessible, ATK_OBJECT(self)); self->priv->children = g_slist_append(self->priv->children, child_accessible); diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 977a587f7..71db2be46 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -1595,9 +1595,9 @@ bool UnityScreen::altTabInitiateCommon(CompAction *action, int show_monitor = (show_mode == switcher::ShowMode::CURRENT_VIEWPORT) ? device : -1; - std::vector results = launcher_controller_->GetAltTabIcons(show_monitor); + auto results = launcher_controller_->GetAltTabIcons(show_monitor); - if (!(results.size() == 1 && results[0]->Type() == AbstractLauncherIcon::IconType::TYPE_BEGIN)) + if (!(results.size() == 1 && results[0]->GetIconType() == AbstractLauncherIcon::IconType::TYPE_BEGIN)) switcher_controller_->Show(show_mode, switcher::SortMode::FOCUS_ORDER, false, results); return true; -- cgit v1.2.3 From 525c435bc687fd2ccfc16263d7d76b5d7fdf7bb7 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sun, 12 Feb 2012 05:53:47 -0500 Subject: make sure desktop icon ends up at start of switcher (bzr r1948.8.2) --- plugins/unityshell/src/DesktopLauncherIcon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/DesktopLauncherIcon.cpp b/plugins/unityshell/src/DesktopLauncherIcon.cpp index 8e1f7b1ae..0637feebb 100644 --- a/plugins/unityshell/src/DesktopLauncherIcon.cpp +++ b/plugins/unityshell/src/DesktopLauncherIcon.cpp @@ -35,7 +35,7 @@ DesktopLauncherIcon::DesktopLauncherIcon() icon_name = "desktop"; SetQuirk(QUIRK_VISIBLE, true); SetQuirk(QUIRK_RUNNING, false); - SetIconType(TYPE_DESKTOP); + SetIconType(TYPE_BEGIN); SetShowInSwitcher(false); } -- cgit v1.2.3 From 7bdd432ddefe47652e5b0586fd9b8b2572abc996 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Sun, 12 Feb 2012 14:47:39 +0000 Subject: grabs the active windows icon for displaying when first showing hud Fixes LP: #929452 (bzr r1948.5.1) --- plugins/unityshell/src/HudController.cpp | 16 ++++++++++++---- plugins/unityshell/src/HudController.h | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/HudController.cpp b/plugins/unityshell/src/HudController.cpp index c1c8c724e..178fae1fc 100644 --- a/plugins/unityshell/src/HudController.cpp +++ b/plugins/unityshell/src/HudController.cpp @@ -24,6 +24,9 @@ #include "PanelStyle.h" #include "UBusMessages.h" #include "UScreen.h" + +#include + namespace unity { namespace hud @@ -219,6 +222,14 @@ void Controller::ShowHud() EnsureHud(); view_->AboutToShow(); + // we first want to grab the currently active window, luckly we can just ask the jason interface(bamf) + BamfMatcher* matcher = bamf_matcher_get_default(); + glib::Object bamf_app((BamfView*)(bamf_matcher_get_active_application(matcher))); + focused_app_icon_ = bamf_view_get_icon(bamf_app); + + LOG_DEBUG(logger) << "Taking application icon: " << focused_app_icon_; + view_->SetIcon(focused_app_icon_); + window_->ShowWindow(true); window_->PushToFront(); window_->EnableInputWindow(true, "Hud", true, false); @@ -229,9 +240,6 @@ void Controller::ShowHud() window_->QueueDraw(); view_->ResetToDefault(); - - view_->SetIcon(""); - hud_service_.RequestQuery(""); need_show_ = false; visible_ = true; @@ -356,7 +364,7 @@ void Controller::OnQuerySelected(Query::Ptr query) void Controller::OnQueriesFinished(Hud::Queries queries) { view_->SetQueries(queries); - std::string icon_name = ""; + std::string icon_name = focused_app_icon_; for (auto query = queries.begin(); query != queries.end(); query++) { if (!(*query)->icon_name.empty()) diff --git a/plugins/unityshell/src/HudController.h b/plugins/unityshell/src/HudController.h index f2c491ab0..c0c029975 100644 --- a/plugins/unityshell/src/HudController.h +++ b/plugins/unityshell/src/HudController.h @@ -102,7 +102,7 @@ private: View* view_; guint ensure_id_; - + std::string focused_app_icon_; nux::Layout* layout_; }; -- cgit v1.2.3 From 2a7e18dab71c69b8082bc16d0043ccfee002659c Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Sun, 12 Feb 2012 15:48:12 +0000 Subject: updates the panel window buttons to support disabled case for hud Fixes LP: #929453 (bzr r1948.3.1) --- .../unityshell/resources/close_dash_disabled.png | Bin 0 -> 1292 bytes .../resources/maximize_dash_disabled.png | Bin 0 -> 1208 bytes .../resources/minimize_dash_disabled.png | Bin 0 -> 1191 bytes .../resources/unmaximize_dash_disabled.png | Bin 0 -> 1208 bytes plugins/unityshell/src/PanelStyle.h | 3 ++- plugins/unityshell/src/WindowButtons.cpp | 28 +++++++++++++++------ 6 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 plugins/unityshell/resources/close_dash_disabled.png create mode 100644 plugins/unityshell/resources/maximize_dash_disabled.png create mode 100644 plugins/unityshell/resources/minimize_dash_disabled.png create mode 100644 plugins/unityshell/resources/unmaximize_dash_disabled.png (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/resources/close_dash_disabled.png b/plugins/unityshell/resources/close_dash_disabled.png new file mode 100644 index 000000000..3925bda11 Binary files /dev/null and b/plugins/unityshell/resources/close_dash_disabled.png differ diff --git a/plugins/unityshell/resources/maximize_dash_disabled.png b/plugins/unityshell/resources/maximize_dash_disabled.png new file mode 100644 index 000000000..06eaf9b0b Binary files /dev/null and b/plugins/unityshell/resources/maximize_dash_disabled.png differ diff --git a/plugins/unityshell/resources/minimize_dash_disabled.png b/plugins/unityshell/resources/minimize_dash_disabled.png new file mode 100644 index 000000000..05352beca Binary files /dev/null and b/plugins/unityshell/resources/minimize_dash_disabled.png differ diff --git a/plugins/unityshell/resources/unmaximize_dash_disabled.png b/plugins/unityshell/resources/unmaximize_dash_disabled.png new file mode 100644 index 000000000..06eaf9b0b Binary files /dev/null and b/plugins/unityshell/resources/unmaximize_dash_disabled.png differ diff --git a/plugins/unityshell/src/PanelStyle.h b/plugins/unityshell/src/PanelStyle.h index d506586cf..524caaccf 100644 --- a/plugins/unityshell/src/PanelStyle.h +++ b/plugins/unityshell/src/PanelStyle.h @@ -42,7 +42,8 @@ enum class WindowState { NORMAL, PRELIGHT, - PRESSED + PRESSED, + DISABLED }; class Style diff --git a/plugins/unityshell/src/WindowButtons.cpp b/plugins/unityshell/src/WindowButtons.cpp index e552870b8..a9c7310dc 100644 --- a/plugins/unityshell/src/WindowButtons.cpp +++ b/plugins/unityshell/src/WindowButtons.cpp @@ -108,13 +108,20 @@ public: if (_overlay_is_open) { - //FIXME should use HasMouseFocus() - if (_mouse_is_down && IsMouseInside()) - tex = _pressed_dash_tex; - else if (IsMouseInside()) - tex = _prelight_dash_tex; + if (_type == panel::WindowButtonType::UNMAXIMIZE && !_overlay_can_maximize) + { + tex = _disabled_dash_tex; + } else - tex = _normal_dash_tex; + { + //FIXME should use HasMouseFocus() + if (_mouse_is_down && IsMouseInside()) + tex = _pressed_dash_tex; + else if (IsMouseInside()) + tex = _prelight_dash_tex; + else + tex = _normal_dash_tex; + } } else { @@ -197,6 +204,7 @@ public: _normal_dash_tex = GetDashMaximizeWindowButton(panel::WindowState::NORMAL); _prelight_dash_tex = GetDashMaximizeWindowButton(panel::WindowState::PRELIGHT); _pressed_dash_tex = GetDashMaximizeWindowButton(panel::WindowState::PRESSED); + _disabled_dash_tex = GetDashMaximizeWindowButton(panel::WindowState::DISABLED); } else { @@ -204,6 +212,7 @@ public: _normal_dash_tex = GetDashWindowButton(_type, panel::WindowState::NORMAL); _prelight_dash_tex = GetDashWindowButton(_type, panel::WindowState::PRELIGHT); _pressed_dash_tex = GetDashWindowButton(_type, panel::WindowState::PRESSED); + _disabled_dash_tex = GetDashWindowButton(_type, panel::WindowState::DISABLED); } // still check if the dash is really opened, @@ -234,12 +243,15 @@ public: private: panel::WindowButtonType _type; + // FIXME - replace with objectptr varients nux::BaseTexture* _normal_tex; nux::BaseTexture* _prelight_tex; nux::BaseTexture* _pressed_tex; nux::BaseTexture* _normal_dash_tex; nux::BaseTexture* _prelight_dash_tex; nux::BaseTexture* _pressed_dash_tex; + nux::BaseTexture* _disabled_dash_tex; + bool _overlay_is_open; bool _overlay_can_maximize; bool _mouse_is_down; @@ -281,7 +293,7 @@ private: panel::WindowState state) { const char* names[] = { "close_dash", "minimize_dash", "unmaximize_dash" }; - const char* states[] = { "", "_prelight", "_pressed" }; + const char* states[] = { "", "_prelight", "_pressed", "_disabled" }; std::ostringstream subpath; subpath << names[static_cast(type)] @@ -298,7 +310,7 @@ private: nux::BaseTexture* GetDashMaximizeWindowButton(panel::WindowState state) { - const char* states[] = { "", "_prelight", "_pressed" }; + const char* states[] = { "", "_prelight", "_pressed", "_disabled" }; std::ostringstream subpath; subpath << "maximize_dash" << states[static_cast(state)] << ".png"; -- cgit v1.2.3 From 56dc13712260f02028e4035901bf9df463427f0a Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Sun, 12 Feb 2012 16:58:40 +0100 Subject: Fix backward key navigation. (bzr r1948.4.1) --- plugins/unityshell/src/ResultViewGrid.cpp | 7 +++---- plugins/unityshell/src/ResultViewGrid.h | 15 +++++++-------- plugins/unityshell/src/SearchBar.cpp | 7 +++++-- 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/ResultViewGrid.cpp b/plugins/unityshell/src/ResultViewGrid.cpp index 0c96d7aec..33faee1f6 100644 --- a/plugins/unityshell/src/ResultViewGrid.cpp +++ b/plugins/unityshell/src/ResultViewGrid.cpp @@ -72,7 +72,7 @@ ResultViewGrid::ResultViewGrid(NUX_FILE_LINE_DECL) vertical_spacing.changed.connect(needredraw_lambda); padding.changed.connect(needredraw_lambda); - key_nav_focus_change.connect (sigc::mem_fun (this, &ResultViewGrid::OnOnKeyNavFocusChange)); + key_nav_focus_change.connect (sigc::mem_fun (this, &ResultViewGrid::OnKeyNavFocusChange)); key_nav_focus_activate.connect ([&] (nux::Area *area) { UriActivated.emit (focused_uri_); }); key_down.connect (sigc::mem_fun (this, &ResultViewGrid::OnKeyDown)); mouse_move.connect(sigc::mem_fun(this, &ResultViewGrid::MouseMove)); @@ -488,8 +488,7 @@ nux::Area* ResultViewGrid::KeyNavIteration(nux::KeyNavDirection direction) return this; } -// crappy name. -void ResultViewGrid::OnOnKeyNavFocusChange(nux::Area *area, bool has_focus, nux::KeyNavDirection direction) +void ResultViewGrid::OnKeyNavFocusChange(nux::Area *area, bool has_focus, nux::KeyNavDirection direction) { if (HasKeyFocus()) { @@ -504,7 +503,7 @@ void ResultViewGrid::OnOnKeyNavFocusChange(nux::Area *area, bool has_focus, nux: int items_per_row = GetItemsPerRow(); - if (direction == nux::KEY_NAV_UP) + if (direction == nux::KEY_NAV_UP && expanded) { // This View just got focused through keyboard navigation and the // focus is comming from the bottom. We want to focus the diff --git a/plugins/unityshell/src/ResultViewGrid.h b/plugins/unityshell/src/ResultViewGrid.h index 7eea40425..891a61392 100644 --- a/plugins/unityshell/src/ResultViewGrid.h +++ b/plugins/unityshell/src/ResultViewGrid.h @@ -20,10 +20,8 @@ * */ - - -#ifndef RESULTVIEWGRID_H -#define RESULTVIEWGRID_H +#ifndef UNITYSHELL_RESULTVIEWGRID_H +#define UNITYSHELL_RESULTVIEWGRID_H #include #include "ResultView.h" @@ -69,7 +67,7 @@ protected: virtual bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character); virtual bool AcceptKeyNavFocus(); virtual nux::Area* KeyNavIteration(nux::KeyNavDirection direction); - virtual void OnOnKeyNavFocusChange(nux::Area* area, bool has_focus, nux::KeyNavDirection direction); + virtual void OnKeyNavFocusChange(nux::Area* area, bool has_focus, nux::KeyNavDirection direction); void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count); virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);; @@ -112,6 +110,7 @@ private: }; -} -} -#endif // RESULTVIEWGRID_H +} // namespace dash +} // namespace unity + +#endif // UNITYSHELL_RESULTVIEWGRID_H diff --git a/plugins/unityshell/src/SearchBar.cpp b/plugins/unityshell/src/SearchBar.cpp index 55bb79b4b..5deaadcb3 100644 --- a/plugins/unityshell/src/SearchBar.cpp +++ b/plugins/unityshell/src/SearchBar.cpp @@ -542,8 +542,11 @@ std::string SearchBar::GetName() const void SearchBar::AddProperties(GVariantBuilder* builder) { - unity::variant::BuilderWrapper(builder).add(GetGeometry()); - g_variant_builder_add (builder, "{sv}", "search_string", g_variant_new_string (pango_entry_->GetText().c_str()) ); + unity::variant::BuilderWrapper wrapper(builder); + + wrapper.add(GetGeometry()); + wrapper.add("has_focus", pango_entry_->HasKeyFocus()); + wrapper.add("search_string", pango_entry_->GetText()); } } // namespace unity -- cgit v1.2.3 From cb8204ecbaf67d959243c570dafcfd0b39d1f4af Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Sun, 12 Feb 2012 17:18:10 +0100 Subject: Style fixes. (bzr r1948.4.2) --- plugins/unityshell/src/ResultViewGrid.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/ResultViewGrid.cpp b/plugins/unityshell/src/ResultViewGrid.cpp index 33faee1f6..fb768ed5f 100644 --- a/plugins/unityshell/src/ResultViewGrid.cpp +++ b/plugins/unityshell/src/ResultViewGrid.cpp @@ -72,9 +72,9 @@ ResultViewGrid::ResultViewGrid(NUX_FILE_LINE_DECL) vertical_spacing.changed.connect(needredraw_lambda); padding.changed.connect(needredraw_lambda); - key_nav_focus_change.connect (sigc::mem_fun (this, &ResultViewGrid::OnKeyNavFocusChange)); - key_nav_focus_activate.connect ([&] (nux::Area *area) { UriActivated.emit (focused_uri_); }); - key_down.connect (sigc::mem_fun (this, &ResultViewGrid::OnKeyDown)); + key_nav_focus_change.connect(sigc::mem_fun(this, &ResultViewGrid::OnKeyNavFocusChange)); + key_nav_focus_activate.connect([&] (nux::Area *area) { UriActivated.emit (focused_uri_); }); + key_down.connect(sigc::mem_fun(this, &ResultViewGrid::OnKeyDown)); mouse_move.connect(sigc::mem_fun(this, &ResultViewGrid::MouseMove)); mouse_click.connect(sigc::mem_fun(this, &ResultViewGrid::MouseClick)); -- cgit v1.2.3 From 15349e11b9acbf46eac7740656232a2953ab6f17 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Sun, 12 Feb 2012 17:46:48 +0000 Subject: fixes the design request, first item in hud should always be focused unless another item takes focus Fixes LP: #929455 (bzr r1948.1.1) --- plugins/unityshell/src/HudButton.cpp | 28 +++++++++++++++++++++------- plugins/unityshell/src/HudButton.h | 6 ++++-- plugins/unityshell/src/HudView.cpp | 26 +++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 10 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/HudButton.cpp b/plugins/unityshell/src/HudButton.cpp index 269ee401f..380753cb7 100644 --- a/plugins/unityshell/src/HudButton.cpp +++ b/plugins/unityshell/src/HudButton.cpp @@ -50,8 +50,7 @@ HudButton::HudButton (nux::TextureArea *image, NUX_FILE_LINE_DECL) , is_rounded(false) , is_focused_(false) { - InitTheme(); - key_nav_focus_change.connect([this](nux::Area *area, bool recieving, nux::KeyNavDirection direction){ QueueDraw(); }); + Init(); } HudButton::HudButton (const std::string label_, NUX_FILE_LINE_DECL) @@ -59,7 +58,7 @@ HudButton::HudButton (const std::string label_, NUX_FILE_LINE_DECL) , is_rounded(false) , is_focused_(false) { - InitTheme(); + Init(); } HudButton::HudButton (const std::string label_, nux::TextureArea *image, NUX_FILE_LINE_DECL) @@ -67,7 +66,7 @@ HudButton::HudButton (const std::string label_, nux::TextureArea *image, NUX_FIL , is_rounded(false) , is_focused_(false) { - InitTheme(); + Init(); } HudButton::HudButton (NUX_FILE_LINE_DECL) @@ -75,12 +74,26 @@ HudButton::HudButton (NUX_FILE_LINE_DECL) , is_rounded(false) , is_focused_(false) { - InitTheme(); + Init(); } HudButton::~HudButton() { } +void HudButton::Init() +{ + InitTheme(); + key_nav_focus_change.connect([this](nux::Area *area, bool recieving, nux::KeyNavDirection direction) + { + QueueDraw(); + }); + + fake_focused.changed.connect([this](bool change) + { + QueueDraw(); + }); +} + void HudButton::InitTheme() { is_rounded.changed.connect([&] (bool rounded) @@ -111,7 +124,8 @@ void HudButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonV bool HudButton::AcceptKeyNavFocus() { - return true; + // say we can't be focused if we have fake focus on + return !fake_focused; } @@ -156,7 +170,7 @@ void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) col); nux::BaseTexture* texture = normal_->GetTexture(); - if (HasKeyFocus()) + if (HasKeyFocus() || fake_focused()) texture = active_->GetTexture(); else if (HasKeyFocus()) texture = prelight_->GetTexture(); diff --git a/plugins/unityshell/src/HudButton.h b/plugins/unityshell/src/HudButton.h index ef55760d3..eb8507887 100644 --- a/plugins/unityshell/src/HudButton.h +++ b/plugins/unityshell/src/HudButton.h @@ -43,13 +43,14 @@ public: HudButton (const std::string label, nux::TextureArea *image, NUX_FILE_LINE_PROTO); HudButton (NUX_FILE_LINE_PROTO); virtual ~HudButton(); - + void SetQuery(Query::Ptr query); std::shared_ptr GetQuery(); nux::Property label; nux::Property hint; nux::Property is_rounded; + nux::Property fake_focused; protected: virtual bool AcceptKeyNavFocus(); @@ -60,7 +61,8 @@ protected: std::string GetName() const; void AddProperties(GVariantBuilder* builder); - + + void Init(); void InitTheme (); void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state); typedef std::unique_ptr NuxCairoPtr; diff --git a/plugins/unityshell/src/HudView.cpp b/plugins/unityshell/src/HudView.cpp index 3abbd01c8..0c0b9393b 100644 --- a/plugins/unityshell/src/HudView.cpp +++ b/plugins/unityshell/src/HudView.cpp @@ -69,10 +69,32 @@ View::View() SetupViews(); search_bar_->key_down.connect (sigc::mem_fun (this, &View::OnKeyDown)); - search_bar_->activated.connect ([&]() { + search_bar_->activated.connect ([&]() + { search_activated.emit(search_bar_->search_string); }); + search_bar_->text_entry()->key_nav_focus_change.connect([&](nux::Area *area, bool receiving, nux::KeyNavDirection direction) + { + // early exit if we have no buttons yet + if (buttons_.empty()) + return; + + if (receiving) + { + // if the search_bar gets focus, fake focus the first button if it exists + if (!buttons_.empty()) + { + buttons_.back()->fake_focused = true; + } + } + else + { + // we are losing focus, so remove the fake focused entry + buttons_.back()->fake_focused = false; + } + }); + mouse_down.connect(sigc::mem_fun(this, &View::OnMouseButtonDown)); Relayout(); @@ -153,6 +175,8 @@ void View::SetQueries(Hud::Queries queries) }); button->is_rounded = (query == --(queries.end())) ? true : false; + button->fake_focused = (query == (queries.begin())) ? true : false; + button->SetMinimumWidth(941); found_items++; } -- cgit v1.2.3 From 629dad5830b8264467fb9c8611faf94a20ab9db5 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Sun, 12 Feb 2012 17:50:17 +0000 Subject: made slight change for mp (bzr r1900.1.15) --- plugins/unityshell/src/HudView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/HudView.cpp b/plugins/unityshell/src/HudView.cpp index 34fc847a4..2617fb986 100644 --- a/plugins/unityshell/src/HudView.cpp +++ b/plugins/unityshell/src/HudView.cpp @@ -366,14 +366,14 @@ void View::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) ProcessGrowShrink(); } - nux::Geometry draw_content_geo = layout_->GetGeometry(); + nux::Geometry draw_content_geo(layout_->GetGeometry()); draw_content_geo.height = current_height_; renderer_.DrawFull(gfx_context, draw_content_geo, absolute_window_geometry_, window_geometry_, true); } void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) { - nux::Geometry draw_content_geo = layout_->GetGeometry(); + nux::Geometry draw_content_geo(layout_->GetGeometry()); draw_content_geo.height = current_height_; renderer_.DrawInner(gfx_context, draw_content_geo, absolute_window_geometry_, window_geometry_); -- cgit v1.2.3 From a0eebdd0d08f642f01aae7bf29b0d9a726caeb05 Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Sun, 12 Feb 2012 18:50:43 +0100 Subject: Auto Scroll the dash when a category header gets the focus. (bzr r1948.6.1) --- plugins/unityshell/src/LensView.cpp | 12 ++++++++---- plugins/unityshell/src/PlacesGroup.cpp | 5 +++++ plugins/unityshell/src/PlacesGroup.h | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index 486e33939..4b6c168ab 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -118,13 +118,17 @@ LensView::LensView(Lens::Ptr lens) nux::Geometry focused_pos; g_variant_get (data, "(iiii)", &focused_pos.x, &focused_pos.y, &focused_pos.width, &focused_pos.height); - for (auto it = categories_.begin(); it != categories_.end(); it++) + for (auto it : categories_) { - if ((*it)->GetLayout() != nullptr) + if (it->GetLayout() != nullptr) { - nux::View *child = (*it)->GetChildView(); - if (child->HasKeyFocus()) + auto expand_label = it->GetExpandLabel(); + auto child = it->GetChildView(); + + if ((child && child->HasKeyFocus()) || + (expand_label && expand_label->HasKeyFocus())) { + focused_pos.x += child->GetGeometry().x; focused_pos.y += child->GetGeometry().y - 30; focused_pos.height += 30; diff --git a/plugins/unityshell/src/PlacesGroup.cpp b/plugins/unityshell/src/PlacesGroup.cpp index f84c450ed..ad6690352 100644 --- a/plugins/unityshell/src/PlacesGroup.cpp +++ b/plugins/unityshell/src/PlacesGroup.cpp @@ -41,6 +41,8 @@ #include #include #include "DashStyle.h" +#include "ubus-server.h" +#include "UBusMessages.h" namespace unity { @@ -191,6 +193,9 @@ PlacesGroup::OnLabelActivated(nux::Area* label) void PlacesGroup::OnLabelFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction) { + _ubus.SendMessage(UBUS_RESULT_VIEW_KEYNAV_CHANGED, + g_variant_new("(iiii)", 0, 0, 0, 0)); + QueueDraw(); } diff --git a/plugins/unityshell/src/PlacesGroup.h b/plugins/unityshell/src/PlacesGroup.h index 4e18f6de6..6f010bc31 100644 --- a/plugins/unityshell/src/PlacesGroup.h +++ b/plugins/unityshell/src/PlacesGroup.h @@ -30,6 +30,7 @@ #include "IconTexture.h" #include "Introspectable.h" #include "StaticCairoText.h" +#include "UBusWrapper.h" namespace nux { @@ -120,6 +121,8 @@ private: char* _cached_name; bool _draw_sep; nux::Geometry _cached_geometry; + + UBusManager _ubus; }; } -- cgit v1.2.3 From 11f606f7a7cc52659045919bc6d8624ca4a527f4 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Sun, 12 Feb 2012 18:22:19 +0000 Subject: ensures the hud gets focus when its invocated Fixes LP: #930048 (bzr r1948.2.1) --- plugins/unityshell/src/HudController.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/HudController.cpp b/plugins/unityshell/src/HudController.cpp index c1c8c724e..c5a374483 100644 --- a/plugins/unityshell/src/HudController.cpp +++ b/plugins/unityshell/src/HudController.cpp @@ -223,7 +223,6 @@ void Controller::ShowHud() window_->PushToFront(); window_->EnableInputWindow(true, "Hud", true, false); window_->SetInputFocus(); - nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus()); window_->CaptureMouseDownAnyWhereElse(true); view_->CaptureMouseDownAnyWhereElse(true); window_->QueueDraw(); @@ -244,6 +243,8 @@ void Controller::ShowHud() GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "hud", FALSE, UScreen::GetDefault()->GetMonitorWithMouse()); ubus.SendMessage(UBUS_OVERLAY_SHOWN, info); + + nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus()); } void Controller::HideHud(bool restore) { @@ -312,7 +313,11 @@ gboolean Controller::OnViewShowHideFrame(Controller* self) { self->window_->ShowWindow(false); } - + else + { + // ensure the text entry is focused + nux::GetWindowCompositor().SetKeyFocusArea(self->view_->default_focus()); + } return FALSE; } -- cgit v1.2.3 From 31587845b8f3dd8016a064f62577d1d8cee68ba0 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sun, 12 Feb 2012 13:43:26 -0500 Subject: dont emit signals in object if reference is not owned to avoid self deletion (bzr r1948.8.3) --- plugins/unityshell/src/LauncherIcon.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp index 48dd20a07..fecef8837 100644 --- a/plugins/unityshell/src/LauncherIcon.cpp +++ b/plugins/unityshell/src/LauncherIcon.cpp @@ -1137,15 +1137,13 @@ LauncherIcon::OnRemoteProgressVisibleChanged(LauncherEntryRemote* remote) void LauncherIcon::EmitNeedsRedraw() { - auto slots = needs_redraw.slots(); - if (slots.begin() != slots.end()) + if (OwnsTheReference()) needs_redraw.emit(AbstractLauncherIcon::Ptr(this)); } void LauncherIcon::EmitRemove() { - auto slots = remove.slots(); - if (slots.begin() != slots.end()) + if (OwnsTheReference()) remove.emit(AbstractLauncherIcon::Ptr(this)); } -- cgit v1.2.3 From a862e95309772a0a2c5ef9be4cc103ffa0ca8845 Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Sun, 12 Feb 2012 20:29:52 +0100 Subject: Add an AP test. (bzr r1948.6.2) --- plugins/unityshell/src/LensView.cpp | 10 ++++++---- plugins/unityshell/src/PlacesGroup.cpp | 2 +- plugins/unityshell/src/SearchBar.cpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index 4b6c168ab..bdd09e5ee 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -52,13 +52,15 @@ public: SetVScrollBar(scroll_bar); } - void ScrollToPosition(nux::Geometry & position) + void ScrollToPosition(nux::Geometry const& position) { // much of this code is copied from Nux/ScrollView.cpp - int child_y = position.y - GetGeometry ().y; + nux::Geometry const& geo = GetGeometry(); + + int child_y = position.y - geo.y; int child_y_diff = child_y - abs (_delta_y); - if (child_y_diff + position.height < GetGeometry ().height && child_y_diff >= 0) + if (child_y_diff + position.height < geo.height && child_y_diff >= 0) { return; } @@ -69,7 +71,7 @@ public: } else { - int size = child_y_diff - GetGeometry ().height; + int size = child_y_diff - geo.height; // always keeps the top of a view on the screen size += position.height; diff --git a/plugins/unityshell/src/PlacesGroup.cpp b/plugins/unityshell/src/PlacesGroup.cpp index ad6690352..df904de9d 100644 --- a/plugins/unityshell/src/PlacesGroup.cpp +++ b/plugins/unityshell/src/PlacesGroup.cpp @@ -194,7 +194,7 @@ void PlacesGroup::OnLabelFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction) { _ubus.SendMessage(UBUS_RESULT_VIEW_KEYNAV_CHANGED, - g_variant_new("(iiii)", 0, 0, 0, 0)); + g_variant_new("(iiii)", 0, -30, 0, -30)); QueueDraw(); } diff --git a/plugins/unityshell/src/SearchBar.cpp b/plugins/unityshell/src/SearchBar.cpp index 55bb79b4b..7e5675ecf 100644 --- a/plugins/unityshell/src/SearchBar.cpp +++ b/plugins/unityshell/src/SearchBar.cpp @@ -542,7 +542,7 @@ std::string SearchBar::GetName() const void SearchBar::AddProperties(GVariantBuilder* builder) { - unity::variant::BuilderWrapper(builder).add(GetGeometry()); + unity::variant::BuilderWrapper(builder).add(GetAbsoluteGeometry()); g_variant_builder_add (builder, "{sv}", "search_string", g_variant_new_string (pango_entry_->GetText().c_str()) ); } -- cgit v1.2.3 From d3952de3a7efe04d941f63eb01818de3a4246d42 Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Mon, 13 Feb 2012 00:00:14 +0100 Subject: Fix. (bzr r1948.6.3) --- plugins/unityshell/src/LensView.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp index bdd09e5ee..b3cd70735 100644 --- a/plugins/unityshell/src/LensView.cpp +++ b/plugins/unityshell/src/LensView.cpp @@ -120,12 +120,12 @@ LensView::LensView(Lens::Ptr lens) nux::Geometry focused_pos; g_variant_get (data, "(iiii)", &focused_pos.x, &focused_pos.y, &focused_pos.width, &focused_pos.height); - for (auto it : categories_) + for (auto category : categories_) { - if (it->GetLayout() != nullptr) + if (category->GetLayout() != nullptr) { - auto expand_label = it->GetExpandLabel(); - auto child = it->GetChildView(); + auto expand_label = category->GetExpandLabel(); + auto child = category->GetChildView(); if ((child && child->HasKeyFocus()) || (expand_label && expand_label->HasKeyFocus())) -- cgit v1.2.3 From 435ea6ba0a635d122d9a5217e55f0b934e97cd47 Mon Sep 17 00:00:00 2001 From: smspillaz Date: Mon, 13 Feb 2012 09:57:53 +0800 Subject: Use .reset () (bzr r1905.1.4) --- plugins/unityshell/src/compizminimizedwindowhandler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/compizminimizedwindowhandler.h b/plugins/unityshell/src/compizminimizedwindowhandler.h index bdd583ee1..6e5d6fc32 100644 --- a/plugins/unityshell/src/compizminimizedwindowhandler.h +++ b/plugins/unityshell/src/compizminimizedwindowhandler.h @@ -251,7 +251,7 @@ compiz::CompizMinimizedWindowHandler::unminimize () if (w && w->mMinimizeHandler) { w->mMinimizeHandler->unminimize (); - w->mMinimizeHandler.release (); + w->mMinimizeHandler.reset (); } } } -- cgit v1.2.3 From fe74b59dc45fe9ebef9835069c7f8d4b95d7f1a9 Mon Sep 17 00:00:00 2001 From: smspillaz Date: Mon, 13 Feb 2012 10:00:19 +0800 Subject: Use reset (bzr r1905.1.5) --- plugins/unityshell/src/unityshell.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 2863a8b37..24a0a96ed 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -2004,7 +2004,7 @@ UnityWindow::minimize () if (!mMinimizeHandler) { - mMinimizeHandler = std::unique_ptr (new UnityMinimizedHandler (window)); + mMinimizeHandler.reset (new UnityMinimizedHandler (window)); mMinimizeHandler->minimize (); } } -- cgit v1.2.3 From 5ec9ad007b762da3ea092c718d997fb56a389348 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Mon, 13 Feb 2012 12:03:06 +0000 Subject: modifes BGHash to cache its background colours, stores cache in a cache file, should speed up startup time somewhat (bzr r1948.7.1) --- plugins/unityshell/src/BGHash.cpp | 187 ++++++++++++++++++++++++++++++---- plugins/unityshell/src/BGHash.h | 10 +- plugins/unityshell/src/unityshell.cpp | 1 + 3 files changed, 178 insertions(+), 20 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/BGHash.cpp b/plugins/unityshell/src/BGHash.cpp index c791687a4..d995dd804 100644 --- a/plugins/unityshell/src/BGHash.cpp +++ b/plugins/unityshell/src/BGHash.cpp @@ -19,6 +19,8 @@ #include "BGHash.h" #include #include +#include +#include #include #include #include @@ -53,7 +55,8 @@ namespace unity { _ubus_handle_request_colour(0) { _override_color.alpha= 0.0f; - + UnSerializeCache(); + background_monitor = gnome_bg_new (); client = g_settings_new ("org.gnome.desktop.background"); @@ -70,11 +73,20 @@ namespace unity { UBusServer *ubus = ubus_server_get_default (); gnome_bg_load_from_preferences (background_monitor, client); + + std::string filepath_hash = CreateFilepathHash(glib::String(g_strdup(gnome_bg_get_filename(background_monitor)))); + if (G_LIKELY(cache_map_.count(filepath_hash))) + { + nux::Color color(cache_map_[filepath_hash]); + LOG_DEBUG(logger) << "cache hit: " << color.red << ", " << color.green << ", " << color.blue; + TransitionToNewColor(cache_map_[filepath_hash]); + } + else + { + LOG_DEBUG(logger) << "cache miss: " << filepath_hash; + g_idle_add_full (G_PRIORITY_DEFAULT, (GSourceFunc)ForceUpdate, (gpointer)this, NULL); + } - glib::Object pixbuf(GetPixbufFromBG()); - LoadPixbufToHash(pixbuf); - - g_idle_add_full (G_PRIORITY_DEFAULT, (GSourceFunc)ForceUpdate, (gpointer)this, NULL); // avoids making a new object method when all we are doing is // calling a method with no logic @@ -84,13 +96,12 @@ namespace unity { _ubus_handle_request_colour = ubus_server_register_interest (ubus, UBUS_BACKGROUND_REQUEST_COLOUR_EMIT, (UBusCallback)request_lambda, this); - - - } BGHash::~BGHash () { + // serialize our cache + SerializeCache(); g_object_unref (client); g_object_unref (background_monitor); UBusServer *ubus = ubus_server_get_default (); @@ -427,21 +438,163 @@ namespace unity { } void BGHash::LoadFileToHash(const std::string path) + { + std::string filepath_hash = CreateFilepathHash(path); + if (G_LIKELY(cache_map_.count(filepath_hash))) + { + TransitionToNewColor(cache_map_[filepath_hash]); + } + else + { + glib::Error error; + glib::Object pixbuf(gdk_pixbuf_new_from_file (path.c_str (), &error)); + + if (error) + { + LOG_WARNING(logger) << "Could not load filename \"" << path << "\": " << error.Message(); + _current_color = unity::colors::Aubergine; + + // try and get a colour from gnome-bg, for various reasons, gnome bg might not + // return a correct image which sucks =\ but this is a fallback + pixbuf = GetPixbufFromBG(); + } + + LoadPixbufToHash (pixbuf); + + cache_map_[filepath_hash] = _new_color; + } + } + + std::string BGHash::CreateFilepathHash(std::string path) { glib::Error error; - glib::Object pixbuf(gdk_pixbuf_new_from_file (path.c_str (), &error)); + glib::Object file(g_file_new_for_path(path.c_str())); + glib::Object file_info(g_file_query_info(file, + G_FILE_ATTRIBUTE_TIME_MODIFIED, + G_FILE_QUERY_INFO_NONE, + NULL, &error)); + if (G_UNLIKELY(error)) + { + LOG_ERROR(logger) << "could not hash path (" << path << ")" + << ": " << error.Message(); + return std::string(""); + } + else + { + glib::String modified_time(g_file_info_get_attribute_as_string(file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED)); + return path + modified_time.Str(); + } + } + + namespace + { + const std::string cachefilename = "/unity/bgcachefile"; + } - if (error) + void BGHash::SerializeCache() + { + glib::Error error; + glib::String cachedir(g_strdup(g_get_user_cache_dir())); + std::string fullpath(cachedir.Str() + cachefilename); + glib::Object cachefile(g_file_new_for_path(fullpath.c_str())); + glib::Object output_stream(G_OUTPUT_STREAM(g_file_replace(cachefile, + NULL, FALSE, G_FILE_CREATE_NONE, + NULL, &error))); + LOG_DEBUG(logger) << "serializing cache: " << fullpath; + if (G_UNLIKELY(error)) { - LOG_WARNING(logger) << "Could not load filename \"" << path << "\": " << error.Message(); - _current_color = unity::colors::Aubergine; + LOG_ERROR(logger) << "could not open file (" << fullpath << ")" + << ": " << error.Message(); + } + else + { + glib::Error write_error; + std::ostringstream buffer; + for (auto ittr=cache_map_.begin(); ittr != cache_map_.end(); ittr++) + { + std::string key = (*ittr).first; + nux::Color value((*ittr).second); + + buffer << key << ":" + << int(value.red * 255) << ":" + << int(value.green * 255) << ":" + << int(value.blue * 255); + if (ittr != --cache_map_.end()) + { + buffer << ","; + } + } + + const char* base_buffer = buffer.str().c_str(); + gsize bytes_written = 0; + LOG_DEBUG(logger) << "writing to buffer (" << buffer.str() << ")"; + g_output_stream_write_all(output_stream, base_buffer, strlen(base_buffer), &bytes_written, NULL, &write_error); + if (write_error) + { + LOG_ERROR(logger) << "could not write to file (" << fullpath << ")" + << ": " << error.Message(); + } + + g_output_stream_close(output_stream, NULL, NULL); + } + } + + void BGHash::UnSerializeCache() + { + glib::Error error; + glib::String cachedir(g_strdup(g_get_user_cache_dir())); + std::string fullpath(cachedir.Str() + cachefilename); + glib::String contents; + gsize length; + g_file_get_contents(fullpath.c_str(), &contents, &length, &error); - // try and get a colour from gnome-bg, for various reasons, gnome bg might not - // return a correct image which sucks =\ but this is a fallback - pixbuf = GetPixbufFromBG(); + if (G_UNLIKELY(error)) + { + LOG_ERROR(logger) << "could not open file (" << fullpath << ")" + << ": " << error.Message(); } + else + { + LOG_DEBUG(logger) << "Loading from hash file (" << fullpath << " - " << length << "): " << contents; + // data is filenamehash:red:green:blue, + // using glib instead of C++ stuff like boost because boost just corrupted everything, very weird. + gchar** super_tokens = NULL; + super_tokens = g_strsplit(contents, ",", -1); + if (super_tokens != NULL) + { + for (int superi = 0; super_tokens[superi]; superi++) + { + glib::String super_token(super_tokens[superi]); + char** sub_tokens = g_strsplit(super_token, ":", 4); + if (sub_tokens != NULL) + { + std::string name, red, green, blue; + for (int i = 0; sub_tokens[i]; i++) + { + glib::String token(sub_tokens[i]); + switch(i) + { + case 0: name = token.Str(); break; + case 1: red = token.Str(); break; + case 2: green = token.Str(); break; + case 3: blue = token.Str(); break; + default: break; + } + } + if (!name.empty()) + { + LOG_DEBUG(logger) << "Unserialized cache value " << name; + cache_map_[name] = nux::Color(atof(red.c_str()) / 255.0f, + atof(green.c_str()) / 255.0f, + atof(blue.c_str()) / 255.0f, 1); + } + g_free(sub_tokens); // only g_free because glib:String will free the strings for us + } + } + g_free(super_tokens); // only g_free because glib::String will free the strings for us + } - LoadPixbufToHash (pixbuf); + } } inline nux::Color GetPixbufSample (GdkPixbuf *pixbuf, int x, int y) @@ -558,7 +711,7 @@ namespace unity { } else { - LOG_DEBUG (logger) << "got a colour image"; + LOG_DEBUG (logger) << "got a colour image wut"; // full colour image for (int i = 0; i < 11; i++) { diff --git a/plugins/unityshell/src/BGHash.h b/plugins/unityshell/src/BGHash.h index e18ead70c..9d4ae0c4c 100644 --- a/plugins/unityshell/src/BGHash.h +++ b/plugins/unityshell/src/BGHash.h @@ -36,8 +36,6 @@ namespace unity class BGHash { public: - - BGHash (); ~BGHash (); @@ -49,7 +47,7 @@ namespace unity void OnBackgroundChanged (GnomeBG *bg); void OnGSettingsChanged (GSettings *settings, gchar *key); void OverrideColor (nux::Color color); - + private: static gboolean OnSlideshowTransition (BGHash *self); static gboolean OnTransitionCallback (BGHash *self); @@ -59,6 +57,10 @@ namespace unity nux::Color InterpolateColor (nux::Color colora, nux::Color colorb, float value); nux::Color HashColor(GdkPixbuf *pixbuf); nux::Color MatchColor (nux::Color base_color); + std::string CreateFilepathHash(std::string path); + + void SerializeCache(); + void UnSerializeCache(); private: GnomeBG *background_monitor; @@ -80,6 +82,8 @@ namespace unity guint64 _hires_time_end; glib::SignalManager signal_manager_; uint _ubus_handle_request_colour; + + std::map cache_map_; }; }; diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 977a587f7..e183e7731 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -348,6 +348,7 @@ UnityScreen::UnityScreen(CompScreen* screen) UnityScreen::~UnityScreen() { + LOG_DEBUG(logger) << "UnityScreen Destructor"; notify_uninit(); unity_a11y_finalize(); -- cgit v1.2.3 From 1dea4f155da4f15606d4ba170c6bb76552291385 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Mon, 13 Feb 2012 12:09:20 +0000 Subject: remove useless depends (bzr r1948.7.3) --- plugins/unityshell/src/BGHash.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/BGHash.cpp b/plugins/unityshell/src/BGHash.cpp index d995dd804..febbcdf34 100644 --- a/plugins/unityshell/src/BGHash.cpp +++ b/plugins/unityshell/src/BGHash.cpp @@ -19,8 +19,6 @@ #include "BGHash.h" #include #include -#include -#include #include #include #include -- cgit v1.2.3 From 66be52e01b929f612ec209afcd6a19334e4c5795 Mon Sep 17 00:00:00 2001 From: Gord Allott Date: Mon, 13 Feb 2012 12:11:49 +0000 Subject: removed debugs (bzr r1948.7.4) --- plugins/unityshell/src/BGHash.cpp | 2 +- plugins/unityshell/src/unityshell.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/BGHash.cpp b/plugins/unityshell/src/BGHash.cpp index febbcdf34..512d3b136 100644 --- a/plugins/unityshell/src/BGHash.cpp +++ b/plugins/unityshell/src/BGHash.cpp @@ -709,7 +709,7 @@ namespace unity { } else { - LOG_DEBUG (logger) << "got a colour image wut"; + LOG_DEBUG (logger) << "got a colour image"; // full colour image for (int i = 0; i < 11; i++) { diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index e183e7731..977a587f7 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -348,7 +348,6 @@ UnityScreen::UnityScreen(CompScreen* screen) UnityScreen::~UnityScreen() { - LOG_DEBUG(logger) << "UnityScreen Destructor"; notify_uninit(); unity_a11y_finalize(); -- cgit v1.2.3