diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-03-06 14:13:37 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-03-06 14:13:37 +0100 |
| commit | 04bb54aa013a82c16aaf41e4869f580cccbca549 (patch) | |
| tree | c4c47e308099e6a7636f0de03f107ad081e8dbb7 /launcher | |
| parent | b9c561820acf8e1661d557e4d76772e866e2b8ca (diff) | |
| parent | b94635ba3f6078b5b16ff029e017817e07fb112f (diff) | |
Merging with trunk
(bzr r3149.1.34)
Diffstat (limited to 'launcher')
| -rw-r--r-- | launcher/BFBLauncherIcon.cpp | 3 | ||||
| -rw-r--r-- | launcher/HudLauncherIcon.cpp | 3 | ||||
| -rw-r--r-- | launcher/Launcher.cpp | 11 | ||||
| -rw-r--r-- | launcher/Launcher.h | 7 | ||||
| -rw-r--r-- | launcher/LauncherController.cpp | 88 | ||||
| -rw-r--r-- | launcher/LauncherControllerPrivate.h | 1 | ||||
| -rw-r--r-- | launcher/StandaloneLauncher.cpp | 1 | ||||
| -rw-r--r-- | launcher/XdndCollectionWindowImp.cpp | 19 |
8 files changed, 114 insertions, 19 deletions
diff --git a/launcher/BFBLauncherIcon.cpp b/launcher/BFBLauncherIcon.cpp index a84d71f7b..f7d701020 100644 --- a/launcher/BFBLauncherIcon.cpp +++ b/launcher/BFBLauncherIcon.cpp @@ -58,8 +58,9 @@ void BFBLauncherIcon::OnOverlayShown(GVariant *data, bool visible) unity::glib::String overlay_identity; gboolean can_maximise = FALSE; gint32 overlay_monitor = 0; + int width, height; g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING, - &overlay_identity, &can_maximise, &overlay_monitor); + &overlay_identity, &can_maximise, &overlay_monitor, &width, &height); if (overlay_identity.Str() == "dash" && IsVisibleOnMonitor(overlay_monitor)) { diff --git a/launcher/HudLauncherIcon.cpp b/launcher/HudLauncherIcon.cpp index 7fea6c4f7..39fa01a0d 100644 --- a/launcher/HudLauncherIcon.cpp +++ b/launcher/HudLauncherIcon.cpp @@ -89,8 +89,9 @@ void HudLauncherIcon::OnOverlayShown(GVariant* data, bool visible) unity::glib::String overlay_identity; gboolean can_maximise = FALSE; gint32 overlay_monitor = 0; + int width, height; g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING, - &overlay_identity, &can_maximise, &overlay_monitor); + &overlay_identity, &can_maximise, &overlay_monitor, &width, &height); // If the hud is open, we show the HUD button if we have a locked launcher if (overlay_identity.Str() == "hud" && diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index 81eedd501..96bbb1923 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -101,7 +101,7 @@ NUX_IMPLEMENT_OBJECT_TYPE(Launcher); const int Launcher::Launcher::ANIM_DURATION_SHORT = 125; -Launcher::Launcher(nux::BaseWindow* parent, +Launcher::Launcher(MockableBaseWindow* parent, NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) #ifdef USE_X11 @@ -1210,8 +1210,9 @@ void Launcher::OnOverlayShown(GVariant* data) unity::glib::String overlay_identity; gboolean can_maximise = FALSE; gint32 overlay_monitor = 0; + int width, height; g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING, - &overlay_identity, &can_maximise, &overlay_monitor); + &overlay_identity, &can_maximise, &overlay_monitor, &width, &height); std::string identity(overlay_identity.Str()); LOG_DEBUG(logger) << "Overlay shown: " << identity @@ -1251,8 +1252,9 @@ void Launcher::OnOverlayHidden(GVariant* data) unity::glib::String overlay_identity; gboolean can_maximise = FALSE; gint32 overlay_monitor = 0; + int width, height; g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING, - &overlay_identity, &can_maximise, &overlay_monitor); + &overlay_identity, &can_maximise, &overlay_monitor, &width, &height); std::string identity = overlay_identity.Str(); @@ -1316,7 +1318,8 @@ void Launcher::SetHidden(bool hide_launcher) TimeUtil::SetTimeStruct(&_times[TIME_AUTOHIDE], &_times[TIME_AUTOHIDE], ANIM_DURATION_SHORT); - _parent->EnableInputWindow(!hide_launcher, launcher::window_title, false, false); + if (nux::GetWindowThread()->IsEmbeddedWindow()) + _parent->EnableInputWindow(!hide_launcher, launcher::window_title, false, false); if (!hide_launcher && GetActionState() == ACTION_DRAG_EXTERNAL) DndReset(); diff --git a/launcher/Launcher.h b/launcher/Launcher.h index 338fa1ab8..f441b6e78 100644 --- a/launcher/Launcher.h +++ b/launcher/Launcher.h @@ -39,6 +39,7 @@ #include "LauncherDragWindow.h" #include "LauncherHideMachine.h" #include "LauncherHoverMachine.h" +#include "unity-shared/MockableBaseWindow.h" #include "unity-shared/UBusWrapper.h" #include "SoftwareCenterLauncherIcon.h" @@ -65,7 +66,7 @@ class Launcher : public unity::debug::Introspectable, NUX_DECLARE_OBJECT_TYPE(Launcher, nux::View); public: - Launcher(nux::BaseWindow* parent, NUX_FILE_LINE_PROTO); + Launcher(MockableBaseWindow* parent, NUX_FILE_LINE_PROTO); nux::Property<Display*> display; nux::Property<int> monitor; @@ -99,7 +100,7 @@ public: BacklightMode GetBacklightMode() const; bool IsBackLightModeToggles() const; - nux::BaseWindow* GetParent() const + MockableBaseWindow* GetParent() const { return _parent; }; @@ -334,7 +335,7 @@ private: bool DndIsSpecialRequest(std::string const& uri) const; LauncherModel::Ptr _model; - nux::BaseWindow* _parent; + MockableBaseWindow* _parent; nux::ObjectPtr<nux::View> _active_tooltip; QuicklistView* _active_quicklist; diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp index dd0ecb10a..25da39a3a 100644 --- a/launcher/LauncherController.cpp +++ b/launcher/LauncherController.cpp @@ -24,7 +24,6 @@ #include <Nux/Nux.h> #include <Nux/HLayout.h> -#include <Nux/BaseWindow.h> #include <NuxCore/Logger.h> #include <UnityCore/DesktopUtilities.h> @@ -68,6 +67,11 @@ const std::string DBUS_INTROSPECTION = " <arg type='s' name='aptdaemon_task' direction='in'/>" " </method>" "" + " <method name='UpdateLauncherIconFavoriteState'>" + " <arg type='s' name='icon_uri' direction='in'/>" + " <arg type='b' name='is_sticky' direction='in'/>" + " </method>" + "" " </interface>" "</node>"; } @@ -89,6 +93,15 @@ namespace const std::string RUNNING_APPS_URI = FavoriteStore::URI_PREFIX_UNITY + "running-apps"; const std::string DEVICES_URI = FavoriteStore::URI_PREFIX_UNITY + "devices"; } + +std::string CreateAppUriNameFromDesktopPath(const std::string &desktop_path) +{ + if (desktop_path.empty()) + return ""; + + return FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(desktop_path); +} + } Controller::Impl::Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager) @@ -306,7 +319,7 @@ void Controller::Impl::OnDndMonitorChanged(int monitor) Launcher* Controller::Impl::CreateLauncher() { - nux::BaseWindow* launcher_window = new nux::BaseWindow(TEXT("LauncherWindow")); + auto* launcher_window = new MockableBaseWindow(TEXT("LauncherWindow")); Launcher* launcher = new Launcher(launcher_window); launcher->options = parent_->options(); @@ -321,7 +334,10 @@ Launcher* Controller::Impl::CreateLauncher() launcher_window->SetLayout(layout); launcher_window->SetBackgroundColor(nux::color::Transparent); launcher_window->ShowWindow(true); - launcher_window->EnableInputWindow(true, launcher::window_title, false, false); + + if (nux::GetWindowThread()->IsEmbeddedWindow()) + launcher_window->EnableInputWindow(true, launcher::window_title, false, false); + launcher_window->InputWindowEnableStruts(parent_->options()->hide_mode == LAUNCHER_HIDE_NEVER); launcher_window->SetEnterFocusInputArea(launcher); @@ -340,7 +356,7 @@ void Controller::Impl::OnLauncherAddRequest(std::string const& icon_uri, Abstrac if (icon_uri.find(FavoriteStore::URI_PREFIX_FILE) == 0) { auto const& desktop_path = icon_uri.substr(FavoriteStore::URI_PREFIX_FILE.length()); - app_uri = FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(desktop_path); + app_uri = local::CreateAppUriNameFromDesktopPath(desktop_path); } auto const& icon = GetIconByUri(app_uri.empty() ? icon_uri : app_uri); @@ -425,6 +441,62 @@ void Controller::Impl::SaveIconsOrder() } void +Controller::Impl::OnLauncherUpdateIconStickyState(std::string const& icon_uri, bool sticky) +{ + if (icon_uri.empty()) + return; + + std::string target_uri = icon_uri; + if (icon_uri.find(FavoriteStore::URI_PREFIX_FILE) == 0) + { + auto const& desktop_path = + icon_uri.substr(FavoriteStore::URI_PREFIX_FILE.length()); + + // app uri instead + target_uri = local::CreateAppUriNameFromDesktopPath(desktop_path); + } + auto const& existing_icon_entry = + GetIconByUri(target_uri); + + if (existing_icon_entry) + { + // use the backgroung mechanism of model updates & propagation + bool should_update = (existing_icon_entry->IsSticky() != sticky); + if (should_update) + { + if (sticky) + { + existing_icon_entry->Stick(true); + } + else + { + existing_icon_entry->UnStick(); + } + + SortAndUpdate(); + } + } + else + { + FavoriteStore& favorite_store = FavoriteStore::Instance(); + + bool should_update = (favorite_store.IsFavorite(target_uri) != sticky); + if (should_update) + { + if (sticky) + { + favorite_store.AddFavorite(target_uri, -1); + RegisterIcon(CreateFavoriteIcon(target_uri)); + } + else + { + favorite_store.RemoveFavorite(target_uri); + } + } + } +} + +void Controller::Impl::OnLauncherAddRequestSpecial(std::string const& path, std::string const& aptdaemon_trans_id, std::string const& icon_path, @@ -1460,6 +1532,14 @@ GVariant* Controller::Impl::OnDBusMethodCall(std::string const& method, GVariant OnLauncherAddRequestSpecial(desktop_file.Str(), aptdaemon_task.Str(), icon.Str(), icon_x, icon_y, icon_size); } + else if (method == "UpdateLauncherIconFavoriteState") + { + gboolean is_sticky; + glib::String icon_uri; + g_variant_get(parameters, "(sb)", &icon_uri, &is_sticky); + + OnLauncherUpdateIconStickyState(icon_uri.Str(), is_sticky); + } return nullptr; } diff --git a/launcher/LauncherControllerPrivate.h b/launcher/LauncherControllerPrivate.h index 32980ca3d..af2ced337 100644 --- a/launcher/LauncherControllerPrivate.h +++ b/launcher/LauncherControllerPrivate.h @@ -72,6 +72,7 @@ public: void OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr const& before); void OnLauncherAddRequestSpecial(std::string const& path, std::string const& aptdaemon_trans_id, std::string const& icon_path, int icon_x, int icon_y, int icon_size); + void OnLauncherUpdateIconStickyState(std::string const& desktop_file, bool sticky); void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr const& icon); void OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry); diff --git a/launcher/StandaloneLauncher.cpp b/launcher/StandaloneLauncher.cpp index ccc5e11e4..777951f6f 100644 --- a/launcher/StandaloneLauncher.cpp +++ b/launcher/StandaloneLauncher.cpp @@ -64,7 +64,6 @@ private: { SetupBackground(); controller.reset(new launcher::Controller(std::make_shared<XdndManager>())); - controller->launcher().GetParent()->EnableInputWindow(false); UScreen* uscreen = UScreen::GetDefault(); std::vector<nux::Geometry> fake_monitor({nux::Geometry(0, 0, win_size.width, win_size.height)}); diff --git a/launcher/XdndCollectionWindowImp.cpp b/launcher/XdndCollectionWindowImp.cpp index e39f373a7..b98075187 100644 --- a/launcher/XdndCollectionWindowImp.cpp +++ b/launcher/XdndCollectionWindowImp.cpp @@ -40,9 +40,14 @@ public: ShowWindow(true); PushToBack(); - // Hack to create the X Window as soon as possible. - EnableInputWindow(true, "XdndCollectionWindowImp"); - EnableInputWindow(false, "XdndCollectionWindowImp"); + + if (nux::GetWindowThread()->IsEmbeddedWindow()) + { + // Hack to create the X Window as soon as possible. + EnableInputWindow(true, "XdndCollectionWindowImp"); + EnableInputWindow(false, "XdndCollectionWindowImp"); + } + SetDndEnabled(false, true); uscreen->changed.connect(sigc::mem_fun(this, &PrivateWindow::OnScreenChanged)); @@ -100,13 +105,17 @@ void XdndCollectionWindowImp::Collect() // the launcher window and the dash window. Don't forget to call PushToBack as // soon as possible. window_->PushToFront(); - window_->EnableInputWindow(true, "XdndCollectionWindowImp"); + + if (nux::GetWindowThread()->IsEmbeddedWindow()) + window_->EnableInputWindow(true, "XdndCollectionWindowImp"); } void XdndCollectionWindowImp::Deactivate() { window_->PushToBack(); - window_->EnableInputWindow(false, "XdndCollectionWindowImp"); + + if (nux::GetWindowThread()->IsEmbeddedWindow()) + window_->EnableInputWindow(false, "XdndCollectionWindowImp"); } } |
