summaryrefslogtreecommitdiff
path: root/launcher
diff options
authorSam Spilsbury <sam.spilsbury@canonical.com>2013-07-22 10:12:08 -0700
committerSam Spilsbury <sam.spilsbury@canonical.com>2013-07-22 10:12:08 -0700
commiteaa4e9347d032bc2347a2d228ad85e411735453f (patch)
tree57a6b539dd566a48e1e189f128114ddb67e285da /launcher
parentce2758c838e027da3f13ace73d4e062e2e103337 (diff)
parentd4cd53fdf21ad2066bb9ea4058679ec1969a591b (diff)
Merge lp:unity
(bzr r3347.5.7)
Diffstat (limited to 'launcher')
-rw-r--r--launcher/AbstractLauncherIcon.h6
-rw-r--r--launcher/ApplicationLauncherIcon.cpp306
-rw-r--r--launcher/ApplicationLauncherIcon.h19
-rw-r--r--launcher/EdgeBarrierController.cpp125
-rw-r--r--launcher/EdgeBarrierControllerPrivate.h9
-rw-r--r--launcher/ExpoLauncherIcon.cpp9
-rw-r--r--launcher/ExpoLauncherIcon.h3
-rw-r--r--launcher/Launcher.cpp8
-rw-r--r--launcher/Launcher.h1
-rw-r--r--launcher/LauncherController.cpp4
-rw-r--r--launcher/LauncherControllerPrivate.h4
-rw-r--r--launcher/LauncherDragWindow.cpp3
-rw-r--r--launcher/LauncherDragWindow.h2
-rw-r--r--launcher/LauncherIcon.cpp42
-rw-r--r--launcher/LauncherIcon.h5
-rw-r--r--launcher/LauncherModel.cpp3
-rw-r--r--launcher/PointerBarrier.cpp173
-rw-r--r--launcher/PointerBarrier.h12
-rw-r--r--launcher/QuicklistMenuItem.cpp1
-rw-r--r--launcher/QuicklistMenuItem.h1
-rw-r--r--launcher/SoftwareCenterLauncherIcon.cpp3
-rw-r--r--launcher/SoftwareCenterLauncherIcon.h2
-rw-r--r--launcher/TrashLauncherIcon.cpp3
-rw-r--r--launcher/VolumeLauncherIcon.cpp20
24 files changed, 386 insertions, 378 deletions
diff --git a/launcher/AbstractLauncherIcon.h b/launcher/AbstractLauncherIcon.h
index a186cb231..0166bc52f 100644
--- a/launcher/AbstractLauncherIcon.h
+++ b/launcher/AbstractLauncherIcon.h
@@ -24,6 +24,7 @@
#include <Nux/Nux.h>
#include <NuxCore/Property.h>
#include <NuxCore/Math/MathInc.h>
+#include <UnityCore/ConnectionManager.h>
#include <sigc++/sigc++.h>
#include <libdbusmenu-glib/menuitem.h>
@@ -247,10 +248,7 @@ public:
sigc::signal<void> position_saved;
sigc::signal<void> position_forgot;
- sigc::connection needs_redraw_connection;
- sigc::connection on_icon_added_connection;
- sigc::connection on_icon_removed_connection;
- sigc::connection on_order_changed_connection;
+ connection::Wrapper on_icon_removed_connection;
};
}
diff --git a/launcher/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp
index 6935e0852..0a6ed3761 100644
--- a/launcher/ApplicationLauncherIcon.cpp
+++ b/launcher/ApplicationLauncherIcon.cpp
@@ -53,6 +53,15 @@ const std::string ICON_REMOVE_TIMEOUT = "bamf-icon-remove";
//const std::string ICON_DND_OVER_TIMEOUT = "bamf-icon-dnd-over";
const std::string DEFAULT_ICON = "application-default-icon";
const int MAXIMUM_QUICKLIST_WIDTH = 300;
+
+enum MenuItemType
+{
+ STICK = 0,
+ QUIT,
+ APP_NAME,
+ SEPARATOR,
+ SIZE
+};
}
NUX_IMPLEMENT_OBJECT_TYPE(ApplicationLauncherIcon);
@@ -111,8 +120,6 @@ ApplicationLauncherIcon::~ApplicationLauncherIcon()
app_->sticky = false;
app_->seen = false;
}
-
- DisconnectApplicationSignalsConnections();
}
void ApplicationLauncherIcon::SetApplication(ApplicationPtr const& app)
@@ -121,7 +128,7 @@ void ApplicationLauncherIcon::SetApplication(ApplicationPtr const& app)
return;
app_ = app;
- DisconnectApplicationSignalsConnections();
+ signals_conn_.Clear();
SetupApplicationSignalsConnections();
}
@@ -129,36 +136,38 @@ void ApplicationLauncherIcon::SetupApplicationSignalsConnections()
{
// Lambda functions should be fine here because when the application the icon
// is only ever removed when the application is closed.
- window_opened_connection_ = app_->window_opened.connect([this](ApplicationWindow const&) {
+ signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindow const&) {
EnsureWindowState();
UpdateMenus();
UpdateIconGeometries(GetCenters());
- });
+ }));
- window_closed_connection_ = app_->window_closed.connect(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState));
- window_moved_connection_ = app_->window_moved.connect(sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState)));
+ signals_conn_.Add(app_->window_closed.connect(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState)));
+ signals_conn_.Add(app_->window_moved.connect(sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState))));
- urgent_changed_connection_ = app_->urgent.changed.connect([this](bool const& urgent) {
+ signals_conn_.Add(app_->urgent.changed.connect([this](bool const& urgent) {
LOG_DEBUG(logger) << tooltip_text() << " urgent now " << (urgent ? "true" : "false");
SetQuirk(Quirk::URGENT, urgent);
- });
+ }));
- active_changed_connection_ = app_->active.changed.connect([this](bool const& active) {
+ signals_conn_.Add(app_->active.changed.connect([this](bool const& active) {
LOG_DEBUG(logger) << tooltip_text() << " active now " << (active ? "true" : "false");
SetQuirk(Quirk::ACTIVE, active);
- });
+ }));
- title_changed_connection_ = app_->title.changed.connect([this](std::string const& name) {
+ signals_conn_.Add(app_->title.changed.connect([this](std::string const& name) {
LOG_DEBUG(logger) << tooltip_text() << " name now " << name;
+ if (_menu_items.size() == MenuItemType::SIZE)
+ _menu_items[MenuItemType::APP_NAME] = nullptr;
tooltip_text = name;
- });
+ }));
- icon_changed_connection_ = app_->icon.changed.connect([this](std::string const& icon) {
+ signals_conn_.Add(app_->icon.changed.connect([this](std::string const& icon) {
LOG_DEBUG(logger) << tooltip_text() << " icon now " << icon;
icon_name = (icon.empty() ? DEFAULT_ICON : icon);
- });
+ }));
- running_changed_connection_ = app_->running.changed.connect([this](bool const& running) {
+ signals_conn_.Add(app_->running.changed.connect([this](bool const& running) {
LOG_DEBUG(logger) << tooltip_text() << " running now " << (running ? "true" : "false");
SetQuirk(Quirk::RUNNING, running);
@@ -169,14 +178,14 @@ void ApplicationLauncherIcon::SetupApplicationSignalsConnections()
EnsureWindowState();
UpdateIconGeometries(GetCenters());
}
- });
+ }));
- visible_changed_connection_ = app_->visible.changed.connect([this](bool const& visible) {
+ signals_conn_.Add(app_->visible.changed.connect([this](bool const& visible) {
if (!IsSticky())
SetQuirk(Quirk::VISIBLE, visible);
- });
+ }));
- closed_changed_connection_ = app_->closed.connect([this]() {
+ signals_conn_.Add(app_->closed.connect([this]() {
if (!IsSticky())
{
SetQuirk(Quirk::VISIBLE, false);
@@ -192,21 +201,7 @@ void ApplicationLauncherIcon::SetupApplicationSignalsConnections()
return false;
}, ICON_REMOVE_TIMEOUT);
}
- });
-}
-
-void ApplicationLauncherIcon::DisconnectApplicationSignalsConnections()
-{
- window_opened_connection_.disconnect();
- window_closed_connection_.disconnect();
- window_moved_connection_.disconnect();
- urgent_changed_connection_.disconnect();
- active_changed_connection_.disconnect();
- running_changed_connection_.disconnect();
- visible_changed_connection_.disconnect();
- title_changed_connection_.disconnect();
- icon_changed_connection_.disconnect();
- closed_changed_connection_.disconnect();
+ }));
}
bool ApplicationLauncherIcon::GetQuirk(AbstractLauncherIcon::Quirk quirk) const
@@ -806,20 +801,6 @@ void ApplicationLauncherIcon::EnsureMenuItemsWindowsReady()
void ApplicationLauncherIcon::UpdateMenus()
{
- // add dynamic quicklist
- if (_menuclient_dynamic_quicklist && _menuclient_dynamic_quicklist.IsType(DBUSMENU_TYPE_CLIENT))
- {
- if (_menu_clients["dynamicquicklist"] != _menuclient_dynamic_quicklist)
- {
- _menu_clients["dynamicquicklist"] = _menuclient_dynamic_quicklist;
- }
- }
- else if (_menu_clients["dynamicquicklist"])
- {
- _menu_clients.erase("dynamicquicklist");
- _menuclient_dynamic_quicklist = nullptr;
- }
-
// make a client for desktop file actions
if (!_menu_desktop_shortcuts.IsType(DBUSMENU_TYPE_MENUITEM))
{
@@ -874,138 +855,112 @@ void ApplicationLauncherIcon::ToggleSticky()
}
}
-void ApplicationLauncherIcon::EnsureMenuItemsReady()
+void ApplicationLauncherIcon::EnsureMenuItemsDefaultReady()
{
- glib::Object<DbusmenuMenuitem> menu_item;
-
- /* Pin */
- if (_menu_items.find("Pin") == _menu_items.end())
- {
- menu_item = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
- dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
+ if (_menu_items.size() == MenuItemType::SIZE)
+ return;
- _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- [this] (DbusmenuMenuitem*, unsigned) {
- ToggleSticky();
- });
-
- _menu_items["Pin"] = menu_item;
- }
+ _menu_items.resize(MenuItemType::SIZE);
+ /* (Un)Stick to Launcher */
+ glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new());
const char* label = !IsSticky() ? _("Lock to Launcher") : _("Unlock from Launcher");
+ dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, label);
+ dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
+ dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
- dbusmenu_menuitem_property_set(_menu_items["Pin"], DBUSMENU_MENUITEM_PROP_LABEL, label);
+ _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ [this] (DbusmenuMenuitem*, unsigned) {
+ ToggleSticky();
+ });
+ _menu_items[MenuItemType::STICK] = menu_item;
/* Quit */
- if (_menu_items.find("Quit") == _menu_items.end())
- {
- menu_item = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Quit"));
- dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
- dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
+ menu_item = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Quit"));
+ dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
+ dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
+
+ _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ [this] (DbusmenuMenuitem*, unsigned) {
+ Quit();
+ });
- _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- [this] (DbusmenuMenuitem*, unsigned) {
- Quit();
- });
+ _menu_items[MenuItemType::QUIT] = menu_item;
- _menu_items["Quit"] = menu_item;
- }
+ /* Separator */
+ menu_item = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
+ _menu_items[MenuItemType::SEPARATOR] = menu_item;
}
AbstractLauncherIcon::MenuItemsVector ApplicationLauncherIcon::GetMenus()
{
MenuItemsVector result;
- bool first_separator_needed = false;
+ glib::Object<DbusmenuMenuitem> quit_item;
+ bool separator_needed = false;
- // FIXME for O: hack around the wrong abstraction
+ EnsureMenuItemsDefaultReady();
UpdateMenus();
- for (auto const& cli : _menu_clients)
+ for (auto const& menus : {GetRemoteMenus(), _menu_desktop_shortcuts})
{
- GList* child = nullptr;
- auto const& client = cli.second;
-
- if (!client || !client.IsType(DBUSMENU_TYPE_CLIENT))
- continue;
-
- DbusmenuMenuitem* root = dbusmenu_client_get_root(client);
-
- if (!root || !dbusmenu_menuitem_property_get_bool(root, DBUSMENU_MENUITEM_PROP_VISIBLE))
+ if (!menus.IsType(DBUSMENU_TYPE_MENUITEM))
continue;
- for (child = dbusmenu_menuitem_get_children(root); child; child = child->next)
+ for (GList* l = dbusmenu_menuitem_get_children(menus); l; l = l->next)
{
- glib::Object<DbusmenuMenuitem> item(static_cast<DbusmenuMenuitem*>(child->data), glib::AddRef());
+ glib::Object<DbusmenuMenuitem> item(static_cast<DbusmenuMenuitem*>(l->data), glib::AddRef());
- if (!item || !item.IsType(DBUSMENU_TYPE_MENUITEM))
+ if (!item.IsType(DBUSMENU_TYPE_MENUITEM))
continue;
if (dbusmenu_menuitem_property_get_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE))
{
- first_separator_needed = true;
dbusmenu_menuitem_property_set_bool(item, QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, FALSE);
- result.push_back(item);
- }
- }
- }
-
- // FIXME: this should totally be added as a _menu_client
- if (DBUSMENU_IS_MENUITEM(_menu_desktop_shortcuts.RawPtr()))
- {
- GList* child = nullptr;
+ const gchar* type = dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_TYPE);
- for (child = dbusmenu_menuitem_get_children(_menu_desktop_shortcuts); child; child = child->next)
- {
- glib::Object<DbusmenuMenuitem> item(static_cast<DbusmenuMenuitem*>(child->data), glib::AddRef());
+ if (!type) // (g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0)
+ {
+ if (dbusmenu_menuitem_property_get_bool(item, QuicklistMenuItem::QUIT_ACTION_PROPERTY))
+ {
+ quit_item = item;
+ continue;
+ }
- if (!item || !item.IsType(DBUSMENU_TYPE_MENUITEM))
- continue;
+ const gchar* l = dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_LABEL);
+ auto const& label = glib::gchar_to_string(l);
- first_separator_needed = true;
+ if (label == _("Quit") || label == "Quit" ||
+ label == _("Exit") || label == "Exit" ||
+ label == _("Close") || label == "Close")
+ {
+ quit_item = item;
+ continue;
+ }
+ }
- result.push_back(item);
+ separator_needed = true;
+ result.push_back(item);
+ }
}
}
- glib::Object<DbusmenuMenuitem> item;
-
- if (first_separator_needed)
+ if (separator_needed)
{
- auto first_sep = _menu_items_extra.find("FirstSeparator");
-
- if (first_sep != _menu_items_extra.end())
- {
- item = first_sep->second;
- }
- else
- {
- item = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(item,
- DBUSMENU_MENUITEM_PROP_TYPE,
- DBUSMENU_CLIENT_TYPES_SEPARATOR);
- _menu_items_extra["FirstSeparator"] = item;
- }
- result.push_back(item);
+ result.push_back(_menu_items[MenuItemType::SEPARATOR]);
+ separator_needed = false;
}
- auto app_name_item = _menu_items_extra.find("AppName");
- if (app_name_item != _menu_items_extra.end())
- {
- item = app_name_item->second;
- }
- else
+ if (!_menu_items[MenuItemType::APP_NAME])
{
glib::String app_name(g_markup_escape_text(app_->title().c_str(), -1));
std::string bold_app_name("<b>"+app_name.Str()+"</b>");
- item = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- bold_app_name.c_str());
+ glib::Object<DbusmenuMenuitem> item(dbusmenu_menuitem_new());
+ dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, bold_app_name.c_str());
dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
dbusmenu_menuitem_property_set_bool(item, QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, TRUE);
@@ -1017,24 +972,11 @@ AbstractLauncherIcon::MenuItemsVector ApplicationLauncherIcon::GetMenus()
});
});
- _menu_items_extra["AppName"] = glib::Object<DbusmenuMenuitem>(item);
+ _menu_items[MenuItemType::APP_NAME] = item;
}
- result.push_back(item);
- auto second_sep = _menu_items_extra.find("SecondSeparator");
- if (second_sep != _menu_items_extra.end())
- {
- item = second_sep->second;
- }
- else
- {
- item = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(item,
- DBUSMENU_MENUITEM_PROP_TYPE,
- DBUSMENU_CLIENT_TYPES_SEPARATOR);
- _menu_items_extra["SecondSeparator"] = glib::Object<DbusmenuMenuitem>(item);
- }
- result.push_back(item);
+ result.push_back(_menu_items[MenuItemType::APP_NAME]);
+ result.push_back(_menu_items[MenuItemType::SEPARATOR]);
EnsureMenuItemsWindowsReady();
@@ -1043,49 +985,20 @@ AbstractLauncherIcon::MenuItemsVector ApplicationLauncherIcon::GetMenus()
for (auto const& it : _menu_items_windows)
result.push_back(it);
- auto third_sep = _menu_items_extra.find("ThirdSeparator");
- if (third_sep != _menu_items_extra.end())
- {
- item = third_sep->second;
- }
- else
- {
- item = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
- _menu_items_extra["ThirdSeparator"] = glib::Object<DbusmenuMenuitem>(item);
- }
-
- result.push_back(item);
+ result.push_back(_menu_items[MenuItemType::SEPARATOR]);
}
- EnsureMenuItemsReady();
+ const char* label = !IsSticky() ? _("Lock to Launcher") : _("Unlock from Launcher");
+ dbusmenu_menuitem_property_set(_menu_items[MenuItemType::STICK], DBUSMENU_MENUITEM_PROP_LABEL, label);
+ result.push_back(_menu_items[MenuItemType::STICK]);
- for (auto it : _menu_items)
+ if (IsRunning())
{
- if (!IsRunning() && it.first == "Quit")
- continue;
-
- bool exists = false;
- std::string label_default(dbusmenu_menuitem_property_get(it.second, DBUSMENU_MENUITEM_PROP_LABEL));
-
- for (auto menu_item : result)
- {
- const gchar* type = dbusmenu_menuitem_property_get(menu_item, DBUSMENU_MENUITEM_PROP_TYPE);
-
- if (!type)//(g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0)
- {
- const gchar* label = dbusmenu_menuitem_property_get(menu_item, DBUSMENU_MENUITEM_PROP_LABEL);
+ if (!quit_item)
+ quit_item = _menu_items[MenuItemType::QUIT];
- if (label && std::string(label) == label_default)
- {
- exists = true;
- break;
- }
- }
- }
-
- if (!exists)
- result.push_back(it.second);
+ dbusmenu_menuitem_property_set(quit_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Quit"));
+ result.push_back(quit_item);
}
return result;
@@ -1093,16 +1006,17 @@ AbstractLauncherIcon::MenuItemsVector ApplicationLauncherIcon::GetMenus()
void ApplicationLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> center)
{
+ if (app_->type() == "webapp")
+ return;
+
nux::Geometry geo;
+
+ // TODO: replace 48 with icon_size;
geo.width = 48;
geo.height = 48;
for (auto& window : app_->GetWindows())
{
- // We don't deal with tabs.
- if (window->type() == "tab")
- continue;
-
Window xid = window->window_id();
int monitor = window->monitor();
monitor = std::max<int>(0, std::min<int>(center.size() - 1, monitor));
diff --git a/launcher/ApplicationLauncherIcon.h b/launcher/ApplicationLauncherIcon.h
index 36e3706f1..eb788ffd7 100644
--- a/launcher/ApplicationLauncherIcon.h
+++ b/launcher/ApplicationLauncherIcon.h
@@ -23,6 +23,7 @@
#include <UnityCore/GLibSignal.h>
#include <UnityCore/GLibWrapper.h>
+#include <UnityCore/ConnectionManager.h>
#include <libindicator/indicator-desktop-shortcuts.h>
@@ -111,10 +112,9 @@ private:
};
void SetupApplicationSignalsConnections();
- void DisconnectApplicationSignalsConnections();
void EnsureWindowState();
void EnsureMenuItemsWindowsReady();
- void EnsureMenuItemsReady();
+ void EnsureMenuItemsDefaultReady();
void UpdateBackgroundColor();
void UpdateMenus();
void UpdateDesktopQuickList();
@@ -138,9 +138,7 @@ private:
ScrollDirection _last_scroll_direction;
unsigned int _progressive_scroll;
std::set<std::string> _supported_types;
- std::map<std::string, glib::Object<DbusmenuClient>> _menu_clients;
- std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items;
- std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items_extra;
+ std::vector<glib::Object<DbusmenuMenuitem>> _menu_items;
std::vector<glib::Object<DbusmenuMenuitem>> _menu_items_windows;
glib::Object<IndicatorDesktopShortcuts> _desktop_shortcuts;
glib::Object<DbusmenuMenuitem> _menu_desktop_shortcuts;
@@ -150,16 +148,7 @@ private:
bool use_custom_bg_color_;
nux::Color bg_color_;
- sigc::connection window_opened_connection_;
- sigc::connection window_closed_connection_;
- sigc::connection window_moved_connection_;
- sigc::connection icon_changed_connection_;
- sigc::connection title_changed_connection_;
- sigc::connection urgent_changed_connection_;
- sigc::connection active_changed_connection_;
- sigc::connection running_changed_connection_;
- sigc::connection visible_changed_connection_;
- sigc::connection closed_changed_connection_;
+ connection::Manager signals_conn_;
};
}
diff --git a/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp
index e1f320b6d..c50f8bc9b 100644
--- a/launcher/EdgeBarrierController.cpp
+++ b/launcher/EdgeBarrierController.cpp
@@ -21,6 +21,7 @@
#include "EdgeBarrierController.h"
#include "EdgeBarrierControllerPrivate.h"
#include "Decaymulator.h"
+#include <NuxCore/Logger.h>
#include "unity-shared/UScreen.h"
#include "UnityCore/GLibSource.h"
@@ -32,11 +33,50 @@ namespace ui
namespace
{
int const Y_BREAK_BUFFER = 20;
+ int const MAJOR = 2;
+ int const MINOR = 3;
}
+DECLARE_LOGGER(logger, "unity.edge_barrier_controller");
+
+int GetXI2OpCode()
+{
+ Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
+
+ int opcode, event_base, error_base;
+ if (!XQueryExtension(dpy, "XFIXES",
+ &opcode,
+ &event_base,
+ &error_base))
+ {
+ LOG_ERROR(logger) << "Missing XFixes";
+ return -1;
+ }
+
+ if (!XQueryExtension (dpy, "XInputExtension",
+ &opcode,
+ &event_base,
+ &error_base))
+ {
+ LOG_ERROR(logger) << "Missing XInput";
+ return -1;
+ }
+
+ int maj = MAJOR;
+ int min = MINOR;
+
+ if (XIQueryVersion(dpy, &maj, &min) == BadRequest)
+ {
+ LOG_ERROR(logger) << "Need XInput version 2.3";
+ return -1;
+ }
+
+ return opcode;
+}
EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent)
- : edge_overcome_pressure_(0)
+ : xi2_opcode_(-1)
+ , edge_overcome_pressure_(0)
, parent_(parent)
{
UScreen *uscreen = UScreen::GetDefault();
@@ -68,6 +108,13 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent)
});
SetupBarriers(UScreen::GetDefault()->GetMonitors());
});
+
+ xi2_opcode_ = GetXI2OpCode();
+}
+
+EdgeBarrierController::Impl::~Impl()
+{
+ nux::GetGraphicsDisplay()->RemoveEventFilter(this);
}
void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> const& layout)
@@ -86,6 +133,18 @@ void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> c
}
}
+void SetupXI2Events()
+{
+ Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
+
+ unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
+ XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
+
+ XISetMask(mask.mask, XI_BarrierHit);
+ XISetMask(mask.mask, XI_BarrierLeave);
+ XISelectEvents (dpy, DefaultRootWindow(dpy), &mask, 1);
+}
+
void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const& layout)
{
bool edge_resist = parent_->sticky_edges();
@@ -112,6 +171,9 @@ void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const
barrier->ConstructBarrier();
}
+ SetupXI2Events();
+ AddEventFilter();
+
float decay_responsiveness_mult = ((parent_->options()->edge_responsiveness() - 1) * .3f) + 1;
decaymulator_.rate_of_decay = parent_->options()->edge_decay_rate() * decay_responsiveness_mult;
@@ -119,6 +181,67 @@ void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const
edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult;
}
+void EdgeBarrierController::Impl::AddEventFilter()
+{
+ // Remove an old one, if it exists
+ nux::GetGraphicsDisplay()->RemoveEventFilter(this);
+
+ nux::GraphicsDisplay::EventFilterArg event_filter;
+ event_filter.filter = &HandleEventCB;
+ event_filter.data = this;
+
+ nux::GetGraphicsDisplay()->AddEventFilter(event_filter);
+}
+
+bool EdgeBarrierController::Impl::HandleEvent(XEvent xevent)
+{
+ Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
+ XGenericEventCookie *cookie = &xevent.xcookie;
+ bool ret = false;
+
+ switch (cookie->evtype)
+ {
+ case (XI_BarrierHit):
+ {
+ if (XGetEventData(dpy, cookie))
+ {
+ XIBarrierEvent* barrier_event = (XIBarrierEvent*)cookie->data;
+ PointerBarrierWrapper::Ptr wrapper = FindBarrierEventOwner(barrier_event);
+
+ if (wrapper)
+ ret = wrapper->HandleBarrierEvent(barrier_event);
+ }
+
+ XFreeEventData(dpy, cookie);
+ break;
+ }
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+bool EdgeBarrierController::Impl::HandleEventCB(XEvent xevent, void* data)
+{
+ auto edge_barrier_controller = static_cast<EdgeBarrierController::Impl*>(data);
+ int const xi2_opcode = edge_barrier_controller->xi2_opcode_;
+
+ if (xevent.type != GenericEvent || xevent.xcookie.extension != xi2_opcode)
+ return false;
+
+ return edge_barrier_controller->HandleEvent(xevent);
+}
+
+PointerBarrierWrapper::Ptr EdgeBarrierController::Impl::FindBarrierEventOwner(XIBarrierEvent* barrier_event)
+{
+ for (auto barrier : barriers_)
+ if (barrier->OwnsBarrierEvent(barrier_event->barrier))
+ return barrier;
+
+ return nullptr;
+}
+
void EdgeBarrierController::Impl::BarrierReset()
{
decaymulator_.value = 0;
diff --git a/launcher/EdgeBarrierControllerPrivate.h b/launcher/EdgeBarrierControllerPrivate.h
index eb4199d19..063c193a8 100644
--- a/launcher/EdgeBarrierControllerPrivate.h
+++ b/launcher/EdgeBarrierControllerPrivate.h
@@ -33,6 +33,7 @@ namespace ui
struct EdgeBarrierController::Impl
{
Impl(EdgeBarrierController *parent);
+ ~Impl();
void ResizeBarrierList(std::vector<nux::Geometry> const& layout);
void SetupBarriers(std::vector<nux::Geometry> const& layout);
@@ -44,10 +45,18 @@ struct EdgeBarrierController::Impl
bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event);
+ void AddEventFilter();
+
+ PointerBarrierWrapper::Ptr FindBarrierEventOwner(XIBarrierEvent* barrier_event);
+
+ static bool HandleEventCB(XEvent event, void* data);
+ bool HandleEvent(XEvent event);
+
std::vector<PointerBarrierWrapper::Ptr> barriers_;
std::vector<EdgeBarrierSubscriber*> subscribers_;
Decaymulator decaymulator_;
glib::Source::UniquePtr release_timeout_;
+ int xi2_opcode_;
float edge_overcome_pressure_;
EdgeBarrierController* parent_;
};
diff --git a/launcher/ExpoLauncherIcon.cpp b/launcher/ExpoLauncherIcon.cpp
index 8e2adc3a8..d7b5dfd31 100644
--- a/launcher/ExpoLauncherIcon.cpp
+++ b/launcher/ExpoLauncherIcon.cpp
@@ -49,19 +49,18 @@ void ExpoLauncherIcon::OnViewportLayoutChanged(int hsize, int vsize)
if (hsize != 2 || vsize != 2)
{
icon_name = "workspace-switcher-top-left";
- screen_viewport_switch_ended_connection_.disconnect();
- terminate_expo_connection_.disconnect();
+ viewport_changes_connections_.Clear();
}
else
{
UpdateIcon();
- if (!terminate_expo_connection_)
+ if (viewport_changes_connections_.Empty())
{
auto& wm = WindowManager::Default();
auto cb = sigc::mem_fun(this, &ExpoLauncherIcon::UpdateIcon);
- screen_viewport_switch_ended_connection_ = wm.screen_viewport_switch_ended.connect(cb);
- terminate_expo_connection_ = wm.terminate_expo.connect(cb);
+ viewport_changes_connections_.Add(wm.screen_viewport_switch_ended.connect(cb));
+ viewport_changes_connections_.Add(wm.terminate_expo.connect(cb));
}
}
}
diff --git a/launcher/ExpoLauncherIcon.h b/launcher/ExpoLauncherIcon.h
index f660cdcaa..6ca563c34 100644
--- a/launcher/ExpoLauncherIcon.h
+++ b/launcher/ExpoLauncherIcon.h
@@ -43,8 +43,7 @@ private:
void OnViewportLayoutChanged(int hsize, int vsize);
void UpdateIcon();
- sigc::connection screen_viewport_switch_ended_connection_;
- sigc::connection terminate_expo_connection_;
+ connection::Manager viewport_changes_connections_;
};
}
diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp
index 9ed8e41da..f96c5e5bf 100644
--- a/launcher/Launcher.cpp
+++ b/launcher/Launcher.cpp
@@ -157,6 +157,7 @@ Launcher::Launcher(MockableBaseWindow* parent,
, _drag_out_delta_x(0.0f)
, _drag_gesture_ongoing(false)
, _last_reveal_progress(0.0f)
+ , _drag_action(nux::DNDACTION_NONE)
, _selection_atom(0)
, icon_renderer(std::make_shared<ui::IconRenderer>())
{
@@ -1740,9 +1741,6 @@ void Launcher::OnIconAdded(AbstractLauncherIcon::Ptr const& icon)
void Launcher::OnIconRemoved(AbstractLauncherIcon::Ptr const& icon)
{
- if (icon->needs_redraw_connection.connected())
- icon->needs_redraw_connection.disconnect();
-
SetIconUnderMouse(AbstractLauncherIcon::Ptr());
if (icon == _icon_mouse_down)
_icon_mouse_down = nullptr;
@@ -2147,9 +2145,7 @@ void Launcher::EndIconDrag()
_model->Save();
}
- if (_drag_window->on_anim_completed.connected())
- _drag_window->on_anim_completed.disconnect();
- _drag_window->on_anim_completed = _drag_window->anim_completed.connect(sigc::mem_fun(this, &Launcher::OnDragWindowAnimCompleted));
+ _drag_window->on_anim_completed_conn_ = _drag_window->anim_completed.connect(sigc::mem_fun(this, &Launcher::OnDragWindowAnimCompleted));
auto const& icon_center = _drag_icon->GetCenter(monitor);
_drag_window->SetAnimationTarget(icon_center.x, icon_center.y),
diff --git a/launcher/Launcher.h b/launcher/Launcher.h
index 1b8626e80..0faeb4169 100644
--- a/launcher/Launcher.h
+++ b/launcher/Launcher.h
@@ -140,7 +140,6 @@ public:
sigc::signal<void> selection_change;
sigc::signal<void> hidden_changed;
sigc::signal<void> sc_launcher_icon_animation;
- sigc::connection sc_launcher_icon_animation_connection;
virtual bool InspectKeyEvent(unsigned int eventType,
unsigned int keysym,
diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp
index a9313fa6b..ae90a5ddf 100644
--- a/launcher/LauncherController.cpp
+++ b/launcher/LauncherController.cpp
@@ -1369,8 +1369,8 @@ void Controller::KeyNavTerminate(bool activate)
if (pimpl->launcher_grabbed)
{
pimpl->keyboard_launcher_->UnGrabKeyboard();
- pimpl->launcher_key_press_connection_.disconnect();
- pimpl->launcher_event_outside_connection_.disconnect();
+ pimpl->launcher_key_press_connection_->disconnect();
+ pimpl->launcher_event_outside_connection_->disconnect();
pimpl->launcher_grabbed = false;
pimpl->ubus.SendMessage(UBUS_LAUNCHER_END_KEY_NAV,
g_variant_new_boolean(pimpl->keynav_restore_window_));
diff --git a/launcher/LauncherControllerPrivate.h b/launcher/LauncherControllerPrivate.h
index 8458efbdd..f3c92225d 100644
--- a/launcher/LauncherControllerPrivate.h
+++ b/launcher/LauncherControllerPrivate.h
@@ -150,8 +150,8 @@ public:
glib::SourceManager sources_;
UBusManager ubus;
- sigc::connection launcher_key_press_connection_;
- sigc::connection launcher_event_outside_connection_;
+ connection::Wrapper launcher_key_press_connection_;
+ connection::Wrapper launcher_event_outside_connection_;
};
} // launcher namespace
diff --git a/launcher/LauncherDragWindow.cpp b/launcher/LauncherDragWindow.cpp
index a3569f60b..d87f1ec1d 100644
--- a/launcher/LauncherDragWindow.cpp
+++ b/launcher/LauncherDragWindow.cpp
@@ -64,9 +64,6 @@ LauncherDragWindow::LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> t
LauncherDragWindow::~LauncherDragWindow()
{
- if (on_anim_completed.connected())
- on_anim_completed.disconnect();
-
UnGrabKeyboard();
}
diff --git a/launcher/LauncherDragWindow.h b/launcher/LauncherDragWindow.h
index 694704dc6..2cb660575 100644
--- a/launcher/LauncherDragWindow.h
+++ b/launcher/LauncherDragWindow.h
@@ -53,7 +53,7 @@ public:
sigc::signal<void> anim_completed;
sigc::signal<void> drag_cancel_request;
- sigc::connection on_anim_completed;
+ connection::Wrapper on_anim_completed_conn_;
protected:
bool InspectKeyEvent(unsigned int event_type, unsigned int keysym, const char* character);
diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp
index 97de02d84..f7403c173 100644
--- a/launcher/LauncherIcon.cpp
+++ b/launcher/LauncherIcon.cpp
@@ -134,24 +134,6 @@ LauncherIcon::LauncherIcon(IconType type)
LauncherIcon::~LauncherIcon()
{
SetQuirk(Quirk::URGENT, false);
-
- // clean up the whole signal-callback mess
- if (needs_redraw_connection.connected())
- needs_redraw_connection.disconnect();
-
- if (on_icon_added_connection.connected())
- on_icon_added_connection.disconnect();
-
- if (on_icon_removed_connection.connected())
- on_icon_removed_connection.disconnect();
-
- if (on_order_changed_connection.connected())
- on_order_changed_connection.disconnect();
-
- if (_unity_theme)
- {
- _unity_theme = NULL;
- }
}
void LauncherIcon::LoadTooltip()
@@ -349,9 +331,9 @@ GtkIconTheme* LauncherIcon::GetUnityTheme()
{
// The theme object is invalid as soon as you add a new icon to change the theme.
// invalidate the cache then and rebuild the theme the first time after a icon theme update.
- if (!GTK_IS_ICON_THEME(_unity_theme.RawPtr()))
+ if (!_unity_theme.IsType(GTK_TYPE_ICON_THEME))
{
- _unity_theme = gtk_icon_theme_new();
+ _unity_theme = gtk_icon_theme_new();
gtk_icon_theme_set_custom_theme(_unity_theme, UNITY_THEME_NAME.c_str());
}
return _unity_theme;
@@ -1113,7 +1095,7 @@ LauncherIcon::RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote)
if (_remote_urgent)
SetQuirk(Quirk::URGENT, false);
- _menuclient_dynamic_quicklist = nullptr;
+ _remote_menus = nullptr;
}
void
@@ -1160,7 +1142,7 @@ LauncherIcon::OnRemoteProgressChanged(LauncherEntryRemote* remote)
void
LauncherIcon::OnRemoteQuicklistChanged(LauncherEntryRemote* remote)
{
- _menuclient_dynamic_quicklist = remote->Quicklist();
+ _remote_menus = remote->Quicklist();
}
void
@@ -1194,6 +1176,22 @@ LauncherIcon::OnRemoteProgressVisibleChanged(LauncherEntryRemote* remote)
SetProgress(remote->Progress());
}
+glib::Object<DbusmenuMenuitem> LauncherIcon::GetRemoteMenus() const
+{
+ if (!_remote_menus.IsType(DBUSMENU_TYPE_CLIENT))
+ return glib::Object<DbusmenuMenuitem>();
+
+ glib::Object<DbusmenuMenuitem> root(dbusmenu_client_get_root(_remote_menus), glib::AddRef());
+
+ if (!root.IsType(DBUSMENU_TYPE_MENUITEM) ||
+ !dbusmenu_menuitem_property_get_bool(root, DBUSMENU_MENUITEM_PROP_VISIBLE))
+ {
+ return glib::Object<DbusmenuMenuitem>();
+ }
+
+ return root;
+}
+
void LauncherIcon::EmitNeedsRedraw()
{
if (OwnsTheReference() && GetReferenceCount() > 0)
diff --git a/launcher/LauncherIcon.h b/launcher/LauncherIcon.h
index 2a12cb207..477f7db2a 100644
--- a/launcher/LauncherIcon.h
+++ b/launcher/LauncherIcon.h
@@ -198,6 +198,8 @@ public:
virtual void UnStick();
+ virtual glib::Object<DbusmenuMenuitem> GetRemoteMenus() const;
+
void PerformScroll(ScrollDirection direction, Time timestamp) override;
protected:
@@ -291,8 +293,6 @@ protected:
// This looks like a case for boost::logical::tribool
static int _current_theme_is_mono;
- glib::Object<DbusmenuClient> _menuclient_dynamic_quicklist;
-
private:
IconType _icon_type;
@@ -339,6 +339,7 @@ private:
bool _allow_quicklist_to_show;
std::list<LauncherEntryRemote::Ptr> _entry_list;
+ glib::Object<DbusmenuClient> _remote_menus;
nux::animation::AnimateValue<double> _tooltip_fade_animator;
diff --git a/launcher/LauncherModel.cpp b/launcher/LauncherModel.cpp
index a9e694924..2a6e2b577 100644
--- a/launcher/LauncherModel.cpp
+++ b/launcher/LauncherModel.cpp
@@ -116,9 +116,6 @@ void LauncherModel::AddIcon(AbstractLauncherIcon::Ptr const& icon)
Sort();
icon_added.emit(icon);
-
- if (icon->on_icon_removed_connection.connected())
- icon->on_icon_removed_connection.disconnect();
icon->on_icon_removed_connection = icon->remove.connect(sigc::mem_fun(this, &LauncherModel::OnIconRemove));
}
diff --git a/launcher/PointerBarrier.cpp b/launcher/PointerBarrier.cpp
index 5d513c5b3..a72b78d3d 100644
--- a/launcher/PointerBarrier.cpp
+++ b/launcher/PointerBarrier.cpp
@@ -13,12 +13,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* Authored by: Jason Smith <jason.smith@canonical.com>
+* Brandon Schaefer <brandon.schaefer@canonical.com>
+*
*/
#include <unistd.h>
#include <stdlib.h>
-#include <stdio.h>
-#include <X11/extensions/Xfixes.h>
#include "PointerBarrier.h"
@@ -27,14 +29,6 @@ namespace unity
namespace ui
{
-namespace local
-{
-namespace
-{
- bool is_selected_for = false;
-}
-}
-
PointerBarrierWrapper::PointerBarrierWrapper()
: active(false)
, released(false)
@@ -42,10 +36,11 @@ PointerBarrierWrapper::PointerBarrierWrapper()
, smoothing(75)
, max_velocity_multiplier(1.0f)
, direction(BOTH)
- , event_base_(0)
+ , xi2_opcode_(0)
, last_event_(0)
+ , current_device_(0)
, first_event_(false)
- , barrier(0)
+ , barrier_(0)
, smoothing_count_(0)
, smoothing_accum_(0)
{}
@@ -62,34 +57,14 @@ void PointerBarrierWrapper::ConstructBarrier()
Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
- int error_base;
- XFixesQueryExtension(dpy, &event_base_, &error_base);
-
- int maj,min;
- XFixesQueryVersion(dpy, &maj, &min);
-
- barrier = XFixesCreatePointerBarrierVelocity(dpy,
- DefaultRootWindow(dpy),
- x1, y1,
- x2, y2,
- static_cast<int>(direction),
- threshold,
- 0,
- NULL);
-
- if (!local::is_selected_for)
- {
- XFixesSelectBarrierInput(dpy, DefaultRootWindow(dpy), 0xdeadbeef);
- local::is_selected_for = true;
- }
+ barrier_ = XFixesCreatePointerBarrier(dpy,
+ DefaultRootWindow(dpy),
+ x1, y1,
+ x2, y2,
+ static_cast<int>(direction),
+ 0, NULL);
active = true;
-
- nux::GraphicsDisplay::EventFilterArg event_filter;
- event_filter.filter = &PointerBarrierWrapper::HandleEventWrapper;
- event_filter.data = this;
-
- nux::GetGraphicsDisplay()->AddEventFilter(event_filter);
}
void PointerBarrierWrapper::DestroyBarrier()
@@ -100,14 +75,13 @@ void PointerBarrierWrapper::DestroyBarrier()
active = false;
Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
- XFixesDestroyPointerBarrier(dpy, barrier);
-
- nux::GetGraphicsDisplay()->RemoveEventFilter(this);
+ XFixesDestroyPointerBarrier(dpy, barrier_);
}
void PointerBarrierWrapper::ReleaseBarrier(int event_id)
{
- XFixesBarrierReleasePointer(nux::GetGraphicsDisplay()->GetX11Display(), barrier, event_id);
+ Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
+ XIBarrierReleasePointer(dpy, current_device_, barrier_, event_id);
}
void PointerBarrierWrapper::EmitCurrentData(int event_id, int x, int y)
@@ -134,63 +108,80 @@ bool PointerBarrierWrapper::IsFirstEvent() const
return first_event_;
}
-bool PointerBarrierWrapper::HandleEvent(XEvent xevent)
+int GetEventVelocity(XIBarrierEvent* event)
+{
+ double dx, dy;
+ double speed;
+ unsigned int millis;
+
+ dx = event->dx;
+ dy = event->dy;
+
+ millis = event->dtime;
+
+ // Sometimes dtime is 0, if so we don't want to divide by zero!
+ if (!millis)
+ return 1;
+
+ speed = sqrt(dx * dx + dy * dy) / millis * 1000;
+
+ return speed;
+}
+
+bool PointerBarrierWrapper::OwnsBarrierEvent(PointerBarrier const barrier) const
+{
+ return barrier_ == barrier;
+}
+
+bool PointerBarrierWrapper::HandleBarrierEvent(XIBarrierEvent* barrier_event)
{
- if (xevent.type - event_base_ == XFixesBarrierNotify)
+ int velocity = GetEventVelocity(barrier_event);
+ smoothing_accum_ += velocity;
+ smoothing_count_++;
+
+ current_device_ = barrier_event->deviceid;
+
+ if (velocity > threshold)
+ {
+ smoothing_timeout_.reset();
+ ReleaseBarrier(barrier_event->eventid);
+ }
+ else if (released)
{
- auto notify_event = reinterpret_cast<XFixesBarrierNotifyEvent*>(&xevent);
+ /* If the barrier is released, just emit the current event without
+ * waiting, so there won't be any delay on releasing the barrier. */
+ smoothing_timeout_.reset();
- if (notify_event->barrier == barrier && notify_event->subtype == XFixesBarrierHitNotify)
+ SendBarrierEvent(barrier_event->root_x, barrier_event->root_y,
+ velocity, barrier_event->eventid);
+ }
+ else if (!smoothing_timeout_)
+ {
+ int x = barrier_event->root_x;
+ int y = barrier_event->root_y;
+ int event = barrier_event->eventid;
+
+ // If we are a new event, don't delay sending the first event
+ if (last_event_ != event)
{
- smoothing_accum_ += notify_event->velocity;
- smoothing_count_++;
-
- if (released)
- {
- /* If the barrier is released, just emit the current event without
- * waiting, so there won't be any delay on releasing the barrier. */
- smoothing_timeout_.reset();
-
- SendBarrierEvent(notify_event->x, notify_event->y,
- notify_event->velocity, notify_event->event_id);
- }
- else if (!smoothing_timeout_)
- {
- int x = notify_event->x;
- int y = notify_event->y;
- int event = notify_event->event_id;
-
- // If we are a new event, don't delay sending the first event
- if (last_event_ != event)
- {
- first_event_ = true;
- last_event_ = event;
-
- SendBarrierEvent(notify_event->x, notify_event->y,
- notify_event->velocity, notify_event->event_id);
-
- first_event_ = false;
- }
-
- smoothing_timeout_.reset(new glib::Timeout(smoothing, [this, event, x, y] () {
- EmitCurrentData(event, x, y);
-
- smoothing_timeout_.reset();
- return false;
- }));
- }
+ first_event_ = true;
+ last_event_ = event;
+
+ SendBarrierEvent(barrier_event->root_x, barrier_event->root_y,
+ velocity, barrier_event->eventid);
+
+ first_event_ = false;
}
- return notify_event->barrier == barrier;
- }
+ smoothing_timeout_.reset(new glib::Timeout(smoothing, [this, event, x, y] () {
+ EmitCurrentData(event, x, y);
- return false;
-}
+ smoothing_timeout_.reset();
+ return false;
+ }));
+ }
-bool PointerBarrierWrapper::HandleEventWrapper(XEvent event, void* data)
-{
- PointerBarrierWrapper* wrapper = (PointerBarrierWrapper*)data;
- return wrapper->HandleEvent(event);
+ return true;
}
}
diff --git a/launcher/PointerBarrier.h b/launcher/PointerBarrier.h
index 6576c090e..88c9cc120 100644
--- a/launcher/PointerBarrier.h
+++ b/launcher/PointerBarrier.h
@@ -23,6 +23,7 @@
#include <Nux/Nux.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
+#include <X11/extensions/XInput2.h>
#include <UnityCore/GLibSource.h>
namespace unity
@@ -88,19 +89,20 @@ public:
bool IsFirstEvent() const;
+ bool OwnsBarrierEvent(PointerBarrier const barrier) const;
+ bool HandleBarrierEvent(XIBarrierEvent* barrier_event);
+
protected:
void EmitCurrentData(int event_id, int x, int y);
- bool HandleEvent(XEvent event);
private:
- static bool HandleEventWrapper(XEvent event, void* data);
-
void SendBarrierEvent(int x, int y, int velocity, int event_id);
- int event_base_;
+ int xi2_opcode_;
int last_event_;
+ int current_device_;
bool first_event_;
- PointerBarrier barrier;
+ PointerBarrier barrier_;
int smoothing_count_;
int smoothing_accum_;
diff --git a/launcher/QuicklistMenuItem.cpp b/launcher/QuicklistMenuItem.cpp
index 9eadb4994..f8cd8351f 100644
--- a/launcher/QuicklistMenuItem.cpp
+++ b/launcher/QuicklistMenuItem.cpp
@@ -32,6 +32,7 @@ const char* QuicklistMenuItem::MARKUP_ENABLED_PROPERTY = "unity-use-markup";
const char* QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY = "unity-disable-accel";
const char* QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY = "unity-max-label-width";
const char* QuicklistMenuItem::OVERLAY_MENU_ITEM_PROPERTY = "unity-overlay-item";
+const char* QuicklistMenuItem::QUIT_ACTION_PROPERTY = "unity-quit-action";
NUX_IMPLEMENT_OBJECT_TYPE(QuicklistMenuItem);
diff --git a/launcher/QuicklistMenuItem.h b/launcher/QuicklistMenuItem.h
index f0af32f74..51c0d54db 100644
--- a/launcher/QuicklistMenuItem.h
+++ b/launcher/QuicklistMenuItem.h
@@ -90,6 +90,7 @@ public:
static const char* MARKUP_ACCEL_DISABLED_PROPERTY;
static const char* MAXIMUM_LABEL_WIDTH_PROPERTY;
static const char* OVERLAY_MENU_ITEM_PROPERTY;
+ static const char* QUIT_ACTION_PROPERTY;
protected:
// Introspection
diff --git a/launcher/SoftwareCenterLauncherIcon.cpp b/launcher/SoftwareCenterLauncherIcon.cpp
index 0681c5abf..4f3a94409 100644
--- a/launcher/SoftwareCenterLauncherIcon.cpp
+++ b/launcher/SoftwareCenterLauncherIcon.cpp
@@ -104,7 +104,7 @@ void SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> const& launche
drag_window_->SetBaseXY(start_x, start_y);
drag_window_->ShowWindow(true);
drag_window_->SetAnimationTarget(icon_center.x, icon_center.y + (launcher->GetIconSize() / 2));
- drag_window_->on_anim_completed = drag_window_->anim_completed.connect(sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnDragAnimationFinished));
+ drag_window_->on_anim_completed_conn_ = drag_window_->anim_completed.connect(sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnDragAnimationFinished));
drag_window_->StartSlowAnimation();
}
@@ -254,6 +254,7 @@ void SoftwareCenterLauncherIcon::OnPropertyChanged(GVariant* params)
{
SetQuirk(Quirk::PROGRESS, true);
finished_ = false;
+ tooltip_text = _("Installing...");
}
SetProgress(progress/100.0f);
diff --git a/launcher/SoftwareCenterLauncherIcon.h b/launcher/SoftwareCenterLauncherIcon.h
index 1b1b6970c..e91cb067b 100644
--- a/launcher/SoftwareCenterLauncherIcon.h
+++ b/launcher/SoftwareCenterLauncherIcon.h
@@ -50,9 +50,9 @@ protected:
std::string GetActualDesktopFileAfterInstall();
void ActivateLauncherIcon(ActionArg arg);
void OnFinished(GVariant *params);
+ void OnPropertyChanged(GVariant* params);
private:
- void OnPropertyChanged(GVariant* params);
void OnDragAnimationFinished();
glib::DBusProxy aptdaemon_trans_;
diff --git a/launcher/TrashLauncherIcon.cpp b/launcher/TrashLauncherIcon.cpp
index cd05f7473..28169f5d6 100644
--- a/launcher/TrashLauncherIcon.cpp
+++ b/launcher/TrashLauncherIcon.cpp
@@ -42,6 +42,7 @@ namespace
TrashLauncherIcon::TrashLauncherIcon(FileManager::Ptr const& fmo)
: SimpleLauncherIcon(IconType::TRASH)
+ , empty_(true)
, file_manager_(fmo ? fmo : GnomeFileManager::Get())
{
tooltip_text = _("Trash");
@@ -85,7 +86,7 @@ AbstractLauncherIcon::MenuItemsVector TrashLauncherIcon::GetMenus()
/* Empty Trash */
glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new());
- dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash..."));
+ dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash…"));
dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !empty_);
dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
empty_activated_signal_.Connect(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
diff --git a/launcher/VolumeLauncherIcon.cpp b/launcher/VolumeLauncherIcon.cpp
index bea548ef5..fdbe03249 100644
--- a/launcher/VolumeLauncherIcon.cpp
+++ b/launcher/VolumeLauncherIcon.cpp
@@ -22,6 +22,7 @@
#include "config.h"
#include <glib/gi18n-lib.h>
#include <NuxCore/Logger.h>
+#include <UnityCore/ConnectionManager.h>
#include <UnityCore/GLibSignal.h>
#include "DevicesSettings.h"
@@ -60,13 +61,6 @@ public:
ConnectSignals();
}
- ~Impl()
- {
- volume_changed_conn_.disconnect();
- volume_removed_conn_.disconnect();
- settings_changed_conn_.disconnect();
- }
-
void UpdateIcon()
{
parent_->tooltip_text = volume_->GetName();
@@ -88,10 +82,10 @@ public:
void ConnectSignals()
{
- volume_changed_conn_ = volume_->changed.connect(sigc::mem_fun(this, &Impl::OnVolumeChanged));
- volume_removed_conn_ = volume_->removed.connect(sigc::mem_fun(this, &Impl::OnVolumeRemoved));
- settings_changed_conn_ = devices_settings_->changed.connect(sigc::mem_fun(this, &Impl::OnSettingsChanged));
- volume_->opened.connect(sigc::hide(sigc::mem_fun(this, &Impl::UpdateIcon)));
+ connections_.Add(volume_->changed.connect(sigc::mem_fun(this, &Impl::OnVolumeChanged)));
+ connections_.Add(volume_->removed.connect(sigc::mem_fun(this, &Impl::OnVolumeRemoved)));
+ connections_.Add(devices_settings_->changed.connect(sigc::mem_fun(this, &Impl::OnSettingsChanged)));
+ connections_.Add(volume_->opened.connect(sigc::hide(sigc::mem_fun(this, &Impl::UpdateIcon))));
}
void OnVolumeChanged()
@@ -286,9 +280,7 @@ public:
DevicesSettings::Ptr devices_settings_;
glib::SignalManager gsignals_;
- sigc::connection settings_changed_conn_;
- sigc::connection volume_changed_conn_;
- sigc::connection volume_removed_conn_;
+ connection::Manager connections_;
};
//