summaryrefslogtreecommitdiff
diff options
-rw-r--r--manual-tests/Dash.txt12
-rw-r--r--manual-tests/Hud.txt1
-rw-r--r--plugins/unityshell/resources/close_dash_disabled.pngbin0 -> 1292 bytes
-rw-r--r--plugins/unityshell/resources/maximize_dash_disabled.pngbin0 -> 1208 bytes
-rw-r--r--plugins/unityshell/resources/minimize_dash_disabled.pngbin0 -> 1191 bytes
-rw-r--r--plugins/unityshell/resources/unmaximize_dash_disabled.pngbin0 -> 1208 bytes
-rw-r--r--plugins/unityshell/src/AbstractLauncherIcon.cpp27
-rw-r--r--plugins/unityshell/src/AbstractLauncherIcon.h23
-rw-r--r--plugins/unityshell/src/BGHash.cpp183
-rw-r--r--plugins/unityshell/src/BGHash.h10
-rw-r--r--plugins/unityshell/src/BamfLauncherIcon.cpp14
-rw-r--r--plugins/unityshell/src/BamfLauncherIcon.h1
-rw-r--r--plugins/unityshell/src/DashStyle.h4
-rw-r--r--plugins/unityshell/src/DashView.cpp3
-rw-r--r--plugins/unityshell/src/DebugDBusInterface.cpp1
-rw-r--r--plugins/unityshell/src/DesktopLauncherIcon.cpp1
-rw-r--r--plugins/unityshell/src/DeviceLauncherSection.cpp4
-rw-r--r--plugins/unityshell/src/DeviceLauncherSection.h2
-rw-r--r--plugins/unityshell/src/FilterBar.cpp7
-rw-r--r--plugins/unityshell/src/FilterExpanderLabel.cpp143
-rw-r--r--plugins/unityshell/src/FilterExpanderLabel.h11
-rw-r--r--plugins/unityshell/src/FilterGenreWidget.cpp16
-rw-r--r--plugins/unityshell/src/FilterGenreWidget.h3
-rw-r--r--plugins/unityshell/src/FilterMultiRangeWidget.cpp28
-rw-r--r--plugins/unityshell/src/FilterMultiRangeWidget.h3
-rw-r--r--plugins/unityshell/src/FilterRatingsWidget.cpp16
-rw-r--r--plugins/unityshell/src/FilterRatingsWidget.h5
-rw-r--r--plugins/unityshell/src/HudButton.cpp28
-rw-r--r--plugins/unityshell/src/HudButton.h6
-rw-r--r--plugins/unityshell/src/HudController.cpp38
-rw-r--r--plugins/unityshell/src/HudController.h2
-rw-r--r--plugins/unityshell/src/HudView.cpp200
-rw-r--r--plugins/unityshell/src/HudView.h8
-rw-r--r--plugins/unityshell/src/IMTextEntry.cpp4
-rw-r--r--plugins/unityshell/src/IMTextEntry.h1
-rw-r--r--plugins/unityshell/src/IconLoader.cpp54
-rw-r--r--plugins/unityshell/src/IconTextureSource.cpp1
-rw-r--r--plugins/unityshell/src/IconTextureSource.h1
-rw-r--r--plugins/unityshell/src/Launcher.cpp120
-rw-r--r--plugins/unityshell/src/Launcher.h68
-rw-r--r--plugins/unityshell/src/LauncherController.cpp148
-rw-r--r--plugins/unityshell/src/LauncherController.h2
-rw-r--r--plugins/unityshell/src/LauncherIcon.cpp37
-rw-r--r--plugins/unityshell/src/LauncherIcon.h17
-rw-r--r--plugins/unityshell/src/LauncherModel.cpp44
-rw-r--r--plugins/unityshell/src/LauncherModel.h36
-rw-r--r--plugins/unityshell/src/LensView.cpp32
-rw-r--r--plugins/unityshell/src/MockLauncherIcon.h17
-rw-r--r--plugins/unityshell/src/PanelMenuView.cpp7
-rw-r--r--plugins/unityshell/src/PanelStyle.h3
-rw-r--r--plugins/unityshell/src/PlacesGroup.cpp5
-rw-r--r--plugins/unityshell/src/PlacesGroup.h3
-rw-r--r--plugins/unityshell/src/ResultViewGrid.cpp11
-rw-r--r--plugins/unityshell/src/ResultViewGrid.h15
-rw-r--r--plugins/unityshell/src/SearchBar.cpp136
-rw-r--r--plugins/unityshell/src/SearchBar.h14
-rw-r--r--plugins/unityshell/src/SimpleLauncherIcon.cpp4
-rw-r--r--plugins/unityshell/src/SimpleLauncherIcon.h1
-rw-r--r--plugins/unityshell/src/SoftwareCenterLauncherIcon.cpp1
-rw-r--r--plugins/unityshell/src/SwitcherController.cpp18
-rw-r--r--plugins/unityshell/src/SwitcherController.h6
-rw-r--r--plugins/unityshell/src/SwitcherModel.cpp18
-rw-r--r--plugins/unityshell/src/SwitcherModel.h14
-rw-r--r--plugins/unityshell/src/SwitcherView.cpp8
-rw-r--r--plugins/unityshell/src/SwitcherView.h4
-rw-r--r--plugins/unityshell/src/WindowButtons.cpp28
-rw-r--r--plugins/unityshell/src/compizminimizedwindowhandler.h19
-rw-r--r--plugins/unityshell/src/comptransientfor.cpp7
-rw-r--r--plugins/unityshell/src/transientfor.cpp19
-rw-r--r--plugins/unityshell/src/unity-launcher-accessible.cpp32
-rw-r--r--plugins/unityshell/src/unity-switcher-accessible.cpp14
-rw-r--r--plugins/unityshell/src/unityshell.cpp39
-rw-r--r--plugins/unityshell/src/unityshell.h5
-rw-r--r--standalone-clients/StandaloneHud.cpp2
-rw-r--r--standalone-clients/TestBGHash.cpp18
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/autopilot/autopilot/emulators/unity.py11
-rw-r--r--tests/autopilot/autopilot/tests/test_dash.py63
-rw-r--r--tests/test_icon_loader.cpp66
-rw-r--r--tests/test_launcher_model.cpp36
80 files changed, 1421 insertions, 589 deletions
diff --git a/manual-tests/Dash.txt b/manual-tests/Dash.txt
index 32c94344c..f4309be6e 100644
--- a/manual-tests/Dash.txt
+++ b/manual-tests/Dash.txt
@@ -67,3 +67,15 @@ Outcome
The text previously selected is pasted on the search bar at mouse pointer
position, if the operation is repeated the text is inserted where
the mouse pointer is.
+
+Dash SearchBar IBus Focus
+------------------------------
+This test shows that the IBus is getting focus when it gets keyboard focus.
+
+#. Open the Dash
+#. Press Ctrl + Space to activate ibus
+#. Type "abc1"
+
+Outcome
+ Typing "abc1" while ibus is focused will produce 阿布从 . If the ibus is not focused
+ then "abc1" will be the outcome (This is incorrect behavior).
diff --git a/manual-tests/Hud.txt b/manual-tests/Hud.txt
index 9975bee38..15ebd35d2 100644
--- a/manual-tests/Hud.txt
+++ b/manual-tests/Hud.txt
@@ -10,6 +10,7 @@ and the panel changes
Outcome
The hud interface presents itself with no other interface such as the dash present.
The Launcher hides, the panel becomes transparent with a colour tint matching the hud
+ The HUD search bar is focused and typing text enters text into it
Hud Search
-----------
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
--- /dev/null
+++ b/plugins/unityshell/resources/close_dash_disabled.png
Binary files 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
--- /dev/null
+++ b/plugins/unityshell/resources/maximize_dash_disabled.png
Binary files 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
--- /dev/null
+++ b/plugins/unityshell/resources/minimize_dash_disabled.png
Binary files 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
--- /dev/null
+++ b/plugins/unityshell/resources/unmaximize_dash_disabled.png
Binary files differ
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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Jason Smith <jason.smith@canonical.com>
+ */
+
+#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<AbstractLauncherIcon> Ptr;
typedef std::vector<nux::Vector4> 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<void, int, int> mouse_down;
sigc::signal<void, int, int> mouse_up;
sigc::signal<void, int, int> mouse_click;
sigc::signal<void, int> mouse_enter;
sigc::signal<void, int> mouse_leave;
- sigc::signal<void, AbstractLauncherIcon*> show;
- sigc::signal<void, AbstractLauncherIcon*> hide;
- sigc::signal<void, AbstractLauncherIcon*> needs_redraw;
- sigc::signal<void, AbstractLauncherIcon*> remove;
+ sigc::signal<void, AbstractLauncherIcon::Ptr> needs_redraw;
+ sigc::signal<void, AbstractLauncherIcon::Ptr> remove;
sigc::connection needs_redraw_connection;
sigc::connection on_icon_added_connection;
diff --git a/plugins/unityshell/src/BGHash.cpp b/plugins/unityshell/src/BGHash.cpp
index c791687a4..512d3b136 100644
--- a/plugins/unityshell/src/BGHash.cpp
+++ b/plugins/unityshell/src/BGHash.cpp
@@ -53,7 +53,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 +71,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<GdkPixbuf> 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 +94,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 ();
@@ -428,20 +437,162 @@ 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<GdkPixbuf> 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<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file (path.c_str (), &error));
+ glib::Object<GFile> file(g_file_new_for_path(path.c_str()));
+ glib::Object<GFileInfo> 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<GFile> cachefile(g_file_new_for_path(fullpath.c_str()));
+ glib::Object<GOutputStream> 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)
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<std::string, nux::Color> cache_map_;
};
};
diff --git a/plugins/unityshell/src/BamfLauncherIcon.cpp b/plugins/unityshell/src/BamfLauncherIcon.cpp
index de4467ec6..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();
@@ -379,6 +381,7 @@ void BamfLauncherIcon::OnWindowMoved(guint32 moved_win)
{
BamfLauncherIcon* self = static_cast<BamfLauncherIcon*>(data);
self->EnsureWindowState();
+ self->UpdateIconGeometries(self->GetCenters());
self->_window_moved_id = 0;
return FALSE;
}, this);
@@ -652,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);
}
@@ -1016,8 +1019,6 @@ void BamfLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> 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 +1030,11 @@ void BamfLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> center)
continue;
Window xid = bamf_window_get_xid(static_cast<BamfWindow*>(l->data));
+ int monitor = bamf_window_get_monitor(static_cast<BamfWindow*>(l->data));
+ monitor = std::max<int>(0, std::min<int>(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/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/DashStyle.h b/plugins/unityshell/src/DashStyle.h
index 71295d01c..4807d5b6f 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 = 8;
-
sigc::signal<void> changed;
private:
diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp
index 67713ceb3..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 + 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/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/DesktopLauncherIcon.cpp b/plugins/unityshell/src/DesktopLauncherIcon.cpp
index 64ad9efb0..729d5d5ff 100644
--- a/plugins/unityshell/src/DesktopLauncherIcon.cpp
+++ b/plugins/unityshell/src/DesktopLauncherIcon.cpp
@@ -36,6 +36,7 @@ DesktopLauncherIcon::DesktopLauncherIcon()
SetQuirk(QUIRK_VISIBLE, true);
SetQuirk(QUIRK_RUNNING, false);
SetIconType(TYPE_BEGIN);
+ 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<void, LauncherIcon*> IconAdded;
+ sigc::signal<void, AbstractLauncherIcon::Ptr> IconAdded;
private:
static bool PopulateEntries(DeviceLauncherSection* self);
diff --git a/plugins/unityshell/src/FilterBar.cpp b/plugins/unityshell/src/FilterBar.cpp
index c1aedfdd9..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 , geom.y + geom.height - 1,
- geom.x + geom.width, 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);
}
diff --git a/plugins/unityshell/src/FilterExpanderLabel.cpp b/plugins/unityshell/src/FilterExpanderLabel.cpp
index be4da93e6..68e325c2d 100644
--- a/plugins/unityshell/src/FilterExpanderLabel.cpp
+++ b/plugins/unityshell/src/FilterExpanderLabel.cpp
@@ -26,7 +26,53 @@
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;
+
+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
@@ -34,8 +80,6 @@ namespace unity
namespace dash
{
-
-
NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel);
FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE_DECL)
@@ -43,6 +87,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 +114,8 @@ void FilterExpanderLabel::SetLabel(std::string const& label)
void FilterExpanderLabel::SetRightHandView(nux::View* view)
{
- view->SetMaximumHeight(30);
+ 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);
@@ -88,33 +135,31 @@ void FilterExpanderLabel::SetContents(nux::Layout* contents)
void FilterExpanderLabel::BuildLayout()
{
layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
+ layout_->SetLeftAndRightPadding(LAYOUT_LEFT_PADDING, LAYOUT_RIGHT_PADDING);
+
top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
- top_bar_layout_->SetHorizontalInternalMargin(8);
+ 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(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN);
+
+ 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_->SetTextColor(nux::color::White);
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,
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);
- 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);
@@ -122,17 +167,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 + TOP_BAR_LAYOUT_WIDTH_ADDER);
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();
}
@@ -160,18 +227,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 = HIGHLIGHT_HEIGHT;
+ geo.width = base.width - HIGHLIGHT_WIDTH_SUBTRACTOR;;
+
+ 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 <memory>
+
#include <Nux/Nux.h>
#include <Nux/GridHLayout.h>
#include <Nux/HLayout.h>
@@ -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<nux::Layout> contents_;
+ std::unique_ptr<nux::AbstractPaintLayer> 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..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,7 +53,8 @@ FilterMultiRange::FilterMultiRange(NUX_FILE_LINE_DECL)
all_button_ = new FilterAllButton(NUX_TRACKER_LOCATION);
layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
- layout_->SetTopAndBottomPadding(9, 12);
+ layout_->SetLeftAndRightPadding(LEFT_PADDING, RIGHT_PADDING);
+ layout_->SetTopAndBottomPadding(TOP_PADDING, BOTTOM_PADDING);
SetRightHandView(all_button_);
SetContents(layout_);
@@ -155,21 +165,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/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<Query> GetQuery();
nux::Property<std::string> label;
nux::Property<std::string> hint;
nux::Property<bool> is_rounded;
+ nux::Property<bool> 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<nux::CairoWrapper> NuxCairoPtr;
diff --git a/plugins/unityshell/src/HudController.cpp b/plugins/unityshell/src/HudController.cpp
index 55aba0bc7..e68bed3fe 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 <libbamf/libbamf.h>
+
namespace unity
{
namespace hud
@@ -96,8 +99,8 @@ void Controller::SetupHudView()
LOG_DEBUG(logger) << "SetupHudView called";
view_ = new View();
- layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
- layout_->AddView(view_, 1);
+ 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));
@@ -148,7 +151,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
@@ -215,23 +218,32 @@ 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();
+ // 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<BamfView> 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);
window_->SetInputFocus();
- nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus());
window_->CaptureMouseDownAnyWhereElse(true);
view_->CaptureMouseDownAnyWhereElse(true);
window_->QueueDraw();
view_->ResetToDefault();
-
- view_->SetIcon("");
- hud_service_.RequestQuery("");
need_show_ = false;
visible_ = true;
@@ -242,8 +254,10 @@ 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);
+
+ nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus());
}
void Controller::HideHud(bool restore)
{
@@ -312,7 +326,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;
}
@@ -356,7 +374,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_;
};
diff --git a/plugins/unityshell/src/HudView.cpp b/plugins/unityshell/src/HudView.cpp
index 3abbd01c8..aef513a77 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] () {
@@ -69,14 +77,35 @@ 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();
-
}
View::~View()
@@ -88,6 +117,45 @@ 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()
{
search_bar_->search_string = "";
@@ -100,7 +168,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();
}
@@ -108,6 +179,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;
}
@@ -153,6 +238,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++;
}
@@ -208,42 +295,58 @@ 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()
{
+ nux::VLayout* super_layout = new nux::VLayout();
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());
+ {
+ // 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 top spacing
- content_layout_->AddLayout(new nux::SpaceLayout(top_spacing,top_spacing,top_spacing,top_spacing), 0);
+ // 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);
- // 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 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);
+ }
- content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_LEFT);
+ layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP);
+ }
+
+ super_layout->AddLayout(layout_.GetPointer(), 0);
+ SetLayout(super_layout);
}
void View::OnSearchChanged(std::string const& search_string)
@@ -282,25 +385,48 @@ 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();
- layout_->ProcessDraw(gfx_context, force_draw);
+ GetLayout()->ProcessDraw(gfx_context, force_draw);
nux::GetPainter().PopBackgroundStack();
}
else
{
- layout_->ProcessDraw(gfx_context, force_draw);
+ GetLayout()->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<View*>(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/IMTextEntry.cpp b/plugins/unityshell/src/IMTextEntry.cpp
index bc1b217c6..63bd498c5 100644
--- a/plugins/unityshell/src/IMTextEntry.cpp
+++ b/plugins/unityshell/src/IMTextEntry.cpp
@@ -46,6 +46,10 @@ IMTextEntry::IMTextEntry()
CheckIMEnabled();
im_enabled ? SetupMultiIM() : SetupSimpleIM();
+ key_nav_focus_change.connect([&](nux::Area* area, bool focus, nux::KeyNavDirection dir)
+ {
+ focus ? 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 ab847bae6..5b9a7d8a0 100644
--- a/plugins/unityshell/src/IMTextEntry.h
+++ b/plugins/unityshell/src/IMTextEntry.h
@@ -66,6 +66,7 @@ private:
void OnFocusIn();
void OnFocusOut();
+
void UpdateCursorLocation();
void OnMouseButtonUp(int x, int y, unsigned long bflags, unsigned long kflags);
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<IconLoaderTask*> 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<std::string, glib::Object<GdkPixbuf>> ImageCache;
ImageCache cache_;
+ typedef std::map<std::string, IconLoaderTask*> CacheQueue;
+ CacheQueue queued_tasks_;
typedef std::queue<IconLoaderTask*> TaskQueue;
TaskQueue tasks_;
typedef std::map<Handle, IconLoaderTask*> 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;
}
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<IconTextureSource> Ptr;
diff --git a/plugins/unityshell/src/Launcher.cpp b/plugins/unityshell/src/Launcher.cpp
index 716999dfe..0fda7f396 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(&current, &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(&current, &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(&current, &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(&current, &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(&current, &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(&current, &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(&current, &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 &current) const
+float Launcher::IconPulseOnceValue(AbstractLauncherIcon::Ptr icon, struct timespec const &current) const
{
struct timespec pulse_time = icon->GetQuirkTime(AbstractLauncherIcon::QUIRK_PULSE_ONCE);
int pulse_ms = unity::TimeUtil::TimeDelta(&current, &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(&current, &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(&current, &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(&current, &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,15 +891,15 @@ 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_DESKTOP ||
- icon->Type() == AbstractLauncherIcon::TYPE_DEVICE ||
- 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_DESKTOP ||
+ icon->GetIconType() == AbstractLauncherIcon::TYPE_DEVICE ||
+ 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);
@@ -949,7 +948,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,
@@ -1028,7 +1027,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),
+ (int)(_drag_icon->GetCenter(monitor).y));
center.y += (half_size * size_modifier) + spacing; // move to end
}
@@ -1191,7 +1191,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &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);
@@ -1219,7 +1219,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &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);
@@ -1269,7 +1269,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();
}
@@ -1701,14 +1701,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();
@@ -1743,9 +1743,8 @@ LauncherModel* Launcher::GetModel() const
return _model;
}
-void Launcher::EnsureIconOnScreen(AbstractLauncherIcon* selection)
+void Launcher::EnsureIconOnScreen(AbstractLauncherIcon::Ptr selection)
{
- nux::Point3 center = selection->GetCenter(monitor);
nux::Geometry geo = GetGeometry();
int natural_y = 0;
@@ -1766,7 +1765,7 @@ void Launcher::EnsureIconOnScreen(AbstractLauncherIcon* selection)
_launcher_drag_delta = std::max<int>(min_drag_delta, std::min<int>(max_drag_delta, _launcher_drag_delta));
}
-void Launcher::OnSelectionChanged(AbstractLauncherIcon* selection)
+void Launcher::OnSelectionChanged(AbstractLauncherIcon::Ptr selection)
{
if (IsInKeyNavMode())
{
@@ -1775,7 +1774,7 @@ void Launcher::OnSelectionChanged(AbstractLauncherIcon* selection)
}
}
-void Launcher::OnIconNeedsRedraw(AbstractLauncherIcon* icon)
+void Launcher::OnIconNeedsRedraw(AbstractLauncherIcon::Ptr icon)
{
EnsureAnimation();
}
@@ -2009,7 +2008,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
@@ -2038,7 +2037,7 @@ void Launcher::StartIconDragRequest(int x, int y)
}
}
-void Launcher::StartIconDrag(AbstractLauncherIcon* icon)
+void Launcher::StartIconDrag(AbstractLauncherIcon::Ptr icon)
{
if (!icon)
return;
@@ -2067,9 +2066,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);
@@ -2082,7 +2081,8 @@ void Launcher::EndIconDrag()
{
_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),
+ (int)(_drag_icon->GetCenter(monitor).y));
_drag_window->StartAnimation();
if (_drag_window->on_anim_completed.connected())
@@ -2108,7 +2108,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, &current);
@@ -2356,7 +2356,7 @@ void Launcher::EventLogic()
GetActionState() == ACTION_DRAG_LAUNCHER)
return;
- AbstractLauncherIcon* launcher_icon = nullptr;
+ AbstractLauncherIcon::Ptr launcher_icon;
if (!_hidden && !IsInKeyNavMode() && _hovered)
{
@@ -2381,7 +2381,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);
@@ -2400,7 +2400,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);
@@ -2431,7 +2431,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;
@@ -2455,11 +2455,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<nux::IOpenGLBaseTexture> texture)
+Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
{
RenderArg arg;
struct timespec current;
@@ -2672,15 +2672,15 @@ Launcher::ProcessDndMove(int x, int y, std::list<char*> 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;
}
@@ -2789,11 +2789,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();
}
@@ -2823,7 +2823,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);
@@ -2861,6 +2861,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
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<void, char*, AbstractLauncherIcon*> launcher_addrequest;
- sigc::signal<void, std::string const&, AbstractLauncherIcon*, std::string const&, std::string const&> launcher_addrequest_special;
- sigc::signal<void, AbstractLauncherIcon*> launcher_removerequest;
+ sigc::signal<void, char*, AbstractLauncherIcon::Ptr> launcher_addrequest;
+ sigc::signal<void, std::string const&, AbstractLauncherIcon::Ptr, std::string const&, std::string const&> launcher_addrequest_special;
+ sigc::signal<void, AbstractLauncherIcon::Ptr> launcher_removerequest;
sigc::signal<void> selection_change;
sigc::signal<void> 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 &current) 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 &current) 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<ui::RenderArg> &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<nux::IOpenGLBaseTexture> texture);
+ void RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> 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<AbstractLauncherIcon> 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<BamfLauncherIcon> ())
{
@@ -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<BamfLauncherIcon*> launchers = model_->GetSublist<BamfLauncherIcon> ();
+ auto launchers = model_->GetSublist<BamfLauncherIcon> ();
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<BamfLauncherIcon*> launchers;
-
- launchers = model_->GetSublist<BamfLauncherIcon>();
+ auto launchers = model_->GetSublist<BamfLauncherIcon>();
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<BamfLauncherIcon*> launchers = model_->GetSublist<BamfLauncherIcon> ();
+ auto launchers = model_->GetSublist<BamfLauncherIcon> ();
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<BamfLauncherIcon*>(icon);
+ BamfLauncherIcon* bamf_icon = dynamic_cast<BamfLauncherIcon*>(icon.GetPointer());
if (bamf_icon)
{
@@ -453,7 +451,7 @@ void Controller::Impl::OnLauncherRemoveRequest(AbstractLauncherIcon* icon)
}
case AbstractLauncherIcon::TYPE_DEVICE:
{
- DeviceLauncherIcon* device_icon = dynamic_cast<DeviceLauncherIcon*>(icon);
+ DeviceLauncherIcon* device_icon = dynamic_cast<DeviceLauncherIcon*>(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<BamfLauncherIcon>();
- 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<SimpleLauncherIcon*>(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<BamfLauncherIcon*>(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<char> Controller::GetAllShortcuts() const
return shortcuts;
}
-std::vector<AbstractLauncherIcon*> Controller::GetAltTabIcons(bool current) const
+std::vector<AbstractLauncherIcon::Ptr> Controller::GetAltTabIcons(bool current) const
{
- std::vector<AbstractLauncherIcon*> results;
+ std::vector<AbstractLauncherIcon::Ptr> 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<char> GetAllShortcuts() const;
- std::vector<AbstractLauncherIcon*> GetAltTabIcons(bool current) const;
+ std::vector<AbstractLauncherIcon::Ptr> GetAltTabIcons(bool current) const;
void PushToFront();
diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp
index d68410604..fecef8837 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);
@@ -704,7 +706,7 @@ LauncherIcon::SetWindowVisibleOnMonitor(bool val, int monitor)
return;
_has_visible_window[monitor] = val;
- needs_redraw.emit(this);
+ EmitNeedsRedraw();
}
gboolean
@@ -758,7 +760,7 @@ LauncherIcon::Remove()
_quicklist->Hide();
SetQuirk(QUIRK_VISIBLE, false);
- remove.emit(this);
+ EmitRemove();
}
void
@@ -780,7 +782,7 @@ LauncherIcon::SortPriority()
}
LauncherIcon::IconType
-LauncherIcon::Type()
+LauncherIcon::GetIconType()
{
return _icon_type;
}
@@ -802,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)
@@ -826,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;
@@ -847,7 +849,7 @@ void
LauncherIcon::UpdateQuirkTime(LauncherIcon::Quirk quirk)
{
clock_gettime(CLOCK_MONOTONIC, &(_quirk_times[quirk]));
- needs_redraw.emit(this);
+ EmitNeedsRedraw();
}
void
@@ -870,7 +872,7 @@ LauncherIcon::SetProgress(float progress)
return;
_progress = progress;
- needs_redraw.emit(this);
+ EmitNeedsRedraw();
}
float
@@ -900,7 +902,7 @@ void
LauncherIcon::SetEmblem(LauncherIcon::BaseTexturePtr const& emblem)
{
_emblem = emblem;
- needs_redraw.emit(this);
+ EmitNeedsRedraw();
}
void
@@ -1133,5 +1135,18 @@ LauncherIcon::OnRemoteProgressVisibleChanged(LauncherEntryRemote* remote)
SetProgress((float) remote->Progress());
}
+void LauncherIcon::EmitNeedsRedraw()
+{
+ if (OwnsTheReference())
+ needs_redraw.emit(AbstractLauncherIcon::Ptr(this));
+}
+
+void LauncherIcon::EmitRemove()
+{
+ if (OwnsTheReference())
+ 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<nux::Point3> 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<LauncherModel> Ptr;
- typedef std::vector<AbstractLauncherIcon*> Base;
+ typedef std::vector<AbstractLauncherIcon::Ptr> 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<void, AbstractLauncherIcon*> icon_added;
- sigc::signal<void, AbstractLauncherIcon*> icon_removed;
+ sigc::signal<void, AbstractLauncherIcon::Ptr> icon_added;
+ sigc::signal<void, AbstractLauncherIcon::Ptr> icon_removed;
sigc::signal<void> order_changed;
sigc::signal<void> saved;
- sigc::signal<void, AbstractLauncherIcon*> selection_changed;
+ sigc::signal<void, AbstractLauncherIcon::Ptr> 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<class T>
- std::list<T*> GetSublist()
+ std::list<AbstractLauncherIcon::Ptr> GetSublist()
{
- std::list<T*> result;
+ std::list<AbstractLauncherIcon::Ptr> result;
iterator it;
for (it = begin(); it != end(); it++)
{
- T* var = dynamic_cast<T*>(*it);
+ T* var = dynamic_cast<T*>((*it).GetPointer());
if (var)
- result.push_back(var);
+ result.push_back(*it);
}
return result;
diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp
index 4e74d798f..b3cd70735 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.
@@ -51,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;
}
@@ -68,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;
@@ -117,13 +120,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 category : categories_)
{
- if ((*it)->GetLayout() != nullptr)
+ if (category->GetLayout() != nullptr)
{
- nux::View *child = (*it)->GetChildView();
- if (child->HasKeyFocus())
+ auto expand_label = category->GetExpandLabel();
+ auto child = category->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;
@@ -163,7 +170,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 +352,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 + FSCROLL_VIEW_WIDTH_ADDER);
+ fscroll_view_->SetMaximumWidth(width * 2 + FSCROLL_VIEW_WIDTH_ADDER);
can_refine_search = true;
}
@@ -371,7 +377,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 +399,7 @@ Lens::Ptr LensView::lens() const
}
int LensView::GetNumRows()
-{
+{
unsigned int columns = dash::Style::Instance().GetDefaultNColumns();
columns -= filters_expanded ? 2 : 0;
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/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();
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/PlacesGroup.cpp b/plugins/unityshell/src/PlacesGroup.cpp
index f84c450ed..df904de9d 100644
--- a/plugins/unityshell/src/PlacesGroup.cpp
+++ b/plugins/unityshell/src/PlacesGroup.cpp
@@ -41,6 +41,8 @@
#include <Nux/Utils.h>
#include <UnityCore/Variant.h>
#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, -30, 0, -30));
+
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;
};
}
diff --git a/plugins/unityshell/src/ResultViewGrid.cpp b/plugins/unityshell/src/ResultViewGrid.cpp
index 0c96d7aec..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::OnOnKeyNavFocusChange));
- 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));
@@ -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 <UnityCore/Categories.h>
#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..40680a00d 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 = _("<small><b>Filter results</b></small>");
+ std::string filter_str(_("<small><b>Filter results</b></small>"));
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,35 @@ 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_->SetVisible(false);
+ 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<void, GtkSettings*, GParamSpec*>
(gtk_settings_get_default(),
@@ -196,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);
}
@@ -326,28 +386,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_ && ShouldBeHighlighted() && !IsFullRedraw())
+ {
+ nux::GetPainter().PushLayer(GfxContext, highlight_layer_->GetGeometry(), highlight_layer_.get());
+ }
+
+
if (!IsFullRedraw())
{
gPainter.PushLayer(GfxContext, bg_layer_->GetGeometry(), bg_layer_);
@@ -407,7 +489,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 +508,6 @@ void SearchBar::UpdateBackground(bool force)
if (disable_glow)
PADDING = 2;
-
x = y = PADDING - 1;
width = last_width_ - (2 * PADDING);
@@ -527,14 +608,26 @@ bool SearchBar::get_im_active() const
}
//
+// Highlight
+//
+bool SearchBar::ShouldBeHighlighted()
+{
+ 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()));
+}
+
+//
// Key navigation
//
-bool
-SearchBar::AcceptKeyNavFocus()
+bool SearchBar::AcceptKeyNavFocus()
{
return false;
}
+//
+// Introspection
+//
std::string SearchBar::GetName() const
{
return "SearchBar";
@@ -542,8 +635,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(GetAbsoluteGeometry());
+ wrapper.add("has_focus", pango_entry_->HasKeyFocus());
+ wrapper.add("search_string", pango_entry_->GetText());
}
} // namespace unity
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 <memory>
+
#include <gtk/gtk.h>
#include <NuxCore/Property.h>
@@ -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<nux::AbstractPaintLayer> 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_;
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<AbstractLauncherIcon*> results)
+ std::vector<AbstractLauncherIcon::Ptr> 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<bool> detail_on_timeout;
nux::Property<int> detail_timeout_length;
- void Show(ShowMode show, SortMode sort, bool reverse, std::vector<launcher::AbstractLauncherIcon*> results);
+ void Show(ShowMode show, SortMode sort, bool reverse, std::vector<launcher::AbstractLauncherIcon::Ptr> 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<AbstractLauncherIcon*> icons)
+SwitcherModel::SwitcherModel(std::vector<AbstractLauncherIcon::Ptr> icons)
: _inner(icons)
, _index(0)
, _last_index(0)
@@ -41,8 +41,7 @@ SwitcherModel::SwitcherModel(std::vector<AbstractLauncherIcon*> 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<SwitcherModel> Ptr;
- typedef std::vector<launcher::AbstractLauncherIcon*> Base;
+ typedef std::vector<launcher::AbstractLauncherIcon::Ptr> 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<launcher::AbstractLauncherIcon*> icons);
+ SwitcherModel(std::vector<launcher::AbstractLauncherIcon::Ptr> 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<Window> 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<void, launcher::AbstractLauncherIcon*> selection_changed;
+ sigc::signal<void, launcher::AbstractLauncherIcon::Ptr> 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<RenderArg>::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<ui::RenderArg> 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/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<int>(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<int>(state)] << ".png";
diff --git a/plugins/unityshell/src/compizminimizedwindowhandler.h b/plugins/unityshell/src/compizminimizedwindowhandler.h
index 8125a036f..6e5d6fc32 100644
--- a/plugins/unityshell/src/compizminimizedwindowhandler.h
+++ b/plugins/unityshell/src/compizminimizedwindowhandler.h
@@ -26,6 +26,7 @@
#include <core/core.h>
#include "minimizedwindowhandler.h"
#include "comptransientfor.h"
+#include <memory>
// Will be merged back into compiz
namespace compiz {
@@ -67,7 +68,7 @@ public:
typedef std::list <Type *> List;
protected:
- virtual std::vector<unsigned int> getTransients ();
+ std::vector<unsigned int> getTransients ();
private:
@@ -103,6 +104,15 @@ compiz::CompizMinimizedWindowHandler<Screen, Window>::CompizMinimizedWindowHandl
template <typename Screen, typename Window>
compiz::CompizMinimizedWindowHandler<Screen, Window>::~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);
}
@@ -158,7 +168,7 @@ compiz::CompizMinimizedWindowHandler<Screen, Window>::minimize ()
{
Window *w = Window::get (win);
if (!w->mMinimizeHandler)
- w->mMinimizeHandler = new Type (win);
+ w->mMinimizeHandler.reset (new Type (win));
w->mMinimizeHandler->minimize ();
}
}
@@ -241,8 +251,7 @@ compiz::CompizMinimizedWindowHandler<Screen, Window>::unminimize ()
if (w && w->mMinimizeHandler)
{
w->mMinimizeHandler->unminimize ();
- delete w->mMinimizeHandler;
- w->mMinimizeHandler = NULL;
+ w->mMinimizeHandler.reset ();
}
}
}
@@ -324,7 +333,7 @@ compiz::CompizMinimizedWindowHandler<Screen, Window>::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/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..66536fc1a 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 = static_cast <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<std::string> strings;
std::list<Atom> 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 = static_cast <Window *> (prop);
- serverClientLeader = *data;
+ serverClientLeader = *data;
}
XFree (prop);
@@ -123,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 <Atom *> (prop);
while (nItems--)
{
@@ -160,7 +167,7 @@ compiz::X11TransientForReader::getTransients ()
{
if (actualType == XA_WINDOW && actualFormat == 32 && nItems && !nLeft)
{
- Window *data = (Window *) prop;
+ Window *data = static_cast <Window *> (prop);
while (nItems--)
{
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<nux::Object*>(*it);
+ child = dynamic_cast<nux::Object*>((*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<Launcher*>(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<Launcher*>(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<AbstractLauncherIcon*>(*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<nux::Object*>(*it);
+ child = dynamic_cast<nux::Object*>((*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<AbstractLauncherIcon*>(*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 bc2ee10fb..192670fd5 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;
@@ -1589,9 +1595,9 @@ bool UnityScreen::altTabInitiateCommon(CompAction *action,
int show_monitor = (show_mode == switcher::ShowMode::CURRENT_VIEWPORT) ? device : -1;
- std::vector<unity::launcher::AbstractLauncherIcon*> 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;
@@ -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)
{
@@ -2005,7 +2014,7 @@ UnityWindow::minimize ()
if (!mMinimizeHandler)
{
- mMinimizeHandler = new UnityMinimizedHandler (window);
+ mMinimizeHandler.reset (new UnityMinimizedHandler (window));
mMinimizeHandler->minimize ();
}
}
@@ -2016,8 +2025,7 @@ UnityWindow::unminimize ()
if (mMinimizeHandler)
{
mMinimizeHandler->unminimize ();
- delete mMinimizeHandler;
- mMinimizeHandler = nullptr;
+ mMinimizeHandler.reset ();
}
}
@@ -2056,7 +2064,7 @@ UnityWindow::focus ()
bool
UnityWindow::minimized ()
{
- return mMinimizeHandler != nullptr;
+ return mMinimizeHandler.get () != nullptr;
}
gboolean
@@ -2623,7 +2631,7 @@ UnityWindow::UnityWindow(CompWindow* window)
, PluginClassHandler<UnityWindow, CompWindow>(window)
, window(window)
, gWindow(GLWindow::get(window))
- , mMinimizeHandler(nullptr)
+ , mMinimizeHandler()
, mShowdesktopHandler(nullptr)
, focusdesktop_handle_(0)
{
@@ -2681,19 +2689,6 @@ 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;
- }
-
if (mShowdesktopHandler)
delete mShowdesktopHandler;
diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h
index 337be3636..39a73e03f 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
@@ -401,7 +404,7 @@ public:
typedef compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>
UnityMinimizedHandler;
- UnityMinimizedHandler *mMinimizeHandler;
+ std::unique_ptr <UnityMinimizedHandler> mMinimizeHandler;
UnityShowdesktopHandler *mShowdesktopHandler;
diff --git a/standalone-clients/StandaloneHud.cpp b/standalone-clients/StandaloneHud.cpp
index 03d1aab85..d9f82a5f4 100644
--- a/standalone-clients/StandaloneHud.cpp
+++ b/standalone-clients/StandaloneHud.cpp
@@ -69,7 +69,7 @@ void TestRunner::Init ()
hud_view_ = new unity::hud::View();
- layout->AddView (hud_view_, 1, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FULL);
+ layout->AddView (hud_view_, 0, nux::MINOR_POSITION_TOP);
nux::GetWindowCompositor().SetKeyFocusArea(hud_view_->default_focus());
nux::GetWindowThread()->SetLayout (layout);
diff --git a/standalone-clients/TestBGHash.cpp b/standalone-clients/TestBGHash.cpp
index 9c9fc1771..5548c2031 100644
--- a/standalone-clients/TestBGHash.cpp
+++ b/standalone-clients/TestBGHash.cpp
@@ -26,6 +26,11 @@
#include "ubus-server.h"
#include "UBusMessages.h"
+namespace
+{
+ nux::logging::Logger logger("unity.BGHash");
+}
+
class TestRunner
{
public:
@@ -52,7 +57,10 @@ void TestRunner::Init ()
{
nux::Color hash = bghash.CurrentColor ();
- g_debug ("hashed color: %f - %f - %f", hash.red, hash.green, hash.blue);
+ LOG_DEBUG(logger) << "hashed color: "
+ << hash.red << ", "
+ << hash.green << ", "
+ << hash.blue;
}
@@ -79,7 +87,10 @@ test_handler_color_change (GVariant *data, gpointer val)
gdouble red, green, blue, alpha;
g_variant_get (data, "(dddd)", &red, &green, &blue, &alpha);
- //g_debug ("new color: %f, %f, %f", red, green, blue);
+ LOG_TRACE(logger) << "hashed color: "
+ << red << ", "
+ << green << ", "
+ << blue;
}
int main(int argc, char **argv)
@@ -98,6 +109,9 @@ int main(int argc, char **argv)
gtk_init (&argc, &argv);
nux::NuxInitialize(0);
+ // Slightly higher as we're more likely to test things we know will fail
+ nux::logging::configure_logging("unity.BGHash=debug");
+
nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));
unity::BGHash bg_hash;
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5f8dded5c..32bc99fac 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -123,6 +123,7 @@ if (GTEST_FOUND AND
test_grabhandle.cpp
test_unityshell_private.cpp
${UNITY_SRC}/AbstractLauncherIcon.h
+ ${UNITY_SRC}/AbstractLauncherIcon.cpp
${UNITY_SRC}/AbstractShortcutHint.h
${UNITY_SRC}/Animator.cpp
${UNITY_SRC}/Animator.h
diff --git a/tests/autopilot/autopilot/emulators/unity.py b/tests/autopilot/autopilot/emulators/unity.py
index 051bc2ed3..98d3542ce 100644
--- a/tests/autopilot/autopilot/emulators/unity.py
+++ b/tests/autopilot/autopilot/emulators/unity.py
@@ -536,12 +536,23 @@ class Dash(Unity):
"""
return bool(self.get_state("/Unity/DashController")[0]["visible"])
+ def get_searchbar_geometry(self):
+ """Returns the searchbar geometry"""
+ search_bar = self.get_state("//SearchBar")[0]
+ return search_bar['x'], search_bar['y'], search_bar['width'], search_bar['height']
+
def get_search_string(self):
"""
Return the current dash search bar search string.
"""
return unicode(self.get_state("//SearchBar")[0]['search_string'])
+ def searchbar_has_focus(self):
+ """
+ Returns True if the search bar has the key focus, False otherwise.
+ """
+ return self.get_state("//SearchBar")[0]['has_focus']
+
def get_current_lens(self):
"""Returns the id of the current lens.
diff --git a/tests/autopilot/autopilot/tests/test_dash.py b/tests/autopilot/autopilot/tests/test_dash.py
index c14d64d1e..523544883 100644
--- a/tests/autopilot/autopilot/tests/test_dash.py
+++ b/tests/autopilot/autopilot/tests/test_dash.py
@@ -101,6 +101,51 @@ class DashTests(AutopilotTestCase):
# ... the lens bar should lose the key focus
self.assertEqual(self.dash.get_focused_lens_icon(), "")
+ def test_category_header_keynav_autoscroll(self):
+ """Test that the dash autoscroll when a category header gets
+ the focus.
+ """
+ self.dash.ensure_hidden()
+ self.dash.reveal_application_lens()
+
+ kb = Keyboard()
+ mouse = Mouse()
+
+ # Expand the first category
+ kb.press_and_release("Down")
+ kb.press_and_release("Enter")
+ category = self.dash.get_focused_category()
+
+ # Get the geometry of that category header.
+ x = category['header-x']
+ y = category['header-y']
+
+ # Manually scroll the dash.
+ mouse.move(x, y, True)
+ mouse.click(5)
+ mouse.click(5)
+ mouse.click(5)
+
+ cached_x = x
+ cached_y = y
+
+ # Focus the search bar with the mouse
+ x, y, w, h = self.dash.get_searchbar_geometry()
+ mouse.move(x+100, y+h/2, True)
+ mouse.click()
+ sleep(2)
+
+ # Then focus again the first category header
+ kb.press_and_release("Down")
+ kb.press_and_release("Enter")
+ category = self.dash.get_focused_category()
+ x = category['header-x']
+ y = category['header-y']
+
+ # Make sure the dash autoscroll
+ self.assertEqual(x, cached_x)
+ self.assertEqual(y, cached_y)
+
def test_category_header_keynav(self):
""" This test makes sure that:
1. A category header can get the focus.
@@ -134,8 +179,22 @@ class DashTests(AutopilotTestCase):
category = self.dash.get_focused_category()
self.assertEqual(category, None)
-
-
+
+ def test_backward_keynav(self):
+ """Test that the backward keyboard navigation works well."""
+ self.dash.ensure_hidden()
+ self.dash.reveal_application_lens()
+ kb = Keyboard()
+
+ # Moves the key focus to the lensbar
+ for i in range(self.dash.get_num_rows()):
+ kb.press_and_release("Down")
+ self.assertIsNot(self.dash.get_focused_lens_icon(), '')
+
+ # backward key navigation...
+ for i in range(self.dash.get_num_rows()):
+ kb.press_and_release("Up")
+ self.assertTrue(self.dash.searchbar_has_focus())
diff --git a/tests/test_icon_loader.cpp b/tests/test_icon_loader.cpp
index 0c9a42a1b..eb3eaf4ca 100644
--- a/tests/test_icon_loader.cpp
+++ b/tests/test_icon_loader.cpp
@@ -85,6 +85,72 @@ TEST(TestIconLoader, TestGetOneIcon)
g_source_remove (tid);
}
+TEST(TestIconLoader, TestGetOneIconManyTimes)
+{
+ std::vector<LoadResult> results;
+ std::vector<int> handles;
+ IconLoader& icon_loader = IconLoader::GetDefault();
+ volatile bool timeout_reached = false;
+ int i, load_count;
+
+ // 100 times should be good
+ load_count = 100;
+ results.resize (load_count);
+ handles.resize (load_count);
+
+ // careful, don't use the same icon as in previous tests, otherwise it'll
+ // be cached already!
+ for (int i = 0; i < load_count; i++)
+ {
+ handles[i] = icon_loader.LoadFromIconName("web-browser", 48,
+ sigc::mem_fun(results[i], &LoadResult::IconLoaded));
+ }
+
+ // disconnect every other handler (and especially the first one)
+ for (i = 0; i < load_count; i += 2)
+ {
+ icon_loader.DisconnectHandle(handles[i]);
+ }
+
+ guint tid = g_timeout_add (10000, TimeoutReached, (gpointer)(&timeout_reached));
+ int iterations = 0;
+ while (!timeout_reached)
+ {
+ g_main_context_iteration (NULL, TRUE);
+ bool all_loaded = true;
+ bool any_loaded = false;
+ for (i = 1; i < load_count; i += 2)
+ {
+ all_loaded &= results[i].got_callback;
+ any_loaded |= results[i].got_callback;
+ if (!all_loaded) break;
+ }
+ // count the number of iterations where we got some results
+ if (any_loaded) iterations++;
+ if (all_loaded) break;
+ }
+
+ EXPECT_FALSE(timeout_reached);
+ // it's all loading the same icon, the results had to come in the same
+ // main loop iteration (that's the desired behaviour)
+ EXPECT_EQ(iterations, 1);
+
+ for (i = 0; i < load_count; i++)
+ {
+ if (i % 2)
+ {
+ EXPECT_TRUE(results[i].got_callback);
+ EXPECT_TRUE(IsValidPixbuf(results[i].pixbuf));
+ }
+ else
+ {
+ EXPECT_FALSE(results[i].got_callback);
+ }
+ }
+
+ g_source_remove (tid);
+}
+
TEST(TestIconLoader, TestGetManyIcons)
{
std::vector<LoadResult> results;
diff --git a/tests/test_launcher_model.cpp b/tests/test_launcher_model.cpp
index e64d3b9d6..476c37fb7 100644
--- a/tests/test_launcher_model.cpp
+++ b/tests/test_launcher_model.cpp
@@ -41,12 +41,12 @@ class EventListener
icon_removed = false;
}
- void OnIconAdded (AbstractLauncherIcon* icon)
+ void OnIconAdded (AbstractLauncherIcon::Ptr icon)
{
icon_added = true;
}
- void OnIconRemoved (AbstractLauncherIcon* icon)
+ void OnIconRemoved (AbstractLauncherIcon::Ptr icon)
{
icon_removed = true;
}
@@ -64,7 +64,7 @@ TEST(TestLauncherModel, TestConstructor)
TEST(TestLauncherModel, TestAdd)
{
- AbstractLauncherIcon* first = new MockLauncherIcon();
+ AbstractLauncherIcon::Ptr first(new MockLauncherIcon());
LauncherModel::Ptr model(new LauncherModel());
EXPECT_EQ(model->Size(), 0);
@@ -74,7 +74,7 @@ TEST(TestLauncherModel, TestAdd)
TEST(TestLauncherModel, TestRemove)
{
- AbstractLauncherIcon* first = new MockLauncherIcon();
+ AbstractLauncherIcon::Ptr first(new MockLauncherIcon());
LauncherModel::Ptr model(new LauncherModel());
EXPECT_EQ(model->Size(), 0);
@@ -86,7 +86,7 @@ TEST(TestLauncherModel, TestRemove)
TEST(TestLauncherModel, TestAddSignal)
{
- AbstractLauncherIcon* first = new MockLauncherIcon();
+ AbstractLauncherIcon::Ptr first(new MockLauncherIcon());
LauncherModel::Ptr model(new LauncherModel());
EventListener *listener = new EventListener();
@@ -100,7 +100,7 @@ TEST(TestLauncherModel, TestAddSignal)
TEST(TestLauncherModel, TestRemoveSignal)
{
- AbstractLauncherIcon* first = new MockLauncherIcon();
+ AbstractLauncherIcon::Ptr first(new MockLauncherIcon());
LauncherModel::Ptr model(new LauncherModel());
EventListener *listener = new EventListener();
@@ -116,10 +116,10 @@ TEST(TestLauncherModel, TestRemoveSignal)
TEST(TestLauncherModel, TestSort)
{
- AbstractLauncherIcon* first = new MockLauncherIcon();
- AbstractLauncherIcon* second = new MockLauncherIcon();
- AbstractLauncherIcon* third = new MockLauncherIcon();
- AbstractLauncherIcon* fourth = new MockLauncherIcon();
+ AbstractLauncherIcon::Ptr first(new MockLauncherIcon());
+ AbstractLauncherIcon::Ptr second(new MockLauncherIcon());
+ AbstractLauncherIcon::Ptr third(new MockLauncherIcon());
+ AbstractLauncherIcon::Ptr fourth(new MockLauncherIcon());
LauncherModel::Ptr model(new LauncherModel());
@@ -149,10 +149,10 @@ TEST(TestLauncherModel, TestSort)
TEST(TestLauncherModel, TestReorderBefore)
{
- AbstractLauncherIcon* first = new MockLauncherIcon();
- AbstractLauncherIcon* second = new MockLauncherIcon();
- AbstractLauncherIcon* third = new MockLauncherIcon();
- AbstractLauncherIcon* fourth = new MockLauncherIcon();
+ AbstractLauncherIcon::Ptr first(new MockLauncherIcon());
+ AbstractLauncherIcon::Ptr second(new MockLauncherIcon());
+ AbstractLauncherIcon::Ptr third(new MockLauncherIcon());
+ AbstractLauncherIcon::Ptr fourth(new MockLauncherIcon());
LauncherModel::Ptr model(new LauncherModel());
@@ -182,10 +182,10 @@ TEST(TestLauncherModel, TestReorderBefore)
TEST(TestLauncherModel, TestReorderSmart)
{
- AbstractLauncherIcon* first = new MockLauncherIcon();
- AbstractLauncherIcon* second = new MockLauncherIcon();
- AbstractLauncherIcon* third = new MockLauncherIcon();
- AbstractLauncherIcon* fourth = new MockLauncherIcon();
+ AbstractLauncherIcon::Ptr first(new MockLauncherIcon());
+ AbstractLauncherIcon::Ptr second(new MockLauncherIcon());
+ AbstractLauncherIcon::Ptr third(new MockLauncherIcon());
+ AbstractLauncherIcon::Ptr fourth(new MockLauncherIcon());
LauncherModel::Ptr model(new LauncherModel());