summaryrefslogtreecommitdiff
diff options
-rw-r--r--launcher/Launcher.cpp323
-rw-r--r--launcher/Launcher.h83
-rw-r--r--launcher/LauncherController.cpp92
-rw-r--r--launcher/LauncherModel.cpp4
-rw-r--r--launcher/LauncherModel.h1
-rw-r--r--launcher/SoftwareCenterLauncherIcon.cpp13
-rw-r--r--plugins/unityshell/src/unity-launcher-accessible.cpp10
7 files changed, 201 insertions, 325 deletions
diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp
index 1f4d67faf..872652ffc 100644
--- a/launcher/Launcher.cpp
+++ b/launcher/Launcher.cpp
@@ -89,9 +89,6 @@ const int START_DRAGICON_DURATION = 250;
const int MOUSE_DEADZONE = 15;
const float DRAG_OUT_PIXELS = 300.0f;
-const std::string S_DBUS_NAME = "com.canonical.Unity.Launcher";
-const std::string S_DBUS_PATH = "/com/canonical/Unity/Launcher";
-
const std::string DND_CHECK_TIMEOUT = "dnd-check-timeout";
const std::string STRUT_HACK_TIMEOUT = "strut-hack-timeout";
const std::string START_DRAGICON_TIMEOUT = "start-dragicon-timeout";
@@ -102,51 +99,68 @@ const std::string ANIMATION_IDLE = "animation-idle";
NUX_IMPLEMENT_OBJECT_TYPE(Launcher);
-const gchar Launcher::introspection_xml[] =
- "<node>"
- " <interface name='com.canonical.Unity.Launcher'>"
- ""
- " <method name='AddLauncherItemFromPosition'>"
- " <arg type='s' name='title' direction='in'/>"
- " <arg type='s' name='icon' direction='in'/>"
- " <arg type='i' name='icon_x' direction='in'/>"
- " <arg type='i' name='icon_y' direction='in'/>"
- " <arg type='i' name='icon_size' direction='in'/>"
- " <arg type='s' name='desktop_file' direction='in'/>"
- " <arg type='s' name='aptdaemon_task' direction='in'/>"
- " </method>"
- ""
- " </interface>"
- "</node>";
-
-GDBusInterfaceVTable Launcher::interface_vtable =
-{
- Launcher::handle_dbus_method_call,
- NULL,
- NULL
-};
-
const int Launcher::Launcher::ANIM_DURATION_SHORT = 125;
Launcher::Launcher(nux::BaseWindow* parent,
NUX_FILE_LINE_DECL)
: View(NUX_FILE_LINE_PARAM)
- , _model(nullptr)
- , _background_color(nux::color::DimGray)
+ , monitor(0)
+ , _parent(parent)
+ , _active_quicklist(nullptr)
+ , _hovered(false)
+ , _hidden(false)
+ , _scroll_limit_reached(false)
+ , _render_drag_window(false)
+ , _shortcuts_shown(false)
+ , _data_checked(false)
+ , _steal_drag(false)
+ , _drag_edge_touching(false)
, _dash_is_open(false)
, _hud_is_open(false)
+ , _folded_angle(1.0f)
+ , _neg_folded_angle(-1.0f)
+ , _folded_z_distance(10.0f)
+ , _last_delta_y(0.0f)
+ , _edge_overcome_pressure(0.0f)
+ , _launcher_action_state(ACTION_NONE)
+ , _space_between_icons(5)
+ , _icon_image_size(48)
+ , _icon_image_size_delta(6)
+ , _icon_glow_size(62)
+ , _icon_size(_icon_image_size + _icon_image_size_delta)
+ , _dnd_delta_y(0)
+ , _dnd_delta_x(0)
+ , _postreveal_mousemove_delta_x(0)
+ , _postreveal_mousemove_delta_y(0)
+ , _launcher_drag_delta(0)
+ , _enter_y(0)
+ , _last_button_press(0)
+ , _drag_out_id(0)
+ , _drag_out_delta_x(0.0f)
+ , _last_reveal_progress(0.0f)
+ , _selection_atom(0)
+ , _background_color(nux::color::DimGray)
{
- _parent = parent;
- _active_quicklist = nullptr;
+ m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
- monitor = 0;
+ _collection_window = new unity::DNDCollectionWindow();
+ _collection_window->collected.connect(sigc::mem_fun(this, &Launcher::OnDNDDataCollected));
+
+ _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8);
+
+ bg_effect_helper_.owner = this;
+ bg_effect_helper_.enabled = false;
+
+ SetCompositionLayout(m_Layout);
+ CaptureMouseDownAnyWhereElse(true);
+ SetAcceptKeyNavFocusOnMouseDown(false);
+ SetAcceptMouseWheelEvent(true);
+ SetDndEnabled(false, true);
_hide_machine.should_hide_changed.connect(sigc::mem_fun(this, &Launcher::SetHidden));
_hide_machine.reveal_progress.changed.connect([&](float value) { EnsureAnimation(); });
_hover_machine.should_hover_changed.connect(sigc::mem_fun(this, &Launcher::SetHover));
- m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
-
mouse_down.connect(sigc::mem_fun(this, &Launcher::RecvMouseDown));
mouse_up.connect(sigc::mem_fun(this, &Launcher::RecvMouseUp));
mouse_drag.connect(sigc::mem_fun(this, &Launcher::RecvMouseDrag));
@@ -156,9 +170,6 @@ Launcher::Launcher(nux::BaseWindow* parent,
mouse_wheel.connect(sigc::mem_fun(this, &Launcher::RecvMouseWheel));
//OnEndFocus.connect (sigc::mem_fun (this, &Launcher::exitKeyNavMode));
- CaptureMouseDownAnyWhereElse(true);
- SetAcceptKeyNavFocusOnMouseDown(false);
-
QuicklistManager& ql_manager = *(QuicklistManager::Default());
ql_manager.quicklist_opened.connect(sigc::mem_fun(this, &Launcher::RecvQuicklistOpened));
ql_manager.quicklist_closed.connect(sigc::mem_fun(this, &Launcher::RecvQuicklistClosed));
@@ -180,88 +191,24 @@ Launcher::Launcher(nux::BaseWindow* parent,
display.changed.connect(sigc::mem_fun(this, &Launcher::OnDisplayChanged));
- SetCompositionLayout(m_Layout);
-
- _folded_angle = 1.0f;
- _neg_folded_angle = -1.0f;
- _space_between_icons = 5;
- _last_delta_y = 0.0f;
- _folded_z_distance = 10.0f;
- _launcher_action_state = ACTION_NONE;
- _icon_under_mouse = NULL;
- _icon_mouse_down = NULL;
- _drag_icon = NULL;
- _icon_image_size = 48;
- _icon_glow_size = 62;
- _icon_image_size_delta = 6;
- _icon_size = _icon_image_size + _icon_image_size_delta;
-
- _enter_y = 0;
- _launcher_drag_delta = 0;
- _dnd_delta_y = 0;
- _dnd_delta_x = 0;
- _last_reveal_progress = 0;
-
- _shortcuts_shown = false;
- _hovered = false;
- _hidden = false;
- _scroll_limit_reached = false;
- _render_drag_window = false;
- _drag_edge_touching = false;
- _steal_drag = false;
- _last_button_press = 0;
- _selection_atom = 0;
- _drag_out_id = 0;
- _drag_out_delta_x = 0.0f;
- _edge_overcome_pressure = 0.0f;
-
- // FIXME: remove
- _initial_drag_animation = false;
-
- _postreveal_mousemove_delta_x = 0;
- _postreveal_mousemove_delta_y = 0;
-
- _data_checked = false;
- _collection_window = new unity::DNDCollectionWindow();
- _collection_window->collected.connect(sigc::mem_fun(this, &Launcher::OnDNDDataCollected));
-
// 0 out timers to avoid wonky startups
- int i;
- for (i = 0; i < TIME_LAST; ++i)
+ for (int i = 0; i < TIME_LAST; ++i)
{
_times[i].tv_sec = 0;
_times[i].tv_nsec = 0;
}
- _dnd_hovered_icon = NULL;
- _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8);
-
ubus_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &Launcher::OnOverlayShown));
ubus_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &Launcher::OnOverlayHidden));
ubus_.RegisterInterest(UBUS_LAUNCHER_ACTION_DONE, sigc::mem_fun(this, &Launcher::OnActionDone));
ubus_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &Launcher::OnBGColorChanged));
ubus_.RegisterInterest(UBUS_LAUNCHER_LOCK_HIDE, sigc::mem_fun(this, &Launcher::OnLockHideChanged));
- _dbus_owner = g_bus_own_name(G_BUS_TYPE_SESSION,
- S_DBUS_NAME.c_str(),
- (GBusNameOwnerFlags)(G_BUS_NAME_OWNER_FLAGS_REPLACE | G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT),
- OnBusAcquired,
- nullptr,
- nullptr,
- this,
- nullptr);
-
- SetDndEnabled(false, true);
-
- icon_renderer = ui::AbstractIconRenderer::Ptr(new ui::IconRenderer());
- icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons);
// request the latest colour from bghash
ubus_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
- SetAcceptMouseWheelEvent(true);
-
- bg_effect_helper_.owner = this;
- bg_effect_helper_.enabled = false;
+ icon_renderer = ui::AbstractIconRenderer::Ptr(new ui::IconRenderer());
+ icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons);
TextureCache& cache = TextureCache::GetDefault();
TextureCache::CreateTextureCallback cb = [&](std::string const& name, int width, int height) -> nux::BaseTexture* {
@@ -271,35 +218,21 @@ Launcher::Launcher(nux::BaseWindow* parent,
launcher_sheen_ = cache.FindTexture("dash_sheen", 0, 0, cb);
launcher_pressure_effect_ = cache.FindTexture("launcher_pressure_effect", 0, 0, cb);
- options.changed.connect (sigc::mem_fun (this, &Launcher::OnOptionsChanged));
-
- // icon information from software center
- sc_icon_x_ = 0;
- sc_icon_y_ = 0;
- sc_icon_size_ = 0;
- sc_anim_icon_ = false;
-}
-
-Launcher::~Launcher()
-{
- g_bus_unown_name(_dbus_owner);
+ options.changed.connect(sigc::mem_fun (this, &Launcher::OnOptionsChanged));
}
/* Introspection */
-std::string
-Launcher::GetName() const
+std::string Launcher::GetName() const
{
return "Launcher";
}
-void
-Launcher::OnDisplayChanged(Display* display)
+void Launcher::OnDisplayChanged(Display* display)
{
_collection_window->display = display;
}
-void
-Launcher::OnDragStart(GeisAdapter::GeisDragData* data)
+void Launcher::OnDragStart(GeisAdapter::GeisDragData* data)
{
if (_drag_out_id && _drag_out_id == data->id)
return;
@@ -319,8 +252,7 @@ Launcher::OnDragStart(GeisAdapter::GeisDragData* data)
}
}
-void
-Launcher::OnDragUpdate(GeisAdapter::GeisDragData* data)
+void Launcher::OnDragUpdate(GeisAdapter::GeisDragData* data)
{
if (data->id == _drag_out_id)
{
@@ -329,8 +261,7 @@ Launcher::OnDragUpdate(GeisAdapter::GeisDragData* data)
}
}
-void
-Launcher::OnDragFinish(GeisAdapter::GeisDragData* data)
+void Launcher::OnDragFinish(GeisAdapter::GeisDragData* data)
{
if (data->id == _drag_out_id)
{
@@ -342,8 +273,7 @@ Launcher::OnDragFinish(GeisAdapter::GeisDragData* data)
}
}
-void
-Launcher::AddProperties(GVariantBuilder* builder)
+void Launcher::AddProperties(GVariantBuilder* builder)
{
timespec current;
clock_gettime(CLOCK_MONOTONIC, &current);
@@ -1410,20 +1340,17 @@ void Launcher::SetHidden(bool hidden)
hidden_changed.emit();
}
-int
-Launcher::GetMouseX() const
+int Launcher::GetMouseX() const
{
return _mouse_position.x;
}
-int
-Launcher::GetMouseY() const
+int Launcher::GetMouseY() const
{
return _mouse_position.y;
}
-bool
-Launcher::OnUpdateDragManagerTimeout()
+bool Launcher::OnUpdateDragManagerTimeout()
{
if (display() == 0)
return false;
@@ -1474,8 +1401,7 @@ void Launcher::DndTimeoutSetup()
timeout->Run(sigc::mem_fun(this, &Launcher::OnUpdateDragManagerTimeout));
}
-void
-Launcher::OnWindowMapped(guint32 xid)
+void Launcher::OnWindowMapped(guint32 xid)
{
//CompWindow* window = _screen->findWindow(xid);
//if (window && window->type() | CompWindowTypeDndMask)
@@ -1487,8 +1413,7 @@ Launcher::OnWindowMapped(guint32 xid)
ResetMouseDragState();
}
-void
-Launcher::OnWindowUnmapped(guint32 xid)
+void Launcher::OnWindowUnmapped(guint32 xid)
{
//CompWindow* window = _screen->findWindow(xid);
//if (window && window->type() | CompWindowTypeDndMask)
@@ -1497,8 +1422,7 @@ Launcher::OnWindowUnmapped(guint32 xid)
//}
}
-void
-Launcher::OnPluginStateChanged()
+void Launcher::OnPluginStateChanged()
{
_hide_machine.SetQuirk (LauncherHideMachine::EXPO_ACTIVE, WindowManager::Default ()->IsExpoActive ());
_hide_machine.SetQuirk (LauncherHideMachine::SCALE_ACTIVE, WindowManager::Default ()->IsScaleActive ());
@@ -1522,22 +1446,19 @@ bool Launcher::StrutHack()
return false;
}
-void
-Launcher::OnOptionsChanged(Options::Ptr options)
+void Launcher::OnOptionsChanged(Options::Ptr options)
{
UpdateOptions(options);
options->option_changed.connect(sigc::mem_fun(this, &Launcher::OnOptionChanged));
}
-void
-Launcher::OnOptionChanged()
+void Launcher::OnOptionChanged()
{
UpdateOptions(options());
}
-void
-Launcher::UpdateOptions(Options::Ptr options)
+void Launcher::UpdateOptions(Options::Ptr options)
{
SetHideMode(options->hide_mode);
SetIconSize(options->tile_size, options->icon_size);
@@ -1597,8 +1518,7 @@ bool Launcher::IsBackLightModeToggles() const
}
}
-void
-Launcher::SetActionState(LauncherActionState actionstate)
+void Launcher::SetActionState(LauncherActionState actionstate)
{
if (_launcher_action_state == actionstate)
return;
@@ -1781,7 +1701,7 @@ void Launcher::OnOrderChanged()
EnsureAnimation();
}
-void Launcher::SetModel(LauncherModel* model)
+void Launcher::SetModel(LauncherModel::Ptr model)
{
_model = model;
@@ -1794,7 +1714,7 @@ void Launcher::SetModel(LauncherModel* model)
_model->selection_changed.connect(sigc::mem_fun(this, &Launcher::OnSelectionChanged));
}
-LauncherModel* Launcher::GetModel() const
+LauncherModel::Ptr Launcher::GetModel() const
{
return _model;
}
@@ -2053,14 +1973,6 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
gPainter.PopBackground(push_count);
GfxContext.PopClippingRectangle();
GfxContext.PopClippingRectangle();
-
- if (sc_anim_icon_)
- {
- launcher_addrequest_special.emit(sc_icon_desktop_file_, AbstractLauncherIcon::Ptr(),
- sc_icon_aptdaemon_task_, sc_icon_, sc_icon_x_,
- sc_icon_y_, sc_icon_size_);
- sc_anim_icon_ = false;
- }
}
void Launcher::PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw)
@@ -2560,8 +2472,7 @@ AbstractLauncherIcon::Ptr Launcher::MouseIconIntersection(int x, int y)
return AbstractLauncherIcon::Ptr();
}
-void
-Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
+void Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
{
RenderArg arg;
struct timespec current;
@@ -2586,8 +2497,7 @@ Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherI
RestoreSystemRenderTarget();
}
-void
-Launcher::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
+void Launcher::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
{
int width = texture->GetWidth();
int height = texture->GetHeight();
@@ -2605,8 +2515,7 @@ Launcher::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> textu
graphics_engine->EmptyClippingRegion();
}
-void
-Launcher::RestoreSystemRenderTarget()
+void Launcher::RestoreSystemRenderTarget()
{
nux::GetWindowCompositor().RestoreRenderingSurface();
}
@@ -2659,8 +2568,7 @@ void Launcher::OnDNDDataCollected(const std::list<char*>& mimes)
}
}
-void
-Launcher::ProcessDndEnter()
+void Launcher::ProcessDndEnter()
{
SetStateMouseOverLauncher(true);
@@ -2672,8 +2580,7 @@ Launcher::ProcessDndEnter()
_dnd_hovered_icon = nullptr;
}
-void
-Launcher::DndReset()
+void Launcher::DndReset()
{
_dnd_data.Reset();
@@ -2704,16 +2611,14 @@ void Launcher::DndHoveredIconReset()
_dnd_hovered_icon = nullptr;
}
-void
-Launcher::ProcessDndLeave()
+void Launcher::ProcessDndLeave()
{
SetStateMouseOverLauncher(false);
DndHoveredIconReset();
}
-void
-Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes)
+void Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes)
{
nux::Area* parent = GetToplevel();
unity::glib::String uri_list_const(g_strdup("text/uri-list"));
@@ -2847,8 +2752,7 @@ Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes)
SendDndStatus(accept, _drag_action, nux::Geometry(x, y, 1, 1));
}
-void
-Launcher::ProcessDndDrop(int x, int y)
+void Launcher::ProcessDndDrop(int x, int y)
{
if (_steal_drag)
{
@@ -2895,84 +2799,17 @@ 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::Ptr
-Launcher::GetSelectedMenuIcon() const
+AbstractLauncherIcon::Ptr Launcher::GetSelectedMenuIcon() const
{
if (!IsInKeyNavMode())
return AbstractLauncherIcon::Ptr();
return _model->Selection();
}
-/* dbus handlers */
-
-void
-Launcher::handle_dbus_method_call(GDBusConnection* connection,
- const gchar* sender,
- const gchar* object_path,
- const gchar* interface_name,
- const gchar* method_name,
- GVariant* parameters,
- GDBusMethodInvocation* invocation,
- gpointer user_data)
-{
- if (g_strcmp0(method_name, "AddLauncherItemFromPosition") == 0)
- {
- auto self = static_cast<Launcher*>(user_data);
- glib::String icon, icon_title, desktop_file, aptdaemon_task;
- gint icon_x, icon_y, icon_size;
-
- g_variant_get(parameters, "(ssiiiss)", &icon_title, &icon, &icon_x, &icon_y,
- &icon_size, &desktop_file, &aptdaemon_task);
-
- self->sc_anim_icon_ = true;
- self->sc_icon_ = icon.Str();
- self->sc_icon_title_ = icon_title.Str();
- self->sc_icon_desktop_file_ = desktop_file.Str();
- self->sc_icon_aptdaemon_task_ = aptdaemon_task.Str();
- self->sc_icon_x_ = icon_x;
- self->sc_icon_y_ = icon_y;
- self->sc_icon_size_ = icon_size;
-
- g_dbus_method_invocation_return_value(invocation, nullptr);
- }
-}
-
-void
-Launcher::OnBusAcquired(GDBusConnection* connection,
- const gchar* name,
- gpointer user_data)
-{
- GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
- guint registration_id;
-
- if (!introspection_data)
- {
- LOG_WARNING(logger) << "No introspection data loaded. Won't get dynamic launcher addition.";
- return;
- }
-
-
-
- registration_id = g_dbus_connection_register_object(connection,
- S_DBUS_PATH.c_str(),
- introspection_data->interfaces[0],
- &interface_vtable,
- user_data,
- NULL,
- NULL);
- if (!registration_id)
- {
- LOG_WARNING(logger) << "Object registration failed. Won't get dynamic launcher addition.";
- }
-
- g_dbus_node_info_unref(introspection_data);
-}
-
//
// Key navigation
//
-bool
-Launcher::InspectKeyEvent(unsigned int eventType,
+bool Launcher::InspectKeyEvent(unsigned int eventType,
unsigned int keysym,
const char* character)
{
diff --git a/launcher/Launcher.h b/launcher/Launcher.h
index c57982296..a7b66444f 100644
--- a/launcher/Launcher.h
+++ b/launcher/Launcher.h
@@ -34,6 +34,7 @@
#include "EdgeBarrierController.h"
#include "GeisAdapter.h"
#include "unity-shared/Introspectable.h"
+#include "LauncherModel.h"
#include "LauncherOptions.h"
#include "LauncherDragWindow.h"
#include "LauncherHideMachine.h"
@@ -47,7 +48,6 @@ namespace unity
namespace launcher
{
class AbstractLauncherIcon;
-class LauncherModel;
class Launcher : public unity::debug::Introspectable, public nux::View, public ui::EdgeBarrierSubscriber
{
@@ -55,7 +55,6 @@ class Launcher : public unity::debug::Introspectable, public nux::View, public u
public:
Launcher(nux::BaseWindow* parent, NUX_FILE_LINE_PROTO);
- ~Launcher();
nux::Property<Display*> display;
nux::Property<int> monitor;
@@ -78,8 +77,8 @@ public:
void ForceReveal(bool force);
void ShowShortcuts(bool show);
- void SetModel(LauncherModel* model);
- LauncherModel* GetModel() const;
+ void SetModel(LauncherModel::Ptr model);
+ LauncherModel::Ptr GetModel() const;
void StartKeyShowLauncher();
void EndKeyShowLauncher();
@@ -112,8 +111,6 @@ public:
void Resize();
sigc::signal<void, char*, AbstractLauncherIcon::Ptr> launcher_addrequest;
- sigc::signal<void, std::string const&, AbstractLauncherIcon::Ptr, std::string const&, std::string const&,
- int, int, int> launcher_addrequest_special;
sigc::signal<void, AbstractLauncherIcon::Ptr> launcher_removerequest;
sigc::signal<void, AbstractLauncherIcon::Ptr> icon_animation_complete;
sigc::signal<void> selection_change;
@@ -310,20 +307,29 @@ private:
void DndHoveredIconReset();
void DndTimeoutSetup();
+ LauncherModel::Ptr _model;
+ nux::BaseWindow* _parent;
+ QuicklistView* _active_quicklist;
+
nux::HLayout* m_Layout;
// used by keyboard/a11y-navigation
AbstractLauncherIcon::Ptr _icon_under_mouse;
AbstractLauncherIcon::Ptr _icon_mouse_down;
AbstractLauncherIcon::Ptr _drag_icon;
-
- QuicklistView* _active_quicklist;
-
- bool _hovered;
- bool _hidden;
- bool _scroll_limit_reached;
- bool _render_drag_window;
- bool _shortcuts_shown;
+ AbstractLauncherIcon::Ptr _dnd_hovered_icon;
+
+ bool _hovered;
+ bool _hidden;
+ bool _scroll_limit_reached;
+ bool _render_drag_window;
+ bool _shortcuts_shown;
+ bool _data_checked;
+ bool _steal_drag;
+ bool _drag_edge_touching;
+ bool _initial_drag_animation;
+ bool _dash_is_open;
+ bool _hud_is_open;
BacklightMode _backlight_mode;
@@ -337,13 +343,11 @@ private:
LaunchAnimation _launch_animation;
UrgentAnimation _urgent_animation;
- nux::ObjectPtr<nux::IOpenGLBaseTexture> _offscreen_drag_texture;
-
int _space_between_icons;
- int _icon_size;
int _icon_image_size;
int _icon_image_size_delta;
int _icon_glow_size;
+ int _icon_size;
int _dnd_delta_y;
int _dnd_delta_x;
int _postreveal_mousemove_delta_x;
@@ -353,63 +357,28 @@ private:
int _last_button_press;
int _drag_out_id;
float _drag_out_delta_x;
- float _background_alpha;
float _last_reveal_progress;
- nux::Point2 _mouse_position;
- nux::BaseWindow* _parent;
- LauncherModel* _model;
+ nux::Point2 _mouse_position;
+ nux::ObjectPtr<nux::IOpenGLBaseTexture> _offscreen_drag_texture;
nux::ObjectPtr<LauncherDragWindow> _drag_window;
+ nux::ObjectPtr<unity::DNDCollectionWindow> _collection_window;
LauncherHideMachine _hide_machine;
LauncherHoverMachine _hover_machine;
unity::DndData _dnd_data;
- nux::DndAction _drag_action;
- bool _data_checked;
- bool _steal_drag;
- bool _drag_edge_touching;
- AbstractLauncherIcon::Ptr _dnd_hovered_icon;
- nux::ObjectPtr<unity::DNDCollectionWindow> _collection_window;
-
- Atom _selection_atom;
-
- /* gdbus */
- guint _dbus_owner;
- static const gchar introspection_xml[];
- static GDBusInterfaceVTable interface_vtable;
-
- static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data);
- static void handle_dbus_method_call(GDBusConnection* connection,
- const gchar* sender,
- const gchar* object_path,
- const gchar* interface_name,
- const gchar* method_name,
- GVariant* parameters,
- GDBusMethodInvocation* invocation,
- gpointer user_data);
+ nux::DndAction _drag_action;
+ Atom _selection_atom;
struct timespec _times[TIME_LAST];
- bool _initial_drag_animation;
-
nux::Color _background_color;
BaseTexturePtr launcher_sheen_;
BaseTexturePtr launcher_pressure_effect_;
- bool _dash_is_open;
- bool _hud_is_open;
ui::AbstractIconRenderer::Ptr icon_renderer;
BackgroundEffectHelper bg_effect_helper_;
- std::string sc_icon_;
- std::string sc_icon_title_;
- std::string sc_icon_desktop_file_;
- std::string sc_icon_aptdaemon_task_;
- unsigned int sc_icon_x_;
- unsigned int sc_icon_y_;
- unsigned int sc_icon_size_;
- bool sc_anim_icon_;
-
UBusManager ubus_;
glib::SourceManager sources_;
};
diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp
index 981021879..d5c5c13b9 100644
--- a/launcher/LauncherController.cpp
+++ b/launcher/LauncherController.cpp
@@ -56,6 +56,25 @@ namespace launcher
namespace
{
nux::logging::Logger logger("unity.launcher");
+
+const std::string DBUS_NAME = "com.canonical.Unity.Launcher";
+const std::string DBUS_PATH = "/com/canonical/Unity/Launcher";
+const std::string DBUS_INTROSPECTION =
+ "<node>"
+ " <interface name='com.canonical.Unity.Launcher'>"
+ ""
+ " <method name='AddLauncherItemFromPosition'>"
+ " <arg type='s' name='title' direction='in'/>"
+ " <arg type='s' name='icon' direction='in'/>"
+ " <arg type='i' name='icon_x' direction='in'/>"
+ " <arg type='i' name='icon_y' direction='in'/>"
+ " <arg type='i' name='icon_size' direction='in'/>"
+ " <arg type='s' name='desktop_file' direction='in'/>"
+ " <arg type='s' name='aptdaemon_task' direction='in'/>"
+ " </method>"
+ ""
+ " </interface>"
+ "</node>";
}
namespace local
@@ -92,8 +111,8 @@ public:
void OnIconRemoved(AbstractLauncherIcon::Ptr 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,
- int icon_x, int icon_y, int icon_size);
+ 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 OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr icon);
void OnSCIconAnimationComplete(AbstractLauncherIcon::Ptr icon);
@@ -143,8 +162,16 @@ public:
const char* character,
unsigned short keyCount);
+ static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data);
+ static void OnDBusMethodCall(GDBusConnection* connection, const gchar* sender, const gchar* object_path,
+ const gchar* interface_name, const gchar* method_name,
+ GVariant* parameters, GDBusMethodInvocation* invocation,
+ gpointer user_data);
+
+ static GDBusInterfaceVTable interface_vtable;
+
Controller* parent_;
- LauncherModel::Ptr model_;
+ LauncherModel::Ptr model_;
nux::ObjectPtr<Launcher> launcher_;
nux::ObjectPtr<Launcher> keyboard_launcher_;
int sort_priority_;
@@ -163,6 +190,7 @@ public:
int reactivate_index;
bool keynav_restore_window_;
int launcher_key_press_time_;
+ unsigned int dbus_owner_;
ui::EdgeBarrierController::Ptr edge_barriers_;
@@ -178,6 +206,8 @@ public:
sigc::connection launcher_event_outside_connection_;
};
+GDBusInterfaceVTable Controller::Impl::interface_vtable =
+ { Controller::Impl::OnDBusMethodCall, NULL, NULL};
Controller::Impl::Impl(Display* display, Controller* parent)
: parent_(parent)
@@ -259,6 +289,9 @@ Controller::Impl::Impl(Display* display, Controller* parent)
for (auto launcher : launchers)
launcher->QueueDraw();
});
+
+ dbus_owner_ = g_bus_own_name(G_BUS_TYPE_SESSION, DBUS_NAME.c_str(), G_BUS_NAME_OWNER_FLAGS_NONE,
+ OnBusAcquired, nullptr, nullptr, this, nullptr);
}
Controller::Impl::~Impl()
@@ -271,6 +304,8 @@ Controller::Impl::~Impl()
if (launcher_ptr.IsValid())
launcher_ptr->GetParent()->UnReference();
}
+
+ g_bus_unown_name(dbus_owner_);
}
void Controller::Impl::EnsureLaunchers(int primary, std::vector<nux::Geometry> const& monitors)
@@ -357,7 +392,7 @@ Launcher* Controller::Impl::CreateLauncher(int monitor)
launcher->display = display_;
launcher->monitor = monitor;
launcher->options = parent_->options();
- launcher->SetModel(model_.get());
+ launcher->SetModel(model_);
nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
layout->AddView(launcher, 1);
@@ -373,7 +408,6 @@ Launcher* Controller::Impl::CreateLauncher(int monitor)
launcher_window->SetEnterFocusInputArea(launcher);
launcher->launcher_addrequest.connect(sigc::mem_fun(this, &Impl::OnLauncherAddRequest));
- launcher->launcher_addrequest_special.connect(sigc::mem_fun(this, &Impl::OnLauncherAddRequestSpecial));
launcher->launcher_removerequest.connect(sigc::mem_fun(this, &Impl::OnLauncherRemoveRequest));
launcher->icon_animation_complete.connect(sigc::mem_fun(this, &Impl::OnSCIconAnimationComplete));
@@ -429,7 +463,6 @@ void Controller::Impl::Save()
void
Controller::Impl::OnLauncherAddRequestSpecial(std::string const& path,
- AbstractLauncherIcon::Ptr before,
std::string const& aptdaemon_trans_id,
std::string const& icon_path,
int icon_x,
@@ -445,12 +478,12 @@ Controller::Impl::OnLauncherAddRequestSpecial(std::string const& path,
SoftwareCenterLauncherIcon::Ptr result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path);
- launcher_->ForceReveal(true);
+ CurrentLauncher()->ForceReveal(true);
if (result)
{
result->SetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE, false);
- result->Animate(launcher_, icon_x, icon_y, icon_size);
+ result->Animate(CurrentLauncher(), icon_x, icon_y, icon_size);
RegisterIcon(result);
Save();
}
@@ -1281,6 +1314,49 @@ void Controller::Impl::ReceiveLauncherKeyPress(unsigned long eventType,
}
}
+void Controller::Impl::OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data)
+{
+ GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(DBUS_INTROSPECTION.c_str(), nullptr);
+ unsigned int reg_id;
+
+ if (!introspection_data)
+ {
+ LOG_WARNING(logger) << "No introspection data loaded. Won't get dynamic launcher addition.";
+ return;
+ }
+
+ reg_id = g_dbus_connection_register_object(connection, DBUS_PATH.c_str(),
+ introspection_data->interfaces[0],
+ &interface_vtable, user_data,
+ nullptr, nullptr);
+ if (!reg_id)
+ {
+ LOG_WARNING(logger) << "Object registration failed. Won't get dynamic launcher addition.";
+ }
+
+ g_dbus_node_info_unref(introspection_data);
+}
+
+void Controller::Impl::OnDBusMethodCall(GDBusConnection* connection, const gchar* sender,
+ const gchar* object_path, const gchar* interface_name,
+ const gchar* method_name, GVariant* parameters,
+ GDBusMethodInvocation* invocation, gpointer user_data)
+{
+ if (g_strcmp0(method_name, "AddLauncherItemFromPosition") == 0)
+ {
+ auto self = static_cast<Controller::Impl*>(user_data);
+ glib::String icon, icon_title, desktop_file, aptdaemon_task;
+ gint icon_x, icon_y, icon_size;
+
+ g_variant_get(parameters, "(ssiiiss)", &icon_title, &icon, &icon_x, &icon_y,
+ &icon_size, &desktop_file, &aptdaemon_task);
+
+ self->OnLauncherAddRequestSpecial(desktop_file.Str(), aptdaemon_task.Str(),
+ icon.Str(), icon_x, icon_y, icon_size);
+
+ g_dbus_method_invocation_return_value(invocation, nullptr);
+ }
+}
} // namespace launcher
} // namespace unity
diff --git a/launcher/LauncherModel.cpp b/launcher/LauncherModel.cpp
index 63be3a236..c3f0f9f38 100644
--- a/launcher/LauncherModel.cpp
+++ b/launcher/LauncherModel.cpp
@@ -33,10 +33,6 @@ LauncherModel::LauncherModel()
{
}
-LauncherModel::~LauncherModel()
-{
-}
-
std::string LauncherModel::GetName() const
{
return "LauncherModel";
diff --git a/launcher/LauncherModel.h b/launcher/LauncherModel.h
index 4ffb20bdc..de3e33867 100644
--- a/launcher/LauncherModel.h
+++ b/launcher/LauncherModel.h
@@ -40,7 +40,6 @@ public:
typedef Base::reverse_iterator const_reverse_iterator;
LauncherModel();
- ~LauncherModel();
void AddIcon(AbstractLauncherIcon::Ptr icon);
void RemoveIcon(AbstractLauncherIcon::Ptr icon);
diff --git a/launcher/SoftwareCenterLauncherIcon.cpp b/launcher/SoftwareCenterLauncherIcon.cpp
index 915063252..e7a7fe0f6 100644
--- a/launcher/SoftwareCenterLauncherIcon.cpp
+++ b/launcher/SoftwareCenterLauncherIcon.cpp
@@ -74,22 +74,21 @@ void SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> launcher,
launcher->RenderIconToTexture(nux::GetWindowThread()->GetGraphicsEngine(),
AbstractLauncherIcon::Ptr(this),
icon_texture_);
- nux::Geometry geo = drag_window_->GetGeometry();
+
drag_window_->SetBaseXY(icon_x, icon_y);
drag_window_->ShowWindow(true);
- drag_window_->SinkReference();
// Find out the center of last BamfLauncherIcon with non-zero co-ordinates
auto bamf_icons = launcher->GetModel()->GetSublist<BamfLauncherIcon>();
//TODO: don't iterate through them and pick the last one, just use back() to get the last one.
for (auto current_bamf_icon : bamf_icons)
{
- int x = (int) current_bamf_icon->GetCenter(launcher->monitor).x;
- int y = (int) current_bamf_icon->GetCenter(launcher->monitor).y;
- if (x != 0 && y != 0)
+ auto icon_center = current_bamf_icon->GetCenter(launcher->monitor);
+
+ if (icon_center.x != 0 && icon_center.y != 0)
{
- target_x = x;
- target_y = y;
+ target_x = icon_center.x;
+ target_y = icon_center.y;
}
}
diff --git a/plugins/unityshell/src/unity-launcher-accessible.cpp b/plugins/unityshell/src/unity-launcher-accessible.cpp
index 25ec6ee94..d20deed28 100644
--- a/plugins/unityshell/src/unity-launcher-accessible.cpp
+++ b/plugins/unityshell/src/unity-launcher-accessible.cpp
@@ -147,7 +147,7 @@ unity_launcher_accessible_initialize(AtkObject* accessible,
Launcher* launcher = NULL;
nux::Object* nux_object = NULL;
UnityLauncherAccessible* self = NULL;
- LauncherModel* model = NULL;
+ LauncherModel::Ptr model = NULL;
ATK_OBJECT_CLASS(unity_launcher_accessible_parent_class)->initialize(accessible, data);
@@ -181,7 +181,7 @@ unity_launcher_accessible_get_n_children(AtkObject* obj)
{
nux::Object* object = NULL;
Launcher* launcher = NULL;
- LauncherModel* launcher_model = NULL;
+ LauncherModel::Ptr launcher_model;
g_return_val_if_fail(UNITY_IS_LAUNCHER_ACCESSIBLE(obj), 0);
@@ -206,7 +206,7 @@ unity_launcher_accessible_ref_child(AtkObject* obj,
gint num = 0;
nux::Object* nux_object = NULL;
Launcher* launcher = NULL;
- LauncherModel* launcher_model = NULL;
+ LauncherModel::Ptr launcher_model;
LauncherModel::iterator it;
nux::Object* child = NULL;
AtkObject* child_accessible = NULL;
@@ -340,7 +340,7 @@ unity_launcher_accessible_is_child_selected(AtkSelection* selection,
Launcher* launcher = NULL;
AbstractLauncherIcon::Ptr icon;
AbstractLauncherIcon::Ptr selected_icon;
- LauncherModel* launcher_model = NULL;
+ LauncherModel::Ptr launcher_model;
LauncherModel::iterator it;
nux::Object* nux_object = NULL;
@@ -426,7 +426,7 @@ update_children_index(UnityLauncherAccessible* self)
gint index = 0;
nux::Object* nux_object = NULL;
Launcher* launcher = NULL;
- LauncherModel* launcher_model = NULL;
+ LauncherModel::Ptr launcher_model;
LauncherModel::iterator it;
nux::Object* child = NULL;
AtkObject* child_accessible = NULL;