summaryrefslogtreecommitdiff
diff options
-rw-r--r--dash/DashController.cpp24
-rw-r--r--dash/DashController.h3
-rw-r--r--hud/HudController.cpp14
-rw-r--r--launcher/ApplicationLauncherIcon.cpp2
-rw-r--r--launcher/BFBLauncherIcon.cpp1
-rw-r--r--launcher/DndData.h8
-rw-r--r--launcher/EdgeBarrierController.cpp17
-rw-r--r--launcher/EdgeBarrierControllerPrivate.h4
-rw-r--r--launcher/HudLauncherIcon.cpp2
-rw-r--r--launcher/Launcher.cpp1223
-rw-r--r--launcher/Launcher.h158
-rw-r--r--launcher/LauncherIcon.cpp43
-rw-r--r--launcher/SpacerLauncherIcon.cpp2
-rw-r--r--launcher/SwitcherController.cpp20
-rw-r--r--panel/PanelMenuView.cpp29
-rw-r--r--plugins/unityshell/src/unityshell.cpp133
-rw-r--r--plugins/unityshell/src/unityshell.h2
-rw-r--r--plugins/unityshell/unityshell.xml.in12
-rw-r--r--shortcuts/CompizShortcutModeller.cpp22
-rw-r--r--shortcuts/ShortcutController.cpp30
-rw-r--r--shortcuts/ShortcutView.cpp35
-rw-r--r--shortcuts/ShortcutView.h5
-rw-r--r--shutdown/SessionController.cpp32
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/autopilot/unity/emulators/launcher.py59
-rw-r--r--tests/autopilot/unity/tests/launcher/test_scroll.py4
-rw-r--r--tests/autopilot/unity/tests/test_hud.py5
-rw-r--r--tests/autopilot/unity/tests/test_ibus.py26
-rw-r--r--tests/autopilot/unity/tests/test_wm_keybindings.py110
-rw-r--r--tests/test_animation_utils.cpp271
-rw-r--r--tests/test_edge_barrier_controller.cpp24
-rw-r--r--tests/test_icon_loader.cpp19
-rw-r--r--tests/test_launcher.cpp64
-rw-r--r--unity-shared/AnimationUtils-inl.h52
-rw-r--r--unity-shared/AnimationUtils.h76
-rw-r--r--unity-shared/PluginAdapter.cpp69
-rw-r--r--unity-shared/PluginAdapter.h8
-rw-r--r--unity-shared/StandaloneWindowManager.cpp78
-rw-r--r--unity-shared/StandaloneWindowManager.h8
-rw-r--r--unity-shared/UBusMessages.h7
-rw-r--r--unity-shared/WindowManager.h6
41 files changed, 1578 insertions, 1130 deletions
diff --git a/dash/DashController.cpp b/dash/DashController.cpp
index dab7214e9..5b00715e5 100644
--- a/dash/DashController.cpp
+++ b/dash/DashController.cpp
@@ -25,6 +25,7 @@
#include "UnityCore/GSettingsScopes.h"
#include "ApplicationStarterImp.h"
+#include "unity-shared/AnimationUtils.h"
#include "unity-shared/DashStyle.h"
#include "unity-shared/PanelStyle.h"
#include "unity-shared/UBusMessages.h"
@@ -67,7 +68,6 @@ Controller::Controller(Controller::WindowCreator const& create_window)
, monitor_(0)
, visible_(false)
, need_show_(false)
- , view_(nullptr)
, ensure_timeout_(PRELOAD_TIMEOUT_LENGTH)
, timeline_animator_(90)
{
@@ -142,10 +142,10 @@ void Controller::SetupWindow()
void Controller::SetupDashView()
{
view_ = new DashView(std::make_shared<GSettingsScopes>(), std::make_shared<ApplicationStarterImp>());
- AddChild(view_);
+ AddChild(view_.GetPointer());
nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
- layout->AddView(view_, 1);
+ layout->AddView(view_.GetPointer(), 1);
layout->SetContentDistribution(nux::MAJOR_POSITION_START);
layout->SetVerticalExternalMargin(0);
layout->SetHorizontalExternalMargin(0);
@@ -378,18 +378,7 @@ void Controller::HideDash(bool restore)
void Controller::StartShowHideTimeline()
{
EnsureDash();
-
- if (timeline_animator_.CurrentState() == nux::animation::Animation::State::Running)
- {
- timeline_animator_.Reverse();
- }
- else
- {
- if (visible_)
- timeline_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
- else
- timeline_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start();
- }
+ animation::StartOrReverseIf(timeline_animator_, visible_);
}
void Controller::OnViewShowHideFrame(double opacity)
@@ -477,6 +466,11 @@ nux::Geometry Controller::GetInputWindowGeometry()
return geo;
}
+nux::ObjectPtr<DashView> const& Controller::Dash() const
+{
+ return view_;
+}
+
}
}
diff --git a/dash/DashController.h b/dash/DashController.h
index da8d064d5..ae9b992a4 100644
--- a/dash/DashController.h
+++ b/dash/DashController.h
@@ -68,6 +68,7 @@ public:
bool IsVisible() const;
bool IsCommandLensOpen() const;
nux::Geometry GetInputWindowGeometry();
+ nux::ObjectPtr<DashView> const& Dash() const;
protected:
std::string GetName() const;
@@ -99,11 +100,11 @@ private:
private:
WindowCreator create_window_;
nux::ObjectPtr<ResizingBaseWindow> window_;
+ nux::ObjectPtr<DashView> view_;
int monitor_;
bool visible_;
bool need_show_;
- DashView* view_;
connection::Wrapper screen_ungrabbed_slot_;
glib::DBusServer dbus_server_;
diff --git a/hud/HudController.cpp b/hud/HudController.cpp
index 61b642236..a22a55d2a 100644
--- a/hud/HudController.cpp
+++ b/hud/HudController.cpp
@@ -22,6 +22,7 @@
#include <Nux/HLayout.h>
#include <UnityCore/Variant.h>
+#include "unity-shared/AnimationUtils.h"
#include "unity-shared/ApplicationManager.h"
#include "unity-shared/WindowManager.h"
#include "unity-shared/PanelStyle.h"
@@ -437,18 +438,7 @@ void Controller::HideHud(bool restore)
void Controller::StartShowHideTimeline()
{
EnsureHud();
-
- if (timeline_animator_.CurrentState() == nux::animation::Animation::State::Running)
- {
- timeline_animator_.Reverse();
- }
- else
- {
- if (visible_)
- timeline_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
- else
- timeline_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start();
- }
+ animation::StartOrReverseIf(timeline_animator_, visible_);
}
void Controller::OnViewShowHideFrame(double opacity)
diff --git a/launcher/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp
index 12d737cde..73aa1efb6 100644
--- a/launcher/ApplicationLauncherIcon.cpp
+++ b/launcher/ApplicationLauncherIcon.cpp
@@ -18,6 +18,7 @@
* Marco Trevisan (TreviƱo) <3v1n0@ubuntu.com>
*/
+#include "config.h"
#include <boost/algorithm/string.hpp>
#include <Nux/Nux.h>
@@ -30,7 +31,6 @@
#include "ApplicationLauncherIcon.h"
#include "FavoriteStore.h"
-#include "Launcher.h"
#include "MultiMonitor.h"
#include "unity-shared/DesktopApplicationManager.h"
#include "unity-shared/GnomeFileManager.h"
diff --git a/launcher/BFBLauncherIcon.cpp b/launcher/BFBLauncherIcon.cpp
index 4480abede..6d0550b22 100644
--- a/launcher/BFBLauncherIcon.cpp
+++ b/launcher/BFBLauncherIcon.cpp
@@ -23,7 +23,6 @@
#include "unity-shared/UBusMessages.h"
#include "BFBLauncherIcon.h"
-#include "Launcher.h"
namespace unity
{
diff --git a/launcher/DndData.h b/launcher/DndData.h
index 48c5014bc..3a0f8aebc 100644
--- a/launcher/DndData.h
+++ b/launcher/DndData.h
@@ -42,22 +42,22 @@ public:
/**
* Returns a std::set<std::string> with all the uris.
**/
- std::set<std::string> const& Uris() const { return uris_; }
+ std::set<std::string> Uris() const { return uris_; }
/**
* Returns a std::set<std::string> with all the types.
**/
- std::set<std::string> const& Types() const { return types_; }
+ std::set<std::string> Types() const { return types_; }
/**
* Returns a std::set<std::string> with all uris of a given type.
**/
- std::set<std::string> const& UrisByType(const std::string& type) const { return types_to_uris_.find(type)->second; }
+ std::set<std::string> UrisByType(const std::string& type) const { return types_to_uris_.find(type)->second; }
/**
* Returns a std::set<std::string> with all types of a given uri.
**/
- std::string const& TypeByUri(const std::string& uris) { return uris_to_types_.find(uris)->second; }
+ std::string TypeByUri(const std::string& uris) { return uris_to_types_.find(uris)->second; }
private:
std::set<std::string> uris_;
diff --git a/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp
index bf2816907..0b85da89e 100644
--- a/launcher/EdgeBarrierController.cpp
+++ b/launcher/EdgeBarrierController.cpp
@@ -86,10 +86,12 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent)
auto monitors = uscreen->GetMonitors();
ResizeBarrierList(monitors);
- uscreen->changed.connect([&](int primary, std::vector<nux::Geometry>& layout) {
+ /* FIXME: Back to c++11 lambda once we get sigc::track_obj.
+ uscreen->changed.connect(sigc::track_obj(([&](int primary, std::vector<nux::Geometry>& layout) {
ResizeBarrierList(layout);
SetupBarriers(layout);
- });
+ }));*/
+ uscreen->changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnUScreenChanged));
parent_->sticky_edges.SetGetterFunction([this] {
return parent_->options() ? parent_->options()->edge_resist() : false;
@@ -105,9 +107,12 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent)
});
parent_->options.changed.connect([&](launcher::Options::Ptr options) {
+ /* FIXME: Back to c++11 lambda once we get sigc::track_obj.
options->option_changed.connect([&]() {
SetupBarriers(UScreen::GetDefault()->GetMonitors());
- });
+ });*/
+ options->option_changed.connect(sigc::bind<1>(sigc::mem_fun(this, &EdgeBarrierController::Impl::SetupBarriers),
+ UScreen::GetDefault()->GetMonitors()));
SetupBarriers(UScreen::GetDefault()->GetMonitors());
});
@@ -119,6 +124,12 @@ EdgeBarrierController::Impl::~Impl()
nux::GetGraphicsDisplay()->RemoveEventFilter(this);
}
+void EdgeBarrierController::Impl::OnUScreenChanged(int primary, std::vector<nux::Geometry>& layout)
+{
+ ResizeBarrierList(layout);
+ SetupBarriers(layout);
+}
+
void EdgeBarrierController::Impl::AddSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers)
{
if (monitor >= subscribers.size())
diff --git a/launcher/EdgeBarrierControllerPrivate.h b/launcher/EdgeBarrierControllerPrivate.h
index 91659cd58..834322c26 100644
--- a/launcher/EdgeBarrierControllerPrivate.h
+++ b/launcher/EdgeBarrierControllerPrivate.h
@@ -30,7 +30,7 @@ namespace ui
{
// NOTE: This private header is not part of the public interface
-struct EdgeBarrierController::Impl
+struct EdgeBarrierController::Impl : public sigc::trackable
{
Impl(EdgeBarrierController *parent);
~Impl();
@@ -41,6 +41,8 @@ struct EdgeBarrierController::Impl
void ResizeBarrierList(std::vector<nux::Geometry> const& layout);
void SetupBarriers(std::vector<nux::Geometry> const& layout);
+ void OnUScreenChanged(int primary, std::vector<nux::Geometry>& layout);
+
void OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event);
void BarrierPush(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event);
void BarrierRelease(PointerBarrierWrapper* owner, int event);
diff --git a/launcher/HudLauncherIcon.cpp b/launcher/HudLauncherIcon.cpp
index 39fa01a0d..ff579473a 100644
--- a/launcher/HudLauncherIcon.cpp
+++ b/launcher/HudLauncherIcon.cpp
@@ -18,13 +18,13 @@
*/
#include "HudLauncherIcon.h"
-#include "Launcher.h"
#include "UnityCore/GLibWrapper.h"
#include "UnityCore/Variant.h"
#include <NuxCore/Logger.h>
#include "unity-shared/UBusMessages.h"
+#include "config.h"
#include <glib/gi18n-lib.h>
namespace unity
diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp
index 2600c6038..87051bb07 100644
--- a/launcher/Launcher.cpp
+++ b/launcher/Launcher.cpp
@@ -19,51 +19,35 @@
*/
#include "config.h"
-#include <math.h>
-
-#include <functional>
#include <Nux/Nux.h>
-#include <Nux/VScrollBar.h>
-#include <Nux/HLayout.h>
-#include <Nux/VLayout.h>
#include <NuxCore/Logger.h>
-#include <NuxGraphics/NuxGraphics.h>
-#include <NuxGraphics/GestureEvent.h>
-#include <NuxGraphics/GpuDevice.h>
-#include <NuxGraphics/GLTextureResourceManager.h>
-
-#include <Nux/BaseWindow.h>
-#include <Nux/WindowCompositor.h>
-
#include "Launcher.h"
#include "AbstractLauncherIcon.h"
-#include "unity-shared/PanelStyle.h"
#include "SpacerLauncherIcon.h"
#include "LauncherModel.h"
#include "QuicklistManager.h"
#include "QuicklistView.h"
+#include "unity-shared/AnimationUtils.h"
#include "unity-shared/IconRenderer.h"
-#include "unity-shared/TimeUtil.h"
-#include "unity-shared/TextureCache.h"
+#include "unity-shared/GraphicsUtils.h"
#include "unity-shared/IconLoader.h"
+#include "unity-shared/PanelStyle.h"
+#include "unity-shared/TextureCache.h"
+#include "unity-shared/TimeUtil.h"
#include "unity-shared/UScreen.h"
#include "unity-shared/UBusMessages.h"
#include "unity-shared/UnitySettings.h"
-#include "unity-shared/GraphicsUtils.h"
-
#include <UnityCore/GLibWrapper.h>
#include <UnityCore/Variant.h>
#include <boost/algorithm/string.hpp>
-#include <sigc++/sigc++.h>
namespace unity
{
using ui::RenderArg;
-using ui::Decaymulator;
namespace launcher
{
@@ -90,8 +74,15 @@ const int ANIM_DURATION = 200;
const int ANIM_DURATION_LONG = 350;
const int START_DRAGICON_DURATION = 250;
+const int DEFAULT_ICON_SIZE = 48;
+const int DEFAULT_ICON_SIZE_DELTA = 6;
+const int SPACE_BETWEEN_ICONS = 5;
+
const int MOUSE_DEADZONE = 15;
+
const float DRAG_OUT_PIXELS = 300.0f;
+const float FOLDED_Z_DISTANCE = 10.f;
+const float NEG_FOLDED_ANGLE = -1.0f;
const int SCROLL_AREA_HEIGHT = 24;
const int SCROLL_FPS = 30;
@@ -106,7 +97,6 @@ const std::string ANIMATION_IDLE = "animation-idle";
const std::string URGENT_TIMEOUT = "urgent-timeout";
}
-
NUX_IMPLEMENT_OBJECT_TYPE(Launcher);
const int Launcher::Launcher::ANIM_DURATION_SHORT = 125;
@@ -114,69 +104,62 @@ const int Launcher::Launcher::ANIM_DURATION_SHORT = 125;
Launcher::Launcher(MockableBaseWindow* parent,
NUX_FILE_LINE_DECL)
: View(NUX_FILE_LINE_PARAM)
-#ifdef USE_X11
- , display(nux::GetGraphicsDisplay()->GetX11Display())
-#else
- , display(0)
-#endif
, monitor(0)
- , _parent(parent)
- , _active_quicklist(nullptr)
- , _hovered(false)
- , _hidden(false)
- , _shortcuts_shown(false)
- , _data_checked(false)
- , _steal_drag(false)
- , _drag_edge_touching(false)
- , _initial_drag_animation(false)
- , _dash_is_open(false)
- , _hud_is_open(false)
- , _folded_angle(1.0f)
- , _neg_folded_angle(-1.0f)
- , _folded_z_distance(10.0f)
- , _edge_overcome_pressure(0.0f)
- , _launcher_action_state(ACTION_NONE)
- , _space_between_icons(5)
- , _icon_image_size(48)
- , _icon_image_size_delta(6)
- , _icon_glow_size(62)
- , _icon_size(_icon_image_size + _icon_image_size_delta)
- , _dnd_delta_y(0)
- , _dnd_delta_x(0)
- , _postreveal_mousemove_delta_x(0)
- , _postreveal_mousemove_delta_y(0)
- , _launcher_drag_delta(0)
- , _launcher_drag_delta_max(0)
- , _launcher_drag_delta_min(0)
- , _enter_y(0)
- , _last_button_press(0)
- , _urgent_wiggle_time(0)
- , _urgent_acked(false)
- , _urgent_timer_running(false)
- , _urgent_ack_needed(false)
- , _drag_out_delta_x(0.0f)
- , _drag_gesture_ongoing(false)
- , _last_reveal_progress(0.0f)
- , _drag_action(nux::DNDACTION_NONE)
- , _selection_atom(0)
+ , parent_(parent)
+ , icon_renderer_(std::make_shared<ui::IconRenderer>())
+ , active_quicklist_(nullptr)
+ , hovered_(false)
+ , hidden_(false)
+ , folded_(true)
+ , shortcuts_shown_(false)
+ , data_checked_(false)
+ , steal_drag_(false)
+ , drag_edge_touching_(false)
+ , initial_drag_animation_(false)
+ , dash_is_open_(false)
+ , hud_is_open_(false)
+ , launcher_action_state_(ACTION_NONE)
+ , icon_size_(DEFAULT_ICON_SIZE + DEFAULT_ICON_SIZE_DELTA)
+ , dnd_delta_y_(0)
+ , dnd_delta_x_(0)
+ , postreveal_mousemove_delta_x_(0)
+ , postreveal_mousemove_delta_y_(0)
+ , launcher_drag_delta_(0)
+ , launcher_drag_delta_max_(0)
+ , launcher_drag_delta_min_(0)
+ , enter_y_(0)
+ , last_button_press_(0)
+ , urgent_wiggle_time_(0)
+ , urgent_acked_(false)
+ , urgent_timer_running_(false)
+ , urgent_ack_needed_(false)
+ , drag_out_delta_x_(0.0f)
+ , drag_gesture_ongoing_(false)
+ , last_reveal_progress_(0.0f)
+ , drag_action_(nux::DNDACTION_NONE)
+ , auto_hide_animation_(ANIM_DURATION_SHORT)
+ , hover_animation_(ANIM_DURATION)
+ , drag_over_animation_(ANIM_DURATION_LONG)
+ , drag_out_animation_(ANIM_DURATION_SHORT)
+ , drag_icon_animation_(ANIM_DURATION_SHORT)
+ , dnd_hide_animation_(ANIM_DURATION * 3)
, dash_showing_animation_(90)
- , icon_renderer(std::make_shared<ui::IconRenderer>())
{
- m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
- icon_renderer->monitor = monitor();
+ icon_renderer_->monitor = monitor();
+ icon_renderer_->SetTargetSize(icon_size_, DEFAULT_ICON_SIZE, SPACE_BETWEEN_ICONS);
bg_effect_helper_.owner = this;
bg_effect_helper_.enabled = false;
- SetCompositionLayout(m_Layout);
CaptureMouseDownAnyWhereElse(true);
SetAcceptKeyNavFocusOnMouseDown(false);
SetAcceptMouseWheelEvent(true);
SetDndEnabled(false, true);
- _hide_machine.should_hide_changed.connect(sigc::mem_fun(this, &Launcher::SetHidden));
- _hide_machine.reveal_progress.changed.connect([&](float value) { EnsureAnimation(); });
- _hover_machine.should_hover_changed.connect(sigc::mem_fun(this, &Launcher::SetHover));
+ auto const& redraw_cb = sigc::hide(sigc::mem_fun(this, &Launcher::QueueDraw));
+ hide_machine_.should_hide_changed.connect(sigc::mem_fun(this, &Launcher::SetHidden));
+ hide_machine_.reveal_progress.changed.connect(redraw_cb);
+ hover_machine_.should_hover_changed.connect(sigc::mem_fun(this, &Launcher::SetHover));
mouse_down.connect(sigc::mem_fun(this, &Launcher::RecvMouseDown));
mouse_up.connect(sigc::mem_fun(this, &Launcher::RecvMouseUp));
@@ -185,7 +168,6 @@ Launcher::Launcher(MockableBaseWindow* parent,
mouse_leave.connect(sigc::mem_fun(this, &Launcher::RecvMouseLeave));
mouse_move.connect(sigc::mem_fun(this, &Launcher::RecvMouseMove));
mouse_wheel.connect(sigc::mem_fun(this, &Launcher::RecvMouseWheel));
- //OnEndFocus.connect (sigc::mem_fun (this, &Launcher::exitKeyNavMode));
QuicklistManager& ql_manager = *(QuicklistManager::Default());
ql_manager.quicklist_opened.connect(sigc::mem_fun(this, &Launcher::RecvQuicklistOpened));
@@ -196,30 +178,29 @@ Launcher::Launcher(MockableBaseWindow* parent,
wm.initiate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));
wm.terminate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));
wm.terminate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged));
- wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &Launcher::EnsureAnimation));
-
- // 0 out timers to avoid wonky startups
- for (int i = 0; i < TIME_LAST; ++i)
- {
- _times[i].tv_sec = 0;
- _times[i].tv_nsec = 0;
- }
+ wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &Launcher::QueueDraw));
- _urgent_finished_time.tv_sec = 0;
- _urgent_finished_time.tv_nsec = 0;
+ urgent_finished_time_.tv_sec = 0;
+ urgent_finished_time_.tv_nsec = 0;
ubus_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &Launcher::OnOverlayShown));
ubus_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &Launcher::OnOverlayHidden));
ubus_.RegisterInterest(UBUS_LAUNCHER_LOCK_HIDE, sigc::mem_fun(this, &Launcher::OnLockHideChanged));
- icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons);
-
TextureCache& cache = TextureCache::GetDefault();
launcher_sheen_ = cache.FindTexture("dash_sheen.png");
launcher_pressure_effect_ = cache.FindTexture("launcher_pressure_effect.png");
options.changed.connect(sigc::mem_fun(this, &Launcher::OnOptionsChanged));
monitor.changed.connect(sigc::mem_fun(this, &Launcher::OnMonitorChanged));
+
+ auto_hide_animation_.updated.connect(redraw_cb);
+ hover_animation_.updated.connect(redraw_cb);
+ drag_over_animation_.updated.connect(redraw_cb);
+ drag_out_animation_.updated.connect(redraw_cb);
+ drag_icon_animation_.updated.connect(redraw_cb);
+ dnd_hide_animation_.updated.connect(redraw_cb);
+ dash_showing_animation_.updated.connect(redraw_cb);
}
/* Introspection */
@@ -231,156 +212,105 @@ std::string Launcher::GetName() const
#ifdef NUX_GESTURES_SUPPORT
void Launcher::OnDragStart(const nux::GestureEvent &event)
{
- _drag_gesture_ongoing = true;
- if (_hidden)
+ drag_gesture_ongoing_ = true;
+ if (hidden_)
{
- _drag_out_delta_x = 0.0f;
+ drag_out_delta_x_ = 0.0f;
}
else
{
- _drag_out_delta_x = DRAG_OUT_PIXELS;
- _hide_machine.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, false);
+ drag_out_delta_x_ = DRAG_OUT_PIXELS;
+ hide_machine_.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, false);
}
}
void Launcher::OnDragUpdate(const nux::GestureEvent &event)
{
- _drag_out_delta_x =
- CLAMP(_drag_out_delta_x + event.GetDelta().x, 0.0f, DRAG_OUT_PIXELS);
- EnsureAnimation();
+ drag_out_delta_x_ =
+ CLAMP(drag_out_delta_x_ + event.GetDelta().x, 0.0f, DRAG_OUT_PIXELS);
+ QueueDraw();
}
void Launcher::OnDragFinish(const nux::GestureEvent &event)
{
- if (_drag_out_delta_x >= DRAG_OUT_PIXELS - 90.0f)
- _hide_machine.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, true);
- TimeUtil::SetTimeStruct(&_times[TIME_DRAG_OUT],
- &_times[TIME_DRAG_OUT],
- ANIM_DURATION_SHORT);
- EnsureAnimation();
- _drag_gesture_ongoing = false;
+ if (drag_out_delta_x_ >= DRAG_OUT_PIXELS - 90.0f)
+ hide_machine_.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, true);
+
+ animation::StartOrReverse(drag_out_animation_, animation::Direction::BACKWARD);
+ drag_gesture_ongoing_ = false;
}
#endif
void Launcher::AddProperties(GVariantBuilder* builder)
{
- timespec current;
- clock_gettime(CLOCK_MONOTONIC, &current);
-
unity::variant::BuilderWrapper(builder)
.add(GetAbsoluteGeometry())
- .add("hover-progress", GetHoverProgress(current))
- .add("dnd-exit-progress", DnDExitProgress(current))
- .add("autohide-progress", AutohideProgress(current))
- .add("dnd-delta", _dnd_delta_y)
- .add("hovered", _hovered)
+ .add("hover-progress", hover_animation_.GetCurrentValue())
+ .add("dnd-exit-progress", drag_over_animation_.GetCurrentValue())
+ .add("autohide-progress", auto_hide_animation_.GetCurrentValue())
+ .add("dnd-delta", dnd_delta_y_)
+ .add("hovered", hovered_)
.add("hidemode", options()->hide_mode)
- .add("hidden", _hidden)
- .add("is_showing", ! _hidden)
+ .add("hidden", hidden_)
+ .add("is_showing", ! hidden_)
.add("monitor", monitor())
- .add("quicklist-open", _hide_machine.GetQuirk(LauncherHideMachine::QUICKLIST_OPEN))
- .add("hide-quirks", _hide_machine.DebugHideQuirks())
- .add("hover-quirks", _hover_machine.DebugHoverQuirks())
- .add("icon-size", _icon_size)
- .add("shortcuts_shown", _shortcuts_shown)
- .add("tooltip-shown", _active_tooltip != nullptr);
+ .add("quicklist-open", hide_machine_.GetQuirk(LauncherHideMachine::QUICKLIST_OPEN))
+ .add("hide-quirks", hide_machine_.DebugHideQuirks())
+ .add("hover-quirks", hover_machine_.DebugHoverQuirks())
+ .add("icon-size", icon_size_)
+ .add("shortcuts_shown", shortcuts_shown_)
+ .add("tooltip-shown", active_tooltip_ != nullptr);
}
void Launcher::SetMousePosition(int x, int y)
{
- bool beyond_drag_threshold = MouseBeyondDragThreshold();
- _mouse_position = nux::Point2(x, y);
+ bool was_beyond_drag_threshold = MouseBeyondDragThreshold();
+ mouse_position_ = nux::Point(x, y);
+ bool is_beyond_drag_threshold = MouseBeyondDragThreshold();
- if (beyond_drag_threshold != MouseBeyondDragThreshold())
- TimeUtil::SetTimeStruct(&_times[TIME_DRAG_THRESHOLD], &_times[TIME_DRAG_THRESHOLD], ANIM_DURATION_SHORT);
+ if (was_beyond_drag_threshold != is_beyond_drag_threshold)
+ animation::StartOrReverseIf(drag_icon_animation_, !is_beyond_drag_threshold);
EnsureScrollTimer();
}
void Launcher::SetStateMouseOverLauncher(bool over_launcher)
{
- _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_OVER_LAUNCHER, over_launcher);
- _hide_machine.SetQuirk(LauncherHideMachine::REVEAL_PRESSURE_PASS, false);
- _hover_machine.SetQuirk(LauncherHoverMachine::MOUSE_OVER_LAUNCHER, over_launcher);
+ hide_machine_.SetQuirk(LauncherHideMachine::MOUSE_OVER_LAUNCHER, over_launcher);
+ hide_machine_.SetQuirk(LauncherHideMachine::REVEAL_PRESSURE_PASS, false);
+ hover_machine_.SetQuirk(LauncherHoverMachine::MOUSE_OVER_LAUNCHER, over_launcher);
tooltip_manager_.SetHover(over_launcher);
}
void Launcher::SetIconUnderMouse(AbstractLauncherIcon::Ptr const& icon)
{
- if (_icon_under_mouse == icon)
+ if (icon_under_mouse_ == icon)
return;
- if (_icon_under_mouse)
- _icon_under_mouse->mouse_leave.emit(monitor);
+ if (icon_under_mouse_)
+ icon_under_mouse_->mouse_leave.emit(monitor);
if (icon)
icon->mouse_enter.emit(monitor);
- _icon_under_mouse = icon;
+ icon_under_mouse_ = icon;
}
bool Launcher::MouseBeyondDragThreshold() const
{
if (GetActionState() == ACTION_DRAG_ICON)
- return _mouse_position.x > GetGeometry().width + _icon_size / 2;
+ return mouse_position_.x > GetGeometry().width + icon_size_ / 2;
return false;
}
/* Render Layout Logic */
-float Launcher::GetHoverProgress(struct timespec const& current) const
+float Launcher::DragOutProgress() const
{
- if (_hovered)
- return CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_ENTER])) / (float) ANIM_DURATION, 0.0f, 1.0f);
- else
- return 1.0f - CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_LEAVE])) / (float) ANIM_DURATION, 0.0f, 1.0f);
-}
+ float progress = drag_out_delta_x_ / DRAG_OUT_PIXELS;
-float Launcher::DnDExitProgress(struct timespec const& current) const
-{
- return pow(1.0f - CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_END])) / (float) ANIM_DURATION_LONG, 0.0f, 1.0f), 2);
-}
-
-float Launcher::DragOutProgress(struct timespec const& current) const
-{
- float timeout = CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_OUT])) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
- float progress = CLAMP(_drag_out_delta_x / DRAG_OUT_PIXELS, 0.0f, 1.0f);
-
- if (_drag_gesture_ongoing
- || _hide_machine.GetQuirk(LauncherHideMachine::MT_DRAG_OUT))
+ if (drag_gesture_ongoing_ || hide_machine_.GetQuirk(LauncherHideMachine::MT_DRAG_OUT))
return progress;
else
- return progress * (1.0f - timeout);
-}
-
-float Launcher::AutohideProgress(struct timespec const& current) const
-{
- // time-based progress (full scale or finish the TRIGGER_AUTOHIDE_MIN -> 0.00f on bfb)
- float animation_progress;
- animation_progress = CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_AUTOHIDE])) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
- if (_hidden)
- return animation_progress;
- else
- return 1.0f - animation_progress;
-}
-
-float Launcher::DragHideProgress(struct timespec const& current) const
-{
- if (_drag_edge_touching)
- return CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_EDGE_TOUCH])) / (float)(ANIM_DURATION * 3), 0.0f, 1.0f);
- else
- return 1.0f - CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_EDGE_TOUCH])) / (float)(ANIM_DURATION * 3), 0.0f, 1.0f);
-}
-
-float Launcher::DragThresholdProgress(struct timespec const& current) const
-{
- if (MouseBeyondDragThreshold())
- return 1.0f - CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_THRESHOLD])) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
- else
- return CLAMP((float)(unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_THRESHOLD])) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
-}
-
-void Launcher::EnsureAnimation()
-{
- QueueDraw();
+ return progress * drag_out_animation_.GetCurrentValue();
}
bool Launcher::IconNeedsAnimation(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
@@ -445,43 +375,12 @@ bool Launcher::AnimationInProgress() const
// performance here can be improved by caching the longer remaining animation found and short circuiting to that each time
// this way extra checks may be avoided
- if (_last_reveal_progress != _hide_machine.reveal_progress)
- return true;
-
// short circuit to avoid unneeded calculations
struct timespec current;
clock_gettime(CLOCK_MONOTONIC, &current);
- // hover in animation
- if (unity::TimeUtil::TimeDelta(&current, &_times[TIME_ENTER]) < ANIM_DURATION)
- return true;
-
- // hover out animation
- if (unity::TimeUtil::TimeDelta(&current, &_times[TIME_LEAVE]) < ANIM_DURATION)
- return true;
-
- // drag end animation
- if (unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_END]) < ANIM_DURATION_LONG)
- return true;
-
- // hide animation (time only), position is trigger manually on the bfb
- if (unity::TimeUtil::TimeDelta(&current, &_times[TIME_AUTOHIDE]) < ANIM_DURATION_SHORT)
- return true;
-
- // collapse animation on DND out of launcher space
- if (unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_THRESHOLD]) < ANIM_DURATION_SHORT)
- return true;
-
- // hide animation for dnd
- if (unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_EDGE_TOUCH]) < ANIM_DURATION * 6)
- return true;
-
- // restore from drag_out animation
- if (unity::TimeUtil::TimeDelta(&current, &_times[TIME_DRAG_OUT]) < ANIM_DURATION_SHORT)
- return true;
-
// animations happening on specific icons
- for (auto const &icon : *_model)
+ for (auto const& icon : *model_)
if (IconNeedsAnimation(icon, current))
return true;
@@ -496,6 +395,7 @@ float Launcher::GetAutohidePositionMin() const
else
return 0.25f;
}
+
/* Max is the initial state over the bfb */
float Launcher::GetAutohidePositionMax() const
{
@@ -505,7 +405,6 @@ float Launcher::GetAutohidePositionMax() const
return 0.75f;
}
-
float Launcher::IconVisibleProgress(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
{
if (!icon->IsVisibleOnMonitor(monitor))
@@ -532,24 +431,24 @@ float Launcher::IconVisibleProgress(AbstractLauncherIcon::Ptr const& icon, struc
void Launcher::SetDndDelta(float x, float y, nux::Geometry const& geo, timespec const& current)
{
- AbstractLauncherIcon::Ptr const& anchor = MouseIconIntersection(x, _enter_y);
+ AbstractLauncherIcon::Ptr const& anchor = MouseIconIntersection(x, enter_y_);
if (anchor)
{
float position = y;
- for (AbstractLauncherIcon::Ptr const& model_icon : *_model)
+ for (AbstractLauncherIcon::Ptr const& model_icon : *model_)
{
if (model_icon == anchor)
{
- position += _icon_size / 2;
- _launcher_drag_delta = _enter_y - position;
+ position += icon_size_ / 2;
+ launcher_drag_delta_ = enter_y_ - position;
- if (position + _icon_size / 2 + _launcher_drag_delta > geo.height)
- _launcher_drag_delta -= (position + _icon_size / 2 + _launcher_drag_delta) - geo.height;
+ if (position + icon_size_ / 2 + launcher_drag_delta_ > geo.height)
+ launcher_drag_delta_ -= (position + icon_size_ / 2 + launcher_drag_delta_) - geo.height;
break;
}
- position += (_icon_size + _space_between_icons) * IconVisibleProgress(model_icon, current);
+ position += (icon_size_ + SPACE_BETWEEN_ICONS) * IconVisibleProgress(model_icon, current);
}
}
}
@@ -805,7 +704,7 @@ void Launcher::SetupRenderArg(AbstractLauncherIcon::Ptr const& icon, struct time
arg.keyboard_nav_hl = false;
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.draw_shortcut = shortcuts_shown_ && !hide_machine_.GetQuirk(LauncherHideMachine::PLACES_VISIBLE);
arg.system_item = icon->GetIconType() == AbstractLauncherIcon::IconType::HOME ||
icon->GetIconType() == AbstractLauncherIcon::IconType::HUD;
arg.colorify_background = icon->GetIconType() == AbstractLauncherIcon::IconType::HOME ||
@@ -882,7 +781,7 @@ void Launcher::SetupRenderArg(AbstractLauncherIcon::Ptr const& icon, struct time
if (IsInKeyNavMode())
{
- if (icon == _model->Selection())
+ if (icon == model_->Selection())
arg.keyboard_nav_hl = true;
}
}
@@ -923,31 +822,36 @@ void Launcher::FillRenderArg(AbstractLauncherIcon::Ptr const& icon,
arg.saturation = 0.0;
}
- if (icon == _drag_icon)
+ if (icon == drag_icon_)
{
- if (MouseBeyondDragThreshold())
+ bool mouse_beyond_drag_threshold = MouseBeyondDragThreshold();
+
+ if (mouse_beyond_drag_threshold)
arg.stick_thingy = true;
if (GetActionState() == ACTION_DRAG_ICON ||
- (_drag_window && _drag_window->Animating()) ||
+ (drag_window_ && drag_window_->Animating()) ||
icon->GetIconType() == AbstractLauncherIcon::IconType::SPACER)
{
arg.skip = true;
}
- size_modifier *= DragThresholdProgress(current);
+ if (drag_icon_animation_.CurrentState() == na::Animation::State::Running)
+ size_modifier *= drag_icon_animation_.GetCurrentValue();
+ else if (mouse_beyond_drag_threshold)
+ size_modifier = 0.0f;
}
if (size_modifier <= 0.0f)
arg.skip = true;
// goes for 0.0f when fully unfolded, to 1.0f folded
- float folding_progress = CLAMP((center.y + _icon_size - folding_threshold) / (float) _icon_size, 0.0f, 1.0f);
+ float folding_progress = CLAMP((center.y + icon_size_ - folding_threshold) / (float) icon_size_, 0.0f, 1.0f);
float unfold_progress = IconUnfoldProgress(icon, current);
folding_progress *= 1.0f - unfold_progress;
- float half_size = (folded_size / 2.0f) + (_icon_size / 2.0f - folded_size / 2.0f) * (1.0f - folding_progress);
+ float half_size = (folded_size / 2.0f) + (icon_size_ / 2.0f - folded_size / 2.0f) * (1.0f - folding_progress);
float icon_hide_offset = autohide_offset;
float present_progress = IconPresentProgress(icon, current);
@@ -957,8 +861,8 @@ void Launcher::FillRenderArg(AbstractLauncherIcon::Ptr const& icon,
center.z += folded_z_distance * folding_progress;
arg.rotation.x = animation_neg_rads * folding_progress;
- float spacing_overlap = CLAMP((float)(center.y + (2.0f * half_size * size_modifier) + (_space_between_icons * size_modifier) - folding_threshold) / (float) _icon_size, 0.0f, 1.0f);
- float spacing = (_space_between_icons * (1.0f - spacing_overlap) + folded_spacing * spacing_overlap) * size_modifier;
+ float spacing_overlap = CLAMP((float)(center.y + (2.0f * half_size * size_modifier) + (SPACE_BETWEEN_ICONS * size_modifier) - folding_threshold) / (float) icon_size_, 0.0f, 1.0f);
+ float spacing = (SPACE_BETWEEN_ICONS * (1.0f - spacing_overlap) + folded_spacing * spacing_overlap) * size_modifier;
nux::Point3 centerOffset;
float center_transit_progress = IconCenterTransitionProgress(icon, current);
@@ -976,10 +880,10 @@ void Launcher::FillRenderArg(AbstractLauncherIcon::Ptr const& icon,
icon->SetCenter(nux::Point3(roundf(center.x), roundf(center.y), roundf(center.z)), monitor, parent_abs_geo);
// FIXME: this is a hack, to avoid that we set the target to the end of the icon
- if (!_initial_drag_animation && icon == _drag_icon && _drag_window && _drag_window->Animating())
+ if (!initial_drag_animation_ && icon == drag_icon_ && drag_window_ && drag_window_->Animating())
{
- auto const& icon_center = _drag_icon->GetCenter(monitor);
- _drag_window->SetAnimationTarget(icon_center.x, icon_center.y);
+ auto const& icon_center = drag_icon_->GetCenter(monitor);
+ drag_window_->SetAnimationTarget(icon_center.x, icon_center.y);
}
center.y += (half_size * size_modifier) + spacing; // move to end
@@ -1015,28 +919,29 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args,
nux::Color const& colorify = FullySaturateColor(options()->background_color);
- float hover_progress = GetHoverProgress(current);
- float folded_z_distance = _folded_z_distance * (1.0f - hover_progress);
- float animation_neg_rads = _neg_folded_angle * (1.0f - hover_progress);
+ float hover_progress = folded_ ? hover_animation_.GetCurrentValue() : 1.0f;
+ float folded_z_distance = FOLDED_Z_DISTANCE * (1.0f - hover_progress);
+ float animation_neg_rads = NEG_FOLDED_ANGLE * (1.0f - hover_progress);
float folding_constant = 0.25f;
float folding_not_constant = folding_constant + ((1.0f - folding_constant) * hover_progress);
- float folded_size = _icon_size * folding_not_constant;
- float folded_spacing = _space_between_icons * folding_not_constant;
+ float folded_size = icon_size_ * folding_not_constant;
+ float folded_spacing = SPACE_BETWEEN_ICONS * folding_not_constant;
center.x = geo.width / 2;
- center.y = _space_between_icons;
+ center.y = SPACE_BETWEEN_ICONS;
center.z = 0;
int launcher_height = geo.height;
+ folded_ = true;
// compute required height of launcher AND folding threshold
float sum = 0.0f + center.y;
- float folding_threshold = launcher_height - _icon_size / 2.5f;
- for (it = _model->begin(); it != _model->end(); ++it)
+ float folding_threshold = launcher_height - icon_size_ / 2.5f;
+ for (it = model_->begin(); it != model_->end(); ++it)
{
- float height = (_icon_size + _space_between_icons) * IconVisibleProgress(*it, current);
+ float height = (icon_size_ + SPACE_BETWEEN_ICONS) * IconVisibleProgress(*it, current);
sum += height;
// magic constant must some day be explained, for now suffice to say this constant prevents the bottom from "marching";
@@ -1046,15 +951,18 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args,
folding_threshold -= CLAMP(sum - launcher_height, 0.0f, height * magic_constant) * (folding_constant + (1.0f - folding_constant) * unfold_progress);
}
- if (sum - _space_between_icons <= launcher_height)
+ if (sum - SPACE_BETWEEN_ICONS <= launcher_height)
+ {
folding_threshold = launcher_height;
+ folded_ = false;
+ }
float autohide_offset = 0.0f;
*launcher_alpha = 1.0f;
- if (options()->hide_mode != LAUNCHER_HIDE_NEVER || _hide_machine.GetQuirk(LauncherHideMachine::LOCK_HIDE))
+ if (options()->hide_mode != LAUNCHER_HIDE_NEVER || hide_machine_.GetQuirk(LauncherHideMachine::LOCK_HIDE))
{
- float autohide_progress = AutohideProgress(current) * (1.0f - DragOutProgress(current));
- if (_dash_is_open)
+ float autohide_progress = auto_hide_animation_.GetCurrentValue() * (1.0f - DragOutProgress());
+ if (dash_is_open_)
{
*launcher_alpha = dash_showing_animation_.GetCurrentValue();
}
@@ -1073,19 +981,19 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args,
}
}
- float drag_hide_progress = DragHideProgress(current);
+ float drag_hide_progress = dnd_hide_animation_.GetCurrentValue();
if (options()->hide_mode != LAUNCHER_HIDE_NEVER && drag_hide_progress > 0.0f)
{
autohide_offset -= geo.width * 0.25f * drag_hide_progress;
if (drag_hide_progress >= 1.0f)
- _hide_machine.SetQuirk(LauncherHideMachine::DND_PUSHED_OFF, true);
+ hide_machine_.SetQuirk(LauncherHideMachine::DND_PUSHED_OFF, true);
}
// Inform the painter where to paint the box
box_geo = geo;
- if (options()->hide_mode != LAUNCHER_HIDE_NEVER || _hide_machine.GetQuirk(LauncherHideMachine::LOCK_HIDE))
+ if (options()->hide_mode != LAUNCHER_HIDE_NEVER || hide_machine_.GetQuirk(LauncherHideMachine::LOCK_HIDE))
box_geo.x += autohide_offset;
/* Why we need last_geo? It stores the last box_geo (note: as it is a static variable,
@@ -1097,39 +1005,39 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args,
static nux::Geometry last_geo = box_geo;
// this happens on hover, basically its a flag and a value in one, we translate this into a dnd offset
- if (_enter_y != 0 && _enter_y + _icon_size / 2 > folding_threshold)
+ if (enter_y_ != 0 && enter_y_ + icon_size_ / 2 > folding_threshold)
SetDndDelta(last_geo.x + last_geo.width / 2, center.y, geo, current);
// Update the last_geo value.
last_geo = box_geo;
- _enter_y = 0;
+ enter_y_ = 0;
-
// logically dnd exit only restores to the clamped ranges
// hover_progress restores to 0
- _launcher_drag_delta_max = 0.0f;
- _launcher_drag_delta_min = MIN(0.0f, launcher_height - sum);
+ launcher_drag_delta_max_ = 0.0f;
+ launcher_drag_delta_min_ = MIN(0.0f, launcher_height - sum);
- if (hover_progress > 0.0f && _launcher_drag_delta != 0)
+ if (hover_progress > 0.0f && launcher_drag_delta_ != 0)
{
- float delta_y = _launcher_drag_delta;
+ float delta_y = launcher_drag_delta_;
- if (_launcher_drag_delta > _launcher_drag_delta_max)
- delta_y = _launcher_drag_delta_max + DragLimiter(delta_y - _launcher_drag_delta_max);
- else if (_launcher_drag_delta < _launcher_drag_delta_min)
- delta_y = _launcher_drag_delta_min + DragLimiter(delta_y - _launcher_drag_delta_min);
+ if (launcher_drag_delta_ > launcher_drag_delta_max_)
+ delta_y = launcher_drag_delta_max_ + DragLimiter(delta_y - launcher_drag_delta_max_);
+ else if (launcher_drag_delta_ < launcher_drag_delta_min_)
+ delta_y = launcher_drag_delta_min_ + DragLimiter(delta_y - launcher_drag_delta_min_);
if (GetActionState() != ACTION_DRAG_LAUNCHER)
{
- float dnd_progress = DnDExitProgress(current);
+ // XXX: nux::Animation should allow to define new kinds of easing curves
+ float dnd_progress = std::pow(drag_over_animation_.GetCurrentValue(), 2);
- if (_launcher_drag_delta > _launcher_drag_delta_max)
- delta_y = _launcher_drag_delta_max + (delta_y - _launcher_drag_delta_max) * dnd_progress;
- else if (_launcher_drag_delta < _launcher_drag_delta_min)
- delta_y = _launcher_drag_delta_min + (delta_y - _launcher_drag_delta_min) * dnd_progress;
+ if (launcher_drag_delta_ > launcher_drag_delta_max_)
+ delta_y = launcher_drag_delta_max_ + (delta_y - launcher_drag_delta_max_) * dnd_progress;
+ else if (launcher_drag_delta_ < launcher_drag_delta_min_)
+ delta_y = launcher_drag_delta_min_ + (delta_y - launcher_drag_delta_min_) * dnd_progress;
if (dnd_progress == 0.0f)
- _launcher_drag_delta = (int) delta_y;
+ launcher_drag_delta_ = (int) delta_y;
}
delta_y *= hover_progress;
@@ -1138,7 +1046,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args,
}
else
{
- _launcher_drag_delta = 0;
+ launcher_drag_delta_ = 0;
}
// The functional position we wish to represent for these icons is not smooth. Rather than introducing
@@ -1146,7 +1054,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args,
// function is not smooth it is continuous, which is more important for our visual representation (icons
// wont start jumping around). As a general rule ANY if () statements that modify center.y should be seen
// as bugs.
- for (it = _model->main_begin(); it != _model->main_end(); ++it)
+ for (it = model_->main_begin(); it != model_->main_end(); ++it)
{
RenderArg arg;
AbstractLauncherIcon::Ptr const& icon = *it;
@@ -1163,21 +1071,21 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args,
// compute maximum height of shelf
float shelf_sum = 0.0f;
- for (it = _model->shelf_begin(); it != _model->shelf_end(); ++it)
+ for (it = model_->shelf_begin(); it != model_->shelf_end(); ++it)
{
- float height = (_icon_size + _space_between_icons) * IconVisibleProgress(*it, current);
+ float height = (icon_size_ + SPACE_BETWEEN_ICONS) * IconVisibleProgress(*it, current);
shelf_sum += height;
}
// add bottom padding
if (shelf_sum > 0.0f)
- shelf_sum += _space_between_icons;
+ shelf_sum += SPACE_BETWEEN_ICONS;
- float shelf_delta = MAX(((launcher_height - shelf_sum) + _space_between_icons) - center.y, 0.0f);
+ float shelf_delta = MAX(((launcher_height - shelf_sum) + SPACE_BETWEEN_ICONS) - center.y, 0.0f);
folding_threshold += shelf_delta;
center.y += shelf_delta;
- for (it = _model->shelf_begin(); it != _model->shelf_end(); ++it)
+ for (it = model_->shelf_begin(); it != model_->shelf_end(); ++it)
{
RenderArg arg;
AbstractLauncherIcon::Ptr const& icon = *it;
@@ -1193,14 +1101,14 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args,
void Launcher::ForceReveal(bool force_reveal)
{
- _hide_machine.SetQuirk(LauncherHideMachine::TRIGGER_BUTTON_SHOW, force_reveal);
+ hide_machine_.SetQuirk(LauncherHideMachine::TRIGGER_BUTTON_SHOW, force_reveal);
}
void Launcher::ShowShortcuts(bool show)
{
- _shortcuts_shown = show;
- _hide_machine.SetQuirk(LauncherHideMachine::SHORTCUT_KEYS_VISIBLE, show);
- EnsureAnimation();
+ shortcuts_shown_ = show;
+ hide_machine_.SetQuirk(LauncherHideMachine::SHORTCUT_KEYS_VISIBLE, show);
+ QueueDraw();
}
void Launcher::OnLockHideChanged(GVariant *data)
@@ -1210,17 +1118,17 @@ void Launcher::OnLockHideChanged(GVariant *data)
if (enable_lock)
{
- _hide_machine.SetQuirk(LauncherHideMachine::LOCK_HIDE, true);
+ hide_machine_.SetQuirk(LauncherHideMachine::LOCK_HIDE, true);
}
else
{
- _hide_machine.SetQuirk(LauncherHideMachine::LOCK_HIDE, false);
+ hide_machine_.SetQuirk(LauncherHideMachine::LOCK_HIDE, false);
}
}
void Launcher::DesaturateIcons()
{
- for (auto icon : *_model)
+ for (auto icon : *model_)
{
if (icon->GetIconType () != AbstractLauncherIcon::IconType::HOME &&
icon->GetIconType () != AbstractLauncherIcon::IconType::HUD)
@@ -1234,7 +1142,7 @@ void Launcher::DesaturateIcons()
void Launcher::SaturateIcons()
{
- for (auto icon : *_model)
+ for (auto icon : *model_)
{
icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
}
@@ -1260,29 +1168,29 @@ void Launcher::OnOverlayShown(GVariant* data)
{
if (identity == "dash")
{
- _dash_is_open = true;
- _hide_machine.SetQuirk(LauncherHideMachine::PLACES_VISIBLE, true);
- _hover_machine.SetQuirk(LauncherHoverMachine::PLACES_VISIBLE, true);
+ dash_is_open_ = true;
+ hide_machine_.SetQuirk(LauncherHideMachine::PLACES_VISIBLE, true);
+ hover_machine_.SetQuirk(LauncherHoverMachine::PLACES_VISIBLE, true);
if (options()->hide_mode != LAUNCHER_HIDE_NEVER)
- dash_showing_animation_.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
+ animation::StartOrReverse(dash_showing_animation_, animation::Direction::FORWARD);
}
if (identity == "hud")
{
- _hud_is_open = true;
+ hud_is_open_ = true;
}
bg_effect_helper_.enabled = true;
// Don't desaturate icons if the mouse is over the launcher:
- if (!_hovered)
+ if (!hovered_)
{
LOG_DEBUG(logger) << "Desaturate on monitor " << monitor();
DesaturateIcons();
}
- if (_icon_under_mouse)
- _icon_under_mouse->HideTooltip();
+ if (icon_under_mouse_)
+ icon_under_mouse_->HideTooltip();
}
- EnsureAnimation();
+ QueueDraw();
}
void Launcher::OnOverlayHidden(GVariant* data)
@@ -1306,14 +1214,14 @@ void Launcher::OnOverlayHidden(GVariant* data)
{
if (identity == "dash")
{
- _dash_is_open = false;
- _hide_machine.SetQuirk(LauncherHideMachine::PLACES_VISIBLE, false);
- _hover_machine.SetQuirk(LauncherHoverMachine::PLACES_VISIBLE, false);
+ dash_is_open_ = false;
+ hide_machine_.SetQuirk(LauncherHideMachine::PLACES_VISIBLE, false);
+ hover_machine_.SetQuirk(LauncherHoverMachine::PLACES_VISIBLE, false);
dash_showing_animation_.Stop();
}
else if (identity == "hud")
{
- _hud_is_open = false;
+ hud_is_open_ = false;
}
// If they are both now shut, then disable the effect helper and saturate the icons.
@@ -1324,80 +1232,79 @@ void Launcher::OnOverlayHidden(GVariant* data)
SaturateIcons();
}
}
- EnsureAnimation();
// as the leave event is no more received when the place is opened
// FIXME: remove when we change the mouse grab strategy in nux
nux::Point pt = nux::GetWindowCompositor().GetMousePosition();
SetStateMouseOverLauncher(GetAbsoluteGeometry().IsInside(pt));
+
+ QueueDraw();
}
bool Launcher::IsOverlayOpen() const
{
- return _dash_is_open || _hud_is_open;
+ return dash_is_open_ || hud_is_open_;
}
void Launcher::SetHidden(bool hide_launcher)
{
- if (hide_launcher == _hidden)
+ if (hide_launcher == hidden_)
return;
- _hidden = hide_launcher;
- _hide_machine.SetQuirk(LauncherHideMachine::LAUNCHER_HIDDEN, hide_launcher);
- _hover_machine.SetQuirk(LauncherHoverMachine::LAUNCHER_HIDDEN, hide_launcher);
+ hidden_ = hide_launcher;
+ hide_machine_.SetQuirk(LauncherHideMachine::LAUNCHER_HIDDEN, hide_launcher);
+ hover_machine_.SetQuirk(LauncherHoverMachine::LAUNCHER_HIDDEN, hide_launcher);
if (hide_launcher)
{
- _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, false);
- _hide_machine.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, false);
+ hide_machine_.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, false);
+ hide_machine_.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, false);
SetStateMouseOverLauncher(false);
}
- _postreveal_mousemove_delta_x = 0;
- _postreveal_mousemove_delta_y = 0;
+ animation::StartOrReverseIf(auto_hide_animation_, hide_launcher);
- TimeUtil::SetTimeStruct(&_times[TIME_AUTOHIDE], &_times[TIME_AUTOHIDE], ANIM_DURATION_SHORT);
+ postreveal_mousemove_delta_x_ = 0;
+ postreveal_mousemove_delta_y_ = 0;
if (nux::GetWindowThread()->IsEmbeddedWindow())
- _parent->EnableInputWindow(!hide_launcher, launcher::window_title, false, false);
+ parent_->EnableInputWindow(!hide_launcher, launcher::window_title, false, false);
if (!hide_launcher && GetActionState() == ACTION_DRAG_EXTERNAL)
DndReset();
- EnsureAnimation();
-
hidden_changed.emit();
}
void Launcher::UpdateChangeInMousePosition(int delta_x, int delta_y)
{
- _postreveal_mousemove_delta_x += delta_x;
- _postreveal_mousemove_delta_y += delta_y;
+ postreveal_mousemove_delta_x_ += delta_x;
+ postreveal_mousemove_delta_y_ += delta_y;
// check the state before changing it to avoid uneeded hide calls
- if (!_hide_machine.GetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL) &&
- (std::abs(_postreveal_mousemove_delta_x) > MOUSE_DEADZONE ||
- std::abs(_postreveal_mousemove_delta_y) > MOUSE_DEADZONE))
+ if (!hide_machine_.GetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL) &&
+ (std::abs(postreveal_mousemove_delta_x_) > MOUSE_DEADZONE ||
+ std::abs(postreveal_mousemove_delta_y_) > MOUSE_DEADZONE))
{
- _hide_machine.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);
+ hide_machine_.SetQuirk(LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);
}
}
int Launcher::GetMouseX() const
{
- return _mouse_position.x;
+ return mouse_position_.x;
}
int Launcher::GetMouseY() const
{
- return _mouse_position.y;
+ return mouse_position_.y;
}
void Launcher::OnPluginStateChanged()
{
WindowManager& wm = WindowManager::Default();
- _hide_machine.SetQuirk(LauncherHideMachine::EXPO_ACTIVE, wm.IsExpoActive());
- _hide_machine.SetQuirk(LauncherHideMachine::SCALE_ACTIVE, wm.IsScaleActive());
+ hide_machine_.SetQuirk(LauncherHideMachine::EXPO_ACTIVE, wm.IsExpoActive());
+ hide_machine_.SetQuirk(LauncherHideMachine::SCALE_ACTIVE, wm.IsScaleActive());
}
LauncherHideMode Launcher::GetHideMode() const
@@ -1425,7 +1332,7 @@ void Launcher::OnMonitorChanged(int new_monitor)
unity::panel::Style &panel_style = panel::Style::Instance();
Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_style.panel_height),
monitor_geo.height - panel_style.panel_height);
- icon_renderer->monitor = new_monitor;
+ icon_renderer_->monitor = new_monitor;
}
void Launcher::UpdateOptions(Options::Ptr options)
@@ -1434,7 +1341,7 @@ void Launcher::UpdateOptions(Options::Ptr options)
SetHideMode(options->hide_mode);
ConfigureBarrier();
- EnsureAnimation();
+ QueueDraw();
}
void Launcher::ConfigureBarrier()
@@ -1442,16 +1349,15 @@ void Launcher::ConfigureBarrier()
float decay_responsiveness_mult = ((options()->edge_responsiveness() - 1) * .3f) + 1;
float reveal_responsiveness_mult = ((options()->edge_responsiveness() - 1) * .025f) + 1;
- _hide_machine.reveal_pressure = options()->edge_reveal_pressure() * reveal_responsiveness_mult;
- _hide_machine.edge_decay_rate = options()->edge_decay_rate() * decay_responsiveness_mult;
+ hide_machine_.reveal_pressure = options()->edge_reveal_pressure() * reveal_responsiveness_mult;
+ hide_machine_.edge_decay_rate = options()->edge_decay_rate() * decay_responsiveness_mult;
}
void Launcher::SetHideMode(LauncherHideMode hidemode)
{
bool fixed_launcher = (hidemode == LAUNCHER_HIDE_NEVER);
- _parent->InputWindowEnableStruts(fixed_launcher);
- _hide_machine.SetMode(static_cast<LauncherHideMachine::HideMode>(hidemode));
- EnsureAnimation();
+ parent_->InputWindowEnableStruts(fixed_launcher);
+ hide_machine_.SetMode(static_cast<LauncherHideMachine::HideMode>(hidemode));
}
BacklightMode Launcher::GetBacklightMode() const
@@ -1473,97 +1379,95 @@ bool Launcher::IsBackLightModeToggles() const
nux::ObjectPtr<nux::View> const& Launcher::GetActiveTooltip() const
{
- return _active_tooltip;
+ return active_tooltip_;
}
nux::ObjectPtr<LauncherDragWindow> const& Launcher::GetDraggedIcon() const
{
- return _drag_window;
+ return drag_window_;
}
void Launcher::SetActionState(LauncherActionState actionstate)
{
- if (_launcher_action_state == actionstate)
+ if (launcher_action_state_ == actionstate)
return;
- _launcher_action_state = actionstate;
+ launcher_action_state_ = actionstate;
- _hover_machine.SetQuirk(LauncherHoverMachine::LAUNCHER_IN_ACTION, (actionstate != ACTION_NONE));
+ hover_machine_.SetQuirk(LauncherHoverMachine::LAUNCHER_IN_ACTION, (actionstate != ACTION_NONE));
}
Launcher::LauncherActionState
Launcher::GetActionState() const
{
- return _launcher_action_state;
+ return launcher_action_state_;
}
void Launcher::SetHover(bool hovered)
{
- if (hovered == _hovered)
+ if (hovered == hovered_)
return;
- _hovered = hovered;
+ hovered_ = hovered;
- if (!IsInKeyNavMode() && _hovered)
- {
- _enter_y = (int) _mouse_position.y;
- TimeUtil::SetTimeStruct(&_times[TIME_ENTER], &_times[TIME_LEAVE], ANIM_DURATION);
- }
- else
- {
- TimeUtil::SetTimeStruct(&_times[TIME_LEAVE], &_times[TIME_ENTER], ANIM_DURATION);
- }
+ if (!IsInKeyNavMode() && hovered_)
+ enter_y_ = mouse_position_.y;
- if (IsOverlayOpen() && !_hide_machine.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE))
+ if (folded_)
+ animation::StartOrReverseIf(hover_animation_, hovered_);
+
+ if (IsOverlayOpen() && !hide_machine_.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE))
{
- if (hovered && !_hide_machine.GetQuirk(LauncherHideMachine::SHORTCUT_KEYS_VISIBLE))
+ if (hovered && !hide_machine_.GetQuirk(LauncherHideMachine::SHORTCUT_KEYS_VISIBLE))
SaturateIcons();
else
DesaturateIcons();
}
-
- EnsureAnimation();
}
bool Launcher::MouseOverTopScrollArea()
{
- return _mouse_position.y < SCROLL_AREA_HEIGHT;
+ return mouse_position_.y < SCROLL_AREA_HEIGHT;
}
bool Launcher::MouseOverBottomScrollArea()
{
- return _mouse_position.y >= GetGeometry().height - SCROLL_AREA_HEIGHT;
+ return mouse_position_.y >= GetGeometry().height - SCROLL_AREA_HEIGHT;
}
bool Launcher::OnScrollTimeout()
{
bool continue_animation = true;
- int speed = 0;
- if (IsInKeyNavMode() || !_hovered ||
- GetActionState() == ACTION_DRAG_LAUNCHER)
+ if (IsInKeyNavMode() || !hovered_ || GetActionState() == ACTION_DRAG_LAUNCHER)
{
continue_animation = false;
}
else if (MouseOverTopScrollArea())
{
- if (_launcher_drag_delta >= _launcher_drag_delta_max)
+ if (launcher_drag_delta_ >= launcher_drag_delta_max_)
+ {
continue_animation = false;
+ }
else
{
- speed = (SCROLL_AREA_HEIGHT - _mouse_position.y) / SCROLL_AREA_HEIGHT * SCROLL_FPS;
- _launcher_drag_delta += speed;
+ int mouse_distance = (SCROLL_AREA_HEIGHT - mouse_position_.y);
+ int speed = static_cast<float>(mouse_distance) / SCROLL_AREA_HEIGHT * SCROLL_FPS;
+ launcher_drag_delta_ += speed;
}
}
else if (MouseOverBottomScrollArea())
{
- if (_launcher_drag_delta <= _launcher_drag_delta_min)
+ if (launcher_drag_delta_ <= launcher_drag_delta_min_)
+ {
continue_animation = false;
+ }
else
{
- speed = ((_mouse_position.y + 1) - (GetGeometry().height - SCROLL_AREA_HEIGHT)) / SCROLL_AREA_HEIGHT * SCROLL_FPS;
- _launcher_drag_delta -= speed;
- }
+ int mouse_distance = (mouse_position_.y + 1) - (GetGeometry().height - SCROLL_AREA_HEIGHT);
+ int speed = static_cast<float>(mouse_distance) / SCROLL_AREA_HEIGHT * SCROLL_FPS;
+ launcher_drag_delta_ -= speed;
+ }
}
else
{
@@ -1572,7 +1476,7 @@ bool Launcher::OnScrollTimeout()
if (continue_animation)
{
- EnsureAnimation();
+ QueueDraw();
}
return continue_animation;
@@ -1602,53 +1506,53 @@ void Launcher::WiggleUrgentIcon(AbstractLauncherIcon::Ptr const& icon)
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, false);
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true);
- clock_gettime(CLOCK_MONOTONIC, &_urgent_finished_time);
+ clock_gettime(CLOCK_MONOTONIC, &urgent_finished_time_);
}
void Launcher::HandleUrgentIcon(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current)
{
struct timespec urgent_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::URGENT);
- DeltaTime urgent_delta = unity::TimeUtil::TimeDelta(&urgent_time, &_urgent_finished_time);
+ DeltaTime urgent_delta = unity::TimeUtil::TimeDelta(&urgent_time, &urgent_finished_time_);
- // If the Launcher is hidden, then add a timer to wiggle the urgent icons at
+ // If the Launcher is hidden, then add a timer to wiggle the urgent icons at
// certain intervals (1m, 2m, 4m, 8m, 16m, & 32m).
- if (_hidden && !_urgent_timer_running && urgent_delta > 0)
+ if (hidden_ && !urgent_timer_running_ && urgent_delta > 0)
{
- _urgent_timer_running = true;
- _urgent_ack_needed = true;
+ urgent_timer_running_ = true;
+ urgent_ack_needed_ = true;
SetUrgentTimer(BASE_URGENT_WIGGLE_PERIOD);
}
// If the Launcher is hidden, the timer is running, an urgent icon is newer than the last time
// icons were wiggled, and the timer did not just start, then reset the timer since a new
// urgent icon just showed up.
- else if (_hidden && _urgent_timer_running && urgent_delta > 0 && _urgent_wiggle_time != 0)
+ else if (hidden_ && urgent_timer_running_ && urgent_delta > 0 && urgent_wiggle_time_ != 0)
{
- _urgent_wiggle_time = 0;
+ urgent_wiggle_time_ = 0;
SetUrgentTimer(BASE_URGENT_WIGGLE_PERIOD);
}
- // If the Launcher is no longer hidden, then after the Launcher is fully revealed, wiggle the
+ // If the Launcher is no longer hidden, then after the Launcher is fully revealed, wiggle the
// urgent icon and then stop the timer (if it's running).
- else if (!_hidden && _urgent_ack_needed)
+ else if (!hidden_ && urgent_ack_needed_)
{
- if (_last_reveal_progress > 0)
+ if (last_reveal_progress_ > 0)
{
- _urgent_acked = false;
+ urgent_acked_ = false;
}
else
{
- if (!_urgent_acked && IconUrgentProgress(icon, current) == 1.0f)
+ if (!urgent_acked_ && IconUrgentProgress(icon, current) == 1.0f)
{
WiggleUrgentIcon(icon);
}
else if (IconUrgentProgress(icon, current) < 1.0f)
{
- if (_urgent_timer_running)
+ if (urgent_timer_running_)
{
sources_.Remove(URGENT_TIMEOUT);
- _urgent_timer_running = false;
+ urgent_timer_running_ = false;
}
- _urgent_acked = true;
- _urgent_ack_needed = false;
+ urgent_acked_ = true;
+ urgent_ack_needed_ = false;
}
}
}
@@ -1659,10 +1563,10 @@ bool Launcher::OnUrgentTimeout()
bool foundUrgent = false,
continue_urgent = true;
- if (options()->urgent_animation() == URGENT_ANIMATION_WIGGLE && _hidden)
+ if (options()->urgent_animation() == URGENT_ANIMATION_WIGGLE && hidden_)
{
// Look for any icons that are still urgent and wiggle them
- for (auto icon : *_model)
+ for (auto icon : *model_)
{
if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
{
@@ -1673,26 +1577,26 @@ bool Launcher::OnUrgentTimeout()
}
}
// Update the time for when the next wiggle will occur.
- if (_urgent_wiggle_time == 0)
+ if (urgent_wiggle_time_ == 0)
{
- _urgent_wiggle_time = BASE_URGENT_WIGGLE_PERIOD;
+ urgent_wiggle_time_ = BASE_URGENT_WIGGLE_PERIOD;
}
else
{
- _urgent_wiggle_time = _urgent_wiggle_time * DOUBLE_TIME;
+ urgent_wiggle_time_ = urgent_wiggle_time_ * DOUBLE_TIME;
}
// If no urgent icons were found or we have reached the time threshold,
// then let's stop the timer. Otherwise, start a new timer with the
// updated wiggle time.
- if (!foundUrgent || (_urgent_wiggle_time > MAX_URGENT_WIGGLE_DELTA))
+ if (!foundUrgent || (urgent_wiggle_time_ > MAX_URGENT_WIGGLE_DELTA))
{
continue_urgent = false;
- _urgent_timer_running = false;
+ urgent_timer_running_ = false;
}
else
{
- SetUrgentTimer(_urgent_wiggle_time);
+ SetUrgentTimer(urgent_wiggle_time_);
}
return continue_urgent;
@@ -1702,72 +1606,64 @@ void Launcher::SetIconSize(int tile_size, int icon_size)
{
ui::IconRenderer::DestroyShortcutTextures();
- _icon_size = tile_size;
- _icon_image_size = icon_size;
- _icon_image_size_delta = tile_size - icon_size;
- _icon_glow_size = icon_size + 14;
-
- icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons);
+ icon_size_ = tile_size;
+ icon_renderer_->SetTargetSize(icon_size_, icon_size, SPACE_BETWEEN_ICONS);
- nux::Geometry const& parent_geo = _parent->GetGeometry();
+ nux::Geometry const& parent_geo = parent_->GetGeometry();
Resize(nux::Point(parent_geo.x, parent_geo.y), parent_geo.height);
}
int Launcher::GetIconSize() const
{
- return _icon_size;
+ return icon_size_;
}
void Launcher::Resize(nux::Point const& offset, int height)
{
- unsigned width = _icon_size + ICON_PADDING * 2 + RIGHT_LINE_WIDTH - 2;
+ unsigned width = icon_size_ + ICON_PADDING * 2 + RIGHT_LINE_WIDTH - 2;
SetMaximumHeight(height);
SetGeometry(nux::Geometry(0, 0, width, height));
- _parent->SetGeometry(nux::Geometry(offset.x, offset.y, width, height));
+ parent_->SetGeometry(nux::Geometry(offset.x, offset.y, width, height));
ConfigureBarrier();
}
void Launcher::OnIconAdded(AbstractLauncherIcon::Ptr const& icon)
{
- EnsureAnimation();
+ QueueDraw();
- icon->needs_redraw.connect(sigc::mem_fun(this, &Launcher::OnIconNeedsRedraw));
+ icon->needs_redraw.connect(sigc::hide(sigc::mem_fun(this, &Launcher::QueueDraw)));
icon->tooltip_visible.connect(sigc::mem_fun(this, &Launcher::OnTooltipVisible));
}
void Launcher::OnIconRemoved(AbstractLauncherIcon::Ptr const& icon)
{
SetIconUnderMouse(AbstractLauncherIcon::Ptr());
- if (icon == _icon_mouse_down)
- _icon_mouse_down = nullptr;
- if (icon == _drag_icon)
- _drag_icon = nullptr;
-
- EnsureAnimation();
-}
+ if (icon == icon_mouse_down_)
+ icon_mouse_down_ = nullptr;
+ if (icon == drag_icon_)
+ drag_icon_ = nullptr;
-void Launcher::OnOrderChanged()
-{
- EnsureAnimation();
+ QueueDraw();
}
void Launcher::SetModel(LauncherModel::Ptr model)
{
- _model = model;
+ model_ = model;
+ auto const& queue_draw_cb = sigc::hide(sigc::mem_fun(this, &Launcher::QueueDraw));
- for (auto icon : *_model)
- icon->needs_redraw.connect(sigc::mem_fun(this, &Launcher::OnIconNeedsRedraw));
+ for (auto const& icon : *model_)
+ icon->needs_redraw.connect(queue_draw_cb);
- _model->icon_added.connect(sigc::mem_fun(this, &Launcher::OnIconAdded));
- _model->icon_removed.connect(sigc::mem_fun(this, &Launcher::OnIconRemoved));
- _model->order_changed.connect(sigc::mem_fun(this, &Launcher::OnOrderChanged));
- _model->selection_changed.connect(sigc::mem_fun(this, &Launcher::OnSelectionChanged));
+ model_->icon_added.connect(sigc::mem_fun(this, &Launcher::OnIconAdded));
+ model_->icon_removed.connect(sigc::mem_fun(this, &Launcher::OnIconRemoved));
+ model_->order_changed.connect(sigc::mem_fun(this, &Launcher::QueueDraw));
+ model_->selection_changed.connect(sigc::mem_fun(this, &Launcher::OnSelectionChanged));
}
LauncherModel::Ptr Launcher::GetModel() const
{
- return _model;
+ return model_;
}
void Launcher::EnsureIconOnScreen(AbstractLauncherIcon::Ptr const& selection)
@@ -1775,7 +1671,7 @@ void Launcher::EnsureIconOnScreen(AbstractLauncherIcon::Ptr const& selection)
nux::Geometry const& geo = GetGeometry();
int natural_y = 0;
- for (auto icon : *_model)
+ for (auto icon : *model_)
{
if (!icon->IsVisible() || !icon->IsVisibleOnMonitor(monitor))
continue;
@@ -1783,13 +1679,13 @@ void Launcher::EnsureIconOnScreen(AbstractLauncherIcon::Ptr const& selection)
if (icon == selection)
break;
- natural_y += _icon_size + _space_between_icons;
+ natural_y += icon_size_ + SPACE_BETWEEN_ICONS;
}
- int max_drag_delta = geo.height - (natural_y + _icon_size + (2 * _space_between_icons));
+ int max_drag_delta = geo.height - (natural_y + icon_size_ + (2 * SPACE_BETWEEN_ICONS));
int min_drag_delta = -natural_y;
- _launcher_drag_delta = std::max<int>(min_drag_delta, std::min<int>(max_drag_delta, _launcher_drag_delta));
+ launcher_drag_delta_ = std::max<int>(min_drag_delta, std::min<int>(max_drag_delta, launcher_drag_delta_));
}
void Launcher::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection)
@@ -1797,18 +1693,13 @@ void Launcher::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection)
if (IsInKeyNavMode())
{
EnsureIconOnScreen(selection);
- EnsureAnimation();
+ QueueDraw();
}
}
-void Launcher::OnIconNeedsRedraw(AbstractLauncherIcon::Ptr const& icon)
-{
- EnsureAnimation();
-}
-
void Launcher::OnTooltipVisible(nux::ObjectPtr<nux::View> view)
{
- _active_tooltip = view;
+ active_tooltip_ = view;
}
void Launcher::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
@@ -1829,10 +1720,7 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
{
auto idle = std::make_shared<glib::Idle>(glib::Source::Priority::DEFAULT);
sources_.Add(idle, ANIMATION_IDLE);
- idle->Run([&]() {
- EnsureAnimation();
- return false;
- });
+ idle->Run([this]() { QueueDraw(); return false; });
}
nux::ROPConfig ROP;
@@ -1843,9 +1731,9 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
nux::Geometry const& geo_absolute = GetAbsoluteGeometry();
RenderArgs(args, bkg_box, &launcher_alpha, geo_absolute);
bkg_box.width -= RIGHT_LINE_WIDTH;
-
+
nux::Color clear_colour = nux::Color(0x00000000);
-
+
if (Settings::Instance().GetLowGfxMode())
{
clear_colour = options()->background_color;
@@ -1868,21 +1756,21 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
// clip vertically but not horizontally
GfxContext.PushClippingRectangle(nux::Geometry(base.x, bkg_box.y, base.width, bkg_box.height));
- float reveal_progress = _hide_machine.reveal_progress;
- if ((reveal_progress > 0 || _last_reveal_progress > 0) && launcher_pressure_effect_.IsValid())
+ float reveal_progress = hide_machine_.reveal_progress;
+ if ((reveal_progress > 0 || last_reveal_progress_ > 0) && launcher_pressure_effect_.IsValid())
{
- if (std::abs(_last_reveal_progress - reveal_progress) <= .1f)
+ if (std::abs(last_reveal_progress_ - reveal_progress) <= .1f)
{
- _last_reveal_progress = reveal_progress;
+ last_reveal_progress_ = reveal_progress;
}
else
{
- if (_last_reveal_progress > reveal_progress)
- _last_reveal_progress -= .1f;
+ if (last_reveal_progress_ > reveal_progress)
+ last_reveal_progress_ -= .1f;
else
- _last_reveal_progress += .1f;
+ last_reveal_progress_ += .1f;
}
- nux::Color pressure_color = nux::color::White * _last_reveal_progress;
+ nux::Color pressure_color = nux::color::White * last_reveal_progress_;
nux::TexCoordXForm texxform_pressure;
GfxContext.QRP_1Tex(base.x, base.y, launcher_pressure_effect_->GetWidth(), base.height,
launcher_pressure_effect_->GetDeviceTexture(),
@@ -1899,49 +1787,53 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
if (BackgroundEffectHelper::blur_type != unity::BLUR_NONE && (bkg_box.x + bkg_box.width > 0))
{
- blur_texture = bg_effect_helper_.GetBlurRegion(blur_geo);
+ blur_texture = bg_effect_helper_.GetBlurRegion(blur_geo);
}
else
{
- blur_texture = bg_effect_helper_.GetRegion(blur_geo);
+ blur_texture = bg_effect_helper_.GetRegion(blur_geo);
}
if (blur_texture.IsValid())
{
- nux::TexCoordXForm texxform_blur_bg;
- texxform_blur_bg.flip_v_coord = true;
- texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
- texxform_blur_bg.uoffset = ((float) base.x) / geo_absolute.width;
- texxform_blur_bg.voffset = ((float) base.y) / geo_absolute.height;
+ nux::TexCoordXForm texxform_blur_bg;
+ texxform_blur_bg.flip_v_coord = true;
+ texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ texxform_blur_bg.uoffset = ((float) base.x) / geo_absolute.width;
+ texxform_blur_bg.voffset = ((float) base.y) / geo_absolute.height;
- GfxContext.PushClippingRectangle(bkg_box);
+ GfxContext.PushClippingRectangle(bkg_box);
#ifndef NUX_OPENGLES_20
- if (GfxContext.UsingGLSLCodePath())
- gPainter.PushDrawCompositionLayer(GfxContext, base,
- blur_texture,
- texxform_blur_bg,
- nux::color::White,
- options()->background_color, nux::LAYER_BLEND_MODE_OVERLAY,
- true, ROP);
- else
- gPainter.PushDrawTextureLayer(GfxContext, base,
- blur_texture,
- texxform_blur_bg,
- nux::color::White,
- true,
- ROP);
+ if (GfxContext.UsingGLSLCodePath())
+ {
+ gPainter.PushDrawCompositionLayer(GfxContext, base,
+ blur_texture,
+ texxform_blur_bg,
+ nux::color::White,
+ options()->background_color, nux::LAYER_BLEND_MODE_OVERLAY,
+ true, ROP);
+ }
+ else
+ {
+ gPainter.PushDrawTextureLayer(GfxContext, base,
+ blur_texture,
+ texxform_blur_bg,
+ nux::color::White,
+ true,
+ ROP);
+ }
#else
- gPainter.PushDrawCompositionLayer(GfxContext, base,
- blur_texture,
- texxform_blur_bg,
- nux::color::White,
- options()->background_color, nux::LAYER_BLEND_MODE_OVERLAY,
- true, ROP);
+ gPainter.PushDrawCompositionLayer(GfxContext, base,
+ blur_texture,
+ texxform_blur_bg,
+ nux::color::White,
+ options()->background_color, nux::LAYER_BLEND_MODE_OVERLAY,
+ true, ROP);
#endif
- GfxContext.PopClippingRectangle();
+ GfxContext.PopClippingRectangle();
- push_count++;
+ push_count++;
}
unsigned int alpha = 0, src = 0, dest = 0;
@@ -1955,7 +1847,7 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
// apply the bg colour
#ifndef NUX_OPENGLES_20
if (GfxContext.UsingGLSLCodePath() == false)
- gPainter.Paint2DQuadColor(GfxContext, bkg_box, options()->background_color);
+ gPainter.Paint2DQuadColor(GfxContext, bkg_box, options()->background_color);
#endif
// apply the shine
@@ -1966,9 +1858,9 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
texxform.uoffset = (1.0f / launcher_sheen_->GetWidth()); // TODO (gord) don't use absolute values here
texxform.voffset = (1.0f / launcher_sheen_->GetHeight()) * panel::Style::Instance().panel_height;
GfxContext.QRP_1Tex(base.x, base.y, base.width, base.height,
- launcher_sheen_->GetDeviceTexture(),
- texxform,
- nux::color::White);
+ launcher_sheen_->GetDeviceTexture(),
+ texxform,
+ nux::color::White);
//reset the blend state
GfxContext.GetRenderStates().SetBlend (alpha, src, dest);
@@ -1983,7 +1875,7 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
- icon_renderer->PreprocessIcons(args, base);
+ icon_renderer_->PreprocessIcons(args, base);
EventLogic();
/* draw launcher */
@@ -1997,7 +1889,7 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
if ((*rev_it).skip)
continue;
- icon_renderer->RenderIcon(GfxContext, *rev_it, bkg_box, base);
+ icon_renderer_->RenderIcon(GfxContext, *rev_it, bkg_box, base);
}
if (!IsOverlayOpen())
@@ -2047,7 +1939,7 @@ long Launcher::PostLayoutManagement(long LayoutResult)
void Launcher::OnDragWindowAnimCompleted()
{
HideDragWindow();
- EnsureAnimation();
+ QueueDraw();
}
bool Launcher::StartIconDragTimeout(int x, int y)
@@ -2056,7 +1948,7 @@ bool Launcher::StartIconDragTimeout(int x, int y)
if (GetActionState() == ACTION_NONE)
{
SetIconUnderMouse(AbstractLauncherIcon::Ptr());
- _initial_drag_animation = true;
+ initial_drag_animation_ = true;
StartIconDragRequest(x, y);
}
@@ -2070,7 +1962,7 @@ void Launcher::StartIconDragRequest(int x, int y)
// FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying
// on an internal Launcher property then
- if (drag_icon && _last_button_press == 1 && drag_icon->position() == AbstractLauncherIcon::Position::FLOATING)
+ if (drag_icon && last_button_press_ == 1 && drag_icon->position() == AbstractLauncherIcon::Position::FLOATING)
{
auto const& icon_center = drag_icon->GetCenter(monitor);
x += abs_geo.x;
@@ -2080,17 +1972,17 @@ void Launcher::StartIconDragRequest(int x, int y)
StartIconDrag(drag_icon);
UpdateDragWindowPosition(icon_center.x, icon_center.y);
- if (_initial_drag_animation)
+ if (initial_drag_animation_)
{
- _drag_window->SetAnimationTarget(x, y);
- _drag_window->StartQuickAnimation();
+ drag_window_->SetAnimationTarget(x, y);
+ drag_window_->StartQuickAnimation();
}
- EnsureAnimation();
+ QueueDraw();
}
else
{
- _drag_icon = nullptr;
+ drag_icon_ = nullptr;
HideDragWindow();
}
}
@@ -2102,76 +1994,74 @@ void Launcher::StartIconDrag(AbstractLauncherIcon::Ptr const& icon)
if (!icon)
return;
- _hide_machine.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, true);
- _drag_icon = icon;
- _drag_icon_position = _model->IconIndex(icon);
+ hide_machine_.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, true);
+ drag_icon_ = icon;
+ drag_icon_position_ = model_->IconIndex(icon);
HideDragWindow();
- auto cb = std::bind(&Launcher::RenderIconToTexture, this, _1, _2, _drag_icon);
- _drag_window = new LauncherDragWindow(GetWidth(), cb);
+ auto cb = std::bind(&Launcher::RenderIconToTexture, this, _1, _2, drag_icon_);
+ drag_window_ = new LauncherDragWindow(GetWidth(), cb);
ShowDragWindow();
-
- ubus_.SendMessage(UBUS_LAUNCHER_ICON_START_DND);
}
void Launcher::EndIconDrag()
{
- if (_drag_window)
+ if (drag_window_)
{
AbstractLauncherIcon::Ptr hovered_icon;
- if (!_drag_window->Cancelled())
- hovered_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y);
+ if (!drag_window_->Cancelled())
+ hovered_icon = MouseIconIntersection(mouse_position_.x, mouse_position_.y);
if (hovered_icon && hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH)
{
hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, true);
- remove_request.emit(_drag_icon);
+ remove_request.emit(drag_icon_);
HideDragWindow();
- EnsureAnimation();
+ QueueDraw();
}
else
{
- if (!_drag_window->Cancelled() && _model->IconIndex(_drag_icon) != _drag_icon_position)
+ if (!drag_window_->Cancelled() && model_->IconIndex(drag_icon_) != drag_icon_position_)
{
- _drag_icon->Stick(true);
+ drag_icon_->Stick(true);
}
- auto const& icon_center = _drag_icon->GetCenter(monitor);
- _drag_window->SetAnimationTarget(icon_center.x, icon_center.y);
- _drag_window->anim_completed.connect(sigc::mem_fun(this, &Launcher::OnDragWindowAnimCompleted));
- _drag_window->StartQuickAnimation();
+ auto const& icon_center = drag_icon_->GetCenter(monitor);
+ drag_window_->SetAnimationTarget(icon_center.x, icon_center.y);
+ drag_window_->anim_completed.connect(sigc::mem_fun(this, &Launcher::OnDragWindowAnimCompleted));
+ drag_window_->StartQuickAnimation();
}
}
if (MouseBeyondDragThreshold())
- TimeUtil::SetTimeStruct(&_times[TIME_DRAG_THRESHOLD], &_times[TIME_DRAG_THRESHOLD], ANIM_DURATION_SHORT);
+ animation::StartOrReverse(drag_icon_animation_, animation::Direction::FORWARD);
- _hide_machine.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, false);
- ubus_.SendMessage(UBUS_LAUNCHER_ICON_END_DND);
+ hide_machine_.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, false);
}
void Launcher::ShowDragWindow()
{
- if (!_drag_window || _drag_window->IsVisible())
+ if (!drag_window_ || drag_window_->IsVisible())
return;
- _drag_window->GrabKeyboard();
- _drag_window->ShowWindow(true);
- _drag_window->PushToFront();
+ drag_window_->GrabKeyboard();
+ drag_window_->ShowWindow(true);
+ drag_window_->PushToFront();
bool is_before;
- AbstractLauncherIcon::Ptr const& closer = _model->GetClosestIcon(_drag_icon, is_before);
- _drag_window->drag_cancel_request.connect([this, closer, is_before] {
+ AbstractLauncherIcon::Ptr const& closer = model_->GetClosestIcon(drag_icon_, is_before);
+ drag_window_->drag_cancel_request.connect([this, closer, is_before] {
if (is_before)
- _model->ReorderAfter(_drag_icon, closer);
+ model_->ReorderAfter(drag_icon_, closer);
else
- _model->ReorderBefore(_drag_icon, closer, true);
+ model_->ReorderBefore(drag_icon_, closer, true);
ResetMouseDragState();
+ SetActionState(ACTION_DRAG_ICON_CANCELLED);
});
}
@@ -2183,46 +2073,44 @@ void Launcher::HideDragWindow()
if (abs_geo.IsInside(mouse))
mouse_enter.emit(mouse.x - abs_geo.x, mouse.y - abs_geo.y, 0, 0);
- if (!_drag_window)
+ if (!drag_window_)
return;
- _drag_window->UnGrabKeyboard();
- _drag_window->ShowWindow(false);
- _drag_window = nullptr;
+ drag_window_->UnGrabKeyboard();
+ drag_window_->ShowWindow(false);
+ drag_window_ = nullptr;
}
void Launcher::UpdateDragWindowPosition(int x, int y)
{
- if (!_drag_window)
+ if (!drag_window_)
return;
- auto const& icon_geo = _drag_window->GetGeometry();
- _drag_window->SetBaseXY(x - icon_geo.width / 2, y - icon_geo.height / 2);
+ auto const& icon_geo = drag_window_->GetGeometry();
+ drag_window_->SetBaseXY(x - icon_geo.width / 2, y - icon_geo.height / 2);
- if (!_drag_icon)
+ if (!drag_icon_)
return;
auto const& launcher_geo = GetGeometry();
auto const& hovered_icon = MouseIconIntersection((launcher_geo.x + launcher_geo.width) / 2.0, y - GetAbsoluteY());
- struct timespec current;
- clock_gettime(CLOCK_MONOTONIC, &current);
- float progress = DragThresholdProgress(current);
+ bool mouse_beyond_drag_threshold = MouseBeyondDragThreshold();
- if (hovered_icon && _drag_icon != hovered_icon)
+ if (hovered_icon && drag_icon_ != hovered_icon)
{
- if (progress >= 1.0f)
+ if (!mouse_beyond_drag_threshold)
{
- _model->ReorderSmart(_drag_icon, hovered_icon, true);
+ model_->ReorderSmart(drag_icon_, hovered_icon, true);
}
- else if (progress == 0.0f)
+ else
{
- _model->ReorderBefore(_drag_icon, hovered_icon, false);
+ model_->ReorderBefore(drag_icon_, hovered_icon, false);
}
}
- else if (!hovered_icon && progress == 0.0f)
+ else if (!hovered_icon && mouse_beyond_drag_threshold)
{
// If no icon is hovered, then we can add our icon to the bottom
- for (auto it = _model->main_rbegin(); it != _model->main_rend(); ++it)
+ for (auto it = model_->main_rbegin(); it != model_->main_rend(); ++it)
{
auto const& icon = *it;
@@ -2231,7 +2119,7 @@ void Launcher::UpdateDragWindowPosition(int x, int y)
if (y >= icon->GetCenter(monitor).y)
{
- _model->ReorderAfter(_drag_icon, icon);
+ model_->ReorderAfter(drag_icon_, icon);
break;
}
}
@@ -2244,22 +2132,20 @@ void Launcher::ResetMouseDragState()
EndIconDrag();
if (GetActionState() == ACTION_DRAG_LAUNCHER)
- _hide_machine.SetQuirk(LauncherHideMachine::VERTICAL_SLIDE_ACTIVE, false);
+ hide_machine_.SetQuirk(LauncherHideMachine::VERTICAL_SLIDE_ACTIVE, false);
SetActionState(ACTION_NONE);
- _dnd_delta_x = 0;
- _dnd_delta_y = 0;
- _last_button_press = 0;
- EnsureAnimation();
+ dnd_delta_x_ = 0;
+ dnd_delta_y_ = 0;
+ last_button_press_ = 0;
}
void Launcher::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- _last_button_press = nux::GetEventButton(button_flags);
+ last_button_press_ = nux::GetEventButton(button_flags);
SetMousePosition(x, y);
MouseDownLogic(x, y, button_flags, key_flags);
- EnsureAnimation();
}
void Launcher::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
@@ -2276,19 +2162,19 @@ void Launcher::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_
* on an internal Launcher property then
*/
- if (_last_button_press != 1)
+ if (last_button_press_ != 1)
return;
SetMousePosition(x, y);
// FIXME: hack (see SetupRenderArg)
- _initial_drag_animation = false;
+ initial_drag_animation_ = false;
- _dnd_delta_y += dy;
- _dnd_delta_x += dx;
+ dnd_delta_y_ += dy;
+ dnd_delta_x_ += dx;
- if (nux::Abs(_dnd_delta_y) < MOUSE_DEADZONE &&
- nux::Abs(_dnd_delta_x) < MOUSE_DEADZONE &&
+ if (nux::Abs(dnd_delta_y_) < MOUSE_DEADZONE &&
+ nux::Abs(dnd_delta_x_) < MOUSE_DEADZONE &&
GetActionState() == ACTION_NONE)
return;
@@ -2297,24 +2183,23 @@ void Launcher::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_
if (GetActionState() == ACTION_NONE)
{
#ifdef USE_X11
- if (nux::Abs(_dnd_delta_y) >= nux::Abs(_dnd_delta_x))
+ if (nux::Abs(dnd_delta_y_) >= nux::Abs(dnd_delta_x_))
{
- _launcher_drag_delta += _dnd_delta_y;
+ launcher_drag_delta_ += dnd_delta_y_;
SetActionState(ACTION_DRAG_LAUNCHER);
- _hide_machine.SetQuirk(LauncherHideMachine::VERTICAL_SLIDE_ACTIVE, true);
+ hide_machine_.SetQuirk(LauncherHideMachine::VERTICAL_SLIDE_ACTIVE, true);
}
else
{
// We we can safely start the icon drag, from the original mouse-down position
sources_.Remove(START_DRAGICON_DURATION);
- StartIconDragRequest(x - _dnd_delta_x, y - _dnd_delta_y);
+ StartIconDragRequest(x - dnd_delta_x_, y - dnd_delta_y_);
}
#endif
}
else if (GetActionState() == ACTION_DRAG_LAUNCHER)
{
- _launcher_drag_delta += dy;
- ubus_.SendMessage(UBUS_LAUNCHER_END_DND);
+ launcher_drag_delta_ += dy;
}
else if (GetActionState() == ACTION_DRAG_ICON)
{
@@ -2322,31 +2207,28 @@ void Launcher::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_
UpdateDragWindowPosition(geo.x + x, geo.y + y);
}
- EnsureAnimation();
+ QueueDraw();
}
void Launcher::RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
{
SetMousePosition(x, y);
SetStateMouseOverLauncher(true);
-
EventLogic();
- EnsureAnimation();
}
void Launcher::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)
{
SetStateMouseOverLauncher(false);
EventLogic();
- EnsureAnimation();
}
void Launcher::RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
{
SetMousePosition(x, y);
- tooltip_manager_.MouseMoved(_icon_under_mouse);
+ tooltip_manager_.MouseMoved(icon_under_mouse_);
- if (!_hidden)
+ if (!hidden_)
UpdateChangeInMousePosition(dx, dy);
// Every time the mouse moves, we check if it is inside an icon...
@@ -2355,7 +2237,7 @@ void Launcher::RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_
void Launcher::RecvMouseWheel(int /*x*/, int /*y*/, int wheel_delta, unsigned long /*button_flags*/, unsigned long key_flags)
{
- if (!_hovered)
+ if (!hovered_)
return;
bool alt_pressed = nux::GetKeyModifierState(key_flags, nux::NUX_STATE_ALT);
@@ -2363,11 +2245,11 @@ void Launcher::RecvMouseWheel(int /*x*/, int /*y*/, int wheel_delta, unsigned lo
{
ScrollLauncher(wheel_delta);
}
- else if (_icon_under_mouse)
+ else if (icon_under_mouse_)
{
auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
auto scroll_direction = (wheel_delta < 0) ? AbstractLauncherIcon::ScrollDirection::DOWN : AbstractLauncherIcon::ScrollDirection::UP;
- _icon_under_mouse->PerformScroll(scroll_direction, timestamp);
+ icon_under_mouse_->PerformScroll(scroll_direction, timestamp);
}
}
@@ -2375,19 +2257,19 @@ void Launcher::ScrollLauncher(int wheel_delta)
{
if (wheel_delta < 0)
// scroll down
- _launcher_drag_delta -= 25;
+ launcher_drag_delta_ -= 25;
else
// scroll up
- _launcher_drag_delta += 25;
+ launcher_drag_delta_ += 25;
- EnsureAnimation();
+ QueueDraw();
}
#ifdef USE_X11
ui::EdgeBarrierSubscriber::Result Launcher::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event)
{
- if (_hide_machine.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE))
+ if (hide_machine_.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE))
{
return ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE;
}
@@ -2397,7 +2279,7 @@ ui::EdgeBarrierSubscriber::Result Launcher::HandleBarrierEvent(ui::PointerBarrie
bool apply_to_reveal = false;
if (event->x >= abs_geo.x && event->x <= abs_geo.x + abs_geo.width)
{
- if (!_hidden)
+ if (!hidden_)
return ui::EdgeBarrierSubscriber::Result::ALREADY_HANDLED;
if (options()->reveal_trigger == RevealTrigger::EDGE)
@@ -2431,7 +2313,7 @@ ui::EdgeBarrierSubscriber::Result Launcher::HandleBarrierEvent(ui::PointerBarrie
return ui::EdgeBarrierSubscriber::Result::IGNORED;
if (!owner->IsFirstEvent())
- _hide_machine.AddRevealPressure(event->velocity);
+ hide_machine_.AddRevealPressure(event->velocity);
return ui::EdgeBarrierSubscriber::Result::HANDLED;
}
@@ -2440,20 +2322,20 @@ ui::EdgeBarrierSubscriber::Result Launcher::HandleBarrierEvent(ui::PointerBarrie
bool Launcher::IsInKeyNavMode() const
{
- return _hide_machine.GetQuirk(LauncherHideMachine::KEY_NAV_ACTIVE);
+ return hide_machine_.GetQuirk(LauncherHideMachine::KEY_NAV_ACTIVE);
}
void Launcher::EnterKeyNavMode()
{
- _hide_machine.SetQuirk(LauncherHideMachine::KEY_NAV_ACTIVE, true);
- _hover_machine.SetQuirk(LauncherHoverMachine::KEY_NAV_ACTIVE, true);
+ hide_machine_.SetQuirk(LauncherHideMachine::KEY_NAV_ACTIVE, true);
+ hover_machine_.SetQuirk(LauncherHoverMachine::KEY_NAV_ACTIVE, true);
SaturateIcons();
}
void Launcher::ExitKeyNavMode()
{
- _hide_machine.SetQuirk(LauncherHideMachine::KEY_NAV_ACTIVE, false);
- _hover_machine.SetQuirk(LauncherHoverMachine::KEY_NAV_ACTIVE, false);
+ hide_machine_.SetQuirk(LauncherHideMachine::KEY_NAV_ACTIVE, false);
+ hover_machine_.SetQuirk(LauncherHoverMachine::KEY_NAV_ACTIVE, false);
}
void Launcher::RecvQuicklistOpened(nux::ObjectPtr<QuicklistView> const& quicklist)
@@ -2461,10 +2343,9 @@ void Launcher::RecvQuicklistOpened(nux::ObjectPtr<QuicklistView> const& quicklis
UScreen* uscreen = UScreen::GetDefault();
if (uscreen->GetMonitorGeometry(monitor).IsInside(nux::Point(quicklist->GetGeometry().x, quicklist->GetGeometry().y)))
{
- _hide_machine.SetQuirk(LauncherHideMachine::QUICKLIST_OPEN, true);
- _hover_machine.SetQuirk(LauncherHoverMachine::QUICKLIST_OPEN, true);
+ hide_machine_.SetQuirk(LauncherHideMachine::QUICKLIST_OPEN, true);
+ hover_machine_.SetQuirk(LauncherHoverMachine::QUICKLIST_OPEN, true);
EventLogic();
- EnsureAnimation();
}
}
@@ -2480,11 +2361,10 @@ void Launcher::RecvQuicklistClosed(nux::ObjectPtr<QuicklistView> const& quicklis
// Cancel any prior state that was set before the Quicklist appeared.
SetActionState(ACTION_NONE);
- _hide_machine.SetQuirk(LauncherHideMachine::QUICKLIST_OPEN, false);
- _hover_machine.SetQuirk(LauncherHoverMachine::QUICKLIST_OPEN, false);
+ hide_machine_.SetQuirk(LauncherHideMachine::QUICKLIST_OPEN, false);
+ hover_machine_.SetQuirk(LauncherHoverMachine::QUICKLIST_OPEN, false);
EventLogic();
- EnsureAnimation();
}
void Launcher::EventLogic()
@@ -2495,9 +2375,9 @@ void Launcher::EventLogic()
AbstractLauncherIcon::Ptr launcher_icon;
- if (!_hidden && !IsInKeyNavMode() && _hovered)
+ if (!hidden_ && !IsInKeyNavMode() && hovered_)
{
- launcher_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y);
+ launcher_icon = MouseIconIntersection(mouse_position_.x, mouse_position_.y);
}
SetIconUnderMouse(launcher_icon);
@@ -2505,11 +2385,11 @@ void Launcher::EventLogic()
void Launcher::MouseDownLogic(int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- AbstractLauncherIcon::Ptr const& launcher_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y);
+ AbstractLauncherIcon::Ptr const& launcher_icon = MouseIconIntersection(mouse_position_.x, mouse_position_.y);
if (launcher_icon)
{
- _icon_mouse_down = launcher_icon;
+ icon_mouse_down_ = launcher_icon;
// if MouseUp after the time ended -> it's an icon drag, otherwise, it's starting an app
auto cb_func = sigc::bind(sigc::mem_fun(this, &Launcher::StartIconDragTimeout), x, y);
sources_.AddTimeout(START_DRAGICON_DURATION, cb_func, START_DRAGICON_TIMEOUT);
@@ -2521,31 +2401,31 @@ 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::Ptr const& launcher_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y);
+ AbstractLauncherIcon::Ptr const& launcher_icon = MouseIconIntersection(mouse_position_.x, mouse_position_.y);
sources_.Remove(START_DRAGICON_TIMEOUT);
- if (_icon_mouse_down && (_icon_mouse_down == launcher_icon))
+ if (icon_mouse_down_ && (icon_mouse_down_ == launcher_icon))
{
- _icon_mouse_down->mouse_up.emit(nux::GetEventButton(button_flags), monitor, key_flags);
+ icon_mouse_down_->mouse_up.emit(nux::GetEventButton(button_flags), monitor, key_flags);
if (GetActionState() == ACTION_NONE)
{
- _icon_mouse_down->mouse_click.emit(nux::GetEventButton(button_flags), monitor, key_flags);
+ icon_mouse_down_->mouse_click.emit(nux::GetEventButton(button_flags), monitor, key_flags);
}
}
- if (launcher_icon && (_icon_mouse_down != launcher_icon))
+ if (launcher_icon && (icon_mouse_down_ != launcher_icon))
{
launcher_icon->mouse_up.emit(nux::GetEventButton(button_flags), monitor, key_flags);
}
if (GetActionState() == ACTION_DRAG_LAUNCHER)
{
- TimeUtil::SetTimeStruct(&_times[TIME_DRAG_END]);
+ animation::StartOrReverse(drag_over_animation_, animation::Direction::BACKWARD);
}
- _icon_mouse_down = nullptr;
+ icon_mouse_down_ = nullptr;
}
AbstractLauncherIcon::Ptr Launcher::MouseIconIntersection(int x, int y) const
@@ -2555,7 +2435,7 @@ AbstractLauncherIcon::Ptr Launcher::MouseIconIntersection(int x, int y) const
nux::Point2 mouse_position(x, y);
int inside = 0;
- for (it = _model->begin(); it != _model->end(); ++it)
+ for (it = model_->begin(); it != model_->end(); ++it)
{
if (!(*it)->IsVisible() || !(*it)->IsVisibleOnMonitor(monitor))
continue;
@@ -2607,8 +2487,8 @@ void Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, nux::ObjectP
nux::Geometry geo(0, 0, texture->GetWidth(), texture->GetWidth());
- icon_renderer->PreprocessIcons(drag_args, geo);
- icon_renderer->RenderIcon(GfxContext, arg, geo, geo);
+ icon_renderer_->PreprocessIcons(drag_args, geo);
+ icon_renderer_->RenderIcon(GfxContext, arg, geo, geo);
unity::graphics::PopOffscreenRenderTarget();
}
@@ -2642,23 +2522,24 @@ void Launcher::ProcessDndEnter()
#ifdef USE_X11
SetStateMouseOverLauncher(true);
- _dnd_data.Reset();
- _drag_action = nux::DNDACTION_NONE;
- _steal_drag = false;
- _data_checked = false;
- _drag_edge_touching = false;
- _dnd_hovered_icon = nullptr;
+ dnd_data_.Reset();
+ drag_action_ = nux::DNDACTION_NONE;
+ steal_drag_ = false;
+ data_checked_ = false;
+ dnd_hovered_icon_ = nullptr;
+ drag_edge_touching_ = false;
+ dnd_hide_animation_.Stop();
#endif
}
void Launcher::DndReset()
{
#ifdef USE_X11
- _dnd_data.Reset();
+ dnd_data_.Reset();
bool is_overlay_open = IsOverlayOpen();
- for (auto it : *_model)
+ for (auto it : *model_)
{
auto icon_type = it->GetIconType();
@@ -2669,7 +2550,7 @@ void Launcher::DndReset()
}
else
{
- it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, is_overlay_open && !_hovered);
+ it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, is_overlay_open && !hovered_);
}
it->SetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, false);
@@ -2682,20 +2563,20 @@ void Launcher::DndReset()
void Launcher::DndHoveredIconReset()
{
#ifdef USE_X11
- _drag_edge_touching = false;
SetActionState(ACTION_NONE);
- if (_steal_drag && _dnd_hovered_icon)
+ if (steal_drag_ && dnd_hovered_icon_)
{
- _dnd_hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false);
- _dnd_hovered_icon->remove.emit(_dnd_hovered_icon);
+ dnd_hovered_icon_->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false);
+ dnd_hovered_icon_->remove.emit(dnd_hovered_icon_);
}
- if (!_steal_drag && _dnd_hovered_icon)
- _dnd_hovered_icon->SendDndLeave();
+ if (!steal_drag_ && dnd_hovered_icon_)
+ dnd_hovered_icon_->SendDndLeave();
- _steal_drag = false;
- _dnd_hovered_icon = nullptr;
+ steal_drag_ = false;
+ drag_edge_touching_ = false;
+ dnd_hovered_icon_ = nullptr;
#endif
}
@@ -2711,11 +2592,11 @@ void Launcher::ProcessDndLeave()
void Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes)
{
#ifdef USE_X11
- if (!_data_checked)
+ if (!data_checked_)
{
const std::string uri_list = "text/uri-list";
- _data_checked = true;
- _dnd_data.Reset();
+ data_checked_ = true;
+ dnd_data_.Reset();
auto& display = nux::GetWindowThread()->GetGraphicsDisplay();
// get the data
@@ -2724,27 +2605,27 @@ void Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes)
if (mime != uri_list)
continue;
- _dnd_data.Fill(display.GetDndData(const_cast<char*>(uri_list.c_str())));
+ dnd_data_.Fill(display.GetDndData(const_cast<char*>(uri_list.c_str())));
break;
}
// see if the launcher wants this one
- auto const& uris = _dnd_data.Uris();
+ auto const& uris = dnd_data_.Uris();
if (std::find_if(uris.begin(), uris.end(), [this] (std::string const& uri)
{return DndIsSpecialRequest(uri);}) != uris.end())
{
- _steal_drag = true;
+ steal_drag_ = true;
}
// only set hover once we know our first x/y
SetActionState(ACTION_DRAG_EXTERNAL);
SetStateMouseOverLauncher(true);
- if (!_steal_drag && !_dnd_data.Uris().empty())
+ if (!steal_drag_ && !dnd_data_.Uris().empty())
{
- for (auto const& it : *_model)
+ for (auto const& it : *model_)
{
- if (it->ShouldHighlightOnDrag(_dnd_data))
+ if (it->ShouldHighlightOnDrag(dnd_data_))
it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
else
it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true);
@@ -2752,117 +2633,119 @@ void Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes)
}
}
- SetMousePosition(x - _parent->GetGeometry().x, y - _parent->GetGeometry().y);
+ SetMousePosition(x - parent_->GetGeometry().x, y - parent_->GetGeometry().y);
- if (monitor() == 0 && !IsOverlayOpen() && _mouse_position.x == 0 && _mouse_position.y <= (_parent->GetGeometry().height - _icon_size - 2 * _space_between_icons) && !_drag_edge_touching)
+ if (options()->hide_mode != LAUNCHER_HIDE_NEVER)
{
- if (_dnd_hovered_icon)
- _dnd_hovered_icon->SendDndLeave();
+ if (monitor() == 0 && !IsOverlayOpen() && mouse_position_.x == 0 && !drag_edge_touching_ &&
+ mouse_position_.y <= (parent_->GetGeometry().height - icon_size_ - 2 * SPACE_BETWEEN_ICONS))
+ {
+ if (dnd_hovered_icon_)
+ dnd_hovered_icon_->SendDndLeave();
- _drag_edge_touching = true;
- TimeUtil::SetTimeStruct(&_times[TIME_DRAG_EDGE_TOUCH], &_times[TIME_DRAG_EDGE_TOUCH], ANIM_DURATION * 3);
- EnsureAnimation();
- }
- else if (_mouse_position.x != 0 && _drag_edge_touching)
- {
- _drag_edge_touching = false;
- TimeUtil::SetTimeStruct(&_times[TIME_DRAG_EDGE_TOUCH], &_times[TIME_DRAG_EDGE_TOUCH], ANIM_DURATION * 3);
- EnsureAnimation();
+ animation::StartOrReverse(dnd_hide_animation_, animation::Direction::FORWARD);
+ drag_edge_touching_ = true;
+ }
+ else if (mouse_position_.x != 0 && drag_edge_touching_)
+ {
+ animation::StartOrReverse(dnd_hide_animation_, animation::Direction::BACKWARD);
+ drag_edge_touching_ = false;
+ }
}
EventLogic();
- AbstractLauncherIcon::Ptr const& hovered_icon = MouseIconIntersection(_mouse_position.x, _mouse_position.y);
+ AbstractLauncherIcon::Ptr const& hovered_icon = MouseIconIntersection(mouse_position_.x, mouse_position_.y);
bool hovered_icon_is_appropriate = false;
if (hovered_icon)
{
if (hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH)
- _steal_drag = false;
+ steal_drag_ = false;
if (hovered_icon->position() == AbstractLauncherIcon::Position::FLOATING)
hovered_icon_is_appropriate = true;
}
- if (_steal_drag)
+ if (steal_drag_)
{
- _drag_action = nux::DNDACTION_COPY;
- if (!_dnd_hovered_icon && hovered_icon_is_appropriate)
+ drag_action_ = nux::DNDACTION_COPY;
+ if (!dnd_hovered_icon_ && hovered_icon_is_appropriate)
{
- _dnd_hovered_icon = new SpacerLauncherIcon(monitor());
- _model->AddIcon(_dnd_hovered_icon);
- _model->ReorderBefore(_dnd_hovered_icon, hovered_icon, true);
+ dnd_hovered_icon_ = new SpacerLauncherIcon(monitor());
+ model_->AddIcon(dnd_hovered_icon_);
+ model_->ReorderBefore(dnd_hovered_icon_, hovered_icon, true);
}
- else if (_dnd_hovered_icon)
+ else if (dnd_hovered_icon_)
{
if (hovered_icon)
{
if (hovered_icon_is_appropriate)
{
- _model->ReorderSmart(_dnd_hovered_icon, hovered_icon, true);
+ model_->ReorderSmart(dnd_hovered_icon_, hovered_icon, true);
}
else
{
- _dnd_hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false);
- _dnd_hovered_icon->remove.emit(_dnd_hovered_icon);
- _dnd_hovered_icon = nullptr;
+ dnd_hovered_icon_->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false);
+ dnd_hovered_icon_->remove.emit(dnd_hovered_icon_);
+ dnd_hovered_icon_ = nullptr;
}
}
}
}
else
{
- if (!_drag_edge_touching && hovered_icon != _dnd_hovered_icon)
+ if (!drag_edge_touching_ && hovered_icon != dnd_hovered_icon_)
{
if (hovered_icon)
{
hovered_icon->SendDndEnter();
- _drag_action = hovered_icon->QueryAcceptDrop(_dnd_data);
+ drag_action_ = hovered_icon->QueryAcceptDrop(dnd_data_);
}
else
{
- _drag_action = nux::DNDACTION_NONE;
+ drag_action_ = nux::DNDACTION_NONE;
}
- if (_dnd_hovered_icon)
- _dnd_hovered_icon->SendDndLeave();
+ if (dnd_hovered_icon_)
+ dnd_hovered_icon_->SendDndLeave();
- _dnd_hovered_icon = hovered_icon;
+ dnd_hovered_icon_ = hovered_icon;
}
}
bool accept;
- if (_drag_action != nux::DNDACTION_NONE)
+ if (drag_action_ != nux::DNDACTION_NONE)
accept = true;
else
accept = false;
- SendDndStatus(accept, _drag_action, nux::Geometry(x, y, 1, 1));
+ SendDndStatus(accept, drag_action_, nux::Geometry(x, y, 1, 1));
#endif
}
void Launcher::ProcessDndDrop(int x, int y)
{
#ifdef USE_X11
- if (_steal_drag)
+ if (steal_drag_)
{
- for (auto const& uri : _dnd_data.Uris())
+ for (auto const& uri : dnd_data_.Uris())
{
if (DndIsSpecialRequest(uri))
- add_request.emit(uri, _dnd_hovered_icon);
+ add_request.emit(uri, dnd_hovered_icon_);
}
}
- else if (_dnd_hovered_icon && _drag_action != nux::DNDACTION_NONE)
+ else if (dnd_hovered_icon_ && drag_action_ != nux::DNDACTION_NONE)
{
if (IsOverlayOpen())
ubus_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
- _dnd_hovered_icon->AcceptDrop(_dnd_data);
+ dnd_hovered_icon_->AcceptDrop(dnd_data_);
}
- if (_drag_action != nux::DNDACTION_NONE)
- SendDndFinished(true, _drag_action);
+ if (drag_action_ != nux::DNDACTION_NONE)
+ SendDndFinished(true, drag_action_);
else
- SendDndFinished(false, _drag_action);
+ SendDndFinished(false, drag_action_);
// reset our shiz
DndReset();
@@ -2878,7 +2761,7 @@ AbstractLauncherIcon::Ptr Launcher::GetSelectedMenuIcon() const
if (!IsInKeyNavMode())
return AbstractLauncherIcon::Ptr();
- return _model->Selection();
+ return model_->Selection();
}
//
@@ -2894,7 +2777,7 @@ bool Launcher::InspectKeyEvent(unsigned int eventType,
int Launcher::GetDragDelta() const
{
- return _launcher_drag_delta;
+ return launcher_drag_delta_;
}
void Launcher::DndStarted(std::string const& data)
@@ -2902,22 +2785,22 @@ void Launcher::DndStarted(std::string const& data)
#ifdef USE_X11
SetDndQuirk();
- _dnd_data.Fill(data.c_str());
+ dnd_data_.Fill(data.c_str());
- auto const& uris = _dnd_data.Uris();
+ auto const& uris = dnd_data_.Uris();
if (std::find_if(uris.begin(), uris.end(), [this] (std::string const& uri)
{return DndIsSpecialRequest(uri);}) != uris.end())
{
- _steal_drag = true;
+ steal_drag_ = true;
if (IsOverlayOpen())
SaturateIcons();
}
else
{
- for (auto const& it : *_model)
+ for (auto const& it : *model_)
{
- if (it->ShouldHighlightOnDrag(_dnd_data))
+ if (it->ShouldHighlightOnDrag(dnd_data_))
{
it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
it->SetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, true);
@@ -2937,9 +2820,9 @@ void Launcher::DndFinished()
#ifdef USE_X11
UnsetDndQuirk();
- _data_checked = false;
+ data_checked_ = false;
- if (IsOverlayOpen() && !_hovered)
+ if (IsOverlayOpen() && !hovered_)
DesaturateIcons();
DndReset();
@@ -2949,15 +2832,15 @@ void Launcher::DndFinished()
void Launcher::SetDndQuirk()
{
#ifdef USE_X11
- _hide_machine.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, true);
+ hide_machine_.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, true);
#endif
}
void Launcher::UnsetDndQuirk()
{
#ifdef USE_X11
- _hide_machine.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false);
- _hide_machine.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false);
+ hide_machine_.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false);
+ hide_machine_.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false);
#endif
}
diff --git a/launcher/Launcher.h b/launcher/Launcher.h
index 380efab30..f9941b008 100644
--- a/launcher/Launcher.h
+++ b/launcher/Launcher.h
@@ -22,7 +22,6 @@
#define LAUNCHER_H
#include <Nux/View.h>
-#include <Nux/BaseWindow.h>
#include <Nux/TimerProc.h>
#include <NuxCore/Animation.h>
#include <NuxGraphics/GestureEvent.h>
@@ -70,7 +69,6 @@ public:
Launcher(MockableBaseWindow* parent, NUX_FILE_LINE_PROTO);
- nux::Property<Display*> display;
nux::Property<int> monitor;
nux::Property<Options::Ptr> options;
@@ -84,7 +82,7 @@ public:
bool Hidden() const
{
- return _hidden;
+ return hidden_;
}
void ForceReveal(bool force);
@@ -104,7 +102,7 @@ public:
MockableBaseWindow* GetParent() const
{
- return _parent;
+ return parent_;
};
nux::ObjectPtr<nux::View> const& GetActiveTooltip() const;
@@ -180,24 +178,10 @@ private:
ACTION_NONE,
ACTION_DRAG_LAUNCHER,
ACTION_DRAG_ICON,
+ ACTION_DRAG_ICON_CANCELLED,
ACTION_DRAG_EXTERNAL,
} LauncherActionState;
- typedef enum
- {
- TIME_ENTER,
- TIME_LEAVE,
- TIME_DRAG_END,
- TIME_DRAG_THRESHOLD,
- TIME_AUTOHIDE,
- TIME_DRAG_EDGE_TOUCH,
- TIME_DRAG_OUT,
- TIME_TAP_SUPER,
- TIME_SUPER_PRESSED,
-
- TIME_LAST
- } LauncherActionTimes;
-
void ConfigureBarrier();
void OnMonitorChanged(int monitor);
@@ -244,20 +228,11 @@ private:
void SetActionState(LauncherActionState actionstate);
LauncherActionState GetActionState() const;
- void EnsureAnimation();
void EnsureScrollTimer();
-
bool MouseOverTopScrollArea();
-
bool MouseOverBottomScrollArea();
- float DnDStartProgress(struct timespec const& current) const;
- float DnDExitProgress(struct timespec const& current) const;
- float GetHoverProgress(struct timespec const& current) const;
- float AutohideProgress(struct timespec const& current) const;
- float DragThresholdProgress(struct timespec const& current) const;
- float DragHideProgress(struct timespec const& current) const;
- float DragOutProgress(struct timespec const& current) const;
+ float DragOutProgress() const;
float IconDesatValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const;
float IconPresentProgress(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const;
float IconUnfoldProgress(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const;
@@ -299,9 +274,7 @@ private:
void OnIconAdded(AbstractLauncherIcon::Ptr const& icon);
void OnIconRemoved(AbstractLauncherIcon::Ptr const& icon);
- void OnOrderChanged();
- void OnIconNeedsRedraw(AbstractLauncherIcon::Ptr const& icon);
void OnTooltipVisible(nux::ObjectPtr<nux::View> view);
void OnOverlayHidden(GVariant* data);
@@ -339,80 +312,73 @@ private:
void DndHoveredIconReset();
bool DndIsSpecialRequest(std::string const& uri) const;
- LauncherModel::Ptr _model;
- MockableBaseWindow* _parent;
- nux::ObjectPtr<nux::View> _active_tooltip;
- QuicklistView* _active_quicklist;
-
- nux::HLayout* m_Layout;
+ LauncherModel::Ptr model_;
+ MockableBaseWindow* parent_;
+ ui::AbstractIconRenderer::Ptr icon_renderer_;
+ nux::ObjectPtr<nux::View> active_tooltip_;
+ QuicklistView* active_quicklist_;
// used by keyboard/a11y-navigation
- AbstractLauncherIcon::Ptr _icon_under_mouse;
- AbstractLauncherIcon::Ptr _icon_mouse_down;
- AbstractLauncherIcon::Ptr _drag_icon;
- AbstractLauncherIcon::Ptr _dnd_hovered_icon;
-
- bool _hovered;
- bool _hidden;
- bool _render_drag_window;
- bool _shortcuts_shown;
- bool _data_checked;
- bool _steal_drag;
- bool _drag_edge_touching;
- bool _initial_drag_animation;
- bool _dash_is_open;
- bool _hud_is_open;
-
- float _folded_angle;
- float _neg_folded_angle;
- float _folded_z_distance;
- float _edge_overcome_pressure;
-
- LauncherActionState _launcher_action_state;
-
- int _space_between_icons;
- int _icon_image_size;
- int _icon_image_size_delta;
- int _icon_glow_size;
- int _icon_size;
- int _dnd_delta_y;
- int _dnd_delta_x;
- int _postreveal_mousemove_delta_x;
- int _postreveal_mousemove_delta_y;
- int _launcher_drag_delta;
- int _launcher_drag_delta_max;
- int _launcher_drag_delta_min;
- int _enter_y;
- int _last_button_press;
- int _drag_icon_position;
- int _urgent_wiggle_time;
- bool _urgent_acked;
- bool _urgent_timer_running;
- bool _urgent_ack_needed;
- float _drag_out_delta_x;
- bool _drag_gesture_ongoing;
- float _last_reveal_progress;
-
- nux::Point2 _mouse_position;
- LauncherDragWindow::Ptr _drag_window;
- LauncherHideMachine _hide_machine;
- LauncherHoverMachine _hover_machine;
+ AbstractLauncherIcon::Ptr icon_under_mouse_;
+ AbstractLauncherIcon::Ptr icon_mouse_down_;
+ AbstractLauncherIcon::Ptr drag_icon_;
+ AbstractLauncherIcon::Ptr dnd_hovered_icon_;
+
+ bool hovered_;
+ bool hidden_;
+ bool folded_;
+ bool render_drag_window_;
+ bool shortcuts_shown_;
+ bool data_checked_;
+ bool steal_drag_;
+ bool drag_edge_touching_;
+ bool initial_drag_animation_;
+ bool dash_is_open_;
+ bool hud_is_open_;
+
+ LauncherActionState launcher_action_state_;
+
+ int icon_size_;
+ int dnd_delta_y_;
+ int dnd_delta_x_;
+ int postreveal_mousemove_delta_x_;
+ int postreveal_mousemove_delta_y_;
+ int launcher_drag_delta_;
+ int launcher_drag_delta_max_;
+ int launcher_drag_delta_min_;
+ int enter_y_;
+ int last_button_press_;
+ int drag_icon_position_;
+ int urgent_wiggle_time_;
+ bool urgent_acked_;
+ bool urgent_timer_running_;
+ bool urgent_ack_needed_;
+ float drag_out_delta_x_;
+ bool drag_gesture_ongoing_;
+ float last_reveal_progress_;
+
+ nux::Point mouse_position_;
+ LauncherDragWindow::Ptr drag_window_;
+ LauncherHideMachine hide_machine_;
+ LauncherHoverMachine hover_machine_;
TooltipManager tooltip_manager_;
- unity::DndData _dnd_data;
- nux::DndAction _drag_action;
- Atom _selection_atom;
-
- struct timespec _times[TIME_LAST];
- struct timespec _urgent_finished_time;
+ unity::DndData dnd_data_;
+ nux::DndAction drag_action_;
+ struct timespec urgent_finished_time_;
BaseTexturePtr launcher_sheen_;
BaseTexturePtr launcher_pressure_effect_;
-
- nux::animation::AnimateValue<double> dash_showing_animation_;
- ui::AbstractIconRenderer::Ptr icon_renderer;
BackgroundEffectHelper bg_effect_helper_;
+ nux::animation::AnimateValue<float> auto_hide_animation_;
+ nux::animation::AnimateValue<float> hover_animation_;
+ nux::animation::AnimateValue<float> drag_over_animation_;
+ nux::animation::AnimateValue<float> drag_out_animation_;
+ nux::animation::AnimateValue<float> drag_icon_animation_;
+ nux::animation::AnimateValue<float> dnd_hide_animation_;
+ nux::animation::AnimateValue<float> dash_showing_animation_;
+
UBusManager ubus_;
glib::SourceManager sources_;
diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp
index bbd4ff314..7a0901826 100644
--- a/launcher/LauncherIcon.cpp
+++ b/launcher/LauncherIcon.cpp
@@ -20,17 +20,13 @@
#include <sys/time.h>
#include <Nux/Nux.h>
-#include <Nux/VScrollBar.h>
-#include <Nux/HLayout.h>
-#include <Nux/VLayout.h>
-#include <Nux/WindowCompositor.h>
-#include <Nux/BaseWindow.h>
#include <NuxCore/Color.h>
#include <NuxCore/Logger.h>
-#include "unity-shared/CairoTexture.h"
-#include "LauncherIcon.h"
#include "Launcher.h"
+#include "LauncherIcon.h"
+#include "unity-shared/AnimationUtils.h"
+#include "unity-shared/CairoTexture.h"
#include "unity-shared/TimeUtil.h"
#include "QuicklistManager.h"
@@ -42,8 +38,6 @@
#include "MultiMonitor.h"
-#include "unity-shared/UBusWrapper.h"
-#include "unity-shared/UBusMessages.h"
#include <UnityCore/GLibWrapper.h>
#include <UnityCore/GTKWrapper.h>
#include <UnityCore/Variant.h>
@@ -117,13 +111,11 @@ LauncherIcon::LauncherIcon(IconType type)
mouse_click.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseClick));
_tooltip_fade_animator.updated.connect([this] (double opacity) {
- if (_tooltip)
- {
- _tooltip->SetOpacity(opacity);
-
- if (opacity == 0.0f && _tooltip_fade_animator.GetStartValue() > _tooltip_fade_animator.GetFinishValue())
- _tooltip->ShowWindow(false);
- }
+ if (_tooltip) _tooltip->SetOpacity(opacity);
+ });
+ _tooltip_fade_animator.finished.connect([this] {
+ if (_tooltip && animation::GetDirection(_tooltip_fade_animator) == animation::Direction::BACKWARD)
+ _tooltip->ShowWindow(false);
});
}
@@ -501,10 +493,7 @@ LauncherIcon::ShowTooltip()
_tooltip->ShowWindow(!tooltip_text().empty());
tooltip_visible.emit(_tooltip);
- if (_tooltip_fade_animator.CurrentState() == nux::animation::Animation::State::Running)
- _tooltip_fade_animator.Reverse();
- else
- _tooltip_fade_animator.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
+ animation::StartOrReverse(_tooltip_fade_animator, animation::Direction::FORWARD);
}
void
@@ -652,17 +641,7 @@ void LauncherIcon::RecvMouseClick(int button, int monitor, unsigned long key_fla
void LauncherIcon::HideTooltip()
{
if (_tooltip)
- {
- if (_tooltip_fade_animator.CurrentState() == nux::animation::Animation::State::Running &&
- _tooltip_fade_animator.GetFinishValue() == 1.0)
- {
- _tooltip_fade_animator.Reverse();
- }
- else
- {
- _tooltip_fade_animator.SetStartValue(1.0f).SetFinishValue(0.0f).Start();
- }
- }
+ animation::StartOrReverse(_tooltip_fade_animator, animation::Direction::BACKWARD);
tooltip_visible.emit(nux::ObjectPtr<nux::View>(nullptr));
}
@@ -855,8 +834,6 @@ LauncherIcon::SetQuirk(LauncherIcon::Quirk quirk, bool value)
{
Present(0.5f, 1500);
}
-
- UBusManager::SendMessage(UBUS_LAUNCHER_ICON_URGENT_CHANGED, g_variant_new_boolean(value));
}
if (quirk == Quirk::VISIBLE)
diff --git a/launcher/SpacerLauncherIcon.cpp b/launcher/SpacerLauncherIcon.cpp
index 3839e4a77..d5a32e6e5 100644
--- a/launcher/SpacerLauncherIcon.cpp
+++ b/launcher/SpacerLauncherIcon.cpp
@@ -18,8 +18,8 @@
*/
#include "SpacerLauncherIcon.h"
-#include "Launcher.h"
+#include "config.h"
#include <glib/gi18n-lib.h>
namespace unity
diff --git a/launcher/SwitcherController.cpp b/launcher/SwitcherController.cpp
index 89a192273..8087a18c7 100644
--- a/launcher/SwitcherController.cpp
+++ b/launcher/SwitcherController.cpp
@@ -21,6 +21,7 @@
#include <Nux/Nux.h>
#include <Nux/HLayout.h>
+#include "unity-shared/AnimationUtils.h"
#include "unity-shared/UBusMessages.h"
#include "unity-shared/WindowManager.h"
#include "unity-shared/UScreen.h"
@@ -423,15 +424,7 @@ void Controller::Impl::ShowView()
view_->live_background = true;
view_window_->ShowWindow(true);
view_window_->PushToFront();
-
- if (fade_animator_.CurrentState() == nux::animation::Animation::State::Running)
- {
- fade_animator_.Reverse();
- }
- else
- {
- fade_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
- }
+ animation::StartOrReverse(fade_animator_, animation::Direction::FORWARD);
}
}
@@ -519,14 +512,7 @@ void Controller::Impl::Hide(bool accept_state)
obj_->visible_ = false;
- if (fade_animator_.CurrentState() == nux::animation::Animation::State::Running)
- {
- fade_animator_.Reverse();
- }
- else
- {
- fade_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start();
- }
+ animation::StartOrReverse(fade_animator_, animation::Direction::BACKWARD);
}
void Controller::Impl::DetailHide()
diff --git a/panel/PanelMenuView.cpp b/panel/PanelMenuView.cpp
index f2a87ed97..e02a312fa 100644
--- a/panel/PanelMenuView.cpp
+++ b/panel/PanelMenuView.cpp
@@ -21,8 +21,9 @@
#include <Nux/Nux.h>
#include <NuxCore/Logger.h>
-#include "unity-shared/CairoTexture.h"
#include "PanelMenuView.h"
+#include "unity-shared/AnimationUtils.h"
+#include "unity-shared/CairoTexture.h"
#include "unity-shared/PanelStyle.h"
#include "unity-shared/UnitySettings.h"
#include "unity-shared/UBusMessages.h"
@@ -34,8 +35,6 @@
#include "config.h"
#include <glib/gi18n-lib.h>
-namespace na = nux::animation;
-
namespace unity
{
DECLARE_LOGGER(logger, "unity.panel.menu");
@@ -305,35 +304,19 @@ void PanelMenuView::PreLayoutManagement()
void PanelMenuView::StartFadeIn(int duration)
{
- if (opacity_animator_.CurrentState() == na::Animation::State::Running)
- {
- if (opacity_animator_.GetFinishValue() != 1.0f)
- opacity_animator_.Reverse();
-
- return;
- }
-
opacity_animator_.SetDuration(duration >= 0 ? duration : menus_fadein_);
- opacity_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
+ animation::StartOrReverse(opacity_animator_, animation::Direction::FORWARD);
}
void PanelMenuView::StartFadeOut(int duration)
{
- if (opacity_animator_.CurrentState() == na::Animation::State::Running)
- {
- if (opacity_animator_.GetFinishValue() != 0.0f)
- opacity_animator_.Reverse();
-
- return;
- }
-
opacity_animator_.SetDuration(duration >= 0 ? duration : menus_fadeout_);
- opacity_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start();
+ animation::StartOrReverse(opacity_animator_, animation::Direction::BACKWARD);
}
void PanelMenuView::OnFadeAnimatorUpdated(double progress)
{
- if (opacity_animator_.GetFinishValue() == 1.0f) /* Fading in... */
+ if (animation::GetDirection(opacity_animator_) == animation::Direction::FORWARD) /* Fading in... */
{
if (ShouldDrawMenus() && opacity() != 1.0f)
opacity = progress;
@@ -341,7 +324,7 @@ void PanelMenuView::OnFadeAnimatorUpdated(double progress)
if (ShouldDrawButtons() && window_buttons_->opacity() != 1.0f)
window_buttons_->opacity = progress;
}
- else if (opacity_animator_.GetFinishValue() == 0.0f) /* Fading out... */
+ else if (animation::GetDirection(opacity_animator_) == animation::Direction::BACKWARD) /* Fading out... */
{
if (!ShouldDrawMenus() && opacity() != 0.0f)
opacity = progress;
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index 3d2dc0e71..b4d3d35e3 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -349,6 +349,9 @@ UnityScreen::UnityScreen(CompScreen* screen)
optionSetLauncherSwitcherPrevInitiate(boost::bind(&UnityScreen::launcherSwitcherPrevInitiate, this, _1, _2, _3));
optionSetLauncherSwitcherForwardTerminate(boost::bind(&UnityScreen::launcherSwitcherTerminate, this, _1, _2, _3));
+ optionSetWindowRightMaximizeInitiate(boost::bind(&UnityScreen::rightMaximizeKeyInitiate, this, _1, _2, _3));
+ optionSetWindowLeftMaximizeInitiate(boost::bind(&UnityScreen::leftMaximizeKeyInitiate, this, _1, _2, _3));
+
optionSetStopVelocityNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
optionSetRevealPressureNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
optionSetEdgeResponsivenessNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
@@ -1334,26 +1337,39 @@ void UnityScreen::donePaint()
if (animation_controller_->HasRunningAnimations())
nuxDamageCompiz();
- std::list <ShowdesktopHandlerWindowInterface *> remove_windows;
-
- for (ShowdesktopHandlerWindowInterface *wi : ShowdesktopHandler::animating_windows)
+ for (auto it = ShowdesktopHandler::animating_windows.begin(); it != ShowdesktopHandler::animating_windows.end();)
{
- ShowdesktopHandlerWindowInterface::PostPaintAction action = wi->HandleAnimations (0);
+ auto const& wi = *it;
+ auto action = wi->HandleAnimations(0);
+
if (action == ShowdesktopHandlerWindowInterface::PostPaintAction::Remove)
- remove_windows.push_back(wi);
+ {
+ it = ShowdesktopHandler::animating_windows.erase(it);
+ continue;
+ }
else if (action == ShowdesktopHandlerWindowInterface::PostPaintAction::Damage)
+ {
wi->AddDamage ();
- }
+ }
- for (ShowdesktopHandlerWindowInterface *wi : remove_windows)
- {
- wi->DeleteHandler ();
- ShowdesktopHandler::animating_windows.remove (wi);
+ ++it;
}
cScreen->donePaint ();
}
+void redraw_view_if_damaged(nux::ObjectPtr<nux::View> const& view, CompRegion const& damage)
+{
+ if (!view || view->IsRedrawNeeded())
+ return;
+
+ auto const& geo = view->GetAbsoluteGeometry();
+ CompRegion region(geo.x, geo.y, geo.width, geo.height);
+
+ if (damage.intersects(region))
+ view->NeedSoftRedraw();
+}
+
void UnityScreen::compizDamageNux(CompRegion const& damage)
{
if (!launcher_controller_)
@@ -1378,79 +1394,28 @@ void UnityScreen::compizDamageNux(CompRegion const& damage)
}
}
+ if (dash_controller_->IsVisible())
+ redraw_view_if_damaged(dash_controller_->Dash(), damage);
+
auto const& launchers = launcher_controller_->launchers();
for (auto const& launcher : launchers)
{
if (!launcher->Hidden())
{
- nux::Geometry const& geo = launcher->GetAbsoluteGeometry();
- CompRegion launcher_region(geo.x, geo.y, geo.width, geo.height);
-
- if (damage.intersects(launcher_region))
- launcher->QueueDraw();
-
- nux::ObjectPtr<nux::View> const& tooltip = launcher->GetActiveTooltip();
-
- if (tooltip)
- {
- nux::Geometry const& g = tooltip->GetAbsoluteGeometry();
- CompRegion tip_region(g.x, g.y, g.width, g.height);
-
- if (damage.intersects(tip_region))
- tooltip->QueueDraw();
- }
-
- nux::ObjectPtr<LauncherDragWindow> const& dragged_icon = launcher->GetDraggedIcon();
-
- if (dragged_icon)
- {
- nux::Geometry const& g = dragged_icon->GetAbsoluteGeometry();
- CompRegion icon_region(g.x, g.y, g.width, g.height);
-
- if (damage.intersects(icon_region))
- dragged_icon->QueueDraw();
- }
+ redraw_view_if_damaged(launcher, damage);
+ redraw_view_if_damaged(launcher->GetActiveTooltip(), damage);
+ redraw_view_if_damaged(launcher->GetDraggedIcon(), damage);
}
}
for (auto const& panel : panel_controller_->panels())
- {
- nux::Geometry const& geo = panel->GetAbsoluteGeometry();
-
- CompRegion panel_region(geo.x, geo.y, geo.width, geo.height);
-
- if (damage.intersects(panel_region))
- panel->QueueDraw();
- }
+ redraw_view_if_damaged(panel, damage);
- QuicklistManager* qm = QuicklistManager::Default();
- if (qm)
- {
- auto const& view = qm->Current();
-
- if (view)
- {
- nux::Geometry const& geo = view->GetAbsoluteGeometry();
- CompRegion quicklist_region(geo.x, geo.y, geo.width, geo.height);
+ if (QuicklistManager* qm = QuicklistManager::Default())
+ redraw_view_if_damaged(qm->Current(), damage);
- if (damage.intersects(quicklist_region))
- view->QueueDraw();
- }
- }
-
- if (switcher_controller_ && switcher_controller_->Visible())
- {
- auto const& view = switcher_controller_->GetView();
-
- if (G_LIKELY(view))
- {
- nux::Geometry const& geo = view->GetAbsoluteGeometry();
- CompRegion switcher_region(geo.x, geo.y, geo.width, geo.height);
-
- if (damage.intersects(switcher_region))
- view->QueueDraw();
- }
- }
+ if (switcher_controller_->Visible())
+ redraw_view_if_damaged(switcher_controller_->GetView(), damage);
}
/* Grab changed nux regions and add damage rects for them */
@@ -2136,12 +2101,14 @@ bool UnityScreen::launcherSwitcherForwardInitiate(CompAction* action, CompAction
action->setState(action->state() | CompAction::StateTermKey);
return true;
}
+
bool UnityScreen::launcherSwitcherPrevInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options)
{
launcher_controller_->KeyNavPrevious();
return true;
}
+
bool UnityScreen::launcherSwitcherTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options)
{
bool accept_state = (state & CompAction::StateCancel) == 0;
@@ -2164,6 +2131,20 @@ bool UnityScreen::launcherSwitcherTerminate(CompAction* action, CompAction::Stat
return true;
}
+bool UnityScreen::rightMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options)
+{
+ auto& WM = WindowManager::Default();
+ WM.RightMaximize(WM.GetActiveWindow());
+ return true;
+}
+
+bool UnityScreen::leftMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options)
+{
+ auto& WM = WindowManager::Default();
+ WM.LeftMaximize(WM.GetActiveWindow());
+ return true;
+}
+
void UnityScreen::OnLauncherStartKeyNav(GVariant* data)
{
// Put the launcher BaseWindow at the top of the BaseWindow stack. The
@@ -2979,11 +2960,11 @@ CompPoint UnityWindow::tryNotIntersectUI(CompPoint& pos)
for (auto const& launcher : launchers)
{
- nux::Geometry geo = launcher->GetAbsoluteGeometry();
-
if (launcher->options()->hide_mode == LAUNCHER_HIDE_AUTOHIDE && launcher->Hidden())
continue;
+ auto const& geo = launcher->GetAbsoluteGeometry();
+
if (geo.IsInside(result))
{
if (geo.x + geo.width + 1 + window_geo.width() < target_monitor.x + target_monitor.width)
@@ -3554,6 +3535,10 @@ void UnityWindow::AddProperties(GVariantBuilder* builder)
.add("xid", (uint64_t)xid)
.add("title", wm.GetWindowName(xid))
.add("fake_decorated", uScreen->fake_decorated_windows_.find(this) != uScreen->fake_decorated_windows_.end())
+ .add("maximized", wm.IsWindowVerticallyMaximized(xid))
+ .add("horizontally_maximized", wm.IsWindowHorizontallyMaximized(xid))
+ .add("vertically_maximized", wm.IsWindowVerticallyMaximized(xid))
+ .add("minimized", wm.IsWindowMinimized(xid))
.add("scaled", scaled)
.add("scaled_close_geo", close_button_geo_)
.add("scaled_close_x", close_button_geo_.x)
diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h
index e2b50badf..1e8d46ab7 100644
--- a/plugins/unityshell/src/unityshell.h
+++ b/plugins/unityshell/src/unityshell.h
@@ -178,6 +178,8 @@ public:
bool launcherSwitcherForwardInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
bool launcherSwitcherPrevInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
bool launcherSwitcherTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options);
+ bool rightMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
+ bool leftMaximizeKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
/* handle option changes and change settings inside of the
* panel and dock views */
diff --git a/plugins/unityshell/unityshell.xml.in b/plugins/unityshell/unityshell.xml.in
index d4357bc91..f5ed1b656 100644
--- a/plugins/unityshell/unityshell.xml.in
+++ b/plugins/unityshell/unityshell.xml.in
@@ -68,6 +68,18 @@
<default>&lt;Alt&gt;F10</default>
</option>
+ <option name="window_right_maximize" type="key">
+ <_short>Key to vertically maximize the focused window to the right</_short>
+ <_long>Semi-maximize vertically the focused window on the half right width of the screen</_long>
+ <default>&lt;Control&gt;&lt;Super&gt;Right</default>
+ </option>
+
+ <option name="window_left_maximize" type="key">
+ <_short>Key to vertically maximize the focused window to the left</_short>
+ <_long>Semi-maximize vertically the focused window to the half left width of the screen</_long>
+ <default>&lt;Control&gt;&lt;Super&gt;Left</default>
+ </option>
+
<option name="panel_opacity" type="float">
<_short>Panel Opacity</_short>
<_long>The opacity of the Panel background.</_long>
diff --git a/shortcuts/CompizShortcutModeller.cpp b/shortcuts/CompizShortcutModeller.cpp
index 418186470..b77966a70 100644
--- a/shortcuts/CompizShortcutModeller.cpp
+++ b/shortcuts/CompizShortcutModeller.cpp
@@ -32,7 +32,6 @@ namespace
// Compiz' plug-in names
const std::string CORE_PLUGIN_NAME = "core";
const std::string EXPO_PLUGIN_NAME = "expo";
- const std::string GRID_PLUGIN_NAME = "grid";
const std::string MOVE_PLUGIN_NAME = "move";
const std::string RESIZE_PLUGIN_NAME = "resize";
const std::string SCALE_PLUGIN_NAME = "scale";
@@ -41,17 +40,14 @@ namespace
// Compiz Core Options
const std::string CORE_OPTION_SHOW_DESKTOP_KEY = "show_desktop_key";
- const std::string CORE_OPTION_MAXIMIZE_WINDOW_KEY = "maximize_window_key";
- const std::string CORE_OPTION_UNMAXIMIZE_OR_MINIMIZE_WINDOW_KEY = "unmaximize_or_minimize_window_key";
+ const std::string CORE_OPTION_MAXIMIZE_KEY = "maximize_window_key";
+ const std::string CORE_OPTION_RESTORE_MINIMIZE_KEY = "unmaximize_or_minimize_window_key";
const std::string CORE_OPTION_CLOSE_WINDOW_KEY = "close_window_key";
const std::string CORE_OPTION_WINDOW_MENU_KEY = "window_menu_key";
// Compiz Expo Options
const std::string EXPO_OPTION_EXPO_KEY = "expo_key";
- // Compiz Grid Options
- const std::string GRID_OPTION_PUT_LEFT_KEY = "put_left_key";
-
// Compiz Move Options
const std::string MOVE_OPTION_INITIATE_BUTTON = "initiate_button";
@@ -69,6 +65,10 @@ namespace
const std::string UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu";
const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward";
const std::string UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window";
+ const std::string UNITYSHELL_OPTION_MAXIMIZE = "window_maximize";
+ const std::string UNITYSHELL_OPTION_LEFT_MAXIMIZE = "window_left_maximize";
+ const std::string UNITYSHELL_OPTION_RIGHT_MAXIMIZE = "window_right_maximize";
+ const std::string UNITYSHELL_OPTION_RESTORE_MINIMIZE = "window_restore_minimize";
// Compiz Wall Options
const std::string WALL_OPTION_LEFT_KEY = "left_key";
@@ -304,19 +304,19 @@ void CompizModeller::AddWindowsHints(std::list<shortcut::AbstractHint::Ptr> &hin
_("Maximises the current window."),
shortcut::OptionType::COMPIZ_KEY,
CORE_PLUGIN_NAME,
- CORE_OPTION_MAXIMIZE_WINDOW_KEY));
+ CORE_OPTION_MAXIMIZE_KEY));
hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Restores or minimises the current window."),
shortcut::OptionType::COMPIZ_KEY,
CORE_PLUGIN_NAME,
- CORE_OPTION_UNMAXIMIZE_OR_MINIMIZE_WINDOW_KEY));
+ CORE_OPTION_RESTORE_MINIMIZE_KEY));
hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" or Right"),
_("Semi-maximise the current window."),
shortcut::OptionType::COMPIZ_KEY,
- GRID_PLUGIN_NAME,
- GRID_OPTION_PUT_LEFT_KEY));
+ UNITYSHELL_PLUGIN_NAME,
+ UNITYSHELL_OPTION_LEFT_MAXIMIZE));
hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Closes the current window."),
@@ -333,7 +333,7 @@ void CompizModeller::AddWindowsHints(std::list<shortcut::AbstractHint::Ptr> &hin
hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
_("Places the window in corresponding position."),
shortcut::OptionType::HARDCODED,
- _("Ctrl + Alt + Num")));
+ _("Ctrl + Alt + Num (keypad)")));
hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"),
_("Moves the window."),
diff --git a/shortcuts/ShortcutController.cpp b/shortcuts/ShortcutController.cpp
index 12ef5e01b..05c1b7b19 100644
--- a/shortcuts/ShortcutController.cpp
+++ b/shortcuts/ShortcutController.cpp
@@ -20,11 +20,10 @@
#include "ShortcutController.h"
#include "ShortcutModel.h"
+#include "unity-shared/AnimationUtils.h"
#include "unity-shared/UBusMessages.h"
#include "unity-shared/UScreen.h"
-namespace na = nux::animation;
-
namespace unity
{
namespace shortcut
@@ -129,16 +128,7 @@ bool Controller::OnShowTimer()
if (visible_)
{
view_->live_background = true;
-
- if (fade_animator_.CurrentState() == na::Animation::State::Running)
- {
- if (fade_animator_.GetFinishValue() == 0.0f)
- fade_animator_.Reverse();
- }
- else
- {
- fade_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
- }
+ animation::StartOrReverse(fade_animator_, animation::Direction::FORWARD);
}
return false;
@@ -214,16 +204,7 @@ void Controller::Hide()
if (view_window_ && view_window_->GetOpacity() > 0.0f)
{
view_->live_background = false;
-
- if (fade_animator_.CurrentState() == na::Animation::State::Running)
- {
- if (fade_animator_.GetFinishValue() == 1.0f)
- fade_animator_.Reverse();
- }
- else
- {
- fade_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start();
- }
+ animation::StartOrReverse(fade_animator_, animation::Direction::BACKWARD);
}
}
@@ -258,12 +239,13 @@ std::string Controller::GetName() const
void Controller::AddProperties(GVariantBuilder* builder)
{
bool animating = (fade_animator_.CurrentState() == na::Animation::State::Running);
+ auto direction = animation::GetDirection(fade_animator_);
unity::variant::BuilderWrapper(builder)
.add("timeout_duration", SUPER_TAP_DURATION + FADE_DURATION)
.add("enabled", IsEnabled())
- .add("about_to_show", (Visible() && animating && fade_animator_.GetFinishValue() == 1.0f))
- .add("about_to_hide", (Visible() && animating && fade_animator_.GetFinishValue() == 0.0f))
+ .add("about_to_show", (Visible() && animating && direction == animation::Direction::FORWARD))
+ .add("about_to_hide", (Visible() && animating && direction == animation::Direction::FORWARD))
.add("visible", (Visible() && view_window_ && view_window_->GetOpacity() == 1.0f));
}
diff --git a/shortcuts/ShortcutView.cpp b/shortcuts/ShortcutView.cpp
index 389c4f73e..85eb93fb2 100644
--- a/shortcuts/ShortcutView.cpp
+++ b/shortcuts/ShortcutView.cpp
@@ -21,6 +21,7 @@
#include "ShortcutView.h"
#include <glib/gi18n-lib.h>
+#include <Nux/VLayout.h>
#include <UnityCore/ConnectionManager.h>
#include <UnityCore/GLibWrapper.h>
@@ -33,8 +34,10 @@ namespace shortcut
{
namespace
{
- const unsigned SECTION_NAME_FONT_SIZE = 17/1.33;
- const unsigned SHORTKEY_ENTRY_FONT_SIZE = 13/1.33;
+ const std::string FONT_NAME = "Ubuntu";
+ const unsigned MAIN_TITLE_FONT_SIZE = 15;
+ const unsigned SECTION_NAME_FONT_SIZE = 12;
+ const unsigned SHORTKEY_ENTRY_FONT_SIZE = 9;
const unsigned INTER_SPACE_SHORTKEY_DESCRIPTION = 10;
const unsigned SHORTKEY_COLUMN_WIDTH = 150;
const unsigned DESCRIPTION_COLUMN_WIDTH = 265;
@@ -75,9 +78,9 @@ View::View()
std::string header = "<b>"+std::string(_("Keyboard Shortcuts"))+"</b>";
- nux::StaticText* header_view = new nux::StaticText(header, NUX_TRACKER_LOCATION);
- header_view->SetTextPointSize(20/1.33);
- header_view->SetFontName("Ubuntu");
+ auto* header_view = new StaticCairoText(header, NUX_TRACKER_LOCATION);
+ header_view->SetFont(FONT_NAME+" "+std::to_string(MAIN_TITLE_FONT_SIZE));
+ header_view->SetLines(-1);
main_layout->AddView(header_view, 1 , nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
main_layout->AddView(new HSeparator(), 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
@@ -108,9 +111,9 @@ nux::LinearLayout* View::CreateSectionLayout(std::string const& section_name)
nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
std::string name("<b>"+glib::String(g_markup_escape_text(section_name.c_str(), -1)).Str()+"</b>");
- nux::StaticText* section_name_view = new nux::StaticText(name, NUX_TRACKER_LOCATION);
- section_name_view->SetTextPointSize(SECTION_NAME_FONT_SIZE);
- section_name_view->SetFontName("Ubuntu");
+ auto* section_name_view = new StaticCairoText(name, NUX_TRACKER_LOCATION);
+ section_name_view->SetFont(FONT_NAME+" "+std::to_string(SECTION_NAME_FONT_SIZE));
+ section_name_view->SetLines(-1);
layout->AddView(new nux::SpaceLayout(10, 10, 10, 10), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);
layout->AddView(section_name_view, 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);
layout->AddView(new nux::SpaceLayout(15, 15, 15, 15), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);
@@ -131,19 +134,19 @@ nux::View* View::CreateShortKeyEntryView(AbstractHint::Ptr const& hint)
glib::String shortkey(g_markup_escape_text(hint->shortkey().c_str(), -1));
std::string skey = "<b>"+shortkey.Str()+"</b>";
- nux::StaticText* shortkey_view = new nux::StaticText(skey, NUX_TRACKER_LOCATION);
- shortkey_view->SetTextAlignment(nux::StaticText::ALIGN_LEFT);
- shortkey_view->SetFontName("Ubuntu");
- shortkey_view->SetTextPointSize(SHORTKEY_ENTRY_FONT_SIZE);
+ auto* shortkey_view = new StaticCairoText(skey, NUX_TRACKER_LOCATION);
+ shortkey_view->SetTextAlignment(StaticCairoText::AlignState::NUX_ALIGN_LEFT);
+ shortkey_view->SetFont(FONT_NAME+" "+std::to_string(SHORTKEY_ENTRY_FONT_SIZE));
+ shortkey_view->SetLines(-1);
shortkey_view->SetMinimumWidth(SHORTKEY_COLUMN_WIDTH);
shortkey_view->SetMaximumWidth(SHORTKEY_COLUMN_WIDTH);
glib::String es_desc(g_markup_escape_text(hint->description().c_str(), -1));
- nux::StaticText* description_view = new nux::StaticText(es_desc.Value(), NUX_TRACKER_LOCATION);
- description_view->SetTextAlignment(nux::StaticText::ALIGN_LEFT);
- shortkey_view->SetFontName("Ubuntu");
- description_view->SetTextPointSize(SHORTKEY_ENTRY_FONT_SIZE);
+ auto* description_view = new StaticCairoText(es_desc.Str(), NUX_TRACKER_LOCATION);
+ description_view->SetTextAlignment(StaticCairoText::AlignState::NUX_ALIGN_LEFT);
+ description_view->SetFont(FONT_NAME+" "+std::to_string(SHORTKEY_ENTRY_FONT_SIZE));
+ description_view->SetLines(-1);
description_view->SetMinimumWidth(DESCRIPTION_COLUMN_WIDTH);
description_view->SetMaximumWidth(DESCRIPTION_COLUMN_WIDTH);
diff --git a/shortcuts/ShortcutView.h b/shortcuts/ShortcutView.h
index 7c77545e3..dc8622600 100644
--- a/shortcuts/ShortcutView.h
+++ b/shortcuts/ShortcutView.h
@@ -20,13 +20,8 @@
#define UNITYSHELL_SHORTCUTVIEW_H
#include <Nux/Nux.h>
-#include <Nux/GridHLayout.h>
#include <Nux/HLayout.h>
-#include <NuxCore/ObjectPtr.h>
-#include <NuxCore/Property.h>
-#include <Nux/StaticText.h>
#include <Nux/View.h>
-#include <Nux/VLayout.h>
#include "unity-shared/UnityWindowView.h"
#include "unity-shared/BackgroundEffectHelper.h"
diff --git a/shutdown/SessionController.cpp b/shutdown/SessionController.cpp
index d4f7f0bf6..2f255dc75 100644
--- a/shutdown/SessionController.cpp
+++ b/shutdown/SessionController.cpp
@@ -19,6 +19,7 @@
#include "SessionController.h"
+#include "unity-shared/AnimationUtils.h"
#include "unity-shared/UBusMessages.h"
#include "unity-shared/UScreen.h"
#include "unity-shared/WindowManager.h"
@@ -58,13 +59,9 @@ Controller::Controller(session::Manager::Ptr const& manager)
ubus_manager_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
- fade_animator_.updated.connect([this] (double opacity) {
- if (!view_window_)
- return;
-
- view_window_->SetOpacity(opacity);
-
- if (opacity == 0.0f && fade_animator_.GetFinishValue() == 0.0f)
+ fade_animator_.updated.connect([this] (double opacity) { view_window_->SetOpacity(opacity); });
+ fade_animator_.finished.connect([this] {
+ if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD)
CloseWindow();
});
}
@@ -109,16 +106,7 @@ void Controller::Show(View::Mode mode, bool inhibitors)
view_window_->PushToFront();
view_window_->SetInputFocus();
nux::GetWindowCompositor().SetKeyFocusArea(view_->key_focus_area());
-
- if (fade_animator_.CurrentState() == na::Animation::State::Running)
- {
- if (fade_animator_.GetFinishValue() == 0.0f)
- fade_animator_.Reverse();
- }
- else
- {
- fade_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
- }
+ animation::StartOrReverse(fade_animator_, animation::Direction::FORWARD);
}
nux::Point Controller::GetOffsetPerMonitor(int monitor)
@@ -189,15 +177,7 @@ void Controller::CancelAndHide()
void Controller::Hide()
{
- if (fade_animator_.CurrentState() == na::Animation::State::Running)
- {
- if (fade_animator_.GetFinishValue() == 1.0f)
- fade_animator_.Reverse();
- }
- else
- {
- fade_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start();
- }
+ animation::StartOrReverse(fade_animator_, animation::Direction::BACKWARD);
}
void Controller::CloseWindow()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index bec6b4e93..d0616ac23 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -132,6 +132,7 @@ if (GMOCK_LIB AND
test_main_xless.cpp
mock-application.cpp
test_abstract_interface_generator.cpp
+ test_animation_utils.cpp
test_connection_manager.cpp
test_glib_dbus_object.cpp
test_glib_cancellable.cpp
diff --git a/tests/autopilot/unity/emulators/launcher.py b/tests/autopilot/unity/emulators/launcher.py
index 42e4a1ae8..a1fc47bd5 100644
--- a/tests/autopilot/unity/emulators/launcher.py
+++ b/tests/autopilot/unity/emulators/launcher.py
@@ -121,16 +121,28 @@ class Launcher(UnityIntrospectionObject, KeybindingsHelper):
logger.debug("Moving mouse to center of launcher.")
self._mouse.move(target_x, target_y)
- def move_mouse_to_icon(self, icon):
- # The icon may be off the bottom of screen, so we do this in a loop:
- while 1:
- target_x = icon.center_x + self.x
- target_y = icon.center_y
+ def move_mouse_to_icon(self, icon, autoscroll_offset=0):
+ """Move the mouse to a specific icon."""
+ (x, y, w, h) = self.geometry
+ found = False
+
+ # Only try 10 times (5 secs.) before giving up.
+ for i in xrange(0, 10):
+ mouse_x = target_x = icon.center_x + self.x
+ mouse_y = target_y = icon.center_y
+ if target_y > h:
+ mouse_y = h + y - autoscroll_offset
+ elif target_y < 0:
+ mouse_y = y + autoscroll_offset
if self._mouse.x == target_x and self._mouse.y == target_y:
+ found = True
break
- self._mouse.move(target_x, target_y)
+ self._mouse.move(mouse_x, mouse_y)
sleep(0.5)
+ if not found:
+ raise RuntimeError("Could not move mouse to the icon")
+
def mouse_reveal_launcher(self):
"""Reveal this launcher with the mouse.
@@ -309,17 +321,11 @@ class Launcher(UnityIntrospectionObject, KeybindingsHelper):
logger.debug("Clicking launcher icon %r on monitor %d with mouse button %d",
icon, self.monitor, button)
- self.mouse_reveal_launcher()
- # The icon may be off the screen, so we do this in a loop:
- while 1:
- target_x = icon.center_x + self.x
- target_y = icon.center_y
- if self._mouse.x == target_x and self._mouse.y == target_y:
- break
- self._mouse.move(target_x, target_y )
- sleep(1)
+ self.mouse_reveal_launcher()
+ self.move_mouse_to_icon(icon)
self._mouse.click(button)
+
if (move_mouse_after):
self.move_mouse_to_right_of_launcher()
@@ -371,7 +377,7 @@ class Launcher(UnityIntrospectionObject, KeybindingsHelper):
if target_y < icon.center_y:
target_y += icon_height / 2
if pos == IconDragType.BEFORE:
- target_y -= icon_height
+ target_y -= icon_height + (icon_height / 2)
self.move_mouse_to_icon(icon)
self._mouse.press()
@@ -422,27 +428,6 @@ class Launcher(UnityIntrospectionObject, KeybindingsHelper):
pin_item = quicklist.get_quicklist_item_by_text('Unlock from Launcher')
quicklist.click_item(pin_item)
- def autoscroll_to_icon(self, icon, autoscroll_offset=0):
- """Moves the mouse to the autoscroll zone to scroll the Launcher to the icon
- in question.
-
- autoscroll_offet is the offset, in number of pixels, from the end of the
- autoscroll zone where is the autoscroll zone is currently 24 pixels high.
- """
- (x, y, w, h) = self.geometry
-
- while 1:
- mouse_x = target_x = icon.center_x + self.x
- mouse_y = target_y = icon.center_y
- if target_y > h:
- mouse_y = h + y - autoscroll_offset
- elif target_y < 0:
- mouse_y = y + autoscroll_offset
- if self._mouse.x == target_x and self._mouse.y == target_y:
- break
- self._mouse.move(mouse_x, mouse_y)
- sleep(0.5)
-
@property
def geometry(self):
"""Returns a tuple of (x,y,w,h) for the current launcher."""
diff --git a/tests/autopilot/unity/tests/launcher/test_scroll.py b/tests/autopilot/unity/tests/launcher/test_scroll.py
index f2b6fc93b..31c162290 100644
--- a/tests/autopilot/unity/tests/launcher/test_scroll.py
+++ b/tests/autopilot/unity/tests/launcher/test_scroll.py
@@ -58,7 +58,7 @@ class LauncherScrollTests(LauncherTestCase):
self.assertThat(last_icon.center_y, Eventually(GreaterThan(h)))
# Autoscroll to the last icon
- launcher_instance.autoscroll_to_icon(last_icon, autoscroll_offset)
+ launcher_instance.move_mouse_to_icon(last_icon, autoscroll_offset)
(x_fin, y_fin) = self.mouse.position()
@@ -90,7 +90,7 @@ class LauncherScrollTests(LauncherTestCase):
self.assertThat(first_icon.center_y, Eventually(LessThan(y)))
# Autoscroll to the first icon
- launcher_instance.autoscroll_to_icon(first_icon, autoscroll_offset)
+ launcher_instance.move_mouse_to_icon(first_icon, autoscroll_offset)
(x_fin, y_fin) = self.mouse.position()
diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py
index 20f8cc6a9..d5378396c 100644
--- a/tests/autopilot/unity/tests/test_hud.py
+++ b/tests/autopilot/unity/tests/test_hud.py
@@ -414,8 +414,9 @@ class HudBehaviorTests(HudTestsBase):
self.assertThat(self.unity.hud.num_buttons, Eventually(Equals(5)))
(x,y,w,h) = self.unity.hud.view.geometry
- self.mouse.move(w/2, 0)
- self.mouse.move(w/2, h)
+ # Specify a slower rate so that HUD can register the mouse movement properly
+ self.mouse.move(w/2, 0, rate=5)
+ self.mouse.move(w/2, h, rate=5)
self.assertThat(self.unity.hud.view.selected_button, Eventually(Equals(5)))
for i in range(5):
diff --git a/tests/autopilot/unity/tests/test_ibus.py b/tests/autopilot/unity/tests/test_ibus.py
index 45c5813d2..4bcf0d7bb 100644
--- a/tests/autopilot/unity/tests/test_ibus.py
+++ b/tests/autopilot/unity/tests/test_ibus.py
@@ -118,8 +118,30 @@ class IBusTests(UnityTestCase):
This method adds a cleanUp to reset the old keys once the test is done.
"""
- # FIXME Need to set this using gsettings...removed old gconf code for now
- self.activate_binding = 'Control+space'
+ bus = get_ibus_bus()
+ config = bus.get_config()
+
+ variant = config.get_value('general/hotkey', 'triggers')
+ shortcuts = []
+
+ # If none, assume default
+ if variant != None:
+ shortcuts = variant.unpack()
+ else:
+ shortcuts = ['<Super>space']
+
+ # IBus uses the format '<mod><mod><mod>key'
+ # Autopilot uses the format 'mod+mod+mod+key'
+ # replace all > with a +, and ignore the < char
+
+ shortcut = ""
+ for c in shortcuts[0]:
+ if c == '>':
+ shortcut += '+'
+ elif c != '<':
+ shortcut += c
+
+ self.activate_binding = shortcut
activate_release_binding_option = 'Alt+Release+Control_L'
self.activate_release_binding = 'Alt+Control_L'
diff --git a/tests/autopilot/unity/tests/test_wm_keybindings.py b/tests/autopilot/unity/tests/test_wm_keybindings.py
new file mode 100644
index 000000000..6e177ca3f
--- /dev/null
+++ b/tests/autopilot/unity/tests/test_wm_keybindings.py
@@ -0,0 +1,110 @@
+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
+# Copyright 2013 Canonical
+# Author: Marco Trevisan (TreviƱo)
+#
+# 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.
+
+from __future__ import absolute_import
+
+from autopilot.matchers import Eventually
+from testtools.matchers import Equals, NotEquals
+from unity.tests import UnityTestCase
+
+class WindowManagerKeybindings(UnityTestCase):
+ """Window Manager keybindings tests"""
+
+ scenarios = [('Restored Window', {'start_restored': True}),
+ ('Maximized Window', {'start_restored': False})]
+
+ def setUp(self):
+ super(WindowManagerKeybindings, self).setUp()
+ self.start_test_window()
+
+ def keybinding_if_not_minimized(self, keybinding):
+ if not self.screen_win.minimized:
+ self.keybinding(keybinding)
+
+ def keybinding_if_not_restored(self, keybinding):
+ if self.screen_win.vertically_maximized or self.screen_win.horizontally_maximized:
+ self.keybinding(keybinding)
+
+ def start_test_window(self, app_name="Character Map"):
+ """Start a restored/maximized window of the requested application"""
+ self.process_manager.close_all_app(app_name)
+ self.bamf_win = self.process_manager.start_app_window(app_name)
+ win_fn = lambda: self.unity.screen.window(self.bamf_win.x_id)
+ self.assertThat(win_fn, Eventually(NotEquals(None)))
+ self.screen_win = win_fn()
+
+ if self.start_restored:
+ if self.screen_win.vertically_maximized or self.screen_win.horizontally_maximized:
+ self.addCleanup(self.keybinding_if_not_minimized, "window/maximize")
+ self.keybinding("window/restore")
+ else:
+ if not self.screen_win.vertically_maximized and not self.screen_win.horizontally_maximized:
+ self.addCleanup(self.keybinding_if_not_restored, "window/restore")
+ self.keybinding("window/maximize")
+
+ def get_window_workarea(self):
+ monitor = self.bamf_win.monitor
+ monitor_geo = self.display.get_screen_geometry(monitor)
+ launcher = self.unity.launcher.get_launcher_for_monitor(monitor)
+ launcher_w = 0 if launcher.hidemode else launcher.geometry[2]
+ panel_h = self.unity.panels.get_panel_for_monitor(monitor).geometry[3]
+ return (monitor_geo[0] + launcher_w, monitor_geo[1] + panel_h,
+ monitor_geo[2] - launcher_w, monitor_geo[3] - panel_h)
+
+ def test_maximize_window(self):
+ if self.start_restored:
+ self.addCleanup(self.keybinding, "window/restore")
+ self.keybinding("window/maximize")
+ self.assertThat(self.screen_win.maximized, Eventually(Equals(True)))
+
+ def test_restore_maximized_window(self):
+ if self.start_restored:
+ self.keybinding("window/maximize")
+ self.keybinding("window/restore")
+ self.assertThat(self.screen_win.maximized, Eventually(Equals(False)))
+ self.assertThat(self.screen_win.minimized, Eventually(Equals(False)))
+
+ def test_restore_vertically_maximized_window(self):
+ if not self.start_restored:
+ self.addCleanup(self.keybinding, "window/maximize")
+ self.keybinding("window/restore")
+ self.keyboard.press_and_release("Ctrl+Super+Right")
+ self.keybinding("window/restore")
+ self.assertThat(self.screen_win.vertically_maximized, Eventually(Equals(False)))
+ self.assertThat(self.screen_win.minimized, Eventually(Equals(False)))
+
+ def test_minimize_restored_window(self):
+ if not self.start_restored:
+ self.addCleanup(self.keybinding_if_not_minimized, "window/maximize")
+ self.keybinding("window/restore")
+ self.keybinding("window/restore")
+ self.assertThat(self.screen_win.minimized, Eventually(Equals(True)))
+
+ def test_left_maximize(self):
+ self.addCleanup(self.keybinding, "window/restore" if self.start_restored else "window/maximize")
+ self.keyboard.press_and_release("Ctrl+Super+Left")
+ self.assertThat(self.screen_win.vertically_maximized, Eventually(Equals(True)))
+ self.assertThat(self.screen_win.horizontally_maximized, Eventually(Equals(False)))
+
+ workarea_geo = self.get_window_workarea()
+ self.assertThat(self.screen_win.x, Eventually(Equals(workarea_geo[0])))
+ self.assertThat(self.screen_win.y, Eventually(Equals(workarea_geo[1])))
+ self.assertThat(self.screen_win.width, Eventually(Equals(workarea_geo[2]/2)))
+ self.assertThat(self.screen_win.height, Eventually(Equals(workarea_geo[3])))
+
+ def test_right_maximize(self):
+ self.addCleanup(self.keybinding, "window/restore" if self.start_restored else "window/maximize")
+ self.keyboard.press_and_release("Ctrl+Super+Right")
+ self.assertThat(self.screen_win.vertically_maximized, Eventually(Equals(True)))
+ self.assertThat(self.screen_win.horizontally_maximized, Eventually(Equals(False)))
+
+ workarea_geo = self.get_window_workarea()
+ self.assertThat(self.screen_win.x, Eventually(Equals(workarea_geo[0]+workarea_geo[2]/2)))
+ self.assertThat(self.screen_win.y, Eventually(Equals(workarea_geo[1])))
+ self.assertThat(self.screen_win.width, Eventually(Equals(workarea_geo[2]/2)))
+ self.assertThat(self.screen_win.height, Eventually(Equals(workarea_geo[3])))
diff --git a/tests/test_animation_utils.cpp b/tests/test_animation_utils.cpp
new file mode 100644
index 000000000..94296cc8e
--- /dev/null
+++ b/tests/test_animation_utils.cpp
@@ -0,0 +1,271 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2013 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: Marco Trevisan <marco.trevisan@canonical.com>
+ */
+
+#include <gmock/gmock.h>
+#include <glib.h>
+#include "unity-shared/AnimationUtils.h"
+
+namespace
+{
+
+using namespace unity::animation;
+
+TEST(TestAnimationUtils, StartOrReverseNotRunning)
+{
+ na::AnimateValue<double> animation;
+ double start = g_random_double_range(std::numeric_limits<double>::min(), -1);
+ double finish = g_random_double_range(1, std::numeric_limits<double>::max());
+
+ StartOrReverse<double>(animation, start, finish);
+ EXPECT_DOUBLE_EQ(start, animation.GetStartValue());
+ EXPECT_DOUBLE_EQ(finish, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseKeepsRunning)
+{
+ na::AnimateValue<double> animation(3);
+ double start = g_random_double_range(std::numeric_limits<double>::min(), -1);
+ double finish = g_random_double_range(1, std::numeric_limits<double>::max());
+
+ animation.SetStartValue(start).SetFinishValue(finish).Start();
+ ASSERT_EQ(na::Animation::State::Running, animation.CurrentState());
+ animation.Advance(1);
+ ASSERT_EQ(1, animation.CurrentTimePosition());
+
+ StartOrReverse<double>(animation, start, finish);
+ EXPECT_DOUBLE_EQ(start, animation.GetStartValue());
+ EXPECT_DOUBLE_EQ(finish, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+ EXPECT_EQ(1, animation.CurrentTimePosition());
+}
+
+TEST(TestAnimationUtils, StartOrReverseReversesRunning)
+{
+ na::AnimateValue<double> animation(3);
+ double start = g_random_double_range(std::numeric_limits<double>::min(), -1);
+ double finish = g_random_double_range(1, std::numeric_limits<double>::max());
+
+ animation.SetStartValue(start).SetFinishValue(finish).Start();
+ ASSERT_EQ(na::Animation::State::Running, animation.CurrentState());
+ animation.Advance(1);
+ ASSERT_EQ(1, animation.CurrentTimePosition());
+
+ StartOrReverse<double>(animation, finish, start);
+ EXPECT_DOUBLE_EQ(finish, animation.GetStartValue());
+ EXPECT_DOUBLE_EQ(start, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+ EXPECT_EQ(2, animation.CurrentTimePosition());
+}
+
+TEST(TestAnimationUtils, StartOrReverseInValidRunning)
+{
+ na::AnimateValue<double> animation(3);
+ double start = g_random_double_range(std::numeric_limits<double>::min(), -1);
+ double finish = g_random_double_range(1, std::numeric_limits<double>::max());
+
+ animation.SetStartValue(start+1).SetFinishValue(finish-1).Start();
+ ASSERT_EQ(na::Animation::State::Running, animation.CurrentState());
+ animation.Advance(1);
+ ASSERT_EQ(1, animation.CurrentTimePosition());
+
+ StartOrReverse<double>(animation, finish, start);
+ EXPECT_DOUBLE_EQ(finish, animation.GetStartValue());
+ EXPECT_DOUBLE_EQ(start, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+ EXPECT_EQ(0, animation.CurrentTimePosition());
+}
+
+TEST(TestAnimationUtils, StartOrReverseDoubleForward)
+{
+ na::AnimateValue<double> animation;
+ StartOrReverse(animation, Direction::FORWARD);
+
+ EXPECT_DOUBLE_EQ(0.0f, animation.GetStartValue());
+ EXPECT_DOUBLE_EQ(1.0f, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseDoubleBackward)
+{
+ na::AnimateValue<double> animation;
+ StartOrReverse(animation, Direction::BACKWARD);
+
+ EXPECT_DOUBLE_EQ(1.0f, animation.GetStartValue());
+ EXPECT_DOUBLE_EQ(0.0f, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseIfDoubleTrue)
+{
+ na::AnimateValue<double> animation;
+
+ StartOrReverseIf(animation, true);
+ EXPECT_DOUBLE_EQ(0.0f, animation.GetStartValue());
+ EXPECT_DOUBLE_EQ(1.0f, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseIfDoubleFalse)
+{
+ na::AnimateValue<double> animation;
+ StartOrReverseIf(animation, false);
+
+ EXPECT_DOUBLE_EQ(1.0f, animation.GetStartValue());
+ EXPECT_DOUBLE_EQ(0.0f, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseFloatForward)
+{
+ na::AnimateValue<float> animation;
+ StartOrReverse(animation, Direction::FORWARD);
+
+ EXPECT_FLOAT_EQ(0.0f, animation.GetStartValue());
+ EXPECT_FLOAT_EQ(1.0f, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseFloatBackward)
+{
+ na::AnimateValue<float> animation;
+ StartOrReverse(animation, Direction::BACKWARD);
+
+ EXPECT_FLOAT_EQ(1.0f, animation.GetStartValue());
+ EXPECT_FLOAT_EQ(0.0f, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseIfFloatTrue)
+{
+ na::AnimateValue<float> animation;
+ StartOrReverseIf(animation, true);
+
+ EXPECT_FLOAT_EQ(0.0f, animation.GetStartValue());
+ EXPECT_FLOAT_EQ(1.0f, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseIfFloatFalse)
+{
+ na::AnimateValue<float> animation;
+ StartOrReverseIf(animation, false);
+
+ EXPECT_FLOAT_EQ(1.0f, animation.GetStartValue());
+ EXPECT_FLOAT_EQ(0.0f, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseIntForward)
+{
+ na::AnimateValue<int> animation;
+ StartOrReverse(animation, Direction::FORWARD);
+
+ EXPECT_EQ(0, animation.GetStartValue());
+ EXPECT_EQ(100, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseIntBackward)
+{
+ na::AnimateValue<int> animation;
+ StartOrReverse(animation, Direction::BACKWARD);
+
+ EXPECT_EQ(100, animation.GetStartValue());
+ EXPECT_EQ(0, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseIfIntTrue)
+{
+ na::AnimateValue<int> animation;
+ StartOrReverseIf(animation, true);
+
+ EXPECT_EQ(0, animation.GetStartValue());
+ EXPECT_EQ(100, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseIfIntFalse)
+{
+ na::AnimateValue<int> animation;
+ StartOrReverseIf(animation, false);
+
+ EXPECT_EQ(100, animation.GetStartValue());
+ EXPECT_EQ(0, animation.GetFinishValue());
+ EXPECT_EQ(na::Animation::State::Running, animation.CurrentState());
+}
+
+TEST(TestAnimationUtils, StartOrReverseExchanges)
+{
+ na::AnimateValue<double> animation;
+
+ for (int i = 0; i < 10; ++i)
+ {
+ StartOrReverse(animation, (i % 2) ? Direction::FORWARD : Direction::BACKWARD);
+ ASSERT_DOUBLE_EQ((i % 2) ? 0.0f : 1.0f, animation.GetStartValue());
+ ASSERT_DOUBLE_EQ((i % 2) ? 1.0f : 0.0f, animation.GetFinishValue());
+ ASSERT_EQ(na::Animation::State::Running, animation.CurrentState());
+ }
+}
+
+TEST(TestAnimationUtils, StartOrReverseIfExchanges)
+{
+ na::AnimateValue<double> animation;
+
+ for (int i = 0; i < 10; ++i)
+ {
+ StartOrReverseIf(animation, (i % 2));
+ ASSERT_DOUBLE_EQ((i % 2) ? 0.0f : 1.0f, animation.GetStartValue());
+ ASSERT_DOUBLE_EQ((i % 2) ? 1.0f : 0.0f, animation.GetFinishValue());
+ ASSERT_EQ(na::Animation::State::Running, animation.CurrentState());
+ }
+}
+
+TEST(TestAnimationUtils, GetDirection)
+{
+ na::AnimateValue<double> animation;
+ EXPECT_EQ(Direction::FORWARD, GetDirection(animation));
+}
+
+TEST(TestAnimationUtils, GetDirectionForward)
+{
+ na::AnimateValue<double> animation;
+ animation.SetStartValue(0).SetFinishValue(10);
+ EXPECT_EQ(Direction::FORWARD, GetDirection(animation));
+}
+
+TEST(TestAnimationUtils, GetDirectionBackward)
+{
+ na::AnimateValue<double> animation;
+ animation.SetStartValue(10).SetFinishValue(0);
+ EXPECT_EQ(Direction::BACKWARD, GetDirection(animation));
+}
+
+TEST(TestAnimationUtils, GetDirectionStartedReversed)
+{
+ na::AnimateValue<double> animation;
+ StartOrReverse(animation, Direction::BACKWARD);
+ EXPECT_EQ(Direction::BACKWARD, GetDirection(animation));
+
+ StartOrReverse(animation, Direction::FORWARD);
+ EXPECT_EQ(Direction::FORWARD, GetDirection(animation));
+}
+
+} // Namespace
diff --git a/tests/test_edge_barrier_controller.cpp b/tests/test_edge_barrier_controller.cpp
index 14ceb15e6..3b0593bf7 100644
--- a/tests/test_edge_barrier_controller.cpp
+++ b/tests/test_edge_barrier_controller.cpp
@@ -126,6 +126,30 @@ TEST_F(TestEdgeBarrierController, Construction)
}
}
+TEST_F(TestEdgeBarrierController, UscreenChangedSignalDisconnection)
+{
+ {
+ EdgeBarrierController bc;
+ bc.options = std::make_shared<launcher::Options>();
+ }
+
+ // Make sure it does not crash.
+ uscreen.changed.emit(uscreen.GetPrimaryMonitor(), uscreen.GetMonitors());
+}
+
+TEST_F(TestEdgeBarrierController, LauncherOptionChangedSignalDisconnection)
+{
+ auto options = std::make_shared<launcher::Options>();
+
+ {
+ EdgeBarrierController bc;
+ bc.options = options;
+ }
+
+ // Make sure it does not crash.
+ options->option_changed.emit();
+}
+
TEST_F(TestEdgeBarrierController, RemoveVerticalSubscriber)
{
for (unsigned i = 0; i < monitors::MAX; ++i)
diff --git a/tests/test_icon_loader.cpp b/tests/test_icon_loader.cpp
index 4cb12ac88..59d690749 100644
--- a/tests/test_icon_loader.cpp
+++ b/tests/test_icon_loader.cpp
@@ -28,6 +28,8 @@ using namespace unity;
namespace
{
+const int WAIT_TIMEOUT = 15000; // 15 seconds
+
bool IsValidPixbuf(GdkPixbuf *pixbuf)
{
return GDK_IS_PIXBUF (pixbuf);
@@ -71,7 +73,7 @@ void CheckResults(std::vector<LoadResult> const& results)
}
return got_all;
- });
+ }, WAIT_TIMEOUT);
for (auto const& result : results)
{
@@ -108,7 +110,8 @@ TEST_F(TestIconLoader, TestGetDefault)
EXPECT_EQ(&icon_loader, &IconLoader::GetDefault());
}
-TEST_F(TestIconLoader, TestGetOneIcon)
+// FIXME: Disabled due to issues on Jenkins using GLibDBusProxy (lp:1224643)
+TEST_F(TestIconLoader, DISABLED_TestGetOneIcon)
{
LoadResult load_result;
@@ -116,12 +119,13 @@ TEST_F(TestIconLoader, TestGetOneIcon)
&LoadResult::IconLoaded));
handles_.push_back(handle);
- Utils::WaitUntilMSec(load_result.got_callback);
+ Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT);
EXPECT_TRUE(load_result.got_callback);
EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf));
}
-TEST_F(TestIconLoader, TestGetAnnotatedIcon)
+// FIXME: Disabled due to issues on Jenkins using GLibDBusProxy (lp:1224643)
+TEST_F(TestIconLoader, DISABLED_TestGetAnnotatedIcon)
{
LoadResult load_result;
@@ -129,12 +133,13 @@ TEST_F(TestIconLoader, TestGetAnnotatedIcon)
&LoadResult::IconLoaded));
handles_.push_back(handle);
- Utils::WaitUntilMSec(load_result.got_callback);
+ Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT);
EXPECT_TRUE(load_result.got_callback);
EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf));
}
-TEST_F(TestIconLoader, TestGetColorizedIcon)
+// FIXME: Disabled due to issues on Jenkins using GLibDBusProxy (lp:1224643)
+TEST_F(TestIconLoader, DISABLED_TestGetColorizedIcon)
{
LoadResult load_result;
@@ -142,7 +147,7 @@ TEST_F(TestIconLoader, TestGetColorizedIcon)
&LoadResult::IconLoaded));
handles_.push_back(handle);
- Utils::WaitUntilMSec(load_result.got_callback);
+ Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT);
EXPECT_TRUE(load_result.got_callback);
EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf));
}
diff --git a/tests/test_launcher.cpp b/tests/test_launcher.cpp
index 937a4b981..fb2a98420 100644
--- a/tests/test_launcher.cpp
+++ b/tests/test_launcher.cpp
@@ -77,9 +77,14 @@ public:
return GetActionState() == Launcher::LauncherActionState::ACTION_DRAG_EXTERNAL;
}
+ bool IsActionStateDragCancelled()
+ {
+ return GetActionState() == Launcher::LauncherActionState::ACTION_DRAG_ICON_CANCELLED;
+ }
+
AbstractLauncherIcon::Ptr MouseIconIntersection(int x, int y) const
{
- for (auto const& icon : *_model)
+ for (auto const& icon : *model_)
{
auto const& center = icon->GetCenter(monitor());
@@ -102,35 +107,35 @@ public:
using Launcher::ProcessDndLeave;
using Launcher::ProcessDndMove;
using Launcher::ProcessDndDrop;
- using Launcher::_drag_icon_position;
- using Launcher::_icon_under_mouse;
+ using Launcher::drag_icon_position_;
+ using Launcher::icon_under_mouse_;
using Launcher::IconStartingBlinkValue;
using Launcher::IconStartingPulseValue;
using Launcher::HandleBarrierEvent;
using Launcher::SetHidden;
using Launcher::HandleUrgentIcon;
using Launcher::SetUrgentTimer;
- using Launcher::_urgent_timer_running;
- using Launcher::_urgent_finished_time;
- using Launcher::_urgent_wiggle_time;
+ using Launcher::urgent_timer_running_;
+ using Launcher::urgent_finished_time_;
+ using Launcher::urgent_wiggle_time_;
void FakeProcessDndMove(int x, int y, std::list<std::string> uris)
{
- _dnd_data.Reset();
+ dnd_data_.Reset();
std::string data_uri;
for (std::string const& uri : uris)
data_uri += uri+"\r\n";
- _dnd_data.Fill(data_uri.c_str());
+ dnd_data_.Fill(data_uri.c_str());
- if (std::find_if(_dnd_data.Uris().begin(), _dnd_data.Uris().end(), [this] (std::string const& uri)
- {return DndIsSpecialRequest(uri);}) != _dnd_data.Uris().end())
+ if (std::find_if(dnd_data_.Uris().begin(), dnd_data_.Uris().end(), [this] (std::string const& uri)
+ {return DndIsSpecialRequest(uri);}) != dnd_data_.Uris().end())
{
- _steal_drag = true;
+ steal_drag_ = true;
}
- _dnd_hovered_icon = MouseIconIntersection(x, y);
+ dnd_hovered_icon_ = MouseIconIntersection(x, y);
}
};
@@ -218,7 +223,7 @@ TEST_F(TestLauncher, TestMouseWheelScroll)
model_->AddIcon(icon);
launcher_->SetHover(true);
- launcher_->_icon_under_mouse = icon;
+ launcher_->icon_under_mouse_ = icon;
unsigned long key_flags = 0;
@@ -318,6 +323,7 @@ TEST_F(TestLauncher, DragLauncherIconCancelRestoresIconOrder)
// Emitting the drag cancel request
launcher_->GetDraggedIcon()->drag_cancel_request.emit();
+ EXPECT_TRUE(launcher_->IsActionStateDragCancelled());
// The icon order should be reset
it = model_->begin();
@@ -345,7 +351,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasChanged)
// Start dragging icon2
launcher_->StartIconDrag(icon2);
launcher_->ShowDragWindow();
- ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2));
+ ASSERT_EQ(launcher_->drag_icon_position_, model_->IconIndex(icon2));
// Moving icon2 at the end
auto const& center3 = icon3->GetCenter(launcher_->monitor());
@@ -353,7 +359,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasChanged)
EXPECT_CALL(*icon2, Stick(true));
- ASSERT_NE(launcher_->_drag_icon_position, model_->IconIndex(icon2));
+ ASSERT_NE(launcher_->drag_icon_position_, model_->IconIndex(icon2));
launcher_->EndIconDrag();
// The icon order should be reset
@@ -378,7 +384,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasNotChanged)
// Start dragging icon2
launcher_->StartIconDrag(icon2);
launcher_->ShowDragWindow();
- ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2));
+ ASSERT_EQ(launcher_->drag_icon_position_, model_->IconIndex(icon2));
// Moving icon2 at the end
auto center3 = icon3->GetCenter(launcher_->monitor());
@@ -395,7 +401,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasNotChanged)
bool model_saved = false;
model_->saved.connect([&model_saved] { model_saved = true; });
- ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2));
+ ASSERT_EQ(launcher_->drag_icon_position_, model_->IconIndex(icon2));
launcher_->EndIconDrag();
// The icon order should be reset
@@ -629,11 +635,11 @@ TEST_F(TestLauncher, UrgentIconWiggleTimerStart)
clock_gettime(CLOCK_MONOTONIC, &current);
- ASSERT_FALSE(launcher_->_urgent_timer_running);
+ ASSERT_FALSE(launcher_->urgent_timer_running_);
launcher_->HandleUrgentIcon(icon, current);
- EXPECT_TRUE(launcher_->_urgent_timer_running);
+ EXPECT_TRUE(launcher_->urgent_timer_running_);
}
TEST_F(TestLauncher, UrgentIconWiggleTimerTimeout)
@@ -644,18 +650,18 @@ TEST_F(TestLauncher, UrgentIconWiggleTimerTimeout)
launcher_->SetHidden(true);
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true);
- ASSERT_EQ(launcher_->_urgent_wiggle_time, 0);
- ASSERT_EQ(launcher_->_urgent_finished_time.tv_sec, 0);
- ASSERT_EQ(launcher_->_urgent_finished_time.tv_nsec, 0);
+ ASSERT_EQ(launcher_->urgent_wiggle_time_, 0);
+ ASSERT_EQ(launcher_->urgent_finished_time_.tv_sec, 0);
+ ASSERT_EQ(launcher_->urgent_finished_time_.tv_nsec, 0);
launcher_->SetUrgentTimer(1);
// Make sure the Urgent Timer expires before checking
Utils::WaitForTimeout(2);
- EXPECT_THAT(launcher_->_urgent_wiggle_time, Gt(0));
- EXPECT_THAT(launcher_->_urgent_finished_time.tv_sec, Gt(0));
- EXPECT_THAT(launcher_->_urgent_finished_time.tv_nsec, Gt(0));
+ EXPECT_THAT(launcher_->urgent_wiggle_time_, Gt(0));
+ EXPECT_THAT(launcher_->urgent_finished_time_.tv_sec, Gt(0));
+ EXPECT_THAT(launcher_->urgent_finished_time_.tv_nsec, Gt(0));
}
TEST_F(TestLauncher, WiggleUrgentIconAfterLauncherIsRevealed)
@@ -673,16 +679,16 @@ TEST_F(TestLauncher, WiggleUrgentIconAfterLauncherIsRevealed)
clock_gettime(CLOCK_MONOTONIC, &current);
launcher_->HandleUrgentIcon(icon, current);
- ASSERT_EQ(launcher_->_urgent_finished_time.tv_sec, 0);
- ASSERT_EQ(launcher_->_urgent_finished_time.tv_nsec, 0);
+ ASSERT_EQ(launcher_->urgent_finished_time_.tv_sec, 0);
+ ASSERT_EQ(launcher_->urgent_finished_time_.tv_nsec, 0);
launcher_->SetHidden(false);
clock_gettime(CLOCK_MONOTONIC, &current);
launcher_->HandleUrgentIcon(icon, current);
- EXPECT_THAT(launcher_->_urgent_finished_time.tv_sec, Gt(0));
- EXPECT_THAT(launcher_->_urgent_finished_time.tv_nsec, Gt(0));
+ EXPECT_THAT(launcher_->urgent_finished_time_.tv_sec, Gt(0));
+ EXPECT_THAT(launcher_->urgent_finished_time_.tv_nsec, Gt(0));
}
}
diff --git a/unity-shared/AnimationUtils-inl.h b/unity-shared/AnimationUtils-inl.h
new file mode 100644
index 000000000..561c25c02
--- /dev/null
+++ b/unity-shared/AnimationUtils-inl.h
@@ -0,0 +1,52 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2013 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: Marco Trevisan <marco.trevisan@canonical.com>
+ */
+
+#ifndef UNITY_ANIMATION_UTILS_INL
+#define UNITY_ANIMATION_UTILS_INL
+
+namespace unity
+{
+namespace animation
+{
+
+template <class VALUE_TYPE>
+void StartOrReverse(na::AnimateValue<VALUE_TYPE>& animation, VALUE_TYPE start, VALUE_TYPE finish)
+{
+ if (animation.CurrentState() == na::Animation::State::Running)
+ {
+ if (animation.GetStartValue() == finish && animation.GetFinishValue() == start)
+ {
+ animation.Reverse();
+ }
+ else if (animation.GetStartValue() != start || animation.GetFinishValue() != finish)
+ {
+ animation.Stop();
+ animation.SetStartValue(start).SetFinishValue(finish).Start();
+ }
+ }
+ else
+ {
+ animation.SetStartValue(start).SetFinishValue(finish).Start();
+ }
+}
+
+} // animation namespace
+} // unity namespace
+
+#endif // UNITY_ANIMATION_UTILS_INL
diff --git a/unity-shared/AnimationUtils.h b/unity-shared/AnimationUtils.h
new file mode 100644
index 000000000..910c4d531
--- /dev/null
+++ b/unity-shared/AnimationUtils.h
@@ -0,0 +1,76 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2013 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: Marco Trevisan <marco.trevisan@canonical.com>
+ */
+
+#ifndef UNITY_ANIMATION_UTILS
+#define UNITY_ANIMATION_UTILS
+
+#include <NuxCore/Animation.h>
+
+namespace na = nux::animation;
+
+namespace unity
+{
+namespace animation
+{
+
+enum class Direction
+{
+ FORWARD,
+ BACKWARD
+};
+
+template <typename VALUE>
+inline Direction GetDirection(na::AnimateValue<VALUE> const& animation)
+{
+ if (animation.GetFinishValue() < animation.GetStartValue())
+ return Direction::BACKWARD;
+
+ return Direction::FORWARD;
+}
+
+template <class VALUE_TYPE>
+void StartOrReverse(na::AnimateValue<VALUE_TYPE>& animation, VALUE_TYPE start, VALUE_TYPE finish);
+
+template <typename VALUE>
+inline void StartOrReverse(na::AnimateValue<VALUE>& animation, Direction dir)
+{
+ StartOrReverse<VALUE>(animation, (dir == Direction::FORWARD) ? 0.0f : 1.0f,
+ (dir == Direction::FORWARD) ? 1.0f : 0.0f);
+}
+
+template <>
+inline void StartOrReverse(na::AnimateValue<int>& animation, Direction dir)
+{
+ StartOrReverse<int>(animation, (dir == Direction::FORWARD) ? 0 : 100,
+ (dir == Direction::FORWARD) ? 100 : 0);
+}
+
+template <typename VALUE>
+inline void StartOrReverseIf(na::AnimateValue<VALUE>& animation, bool condition)
+{
+ StartOrReverse(animation, condition ? Direction::FORWARD : Direction::BACKWARD);
+}
+
+} // animation namespace
+} // unity namespace
+
+#include "AnimationUtils-inl.h"
+
+#endif // UNITY_ANIMATION_UTILS
+
diff --git a/unity-shared/PluginAdapter.cpp b/unity-shared/PluginAdapter.cpp
index da6dc6bc6..357fe9f1f 100644
--- a/unity-shared/PluginAdapter.cpp
+++ b/unity-shared/PluginAdapter.cpp
@@ -461,6 +461,22 @@ bool PluginAdapter::IsWindowMaximized(Window window_id) const
return false;
}
+bool PluginAdapter::IsWindowVerticallyMaximized(Window window_id) const
+{
+ if (CompWindow* window = m_Screen->findWindow(window_id))
+ return (window->state() & CompWindowStateMaximizedVertMask);
+
+ return false;
+}
+
+bool PluginAdapter::IsWindowHorizontallyMaximized(Window window_id) const
+{
+ if (CompWindow* window = m_Screen->findWindow(window_id))
+ return (window->state() & CompWindowStateMaximizedHorzMask);
+
+ return false;
+}
+
unsigned long PluginAdapter::GetMwnDecorations(Window window_id) const
{
Display* display = m_Screen->dpy();
@@ -697,6 +713,59 @@ void PluginAdapter::Maximize(Window window_id)
window->maximize(MAXIMIZE_STATE);
}
+void PluginAdapter::VerticallyMaximizeWindowAt(CompWindow* window, nux::Geometry const& geo)
+{
+ if (window && ((window->type() & CompWindowTypeNormalMask) ||
+ ((window->actions() & CompWindowActionMaximizeVertMask) &&
+ window->actions() & CompWindowActionResizeMask)))
+ {
+ /* First we unmaximize the Window */
+ if (window->state() & MAXIMIZE_STATE)
+ window->maximize(0);
+
+ /* Then we vertically maximize the it so it can be unminimized correctly */
+ if (!(window->state() & CompWindowStateMaximizedVertMask))
+ window->maximize(CompWindowStateMaximizedVertMask);
+
+ /* Then we resize and move it on the requested place */
+ MoveResizeWindow(window->id(), geo);
+ }
+}
+
+void PluginAdapter::LeftMaximize(Window window_id)
+{
+ CompWindow* window = m_Screen->findWindow(window_id);
+
+ if (!window)
+ return;
+
+ /* Let's compute the area where the window should stay */
+ CompRect workarea = m_Screen->getWorkareaForOutput(window->outputDevice());
+ nux::Geometry win_geo(workarea.x() + window->border().left,
+ workarea.y() + window->border().top,
+ workarea.width() / 2 - (window->border().left + window->border().right),
+ workarea.height() - (window->border().top + window->border().bottom));
+
+ VerticallyMaximizeWindowAt(window, win_geo);
+}
+
+void PluginAdapter::RightMaximize(Window window_id)
+{
+ CompWindow* window = m_Screen->findWindow(window_id);
+
+ if (!window)
+ return;
+
+ /* Let's compute the area where the window should stay */
+ CompRect workarea = m_Screen->getWorkareaForOutput(window->outputDevice());
+ nux::Geometry win_geo(workarea.x() + workarea.width() / 2 + window->border().left,
+ workarea.y() + window->border().top,
+ workarea.width() / 2 - (window->border().left + window->border().right),
+ workarea.height() - (window->border().top + window->border().bottom));
+
+ VerticallyMaximizeWindowAt(window, win_geo);
+}
+
void PluginAdapter::Restore(Window window_id)
{
CompWindow* window = m_Screen->findWindow(window_id);
diff --git a/unity-shared/PluginAdapter.h b/unity-shared/PluginAdapter.h
index 6690fdd89..6bef259e1 100644
--- a/unity-shared/PluginAdapter.h
+++ b/unity-shared/PluginAdapter.h
@@ -130,6 +130,8 @@ public:
// WindowManager implementation
bool IsWindowMaximized(Window window_id) const;
+ bool IsWindowVerticallyMaximized(Window window_id) const;
+ bool IsWindowHorizontallyMaximized(Window window_id) const;
bool IsWindowDecorated(Window window_id) const;
bool IsWindowOnCurrentDesktop(Window window_id) const;
bool IsWindowObscured(Window window_id) const;
@@ -143,6 +145,8 @@ public:
bool HasWindowDecorations(Window window_id) const;
void Maximize(Window window_id);
+ void LeftMaximize(Window window_id);
+ void RightMaximize(Window window_id);
void Restore(Window window_id);
void RestoreAt(Window window_id, int x, int y);
void Minimize(Window window_id);
@@ -196,6 +200,8 @@ public:
Window GetTopWindowAbove(Window xid) const;
+ void MoveResizeWindow(guint32 xid, nux::Geometry geometry);
+
protected:
PluginAdapter(CompScreen* screen);
void AddProperties(GVariantBuilder* builder);
@@ -215,6 +221,8 @@ private:
std::string GetUtf8Property(Window xid, Atom atom) const;
std::vector<long> GetCardinalProperty(Window xid, Atom atom) const;
+ void VerticallyMaximizeWindowAt(CompWindow* window, nux::Geometry const& geo);
+
CompScreen* m_Screen;
MultiActionList m_ExpoActionList;
MultiActionList m_ScaleActionList;
diff --git a/unity-shared/StandaloneWindowManager.cpp b/unity-shared/StandaloneWindowManager.cpp
index 3c4173207..c6bbf1714 100644
--- a/unity-shared/StandaloneWindowManager.cpp
+++ b/unity-shared/StandaloneWindowManager.cpp
@@ -43,7 +43,8 @@ StandaloneWindow::StandaloneWindow(Window xid)
, active(false)
, mapped(true)
, visible(true)
- , maximized(false)
+ , v_maximized(false)
+ , h_maximized(false)
, minimized(false)
, decorated(true)
, has_decorations(true)
@@ -67,6 +68,20 @@ StandaloneWindow::StandaloneWindow(Window xid)
return false;
});
+
+ maximized.SetGetterFunction([this] { return v_maximized && h_maximized; });
+ maximized.SetSetterFunction([this] (bool value) {
+ if (maximized() == value)
+ return false;
+
+ v_maximized = value;
+ h_maximized = value;
+ decorated = !value;
+ return true;
+ });
+
+ v_maximized.changed.connect([this] (bool value) { maximized.changed.emit(maximized()); });
+ h_maximized.changed.connect([this] (bool value) { maximized.changed.emit(maximized()); });
}
WindowManagerPtr create_window_manager()
@@ -125,6 +140,24 @@ bool StandaloneWindowManager::IsWindowMaximized(Window window_id) const
return false;
}
+bool StandaloneWindowManager::IsWindowVerticallyMaximized(Window window_id) const
+{
+ auto window = GetWindowByXid(window_id);
+ if (window)
+ return window->v_maximized;
+
+ return false;
+}
+
+bool StandaloneWindowManager::IsWindowHorizontallyMaximized(Window window_id) const
+{
+ auto window = GetWindowByXid(window_id);
+ if (window)
+ return window->h_maximized;
+
+ return false;
+}
+
bool StandaloneWindowManager::IsWindowDecorated(Window window_id) const
{
auto window = GetWindowByXid(window_id);
@@ -249,20 +282,51 @@ void StandaloneWindowManager::Maximize(Window window_id)
{
auto window = GetWindowByXid(window_id);
if (window)
- {
window->maximized = true;
- Undecorate(window_id);
- }
+}
+
+void StandaloneWindowManager::LeftMaximize(Window window_id)
+{
+ auto window = GetWindowByXid(window_id);
+
+ if (!window)
+ return;
+
+ /* Let's compute the area where the window should be put */
+ auto workarea = GetWorkAreaGeometry(window_id);
+ workarea.width /= 2;
+
+ if (window->maximized)
+ window->maximized = false;
+
+ window->v_maximized = true;
+ MoveResizeWindow(window_id, workarea);
+}
+
+void StandaloneWindowManager::RightMaximize(Window window_id)
+{
+ auto window = GetWindowByXid(window_id);
+
+ if (!window)
+ return;
+
+ /* Let's compute the area where the window should be put */
+ auto workarea = GetWorkAreaGeometry(window_id);
+ workarea.width /= 2;
+ workarea.x += workarea.width;
+
+ if (window->maximized)
+ window->maximized = false;
+
+ window->v_maximized = true;
+ MoveResizeWindow(window_id, workarea);
}
void StandaloneWindowManager::Restore(Window window_id)
{
auto window = GetWindowByXid(window_id);
if (window)
- {
window->maximized = false;
- Decorate(window_id);
- }
}
void StandaloneWindowManager::RestoreAt(Window window_id, int x, int y)
diff --git a/unity-shared/StandaloneWindowManager.h b/unity-shared/StandaloneWindowManager.h
index cdd2661df..bd8911718 100644
--- a/unity-shared/StandaloneWindowManager.h
+++ b/unity-shared/StandaloneWindowManager.h
@@ -48,7 +48,9 @@ public:
nux::Property<bool> active;
nux::Property<bool> mapped;
nux::Property<bool> visible;
- nux::Property<bool> maximized;
+ nux::RWProperty<bool> maximized;
+ nux::Property<bool> v_maximized;
+ nux::Property<bool> h_maximized;
nux::Property<bool> minimized;
nux::Property<bool> decorated;
nux::Property<bool> has_decorations;
@@ -70,6 +72,8 @@ public:
std::vector<Window> GetWindowsInStackingOrder() const override;
virtual bool IsWindowMaximized(Window window_id) const;
+ virtual bool IsWindowVerticallyMaximized(Window window_id) const;
+ virtual bool IsWindowHorizontallyMaximized(Window window_id) const;
virtual bool IsWindowDecorated(Window window_id) const;
virtual bool IsWindowOnCurrentDesktop(Window window_id) const;
virtual bool IsWindowObscured(Window window_id) const;
@@ -86,6 +90,8 @@ public:
virtual bool InShowDesktop() const;
virtual void Maximize(Window window_id);
+ virtual void LeftMaximize(Window window_id);
+ virtual void RightMaximize(Window window_id);
virtual void Restore(Window window_id);
virtual void RestoreAt(Window window_id, int x, int y);
virtual void Minimize(Window window_id);
diff --git a/unity-shared/UBusMessages.h b/unity-shared/UBusMessages.h
index f15e48947..755a1cf2c 100644
--- a/unity-shared/UBusMessages.h
+++ b/unity-shared/UBusMessages.h
@@ -47,16 +47,9 @@
#define UBUS_LAUNCHER_START_KEY_SWITCHER "LAUNCHER_START_KEY_SWITCHER"
#define UBUS_LAUNCHER_END_KEY_SWITCHER "LAUNCHER_END_KEY_SWITCHER"
#define UBUS_LAUNCHER_SELECTION_CHANGED "LAUNCHER_ICON_SELECTION_CHANGED"
-#define UBUS_LAUNCHER_ICON_URGENT_CHANGED "LAUNCHER_ICON_URGENT_CHANGED"
#define UBUS_QUICKLIST_START_KEY_NAV "QUICKLIST_START_KEY_NAV"
#define UBUS_QUICKLIST_END_KEY_NAV "QUICKLIST_END_KEY_NAV"
-// Signals that fired on various launcher dnd tasks
-#define UBUS_LAUNCHER_START_DND "LAUNCHER_START_DRAG"
-#define UBUS_LAUNCHER_END_DND "LAUNCHER_END_DRAG"
-#define UBUS_LAUNCHER_ICON_START_DND "LAUNCHER_ICON_START_DND"
-#define UBUS_LAUNCHER_ICON_END_DND "LAUNCHER_ICON_END_DND"
-
// Signal to force the launcher into locked mode, (b)
#define UBUS_LAUNCHER_LOCK_HIDE "LAUNCHER_LOCK_HIDE"
diff --git a/unity-shared/WindowManager.h b/unity-shared/WindowManager.h
index 4257fb5ec..62440031a 100644
--- a/unity-shared/WindowManager.h
+++ b/unity-shared/WindowManager.h
@@ -77,6 +77,9 @@ public:
virtual std::vector<Window> GetWindowsInStackingOrder() const = 0;
virtual bool IsWindowMaximized(Window window_id) const = 0;
+ virtual bool IsWindowVerticallyMaximized(Window window_id) const = 0;
+ virtual bool IsWindowHorizontallyMaximized(Window window_id) const = 0;
+ virtual bool IsWindowMaximizable(Window window_id) const = 0;
virtual bool IsWindowDecorated(Window window_id) const = 0;
virtual bool IsWindowOnCurrentDesktop(Window window_id) const = 0;
virtual bool IsWindowObscured(Window window_id) const = 0;
@@ -86,13 +89,14 @@ public:
virtual bool IsWindowClosable(Window window_id) const = 0;
virtual bool IsWindowMinimized(Window window_id) const = 0;
virtual bool IsWindowMinimizable(Window window_id) const = 0;
- virtual bool IsWindowMaximizable(Window window_id) const = 0;
virtual bool HasWindowDecorations(Window window_id) const = 0;
virtual void ShowDesktop() = 0;
virtual bool InShowDesktop() const = 0;
virtual void Maximize(Window window_id) = 0;
+ virtual void LeftMaximize(Window window_id) = 0;
+ virtual void RightMaximize(Window window_id) = 0;
virtual void Restore(Window window_id) = 0;
virtual void RestoreAt(Window window_id, int x, int y) = 0;
virtual void Minimize(Window window_id) = 0;