summaryrefslogtreecommitdiff
diff options
authorNeil Jagdish Patel <neil.patel@canonical.com>2010-12-17 08:33:31 +0000
committerNeil Jagdish Patel <neil.patel@canonical.com>2010-12-17 08:33:31 +0000
commit21a5a78cce4caa105fd72bad08fa3491731221b8 (patch)
tree850cc430ba9ceb0adde12bd4d625b290844e20dc
parentb72ce4c793071bf99c01f59b716d1d31e8d3219f (diff)
parenta2c10e2b592176d55b44ce57a4a11cdc3245a927 (diff)
[merge] trunk
(bzr r669.3.27)
-rw-r--r--CMakeLists.txt12
-rw-r--r--libunity/perf-logger-utility.h25
-rw-r--r--libunity/ubus-server.c33
-rw-r--r--po/unity.pot2
-rw-r--r--resources/progress_bar_fill.pngbin0 -> 209 bytes
-rw-r--r--resources/progress_bar_trough.pngbin0 -> 521 bytes
-rw-r--r--src/BamfLauncherIcon.cpp41
-rw-r--r--src/BamfLauncherIcon.h4
-rw-r--r--src/Launcher.cpp475
-rw-r--r--src/Launcher.h101
-rw-r--r--src/LauncherController.cpp124
-rw-r--r--src/LauncherController.h7
-rw-r--r--src/LauncherDragWindow.cpp58
-rw-r--r--src/LauncherDragWindow.h18
-rw-r--r--src/LauncherIcon.cpp16
-rw-r--r--src/LauncherIcon.h7
-rw-r--r--src/PanelHomeButton.cpp42
-rw-r--r--src/PlacesController.cpp142
-rw-r--r--src/PlacesController.h56
-rw-r--r--src/PlacesView.cpp131
-rw-r--r--src/PlacesView.h54
-rw-r--r--src/PluginAdapter.cpp25
-rw-r--r--src/PluginAdapter.h7
-rw-r--r--src/UBusMessages.h27
-rw-r--r--src/unity.cpp43
-rw-r--r--src/unity.h34
-rw-r--r--tests/CMakeLists.txt16
-rw-r--r--tests/TestPlaces.cpp144
28 files changed, 1214 insertions, 430 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3eaf5f75..eff136f25 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,6 +72,14 @@ if (${GETTEXT_FOUND} STREQUAL "TRUE")
endif (${GETTEXT_FOUND} STREQUAL "TRUE")
#
+# Enable or disable boot logging
+#
+option (BOOT_LOGGER "Enable startup performance logging" OFF)
+if (BOOT_LOGGER)
+ SET (BOOT_LOGGER_FLAG "-DENABLE_LOGGER")
+endif (BOOT_LOGGER)
+
+#
# src (Compiz Plugin)
#
set (UNITY_PLUGIN_DEPS "nux-0.9;libbamf;dbus-glib-1;dee-1.0;gio-2.0;gio-unix-2.0;dbusmenu-glib;x11;libstartup-notification-1.0;gthread-2.0;indicator")
@@ -81,10 +89,10 @@ include (CompizPlugin)
compiz_plugin (unityshell
PKGDEPS ${UNITY_PLUGIN_DEPS}
PLUGINDEPS composite opengl
- CFLAGSADD "-DINSTALLPREFIX='\"${CMAKE_INSTALL_PREFIX}\"' -DPKGDATADIR='\"${CMAKE_INSTALL_PREFIX}/share/unity/3\"' -I${CMAKE_BINARY_DIR}"
+ CFLAGSADD "-DINSTALLPREFIX='\"${CMAKE_INSTALL_PREFIX}\"' -DPKGDATADIR='\"${CMAKE_INSTALL_PREFIX}/share/unity/3\"' -I${CMAKE_BINARY_DIR} ${BOOT_LOGGER_FLAG}"
LIBRARIES "unity"
)
-
+
#
# GSettings Schema
#
diff --git a/libunity/perf-logger-utility.h b/libunity/perf-logger-utility.h
index aee02abea..7a403464d 100644
--- a/libunity/perf-logger-utility.h
+++ b/libunity/perf-logger-utility.h
@@ -21,14 +21,23 @@
#include <libunity/unity.h>
-#define START_FUNCTION() G_STMT_START { \
- perf_timeline_logger_start_process (perf_timeline_logger_get_default(), G_STRFUNC);\
- } G_STMT_END
-#define LOGGER_START_PROCESS(process) { perf_timeline_logger_start_process (perf_timeline_logger_get_default(), process);}
+#ifdef ENABLE_LOGGER
+ #define START_FUNCTION() G_STMT_START { \
+ perf_timeline_logger_start_process (perf_timeline_logger_get_default(), G_STRFUNC);\
+ } G_STMT_END
+ #define LOGGER_START_PROCESS(process) { perf_timeline_logger_start_process (perf_timeline_logger_get_default(), process);}
-#define END_FUNCTION() G_STMT_START { \
- perf_timeline_logger_end_process (perf_timeline_logger_get_default(), G_STRFUNC);\
- } G_STMT_END
-#define LOGGER_END_PROCESS(process) { perf_timeline_logger_end_process (perf_timeline_logger_get_default(), process);}
+ #define END_FUNCTION() G_STMT_START { \
+ perf_timeline_logger_end_process (perf_timeline_logger_get_default(), G_STRFUNC);\
+ } G_STMT_END
+ #define LOGGER_END_PROCESS(process) { perf_timeline_logger_end_process (perf_timeline_logger_get_default(), process);}
+ #define LOGGER_WRITE_LOG(file) { perf_timeline_logger_write_log (perf_timeline_logger_get_default(), file);}
+#else
+ #define START_FUNCTION()
+ #define LOGGER_START_PROCESS(process)
+ #define END_FUNCTION()
+ #define LOGGER_END_PROCESS(process)
+ #define LOGGER_WRITE_LOG(file)
+#endif /* ENABLE_LOGGER */
#endif /* PERF_LOGGER_H */
diff --git a/libunity/ubus-server.c b/libunity/ubus-server.c
index 48126d64e..bc1e628f6 100644
--- a/libunity/ubus-server.c
+++ b/libunity/ubus-server.c
@@ -106,13 +106,13 @@ static UBusMessageInfo*
ubus_message_info_new (GVariant *data)
{
UBusMessageInfo *info;
-
+
info = g_slice_new (UBusMessageInfo);
info->data = data;
if (data != NULL)
g_variant_ref_sink (data);
-
+
return info;
}
@@ -121,7 +121,7 @@ ubus_message_info_free (UBusMessageInfo *info)
{
if (info->data != NULL)
g_variant_unref (info->data);
-
+
g_slice_free (UBusMessageInfo, info);
}
@@ -129,7 +129,7 @@ static void
ubus_server_init (UBusServer *server)
{
UBusServerPrivate *priv;
-
+
priv = server->priv = UBUS_SERVER_GET_PRIVATE (server);
/* message_interest_table holds the message/DispatchInfo relationship
@@ -159,10 +159,10 @@ ubus_server_finalize (GObject *object)
{
UBusServer *server;
UBusServerPrivate *priv;
-
+
server = UBUS_SERVER (object);
priv = server->priv;
-
+
g_hash_table_destroy (priv->message_interest_table);
g_hash_table_destroy (priv->dispatch_table);
@@ -191,9 +191,9 @@ ubus_server_get_default ()
{
UBusServer *server;
static gsize singleton;
-
+
if (g_once_init_enter (&singleton))
- {
+ {
server = g_object_new (UBUS_TYPE_SERVER, NULL);
g_object_ref_sink (server);
g_once_init_leave (&singleton, (gsize) server);
@@ -250,14 +250,13 @@ ubus_server_pump_message_queue (UBusServer *server)
UBusServerPrivate *priv = server->priv;
UBusMessageInfo *info;
- priv->message_pump_queued = TRUE;
+ priv->message_pump_queued = FALSE;
// loop through each message queued and call the dispatch functions associated
// with it. something in the back of my mind says it would be quicker in some
// situations to sort the queue first so that duplicate messages can re-use
// the same dispatch_list lookups.. but thats a specific case.
-
info = g_queue_pop_tail (priv->message_queue);
for (; info != NULL; info = g_queue_pop_tail (priv->message_queue))
{
@@ -266,7 +265,9 @@ ubus_server_pump_message_queue (UBusServer *server)
info->message);
if (dispatch_list == NULL)
- continue; // no handlers for this message
+ {
+ continue; // no handlers for this message
+ }
GSequenceIter *iter = g_sequence_get_begin_iter (dispatch_list);
GSequenceIter *end = g_sequence_get_end_iter (dispatch_list);
@@ -292,7 +293,7 @@ static void
ubus_server_queue_message_pump (UBusServer *server)
{
UBusServerPrivate *priv;
-
+
g_return_if_fail (UBUS_IS_SERVER (server));
priv = server->priv;
@@ -310,9 +311,9 @@ ubus_server_send_message (UBusServer *server,
{
UBusServerPrivate *priv;
UBusMessageInfo *message_info;
-
+
g_return_if_fail (UBUS_IS_SERVER (server));
- g_return_if_fail (message != NULL);
+ g_return_if_fail (message != NULL);
priv = server->priv;
message_info = ubus_message_info_new (data);
@@ -329,11 +330,11 @@ ubus_server_unregister_interest (UBusServer* server, guint handle)
UBusServerPrivate *priv;
GSequence *dispatch_list;
UBusDispatchInfo *info;
-
+
g_return_if_fail (UBUS_IS_SERVER (server));
g_return_if_fail (handle > 0);
- priv = server->priv;
+ priv = server->priv;
info = g_hash_table_lookup (priv->dispatch_table, GUINT_TO_POINTER (handle));
if (info == NULL)
diff --git a/po/unity.pot b/po/unity.pot
index df224acaa..8cdb2e483 100644
--- a/po/unity.pot
+++ b/po/unity.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: ayatana-dev@lists.launchpad.net\n"
-"POT-Creation-Date: 2010-12-09 12:09-0500\n"
+"POT-Creation-Date: 2010-12-15 16:03+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/resources/progress_bar_fill.png b/resources/progress_bar_fill.png
new file mode 100644
index 000000000..f35aa9a36
--- /dev/null
+++ b/resources/progress_bar_fill.png
Binary files differ
diff --git a/resources/progress_bar_trough.png b/resources/progress_bar_trough.png
new file mode 100644
index 000000000..bcc258f2e
--- /dev/null
+++ b/resources/progress_bar_trough.png
Binary files differ
diff --git a/src/BamfLauncherIcon.cpp b/src/BamfLauncherIcon.cpp
index d376061dd..aea89be9b 100644
--- a/src/BamfLauncherIcon.cpp
+++ b/src/BamfLauncherIcon.cpp
@@ -78,11 +78,16 @@ BamfLauncherIcon::BamfLauncherIcon (Launcher* IconManager, BamfApplication *app,
g_signal_connect (app, "active-changed", (GCallback) &BamfLauncherIcon::OnActiveChanged, this);
g_signal_connect (app, "user-visible-changed", (GCallback) &BamfLauncherIcon::OnUserVisibleChanged, this);
g_signal_connect (app, "closed", (GCallback) &BamfLauncherIcon::OnClosed, this);
-
+
g_object_ref (m_App);
EnsureWindowState ();
UpdateMenus ();
+
+ PluginAdapter::Default ()->window_minimized.connect (sigc::mem_fun (this, &BamfLauncherIcon::OnWindowMinimized));
+
+ /* hack */
+ SetProgress (0.5f);
}
BamfLauncherIcon::~BamfLauncherIcon()
@@ -98,6 +103,16 @@ BamfLauncherIcon::~BamfLauncherIcon()
g_object_unref (m_App);
}
+void
+BamfLauncherIcon::OnWindowMinimized (CompWindow *window)
+{
+ if (!OwnsWindow (window->id ()))
+ return;
+
+ Present (0.5f, 600);
+ UpdateQuirkTimeDelayed (300, LAUNCHER_ICON_QUIRK_SHIMMER);
+}
+
bool
BamfLauncherIcon::IsSticky ()
{
@@ -138,7 +153,7 @@ BamfLauncherIcon::AddProperties (GVariantBuilder *builder)
}
bool
-BamfLauncherIcon::IconOwnsWindow (Window w)
+BamfLauncherIcon::OwnsWindow (Window w)
{
GList *children, *l;
BamfView *view;
@@ -210,7 +225,7 @@ BamfLauncherIcon::Focus ()
if (window)
{
- if (window->state () & CompWindowStateDemandsAttentionMask)
+ if (bamf_view_is_urgent (view))
any_urgent = true;
windows.push_back (window);
}
@@ -246,13 +261,31 @@ BamfLauncherIcon::Focus ()
if (any_urgent)
{
- for (it = windows.begin (); it != windows.end (); it++)
+ // we cant use the compiz tracking since it is currently broken
+ /*for (it = windows.begin (); it != windows.end (); it++)
{
if ((*it)->state () & CompWindowStateDemandsAttentionMask)
{
(*it)->activate ();
break;
}
+ }*/
+ for (l = children; l; l = l->next)
+ {
+ view = (BamfView *) l->data;
+
+ if (BAMF_IS_WINDOW (view))
+ {
+ guint32 xid = bamf_window_get_xid (BAMF_WINDOW (view));
+
+ CompWindow *window = m_Screen->findWindow ((Window) xid);
+
+ if (window && bamf_view_is_urgent (view))
+ {
+ window->activate ();
+ break;
+ }
+ }
}
}
else if (any_on_current)
diff --git a/src/BamfLauncherIcon.h b/src/BamfLauncherIcon.h
index 0550e9257..488ab4740 100644
--- a/src/BamfLauncherIcon.h
+++ b/src/BamfLauncherIcon.h
@@ -48,7 +48,6 @@ protected:
void UpdateIconGeometries (nux::Point3 center);
void OnCenterStabilized (nux::Point3 center);
- bool IconOwnsWindow (Window w);
void AddProperties (GVariantBuilder *builder);
@@ -68,6 +67,9 @@ private:
void Spread ();
void EnsureMenuItemsReady ();
+
+ void OnWindowMinimized (CompWindow *window);
+ bool OwnsWindow (Window w);
static void OnClosed (BamfView *view, gpointer data);
static void OnUserVisibleChanged (BamfView *view, gboolean visible, gpointer data);
diff --git a/src/Launcher.cpp b/src/Launcher.cpp
index a732f9c7b..e3ad4916e 100644
--- a/src/Launcher.cpp
+++ b/src/Launcher.cpp
@@ -183,16 +183,26 @@ Launcher::Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_DE
m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
- OnMouseDown.connect(sigc::mem_fun(this, &Launcher::RecvMouseDown));
- OnMouseUp.connect(sigc::mem_fun(this, &Launcher::RecvMouseUp));
- OnMouseDrag.connect(sigc::mem_fun(this, &Launcher::RecvMouseDrag));
- OnMouseEnter.connect(sigc::mem_fun(this, &Launcher::RecvMouseEnter));
- OnMouseLeave.connect(sigc::mem_fun(this, &Launcher::RecvMouseLeave));
- OnMouseMove.connect(sigc::mem_fun(this, &Launcher::RecvMouseMove));
- OnMouseWheel.connect(sigc::mem_fun(this, &Launcher::RecvMouseWheel));
+ OnMouseDown.connect (sigc::mem_fun (this, &Launcher::RecvMouseDown));
+ OnMouseUp.connect (sigc::mem_fun (this, &Launcher::RecvMouseUp));
+ OnMouseDrag.connect (sigc::mem_fun (this, &Launcher::RecvMouseDrag));
+ OnMouseEnter.connect (sigc::mem_fun (this, &Launcher::RecvMouseEnter));
+ OnMouseLeave.connect (sigc::mem_fun (this, &Launcher::RecvMouseLeave));
+ OnMouseMove.connect (sigc::mem_fun (this, &Launcher::RecvMouseMove));
+ OnMouseWheel.connect (sigc::mem_fun (this, &Launcher::RecvMouseWheel));
QuicklistManager::Default ()->quicklist_opened.connect (sigc::mem_fun(this, &Launcher::RecvQuicklistOpened));
QuicklistManager::Default ()->quicklist_closed.connect (sigc::mem_fun(this, &Launcher::RecvQuicklistClosed));
+
+ PluginAdapter::Default ()->window_maximized.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide));
+ PluginAdapter::Default ()->window_restored.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide));
+ PluginAdapter::Default ()->window_unminimized.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide));
+ PluginAdapter::Default ()->window_mapped.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide));
+ PluginAdapter::Default ()->window_unmapped.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide));
+ PluginAdapter::Default ()->window_shown.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide));
+ PluginAdapter::Default ()->window_hidden.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide));
+ PluginAdapter::Default ()->window_resized.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide));
+ PluginAdapter::Default ()->window_moved.connect (sigc::mem_fun (this, &Launcher::OnWindowMaybeIntellihide));
m_ActiveTooltipIcon = NULL;
m_ActiveMenuIcon = NULL;
@@ -235,7 +245,6 @@ Launcher::Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_DE
_icon_under_mouse = NULL;
_icon_mouse_down = NULL;
_drag_icon = NULL;
- _drag_icon_under_mouse = NULL;
_icon_image_size = 48;
_icon_glow_size = 62;
_icon_image_size_delta = 6;
@@ -245,16 +254,14 @@ Launcher::Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_DE
_icon_outline_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_outline_54x54.png");
_icon_shine_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_shine_54x54.png");
_icon_glow_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_glow_62x62.png");
- _icon_2indicator = nux::CreateTextureFromFile (PKGDATADIR"/2indicate_54x54.png");
- _icon_3indicator = nux::CreateTextureFromFile (PKGDATADIR"/3indicate_54x54.png");
- _icon_4indicator = nux::CreateTextureFromFile (PKGDATADIR"/4indicate_54x54.png");
+ _progress_bar_trough = nux::CreateTextureFromFile (PKGDATADIR"/progress_bar_trough.png");
+ _progress_bar_fill = nux::CreateTextureFromFile (PKGDATADIR"/progress_bar_fill.png");
_enter_y = 0;
_dnd_security = 15;
_launcher_drag_delta = 0;
_dnd_delta_y = 0;
_dnd_delta_x = 0;
- _anim_handle = 0;
_autohide_handle = 0;
_floating = false;
_hovered = false;
@@ -274,11 +281,14 @@ Launcher::Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_DE
_drag_end_time.tv_nsec = 0;
_drag_start_time.tv_sec = 0;
_drag_start_time.tv_nsec = 0;
+ _drag_threshold_time.tv_sec = 0;
+ _drag_threshold_time.tv_nsec = 0;
_autohide_time.tv_sec = 0;
_autohide_time.tv_nsec = 0;
_drag_window = NULL;
- _offscreen_rt_texture = nux::GetThreadGLDeviceFactory()->CreateSystemCapableDeviceTexture (2, 2, 1, nux::BITFMT_R8G8B8A8);
+ _offscreen_drag_texture = nux::GetThreadGLDeviceFactory()->CreateSystemCapableDeviceTexture (2, 2, 1, nux::BITFMT_R8G8B8A8);
+ _offscreen_progress_texture = nux::GetThreadGLDeviceFactory()->CreateSystemCapableDeviceTexture (2, 2, 1, nux::BITFMT_R8G8B8A8);
}
Launcher::~Launcher()
@@ -312,8 +322,23 @@ Launcher::AddProperties (GVariantBuilder *builder)
g_variant_builder_add (builder, "{sv}", "mouse-inside-launcher", g_variant_new_boolean (_mouse_inside_launcher));
}
-/* Render Layout Logic */
+void Launcher::SetMousePosition (int x, int y)
+{
+ bool beyond_drag_threshold = MouseBeyondDragThreshold ();
+ _mouse_position = nux::Point2 (x, y);
+
+ if (beyond_drag_threshold != MouseBeyondDragThreshold ())
+ SetTimeStruct (&_drag_threshold_time, &_drag_threshold_time, ANIM_DURATION_SHORT);
+}
+
+bool Launcher::MouseBeyondDragThreshold ()
+{
+ if (_launcher_action_state != ACTION_DRAG_ICON)
+ return false;
+ return _mouse_position.x > GetGeometry ().width + _icon_size / 2;
+}
+/* Render Layout Logic */
float Launcher::GetHoverProgress (struct timespec const &current)
{
if (_hovered)
@@ -343,6 +368,14 @@ float Launcher::AutohideProgress (struct timespec const &current)
return 1.0f - CLAMP ((float) (TimeDelta (&current, &_autohide_time)) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
}
+float Launcher::DragThresholdProgress (struct timespec const &current)
+{
+ if (MouseBeyondDragThreshold ())
+ return 1.0f - CLAMP ((float) (TimeDelta (&current, &_drag_threshold_time)) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
+ else
+ return CLAMP ((float) (TimeDelta (&current, &_drag_threshold_time)) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
+}
+
gboolean Launcher::AnimationTimeout (gpointer data)
{
Launcher *self = (Launcher*) data;
@@ -385,6 +418,9 @@ bool Launcher::IconNeedsAnimation (LauncherIcon *icon, struct timespec const &cu
if (TimeDelta (&current, &time) < ANIM_DURATION)
return true;
+ time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_PROGRESS);
+ if (TimeDelta (&current, &time) < ANIM_DURATION)
+ return true;
return false;
}
@@ -416,6 +452,9 @@ bool Launcher::AnimationInProgress ()
if (TimeDelta (&current, &_autohide_time) < ANIM_DURATION_SHORT)
return true;
+
+ if (TimeDelta (&current, &_drag_threshold_time) < ANIM_DURATION_SHORT)
+ return true;
// animations happening on specific icons
LauncherModel::iterator it;
@@ -592,6 +631,18 @@ float Launcher::IconBackgroundIntensity (LauncherIcon *icon, struct timespec con
return result;
}
+float Launcher::IconProgressBias (LauncherIcon *icon, struct timespec const &current)
+{
+ struct timespec icon_progress_time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_PROGRESS);
+ int ms = TimeDelta (&current, &icon_progress_time);
+ float result = CLAMP ((float) ms / (float) ANIM_DURATION, 0.0f, 1.0f);
+
+ if (icon->GetQuirk (LAUNCHER_ICON_QUIRK_PROGRESS))
+ return -1.0f + result;
+ else
+ return result;
+}
+
void Launcher::SetupRenderArg (LauncherIcon *icon, struct timespec const &current, RenderArg &arg)
{
arg.icon = icon;
@@ -604,7 +655,9 @@ void Launcher::SetupRenderArg (LauncherIcon *icon, struct timespec const &curren
arg.y_rotation = 0.0f;
arg.z_rotation = 0.0f;
arg.skip = false;
-
+ arg.stick_thingy = false;
+ arg.progress_bias = IconProgressBias (icon, current);
+ arg.progress = CLAMP (icon->GetProgress (), 0.0f, 1.0f);
// we dont need to show strays
if (!icon->GetQuirk (LAUNCHER_ICON_QUIRK_RUNNING))
@@ -647,9 +700,18 @@ void Launcher::FillRenderArg (LauncherIcon *icon,
center.z = 300.0f * (1.0f - size_modifier);
}
- if (size_modifier <= 0.0f || icon == _drag_icon)
+ if (icon == _drag_icon)
+ {
+ if (MouseBeyondDragThreshold ())
+ arg.stick_thingy = true;
+
+ if (_launcher_action_state == ACTION_DRAG_ICON || (_drag_window && _drag_window->Animating ()))
+ arg.skip = true;
+ size_modifier *= DragThresholdProgress (current);
+ }
+
+ 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);
@@ -683,6 +745,9 @@ void Launcher::FillRenderArg (LauncherIcon *icon,
icon->SetCenter (nux::Point3 (roundf (center.x), roundf (center.y), roundf (center.z)));
+ if (icon == _drag_icon && _drag_window && _drag_window->Animating ())
+ _drag_window->SetAnimationTarget ((int) center.x, (int) center.y + _parent->GetGeometry ().y);
+
center.y += (half_size * size_modifier) + spacing; // move to end
}
@@ -882,7 +947,7 @@ Launcher::CheckWindowOverLauncher ()
{
CompWindow *window = *it;
- if (window->type () != CompWindowTypeNormalMask || window->invisible ())
+ if (window->type () != CompWindowTypeNormalMask || !window->isMapped ())
continue;
if (CompRegion (window->inputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height)))
@@ -898,27 +963,7 @@ Launcher::CheckWindowOverLauncher ()
}
void
-Launcher::OnWindowMoved (CompWindow *window)
-{
- if (_autohide)
- CheckWindowOverLauncher ();
-}
-
-void
-Launcher::OnWindowResized (CompWindow *window)
-{
- if (_autohide)
- CheckWindowOverLauncher ();
-}
-
-void
-Launcher::OnWindowAppear (CompWindow *window)
-{
- if (_autohide)
- CheckWindowOverLauncher ();
-}
-void
-Launcher::OnWindowDisappear (CompWindow *window)
+Launcher::OnWindowMaybeIntellihide (CompWindow *window)
{
if (_autohide)
CheckWindowOverLauncher ();
@@ -1045,10 +1090,10 @@ void Launcher::OnIconAdded (LauncherIcon *icon)
EnsureAnimation();
// How to free these properly?
- icon->_xform_coords["HitArea"] = new nux::Vector4[4];
- icon->_xform_coords["Image"] = new nux::Vector4[4];
- icon->_xform_coords["Tile"] = new nux::Vector4[4];
- icon->_xform_coords["Glow"] = new nux::Vector4[4];
+ icon->_xform_coords["HitArea"] = new nux::Vector4[4];
+ icon->_xform_coords["Image"] = new nux::Vector4[4];
+ icon->_xform_coords["Tile"] = new nux::Vector4[4];
+ icon->_xform_coords["Glow"] = new nux::Vector4[4];
// needs to be disconnected
icon->needs_redraw.connect (sigc::mem_fun(this, &Launcher::OnIconNeedsRedraw));
@@ -1170,13 +1215,12 @@ void Launcher::RenderIndicators (nux::GraphicsEngine& GfxContext,
void Launcher::RenderIcon(nux::GraphicsEngine& GfxContext,
RenderArg const &arg,
- nux::BaseTexture *icon,
+ nux::IntrusiveSP<nux::IOpenGLBaseTexture> icon,
nux::Color bkg_color,
float alpha,
- nux::Vector4 xform_coords[],
- nux::Geometry geo)
+ nux::Vector4 xform_coords[])
{
- if (icon == NULL || icon->IsNull ())
+ if (icon == NULL)
return;
nux::Matrix4 ObjectMatrix;
@@ -1185,9 +1229,9 @@ void Launcher::RenderIcon(nux::GraphicsEngine& GfxContext,
nux::Matrix4 ViewProjectionMatrix;
if(nux::Abs (arg.x_rotation) < 0.01f)
- icon->GetDeviceTexture()->SetFiltering(GL_NEAREST, GL_NEAREST);
+ icon->SetFiltering(GL_NEAREST, GL_NEAREST);
else
- icon->GetDeviceTexture()->SetFiltering(GL_LINEAR, GL_LINEAR);
+ icon->SetFiltering(GL_LINEAR, GL_LINEAR);
nux::Vector4 v0;
nux::Vector4 v1;
@@ -1214,7 +1258,7 @@ void Launcher::RenderIcon(nux::GraphicsEngine& GfxContext,
float s0, t0, s1, t1, s2, t2, s3, t3;
nux::Color color = nux::Color::White;
- if (icon->Type ().IsDerivedFromType(nux::TextureRectangle::StaticObjectType))
+ if (icon->GetResourceType () == nux::RTTEXTURERECTANGLE)
{
s0 = 0.0f; t0 = 0.0f;
s1 = 0.0f; t1 = icon->GetHeight();
@@ -1336,27 +1380,27 @@ void Launcher::DrawRenderArg (nux::GraphicsEngine& GfxContext, RenderArg const &
GfxContext.GetRenderStates ().SetColorMask (true, true, true, true);
+ /* draw tile */
if (arg.backlight_intensity < 1.0f)
{
RenderIcon(GfxContext,
arg,
- _icon_outline_texture,
+ _icon_outline_texture->GetDeviceTexture (),
nux::Color(0xAAFFFFFF),
1.0f - arg.backlight_intensity,
- arg.icon->_xform_coords["Tile"],
- geo);
+ arg.icon->_xform_coords["Tile"]);
}
if (arg.backlight_intensity > 0.0f)
{
RenderIcon(GfxContext,
arg,
- _icon_bkg_texture,
+ _icon_bkg_texture->GetDeviceTexture (),
arg.icon->BackgroundColor (),
arg.backlight_intensity,
- arg.icon->_xform_coords["Tile"],
- geo);
+ arg.icon->_xform_coords["Tile"]);
}
+ /* end tile draw */
GfxContext.GetRenderStates ().SetSeparateBlend (true,
GL_SRC_ALPHA,
@@ -1365,70 +1409,37 @@ void Launcher::DrawRenderArg (nux::GraphicsEngine& GfxContext, RenderArg const &
GL_ONE);
GfxContext.GetRenderStates ().SetColorMask (true, true, true, true);
+ /* draw icon */
RenderIcon (GfxContext,
arg,
- arg.icon->TextureForSize (_icon_image_size),
+ arg.icon->TextureForSize (_icon_image_size)->GetDeviceTexture (),
nux::Color::White,
arg.alpha,
- arg.icon->_xform_coords["Image"],
- geo);
+ arg.icon->_xform_coords["Image"]);
+ /* draw overlay shine */
if (arg.backlight_intensity > 0.0f)
{
RenderIcon(GfxContext,
arg,
- _icon_shine_texture,
+ _icon_shine_texture->GetDeviceTexture (),
nux::Color::White,
arg.backlight_intensity,
- arg.icon->_xform_coords["Tile"],
- geo);
- }
-
- if (false)
- {
- switch (arg.window_indicators)
- {
- case 2:
- RenderIcon(GfxContext,
- arg,
- _icon_2indicator,
- nux::Color::White,
- 1.0f,
- arg.icon->_xform_coords["Tile"],
- geo);
- break;
- case 3:
- RenderIcon(GfxContext,
- arg,
- _icon_3indicator,
- nux::Color::White,
- 1.0f,
- arg.icon->_xform_coords["Tile"],
- geo);
- break;
- case 4:
- RenderIcon(GfxContext,
- arg,
- _icon_4indicator,
- nux::Color::White,
- 1.0f,
- arg.icon->_xform_coords["Tile"],
- geo);
- break;
- }
+ arg.icon->_xform_coords["Tile"]);
}
+ /* draw glow */
if (arg.glow_intensity > 0.0f)
{
RenderIcon(GfxContext,
arg,
- _icon_glow_texture,
+ _icon_glow_texture->GetDeviceTexture (),
arg.icon->GlowColor (),
arg.glow_intensity,
- arg.icon->_xform_coords["Glow"],
- geo);
+ arg.icon->_xform_coords["Glow"]);
}
-
+
+ /* draw shimmer */
if (arg.shimmer_progress > 0.0f && arg.shimmer_progress < 1.0f)
{
nux::Geometry base = GetGeometry ();
@@ -1443,15 +1454,30 @@ void Launcher::DrawRenderArg (nux::GraphicsEngine& GfxContext, RenderArg const &
RenderIcon(GfxContext,
arg,
- _icon_glow_texture,
+ _icon_glow_texture->GetDeviceTexture (),
arg.icon->GlowColor (),
fade_out,
- arg.icon->_xform_coords["Glow"],
- geo);
+ arg.icon->_xform_coords["Glow"]);
GfxContext.PopClippingRectangle();
}
+
+ /* draw progress bar */
+ if (arg.progress_bias > -1.0f && arg.progress_bias < 1.0f)
+ {
+ if (_offscreen_progress_texture->GetWidth () != _icon_size || _offscreen_progress_texture->GetHeight () != _icon_size)
+ _offscreen_progress_texture = nux::GetThreadGLDeviceFactory()->CreateSystemCapableDeviceTexture (_icon_size, _icon_size, 1, nux::BITFMT_R8G8B8A8);
+ RenderProgressToTexture (GfxContext, _offscreen_progress_texture, arg.progress, arg.progress_bias);
+
+ RenderIcon(GfxContext,
+ arg,
+ _offscreen_progress_texture,
+ nux::Color::White,
+ 1.0f,
+ arg.icon->_xform_coords["Tile"]);
+ }
+ /* draw indicators */
RenderIndicators (GfxContext,
arg,
arg.running_arrow ? arg.window_indicators : 0,
@@ -1480,28 +1506,7 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
if (_drag_icon && _render_drag_window)
{
- RenderArg arg;
- struct timespec current;
- clock_gettime (CLOCK_MONOTONIC, &current);
-
- SetupRenderArg (_drag_icon, current, arg);
- arg.render_center = nux::Point3 (_icon_size / 2.0f, _icon_size / 2.0f, 0.0f);
- arg.logical_center = arg.render_center;
- arg.x_rotation = 0.0f;
- arg.running_arrow = false;
- arg.active_arrow = false;
- arg.skip = false;
- arg.window_indicators = 0;
- arg.alpha = 1.0f;
-
- std::list<Launcher::RenderArg> drag_args;
- drag_args.push_front (arg);
- UpdateIconXForm (drag_args);
-
- SetOffscreenRenderTarget ();
- DrawRenderArg (nux::GetGraphicsEngine (), arg, nux::Geometry (0, 0, _icon_size, _icon_size));
- RestoreSystemRenderTarget ();
-
+ RenderIconToTexture (GfxContext, _drag_icon, _offscreen_drag_texture);
_drag_window->ShowWindow (true);
nux::GetWindowCompositor ().SetAlwaysOnFrontWindow (_drag_window);
@@ -1529,6 +1534,11 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
/* draw launcher */
for (rev_it = args.rbegin (); rev_it != args.rend (); rev_it++)
{
+ if ((*rev_it).stick_thingy)
+ gPainter.Paint2DQuadColor (GfxContext,
+ nux::Geometry (bkg_box.x, (*rev_it).render_center.y - 3, bkg_box.width, 2),
+ nux::Color(0xAAFFFFFF));
+
if ((*rev_it).x_rotation >= 0.0f || (*rev_it).skip)
continue;
@@ -1537,6 +1547,11 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
for (it = args.begin(); it != args.end(); it++)
{
+ if ((*it).stick_thingy)
+ gPainter.Paint2DQuadColor (GfxContext,
+ nux::Geometry (bkg_box.x, (*it).render_center.y - 3, bkg_box.width, 2),
+ nux::Color(0xAAFFFFFF));
+
if ((*it).x_rotation < 0.0f || (*it).skip)
continue;
@@ -1575,7 +1590,7 @@ long Launcher::PostLayoutManagement(long LayoutResult)
{
View::PostLayoutManagement(LayoutResult);
- _mouse_position = nux::Point2 (0, 0);
+ SetMousePosition (0, 0);
return nux::eCompliantHeight | nux::eCompliantWidth;
}
@@ -1584,22 +1599,12 @@ void Launcher::PositionChildLayout(float offsetX, float offsetY)
{
}
-bool Launcher::TooltipNotify(LauncherIcon* Icon)
-{
- if(GetActiveMenuIcon())
- return false;
- return true;
-}
-
-bool Launcher::MenuNotify(LauncherIcon* Icon)
-{
-
-
- return true;
-}
-
-void Launcher::NotifyMenuTermination(LauncherIcon* Icon)
+void Launcher::OnDragWindowAnimCompleted ()
{
+ if (_drag_window)
+ _drag_window->ShowWindow (false);
+
+ EnsureAnimation ();
}
void Launcher::StartIconDrag (LauncherIcon *icon)
@@ -1616,8 +1621,8 @@ void Launcher::StartIconDrag (LauncherIcon *icon)
_drag_window = NULL;
}
- _offscreen_rt_texture = nux::GetThreadGLDeviceFactory()->CreateSystemCapableDeviceTexture (_icon_size, _icon_size, 1, nux::BITFMT_R8G8B8A8);
- _drag_window = new LauncherDragWindow (_offscreen_rt_texture);
+ _offscreen_drag_texture = nux::GetThreadGLDeviceFactory()->CreateSystemCapableDeviceTexture (_icon_size, _icon_size, 1, nux::BITFMT_R8G8B8A8);
+ _drag_window = new LauncherDragWindow (_offscreen_drag_texture);
_drag_window->SinkReference ();
_render_drag_window = true;
@@ -1627,13 +1632,14 @@ void Launcher::EndIconDrag ()
{
if (_drag_window)
{
- _drag_window->ShowWindow (false);
- _drag_window->UnReference ();
- _drag_window = NULL;
+ _drag_window->SetAnimationTarget ((int) (_drag_icon->GetCenter ().x), (int) (_drag_icon->GetCenter ().y));
+ _drag_window->StartAnimation ();
+ _drag_window->anim_completed.connect (sigc::mem_fun (this, &Launcher::OnDragWindowAnimCompleted));
}
- _drag_icon_under_mouse = NULL;
- _drag_icon = NULL;
+ if (MouseBeyondDragThreshold ())
+ SetTimeStruct (&_drag_threshold_time, &_drag_threshold_time, ANIM_DURATION_SHORT);
+
_render_drag_window = false;
}
@@ -1646,14 +1652,23 @@ void Launcher::UpdateDragWindowPosition (int x, int y)
LauncherIcon *hovered_icon = MouseIconIntersection ((int) (GetGeometry ().x / 2.0f), y);
+ struct timespec current;
+ clock_gettime (CLOCK_MONOTONIC, &current);
if (_drag_icon && hovered_icon && _drag_icon != hovered_icon)
- request_reorder.emit (_drag_icon, hovered_icon);
+ {
+ float progress = DragThresholdProgress (current);
+
+ if (progress >= 1.0f)
+ request_reorder_smart.emit (_drag_icon, hovered_icon, true);
+ else if (progress == 0.0f)
+ request_reorder_before.emit (_drag_icon, hovered_icon, false);
+ }
}
}
void Launcher::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- _mouse_position = nux::Point2 (x, y);
+ SetMousePosition (x, y);
MouseDownLogic (x, y, button_flags, key_flags);
EnsureAnimation ();
@@ -1661,7 +1676,7 @@ void Launcher::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned
void Launcher::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- _mouse_position = nux::Point2 (x, y);
+ SetMousePosition (x, y);
nux::Geometry geo = GetGeometry ();
if (_launcher_action_state != ACTION_NONE && !geo.IsInside(nux::Point(x, y)))
@@ -1678,12 +1693,13 @@ void Launcher::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned lo
_launcher_action_state = ACTION_NONE;
_dnd_delta_x = 0;
_dnd_delta_y = 0;
+ EnsureHoverState ();
EnsureAnimation ();
}
void Launcher::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
{
- _mouse_position = nux::Point2 (x, y);
+ SetMousePosition (x, y);
_dnd_delta_y += dy;
_dnd_delta_x += dx;
@@ -1736,7 +1752,7 @@ void Launcher::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_
void Launcher::RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- _mouse_position = nux::Point2 (x, y);
+ SetMousePosition (x, y);
_mouse_inside_launcher = true;
EnsureHoverState ();
@@ -1747,7 +1763,7 @@ void Launcher::RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned
void Launcher::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- _mouse_position = nux::Point2 (x, y);
+ SetMousePosition (x, y);
_mouse_inside_launcher = false;
if (_launcher_action_state == ACTION_NONE)
@@ -1759,7 +1775,7 @@ void Launcher::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned
void Launcher::RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
{
- _mouse_position = nux::Point2 (x, y);
+ SetMousePosition (x, y);
// Every time the mouse moves, we check if it is inside an icon...
EventLogic ();
@@ -2102,58 +2118,118 @@ void GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& P
float AspectRatio = (float)ViewportWidth/(float)ViewportHeight;
float CameraToScreenDistance = -1.0f;
- float y_cs = -CameraToScreenDistance*tanf(0.5f*Fovy/* *3.1415926/180.0f*/);
+ float y_cs = -CameraToScreenDistance*tanf(0.5f*Fovy/* *M_PI/180.0f*/);
float x_cs = y_cs*AspectRatio;
- //float CameraToScreenDistance = -y_cs*1.0f/(tanf(0.5f*Fovy/* *3.1415926/180.0f*/));
ViewMatrix = nux::Matrix4::TRANSLATE(-x_cs, y_cs, CameraToScreenDistance) *
nux::Matrix4::SCALE(2.0f*x_cs/ViewportWidth, -2.0f*y_cs/ViewportHeight, -2.0f * 3 * y_cs/ViewportHeight /* or -2.0f * x_cs/ViewportWidth*/ );
PerspectiveMatrix.Perspective(Fovy, AspectRatio, NearClipPlane, FarClipPlane);
+}
+
+void
+Launcher::RenderIconToTexture (nux::GraphicsEngine& GfxContext, LauncherIcon *icon, nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture)
+{
+ RenderArg arg;
+ struct timespec current;
+ clock_gettime (CLOCK_MONOTONIC, &current);
+
+ SetupRenderArg (icon, current, arg);
+ arg.render_center = nux::Point3 (_icon_size / 2.0f, _icon_size / 2.0f, 0.0f);
+ arg.logical_center = arg.render_center;
+ arg.x_rotation = 0.0f;
+ arg.running_arrow = false;
+ arg.active_arrow = false;
+ arg.skip = false;
+ arg.window_indicators = 0;
+ arg.alpha = 1.0f;
+
+ std::list<Launcher::RenderArg> drag_args;
+ drag_args.push_front (arg);
+ UpdateIconXForm (drag_args);
+
+ SetOffscreenRenderTarget (texture);
+ DrawRenderArg (nux::GetGraphicsEngine (), arg, nux::Geometry (0, 0, _icon_size, _icon_size));
+ RestoreSystemRenderTarget ();
+}
+
+void
+Launcher::RenderProgressToTexture (nux::GraphicsEngine& GfxContext, nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture, float progress_fill, float bias)
+{
+ int width = texture->GetWidth ();
+ int height = texture->GetHeight ();
+
+ int progress_width = _progress_bar_trough->GetWidth ();
+ int progress_height = _progress_bar_trough->GetHeight ();
+
+ int fill_width = _progress_bar_fill->GetWidth ();
+ int fill_height = _progress_bar_fill->GetHeight ();
+
+ int fill_offset = (progress_width - fill_width) / 2;
+
+ /* We need to perform a barn doors effect to acheive the slide in and out */
+
+ int left_edge = width / 2 - progress_width / 2;
+ int right_edge = width / 2 + progress_width / 2;
+
+ if (bias < 0.0f)
+ {
+ // pulls the right edge in
+ right_edge -= (int) (-bias * (float) progress_width);
+ }
+ else if (bias > 0.0f)
+ {
+ // pulls the left edge in
+ left_edge += (int) (bias * progress_width);
+ }
+
+ int fill_y = (height - fill_height) / 2;
+ int progress_y = (height - progress_height) / 2;
+ int half_size = (right_edge - left_edge) / 2;
+
+ SetOffscreenRenderTarget (texture);
+
+ // FIXME
+ glClear (GL_COLOR_BUFFER_BIT);
+ nux::TexCoordXForm texxform;
+
+ fill_width *= progress_fill;
+
+ // left door
+ GfxContext.PushClippingRectangle(nux::Geometry (left_edge, 0, half_size, height));
+
+ GfxContext.QRP_GLSL_1Tex (left_edge, progress_y, progress_width, progress_height,
+ _progress_bar_trough->GetDeviceTexture (), texxform, nux::Color::White);
+
+ GfxContext.QRP_GLSL_1Tex (left_edge + fill_offset, fill_y, fill_width, fill_height,
+ _progress_bar_fill->GetDeviceTexture (), texxform, nux::Color::White);
+
+ GfxContext.PopClippingRectangle ();
+
-// // Example usage with the matrices above:
-// float W = 300;
-// float H = 300;
-// // centered quad
-// float X = (ViewportWidth - W)/2.0;
-// float Y = (ViewportHeight - H)/2.0;
-// float Z = 0.0f;
-//
-// {
-// glPushMatrix();
-// // Local Transformation of the object
-// glTranslatef(0.0f, 0.0f, ObjectDistanceToCamera);
-// glTranslatef(X + W/2.0f, Y + H/2.0f, 0.0f);
-// glRotatef(cameraAngleY, 1, 0, 0);
-// glRotatef(cameraAngleX, 0, 1, 0);
-// glTranslatef(-X - W/2.0f, -Y - H/2.0f, 0.0f);
-//
-// glBegin(GL_QUADS);
-// {
-// glNormal3f(0.0f, 0.0f, 1.0f);
-//
-// glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
-// glVertex4f(X, Y, Z, 1.0f);
-//
-// glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
-// glVertex4f(X, Y+H, Z, 1.0f);
-//
-// glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
-// glVertex4f(X+W, Y+H, Z, 1.0f);
-//
-// glColor4f(0.0f, 1.0f, 1.0f, 1.0f);
-// glVertex4f(X+W, Y, Z, 1.0f);
-// }
-// glEnd();
-}
-
-void Launcher::SetOffscreenRenderTarget ()
-{
- int width = _offscreen_rt_texture->GetWidth ();
- int height = _offscreen_rt_texture->GetHeight ();
+ // right door
+ GfxContext.PushClippingRectangle(nux::Geometry (left_edge + half_size, 0, half_size, height));
+
+ GfxContext.QRP_GLSL_1Tex (right_edge - progress_width, progress_y, progress_width, progress_height,
+ _progress_bar_trough->GetDeviceTexture (), texxform, nux::Color::White);
+
+ GfxContext.QRP_GLSL_1Tex (right_edge - progress_width + fill_offset, fill_y, fill_width, fill_height,
+ _progress_bar_fill->GetDeviceTexture (), texxform, nux::Color::White);
+
+ GfxContext.PopClippingRectangle ();
+
+
+ RestoreSystemRenderTarget ();
+}
+
+void
+Launcher::SetOffscreenRenderTarget (nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture)
+{
+ int width = texture->GetWidth ();
+ int height = texture->GetHeight ();
nux::GetThreadGLDeviceFactory ()->FormatFrameBufferObject (width, height, nux::BITFMT_R8G8B8A8);
- nux::GetThreadGLDeviceFactory ()->SetColorRenderTargetSurface (0, _offscreen_rt_texture->GetSurfaceLevel (0));
+ nux::GetThreadGLDeviceFactory ()->SetColorRenderTargetSurface (0, texture->GetSurfaceLevel (0));
nux::GetThreadGLDeviceFactory ()->ActivateFrameBuffer ();
nux::GetThreadGraphicsContext ()->SetContext (0, 0, width, height);
@@ -2162,7 +2238,8 @@ void Launcher::SetOffscreenRenderTarget ()
nux::GetThreadGraphicsContext ()->EmptyClippingRegion();
}
-void Launcher::RestoreSystemRenderTarget ()
+void
+Launcher::RestoreSystemRenderTarget ()
{
nux::GetWindowCompositor ().RestoreRenderingSurface ();
}
diff --git a/src/Launcher.h b/src/Launcher.h
index 9c53e0b76..b759683c5 100644
--- a/src/Launcher.h
+++ b/src/Launcher.h
@@ -30,6 +30,7 @@
#include "LauncherDragWindow.h"
#include "NuxGraphics/IOpenGLAsmShader.h"
#include "Nux/TimerProc.h"
+#include "PluginAdapter.h"
class LauncherModel;
class QuicklistView;
@@ -37,53 +38,45 @@ class QuicklistView;
class Launcher : public Introspectable, public nux::View
{
public:
- Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_PROTO);
- ~Launcher();
+ Launcher(nux::BaseWindow *parent, CompScreen *screen, NUX_FILE_LINE_PROTO);
+ ~Launcher();
- virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
- virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
- virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
- virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
+ virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
- LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;}
- LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;}
+ LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;}
+ LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;}
- bool TooltipNotify(LauncherIcon* Icon);
- bool MenuNotify(LauncherIcon* Icon);
+ void SetIconSize(int tile_size, int icon_size);
- void SetIconSize(int tile_size, int icon_size);
- void NotifyMenuTermination(LauncherIcon* Icon);
+ void SetModel (LauncherModel *model);
- void SetModel (LauncherModel *model);
+ void SetFloating (bool floating);
- void SetFloating (bool floating);
-
- void SetAutohide (bool autohide, nux::View *show_trigger);
- bool AutohideEnabled ();
-
- nux::BaseWindow* GetParent () { return _parent; };
-
- void OnWindowMoved (CompWindow *window);
- void OnWindowResized (CompWindow *window);
- void OnWindowAppear (CompWindow *window);
- void OnWindowDisappear (CompWindow *window);
+ void SetAutohide (bool autohide, nux::View *show_trigger);
+ bool AutohideEnabled ();
+
+ nux::BaseWindow* GetParent () { return _parent; };
- virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
- virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
- virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
- virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
- virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
- virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
- virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);
+ virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
+ virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
+ virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
+ virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
+ virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
+ virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
+ virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);
- virtual void RecvQuicklistOpened (QuicklistView *quicklist);
- virtual void RecvQuicklistClosed (QuicklistView *quicklist);
+ virtual void RecvQuicklistOpened (QuicklistView *quicklist);
+ virtual void RecvQuicklistClosed (QuicklistView *quicklist);
- sigc::signal<void, LauncherIcon *, LauncherIcon *> request_reorder;
+ sigc::signal<void, LauncherIcon *, LauncherIcon *, bool> request_reorder_smart;
+ sigc::signal<void, LauncherIcon *, LauncherIcon *, bool> request_reorder_before;
protected:
- // Introspectable methods
- const gchar* GetName ();
- void AddProperties (GVariantBuilder *builder);
+ // Introspectable methods
+ const gchar* GetName ();
+ void AddProperties (GVariantBuilder *builder);
private:
typedef enum
@@ -111,18 +104,28 @@ private:
float backlight_intensity;
float glow_intensity;
float shimmer_progress;
+ float progress;
+ float progress_bias;
bool running_arrow;
bool running_colored;
bool active_arrow;
bool active_colored;
bool skip;
+ bool stick_thingy;
int window_indicators;
} RenderArg;
+ void OnWindowMaybeIntellihide (CompWindow *window);
+
static gboolean AnimationTimeout (gpointer data);
static gboolean OnAutohideTimeout (gpointer data);
static gboolean StrutHack (gpointer data);
+
+ void SetMousePosition (int x, int y);
+
+ bool MouseBeyondDragThreshold ();
+ void OnDragWindowAnimCompleted ();
void OnTriggerMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);
void OnTriggerMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);
@@ -141,12 +144,14 @@ private:
float DnDExitProgress (struct timespec const &current);
float GetHoverProgress (struct timespec const &current);
float AutohideProgress (struct timespec const &current);
+ float DragThresholdProgress (struct timespec const &current);
float IconPresentProgress (LauncherIcon *icon, struct timespec const &current);
float IconUrgentProgress (LauncherIcon *icon, struct timespec const &current);
float IconShimmerProgress (LauncherIcon *icon, struct timespec const &current);
float IconUrgentPulseValue (LauncherIcon *icon, struct timespec const &current);
float IconStartingPulseValue (LauncherIcon *icon, struct timespec const &current);
float IconBackgroundIntensity (LauncherIcon *icon, struct timespec const &current);
+ float IconProgressBias (LauncherIcon *icon, struct timespec const &current);
float IconCenterTransitionProgress (LauncherIcon *icon, struct timespec const &current);
void SetHover ();
@@ -187,11 +192,13 @@ private:
void RenderIcon (nux::GraphicsEngine& GfxContext,
RenderArg const &arg,
- nux::BaseTexture *icon,
+ nux::IntrusiveSP<nux::IOpenGLBaseTexture> icon,
nux::Color bkg_color,
float alpha,
- nux::Vector4 xform_coords[],
- nux::Geometry geo);
+ nux::Vector4 xform_coords[]);
+
+ void RenderIconToTexture (nux::GraphicsEngine& GfxContext, LauncherIcon *icon, nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture);
+ void RenderProgressToTexture (nux::GraphicsEngine& GfxContext, nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture, float progress_fill, float bias);
void SetIconXForm (LauncherIcon *icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry geo,
float x, float y, float w, float h, float z, std::string name);
@@ -210,7 +217,7 @@ private:
virtual long PostLayoutManagement(long LayoutResult);
virtual void PositionChildLayout(float offsetX, float offsetY);
- void SetOffscreenRenderTarget ();
+ void SetOffscreenRenderTarget (nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture);
void RestoreSystemRenderTarget ();
nux::HLayout* m_Layout;
@@ -242,9 +249,7 @@ private:
LauncherIcon* _icon_under_mouse;
LauncherIcon* _icon_mouse_down;
-
LauncherIcon* _drag_icon;
- LauncherIcon* _drag_icon_under_mouse;
int _space_between_icons;
int _icon_size;
@@ -261,13 +266,12 @@ private:
nux::BaseTexture* _icon_shine_texture;
nux::BaseTexture* _icon_outline_texture;
nux::BaseTexture* _icon_glow_texture;
- nux::BaseTexture* _icon_2indicator;
- nux::BaseTexture* _icon_3indicator;
- nux::BaseTexture* _icon_4indicator;
+ nux::BaseTexture* _progress_bar_trough;
+ nux::BaseTexture* _progress_bar_fill;
- nux::IntrusiveSP<nux::IOpenGLBaseTexture> _offscreen_rt_texture;
+ nux::IntrusiveSP<nux::IOpenGLBaseTexture> _offscreen_drag_texture;
+ nux::IntrusiveSP<nux::IOpenGLBaseTexture> _offscreen_progress_texture;
- guint _anim_handle;
guint _autohide_handle;
nux::Matrix4 _view_matrix;
@@ -290,6 +294,7 @@ private:
struct timespec _exit_time;
struct timespec _drag_end_time;
struct timespec _drag_start_time;
+ struct timespec _drag_threshold_time;
struct timespec _autohide_time;
};
diff --git a/src/LauncherController.cpp b/src/LauncherController.cpp
index 242c5d184..c295554c7 100644
--- a/src/LauncherController.cpp
+++ b/src/LauncherController.cpp
@@ -42,7 +42,8 @@ LauncherController::LauncherController(Launcher* launcher, CompScreen *screen, n
InsertExpoAction ();
InsertTrash ();
- _launcher->request_reorder.connect (sigc::mem_fun (this, &LauncherController::OnLauncherRequestReorder));
+ _launcher->request_reorder_smart.connect (sigc::mem_fun (this, &LauncherController::OnLauncherRequestReorderSmart));
+ _launcher->request_reorder_before.connect (sigc::mem_fun (this, &LauncherController::OnLauncherRequestReorderBefore));
}
LauncherController::~LauncherController()
@@ -51,7 +52,74 @@ LauncherController::~LauncherController()
}
void
-LauncherController::OnLauncherRequestReorder (LauncherIcon *icon, LauncherIcon *other)
+LauncherController::SortAndSave ()
+{
+ LauncherModel::iterator it;
+ _model->Sort (&LauncherController::CompareIcons);
+
+ std::list<const char*> desktop_paths;
+ for (it = _model->begin (); it != _model->end (); it++)
+ {
+ BamfLauncherIcon *icon;
+ icon = dynamic_cast<BamfLauncherIcon*> (*it);
+
+ if (!icon)
+ continue;
+
+ if (!icon->IsSticky ())
+ continue;
+
+ const char* desktop_file = icon->DesktopFile ();
+
+ if (desktop_file && strlen (desktop_file) > 0)
+ desktop_paths.push_back (desktop_file);
+ }
+
+ _favorite_store->SetFavorites (desktop_paths);
+}
+
+void
+LauncherController::OnLauncherRequestReorderBefore (LauncherIcon *icon, LauncherIcon *other, bool save)
+{
+ if (icon == other)
+ return;
+
+ LauncherModel::iterator it;
+
+ int i = 0;
+ int j = 0;
+ for (it = _model->begin (); it != _model->end (); it++)
+ {
+ if ((*it) == icon)
+ {
+ j++;
+ continue;
+ }
+
+ if ((*it) == other)
+ {
+ icon->SetSortPriority (i);
+ if (i != j && save) (*it)->SaveCenter ();
+ i++;
+
+ (*it)->SetSortPriority (i);
+ if (i != j && save) (*it)->SaveCenter ();
+ i++;
+ }
+ else
+ {
+ (*it)->SetSortPriority (i);
+ if (i != j && save) (*it)->SaveCenter ();
+ i++;
+ }
+ j++;
+ }
+
+ SortAndSave ();
+}
+
+void
+LauncherController::OnLauncherRequestReorderSmart (LauncherIcon *icon, LauncherIcon *other, bool save)
{
if (icon == other)
return;
@@ -75,73 +143,31 @@ LauncherController::OnLauncherRequestReorder (LauncherIcon *icon, LauncherIcon *
if (!skipped)
{
icon->SetSortPriority (i);
- if (i != j) (*it)->SaveCenter ();
+ if (i != j && save) (*it)->SaveCenter ();
i++;
}
(*it)->SetSortPriority (i);
- if (i != j) (*it)->SaveCenter ();
+ if (i != j && save) (*it)->SaveCenter ();
i++;
if (skipped)
{
icon->SetSortPriority (i);
- if (i != j) (*it)->SaveCenter ();
+ if (i != j && save) (*it)->SaveCenter ();
i++;
}
}
else
{
(*it)->SetSortPriority (i);
- if (i != j) (*it)->SaveCenter ();
+ if (i != j && save) (*it)->SaveCenter ();
i++;
}
j++;
}
- _model->Sort (&LauncherController::CompareIcons);
-
- std::list<const char*> desktop_paths;
- for (it = _model->begin (); it != _model->end (); it++)
- {
- BamfLauncherIcon *icon;
- icon = dynamic_cast<BamfLauncherIcon*> (*it);
-
- if (!icon)
- continue;
-
- if (!icon->IsSticky ())
- continue;
-
- const char* desktop_file = icon->DesktopFile ();
-
- if (desktop_file && strlen (desktop_file) > 0)
- desktop_paths.push_back (desktop_file);
- }
-
- _favorite_store->SetFavorites (desktop_paths);
-}
-
-void
-LauncherController::PresentIconOwningWindow (Window window)
-{
- LauncherModel::iterator it;
- LauncherIcon *owner = 0;
-
- for (it = _model->begin (); it != _model->end (); it++)
- {
- if ((*it)->IconOwnsWindow (window))
- {
- owner = *it;
- break;
- }
- }
-
- if (owner)
- {
- owner->Present (0.5f, 600);
- owner->UpdateQuirkTimeDelayed (300, LAUNCHER_ICON_QUIRK_SHIMMER);
- }
+ SortAndSave ();
}
void
diff --git a/src/LauncherController.h b/src/LauncherController.h
index 98278866b..a63afd150 100644
--- a/src/LauncherController.h
+++ b/src/LauncherController.h
@@ -43,8 +43,6 @@ public:
LauncherController(Launcher* launcher, CompScreen *screen, nux::BaseWindow* window);
~LauncherController();
- void PresentIconOwningWindow (Window window);
-
private:
BamfMatcher* _matcher;
CompAction* _expo_action;
@@ -55,7 +53,10 @@ private:
FavoriteStore* _favorite_store;
int _sort_priority;
- void OnLauncherRequestReorder (LauncherIcon *icon, LauncherIcon *other);
+ void SortAndSave ();
+
+ void OnLauncherRequestReorderSmart (LauncherIcon *icon, LauncherIcon *other, bool save);
+ void OnLauncherRequestReorderBefore (LauncherIcon *icon, LauncherIcon *before, bool save);
void InsertExpoAction ();
diff --git a/src/LauncherDragWindow.cpp b/src/LauncherDragWindow.cpp
index 75935575c..7fe189e63 100644
--- a/src/LauncherDragWindow.cpp
+++ b/src/LauncherDragWindow.cpp
@@ -29,18 +29,72 @@ LauncherDragWindow::LauncherDragWindow (nux::IntrusiveSP<nux::IOpenGLBaseTexture
: nux::BaseWindow ("")
{
_icon = icon;
+ _anim_handle = 0;
SetBaseSize (_icon->GetWidth(), _icon->GetHeight());
}
LauncherDragWindow::~LauncherDragWindow ()
{
+ if (_anim_handle)
+ g_source_remove (_anim_handle);
}
-void LauncherDragWindow::Draw (nux::GraphicsEngine& GfxContext, bool forceDraw)
+bool
+LauncherDragWindow::Animating ()
{
+ return _anim_handle != 0;
}
-void LauncherDragWindow::DrawContent (nux::GraphicsEngine& GfxContext, bool force_draw)
+void
+LauncherDragWindow::SetAnimationTarget (int x, int y)
+{
+ _animation_target = nux::Point2 (x, y);
+}
+
+void
+LauncherDragWindow::StartAnimation ()
+{
+ if (_anim_handle)
+ return;
+
+ _anim_handle = g_timeout_add (15, &LauncherDragWindow::OnAnimationTimeout, this);
+}
+
+gboolean
+LauncherDragWindow::OnAnimationTimeout (gpointer data)
+{
+ LauncherDragWindow *self = (LauncherDragWindow*) data;
+ nux::Geometry geo = self->GetGeometry ();
+
+ int half_size = geo.width / 2;
+
+ int target_x = (int) (self->_animation_target.x) - half_size;
+ int target_y = (int) (self->_animation_target.y) - half_size;
+
+ int x_delta = (int) ((float) (target_x - geo.x) * .3f);
+ if (abs (x_delta) < 5)
+ x_delta = (x_delta >= 0) ? MIN (5, target_x - geo.x) : MAX (-5, target_x - geo.x);
+
+ int y_delta = (int) ((float) (target_y - geo.y) * .3f);
+ if (abs (y_delta) < 5)
+ y_delta = (y_delta >= 0) ? MIN (5, target_y - geo.y) : MAX (-5, target_y - geo.y);
+
+ self->SetBaseXY (geo.x + x_delta, geo.y + y_delta);
+
+ geo = self->GetGeometry ();
+
+ if (geo.x == target_x && geo.y == target_y)
+ {
+ self->anim_completed.emit ();
+ self->_anim_handle = 0;
+ return false;
+ }
+
+ return true;
+}
+
+void
+LauncherDragWindow::DrawContent (nux::GraphicsEngine& GfxContext, bool force_draw)
{
nux::Geometry geo = GetGeometry ();
geo.SetX (0);
diff --git a/src/LauncherDragWindow.h b/src/LauncherDragWindow.h
index e502f0a29..9e4853834 100644
--- a/src/LauncherDragWindow.h
+++ b/src/LauncherDragWindow.h
@@ -33,16 +33,22 @@ public:
~LauncherDragWindow ();
- void Draw (nux::GraphicsEngine& gfxContext,
- bool forceDraw);
-
- void DrawContent (nux::GraphicsEngine& gfxContext,
- bool forceDraw);
+ void DrawContent (nux::GraphicsEngine& gfxContext, bool forceDraw);
+
+ void SetAnimationTarget (int x, int y);
+ void StartAnimation ();
+
+ bool Animating ();
+
+ sigc::signal<void> anim_completed;
private:
- nux::IntrusiveSP<nux::IOpenGLBaseTexture> _icon;
+ static gboolean OnAnimationTimeout (gpointer data);
+ nux::IntrusiveSP<nux::IOpenGLBaseTexture> _icon;
+ nux::Point2 _animation_target;
+ guint32 _anim_handle;
};
diff --git a/src/LauncherIcon.cpp b/src/LauncherIcon.cpp
index fb0e55fc9..8471a3d2b 100644
--- a/src/LauncherIcon.cpp
+++ b/src/LauncherIcon.cpp
@@ -580,6 +580,22 @@ LauncherIcon::RelatedWindows ()
return _related_windows;
}
+void
+LauncherIcon::SetProgress (float progress)
+{
+ if (progress == _progress)
+ return;
+
+ _progress = progress;
+ needs_redraw.emit (this);
+}
+
+float
+LauncherIcon::GetProgress ()
+{
+ return _progress;
+}
+
std::list<DbusmenuMenuitem *> LauncherIcon::Menus ()
{
return GetMenus ();
diff --git a/src/LauncherIcon.h b/src/LauncherIcon.h
index 43f172235..1ba0821cb 100644
--- a/src/LauncherIcon.h
+++ b/src/LauncherIcon.h
@@ -62,6 +62,7 @@ typedef enum
LAUNCHER_ICON_QUIRK_STARTING,
LAUNCHER_ICON_QUIRK_SHIMMER,
LAUNCHER_ICON_QUIRK_CENTER_SAVED,
+ LAUNCHER_ICON_QUIRK_PROGRESS,
LAUNCHER_ICON_QUIRK_LAST,
} LauncherIconQuirk;
@@ -91,8 +92,11 @@ public:
int SortPriority ();
int RelatedWindows ();
+
float PresentUrgency ();
+ float GetProgress ();
+
bool GetQuirk (LauncherIconQuirk quirk);
struct timespec GetQuirkTime (LauncherIconQuirk quirk);
@@ -128,6 +132,7 @@ protected:
void SetRelatedWindows (int windows);
void Remove ();
+ void SetProgress (float progress);
void Present (float urgency, int length);
void Unpresent ();
@@ -139,7 +144,6 @@ protected:
virtual nux::BaseTexture * GetTextureForSize (int size) = 0;
virtual void OnCenterStabilized (nux::Point3 center) {};
- virtual bool IconOwnsWindow (Window w) { return false; }
nux::BaseTexture * TextureFromGtkTheme (const char *name, int size);
nux::BaseTexture * TextureFromPath (const char *name, int size);
@@ -183,6 +187,7 @@ private:
int _sort_priority;
int _related_windows;
float _present_urgency;
+ float _progress;
guint _present_time_handle;
guint _center_stabilize_handle;
bool _quicklist_is_initialized;
diff --git a/src/PanelHomeButton.cpp b/src/PanelHomeButton.cpp
index 154a5972d..711a0d824 100644
--- a/src/PanelHomeButton.cpp
+++ b/src/PanelHomeButton.cpp
@@ -22,6 +22,9 @@
#include "NuxGraphics/GLThread.h"
+#include "../libunity/ubus-server.h"
+#include "UBusMessages.h"
+
#include "PanelHomeButton.h"
#include <glib.h>
@@ -74,17 +77,17 @@ PanelHomeButton::Refresh ()
cairo_destroy (cr);
nux::NBitmapData* bitmap = cairo_graphics.GetBitmap();
-
+
// The Texture is created with a reference count of 1.
nux::BaseTexture* texture2D = nux::GetThreadGLDeviceFactory ()->CreateSystemCapableTexture ();
texture2D->Update(bitmap);
delete bitmap;
-
+
nux::TexCoordXForm texxform;
texxform.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD);
texxform.SetWrap (nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
-
- nux::ROPConfig rop;
+
+ nux::ROPConfig rop;
rop.Blend = true; // Enable the blending. By default rop.Blend is false.
rop.SrcBlend = GL_ONE; // Set the source blend factor.
rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA; // Set the destination blend factor.
@@ -98,12 +101,12 @@ PanelHomeButton::Refresh ()
SetPaintLayer(texture_layer);
// We don't need the texture anymore. Since it hasn't been reference, it ref count should still be 1.
- // UnReference it and it will be destroyed.
+ // UnReference it and it will be destroyed.
texture2D->UnReference ();
-
+
// The texture layer has been cloned by this object when calling SetPaintLayer. It is safe to delete it now.
delete texture_layer;
-
+
NeedRedraw ();
}
@@ -113,31 +116,10 @@ PanelHomeButton::RecvMouseClick (int x,
unsigned long button_flags,
unsigned long key_flags)
{
-#define APPS_URI "file:///usr/share/applications"
-
- /* FIXME: This is just for Alpha 1, so we have some feedback on clicking the
- * PanelHomeButton, and especially because we don't have any other way of
- * launching non-launcher apps right now
- */
if (nux::GetEventButton (button_flags) == 1)
{
- GdkAppLaunchContext *context;
- GError *error = NULL;
-
- context = gdk_app_launch_context_new ();
- gdk_app_launch_context_set_screen (context, gdk_screen_get_default ());
- gdk_app_launch_context_set_timestamp (context, GDK_CURRENT_TIME);
-
- if (!g_app_info_launch_default_for_uri (APPS_URI,
- (GAppLaunchContext *)context,
- &error))
- {
- g_warning ("Unable to launcher applications folder: %s",
- error->message);
- g_error_free (error);
- }
-
- g_object_unref (context);
+ UBusServer *ubus = ubus_server_get_default ();
+ ubus_server_send_message (ubus, UBUS_HOME_BUTTON_ACTIVATED, NULL);
}
}
diff --git a/src/PlacesController.cpp b/src/PlacesController.cpp
new file mode 100644
index 000000000..cb7d2e417
--- /dev/null
+++ b/src/PlacesController.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2010 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: Gordon Allott <gord.allott@canonical.com>
+ */
+
+#include "config.h"
+
+#include "Nux/Nux.h"
+#include "Nux/HLayout.h"
+
+#include "NuxGraphics/GLThread.h"
+#include <glib.h>
+#include <pango/pangocairo.h>
+#include <gtk/gtk.h>
+
+#include "../libunity/ubus-server.h"
+#include "UBusMessages.h"
+
+#include "PlacesController.h"
+
+PlacesController::PlacesController ()
+{
+
+ // register interest with ubus so that we get activation messages
+ UBusServer *ubus = ubus_server_get_default ();
+ ubus_server_register_interest (ubus, UBUS_HOME_BUTTON_ACTIVATED,
+ (UBusCallback)&PlacesController::ExternalActivation,
+ this);
+
+ _Window = new PlacesView ();
+ _Window->Reference ();
+ _Window->SetConfigureNotifyCallback(&PlacesController::WindowConfigureCallback, this);
+ //_Window->SetBlurredBackground(true);
+ _Window->ShowWindow(false);
+ //_Window->EnableInputWindow(false);
+ //_Window->InputWindowEnableStruts(false);
+
+ _Window->OnMouseDownOutsideArea.connect (sigc::mem_fun (this, &PlacesController::RecvMouseDownOutsideOfView));
+
+}
+
+PlacesController::~PlacesController ()
+{
+ _Window->UnReference ();
+}
+
+void PlacesController::Show ()
+{
+ // show called
+ _Window->Show ();
+}
+
+void PlacesController::Hide ()
+{
+ _Window->Hide ();
+}
+
+void PlacesController::ToggleShowHide ()
+{
+ if (_Window->IsVisible ())
+ Hide ();
+ else
+ Show ();
+}
+
+/* Configure callback for the window */
+void
+PlacesController::WindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void *user_data)
+{
+ GdkScreen *screen = gdk_screen_get_default ();
+ int height = gdk_screen_get_height (screen) - 12;
+ geo = nux::Geometry(32, 12, 1024, height);
+}
+
+void
+PlacesController::ExternalActivation (GVariant *data, void *val)
+{
+ if (g_getenv ("UNITY_ENABLE_PLACES"))
+ {
+ PlacesController *self = (PlacesController*)val;
+ self->ToggleShowHide ();
+ }
+ else
+ {
+ // not removing the nautilus behaviour until we can launch applications in places :)
+ #define APPS_URI "file:///usr/share/applications"
+
+ /* FIXME: This is just for Alpha 1, so we have some feedback on clicking the
+ * PanelHomeButton, and especially because we don't have any other way of
+ * launching non-launcher apps right now
+ */
+ GdkAppLaunchContext *context;
+ GError *error = NULL;
+
+ context = gdk_app_launch_context_new ();
+ gdk_app_launch_context_set_screen (context, gdk_screen_get_default ());
+ gdk_app_launch_context_set_timestamp (context, GDK_CURRENT_TIME);
+
+ if (!g_app_info_launch_default_for_uri (APPS_URI,
+ (GAppLaunchContext *)context,
+ &error))
+ {
+ g_warning ("Unable to launcher applications folder: %s",
+ error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (context);
+ }
+}
+
+void
+PlacesController::RecvMouseDownOutsideOfView (int x, int y, unsigned long button_flags, unsigned long key_flags)
+{
+ Hide ();
+}
+
+/* Introspection */
+const gchar *
+PlacesController::GetName ()
+{
+ return "PlacesController";
+}
+
+void
+PlacesController::AddProperties (GVariantBuilder *builder)
+{
+}
+
diff --git a/src/PlacesController.h b/src/PlacesController.h
new file mode 100644
index 000000000..0b5dbd841
--- /dev/null
+++ b/src/PlacesController.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 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: Gordon Allott <gord.allott@canonical.com>
+ */
+
+#ifndef PLACES_CONTROLLER_H
+#define PLACES_CONTROLLER_H
+
+#include <Nux/TextureArea.h>
+#include <Nux/View.h>
+#include "Nux/Layout.h"
+#include <NuxImage/CairoGraphics.h>
+#include <NuxGraphics/GraphicsEngine.h>
+
+#include "PlacesView.h"
+#include "Introspectable.h"
+
+class PlacesController : public Introspectable
+{
+public:
+ PlacesController ();
+ ~PlacesController ();
+
+ void Show ();
+ void Hide ();
+ void ToggleShowHide ();
+
+ PlacesView *_Window;
+protected:
+ const gchar* GetName ();
+ void AddProperties (GVariantBuilder *builder);
+
+ static void ExternalActivation (GVariant *data, void *val);
+ static void WindowConfigureCallback(int WindowWidth, int WindowHeight,
+ nux::Geometry& geo, void *user_data);
+
+ void RecvMouseDownOutsideOfView (int x, int y, unsigned long button_flags, unsigned long key_flags);
+
+
+ nux::Layout *_Layout;
+};
+
+#endif // PLACES_CONTROLLER_H
diff --git a/src/PlacesView.cpp b/src/PlacesView.cpp
new file mode 100644
index 000000000..a4cc66e73
--- /dev/null
+++ b/src/PlacesView.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2010 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: Gordon Allott <gord.allott@canonical.com>
+ */
+
+#include "config.h"
+
+#include "Nux/Nux.h"
+#include "NuxGraphics/GLThread.h"
+#include "UBusMessages.h"
+
+#include "PlacesView.h"
+
+NUX_IMPLEMENT_OBJECT_TYPE (PlacesView);
+
+PlacesView::PlacesView (NUX_FILE_LINE_DECL)
+: nux::BaseWindow("", NUX_FILE_LINE_PARAM)
+{
+ Hide ();
+}
+
+PlacesView::~PlacesView ()
+{
+
+}
+
+long PlacesView::ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
+{
+ long ret = TraverseInfo;
+ long ProcEvInfo = 0;
+
+ nux::IEvent window_event = ievent;
+ nux::Geometry base = GetGeometry();
+ window_event.e_x_root = base.x;
+ window_event.e_y_root = base.y;
+
+ // The child layout get the Mouse down button only if the MouseDown happened inside the client view Area
+ nux::Geometry viewGeometry = GetGeometry();
+
+ if (ievent.e_event == nux::NUX_MOUSE_PRESSED)
+ {
+ if (!viewGeometry.IsPointInside (ievent.e_x - ievent.e_x_root, ievent.e_y - ievent.e_y_root) )
+ {
+ ProcEvInfo = nux::eDoNotProcess;
+ }
+ }
+
+ // hide if outside our window
+ if (ievent.e_event == nux::NUX_MOUSE_PRESSED)
+ {
+ if (!(GetGeometry ().IsPointInside (ievent.e_x, ievent.e_y)))
+ {
+ Hide ();
+ return nux::eMouseEventSolved;
+ }
+ }
+
+ return ret;
+}
+
+void PlacesView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
+{
+ nux::Color *color = new nux::Color (0.9, 0.3, 0.1, 1.0);
+ nux::GetPainter ().Paint2DQuadColor (GfxContext, GetGeometry (), *color);
+}
+
+
+void PlacesView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
+{
+
+}
+
+void PlacesView::PostDraw (nux::GraphicsEngine &GfxContext, bool force_draw)
+{
+
+}
+
+void PlacesView::ShowWindow (bool b, bool start_modal)
+{
+ nux::BaseWindow::ShowWindow (b, start_modal);
+}
+
+void PlacesView::Show ()
+{
+ if (IsVisible ())
+ return;
+
+ // FIXME: ShowWindow shouldn't need to be called first
+ ShowWindow (true, false);
+ EnableInputWindow (true, 1);
+ GrabPointer ();
+ NeedRedraw ();
+}
+
+void PlacesView::Hide ()
+{
+ if (!IsVisible ())
+ return;
+
+ CaptureMouseDownAnyWhereElse (false);
+ ForceStopFocus (1, 1);
+ UnGrabPointer ();
+ EnableInputWindow (false);
+ ShowWindow (false, false);
+}
+
+
+/* Introspection */
+const gchar *
+PlacesView::GetName ()
+{
+ return "PlacesView";
+}
+
+void
+PlacesView::AddProperties (GVariantBuilder *builder)
+{
+}
diff --git a/src/PlacesView.h b/src/PlacesView.h
new file mode 100644
index 000000000..43271f503
--- /dev/null
+++ b/src/PlacesView.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 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: Gordon Allott <gord.allott@canonical.com>
+ */
+
+#ifndef PLACES_VIEW_H
+#define PLACES_VIEW_H
+
+#include <Nux/Nux.h>
+#include <Nux/View.h>
+#include <NuxImage/CairoGraphics.h>
+#include "NuxGraphics/GraphicsEngine.h"
+#include "Nux/AbstractPaintLayer.h"
+#include <Nux/BaseWindow.h>
+
+#include "Introspectable.h"
+
+class PlacesView : public nux::BaseWindow, public Introspectable
+{
+ NUX_DECLARE_OBJECT_TYPE (PlacesView, nux::BaseWindow);
+public:
+ PlacesView (NUX_FILE_LINE_PROTO);
+ ~PlacesView ();
+
+ virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
+ virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
+ virtual void PostDraw (nux::GraphicsEngine &GfxContext, bool force_draw);
+ virtual void ShowWindow (bool b, bool start_modal = false);
+
+ void Show ();
+ void Hide ();
+
+protected:
+
+ const gchar* GetName ();
+ void AddProperties (GVariantBuilder *builder);
+};
+
+#endif // PANEL_HOME_BUTTON_H
+
diff --git a/src/PluginAdapter.cpp b/src/PluginAdapter.cpp
index 72bfd0a6d..d09f67513 100644
--- a/src/PluginAdapter.cpp
+++ b/src/PluginAdapter.cpp
@@ -25,28 +25,39 @@ PluginAdapter * PluginAdapter::_default = 0;
PluginAdapter *
PluginAdapter::Default ()
{
- if (!_default)
- return 0;
- return _default;
+ if (!_default)
+ return 0;
+ return _default;
}
/* static */
void
PluginAdapter::Initialize (CompScreen *screen)
{
- _default = new PluginAdapter (screen);
+ _default = new PluginAdapter (screen);
}
PluginAdapter::PluginAdapter(CompScreen *screen)
{
- m_Screen = screen;
- m_ExpoAction = 0;
- m_ScaleAction = 0;
+ m_Screen = screen;
+ m_ExpoAction = 0;
+ m_ScaleAction = 0;
}
PluginAdapter::~PluginAdapter()
{
+}
+void
+PluginAdapter::NotifyResized (CompWindow *window, int x, int y, int w, int h)
+{
+ window_resized.emit (window);
+}
+
+void
+PluginAdapter::NotifyMoved (CompWindow *window, int x, int y)
+{
+ window_moved.emit (window);
}
void
diff --git a/src/PluginAdapter.h b/src/PluginAdapter.h
index 4c3ae5c24..2051e572a 100644
--- a/src/PluginAdapter.h
+++ b/src/PluginAdapter.h
@@ -45,10 +45,11 @@ public:
void InitiateExpo ();
+ void Notify (CompWindow *window, CompWindowNotify notify);
+ void NotifyMoved (CompWindow *window, int x, int y);
+ void NotifyResized (CompWindow *window, int x, int y, int w, int h);
void NotifyStateChange (CompWindow *window, unsigned int state, unsigned int last_state);
- void Notify (CompWindow *window, CompWindowNotify notify);
-
// WindowManager implementation
bool IsWindowMaximized (guint xid);
bool IsWindowDecorated (guint xid);
@@ -66,6 +67,8 @@ public:
sigc::signal<void, CompWindow *> window_unmapped;
sigc::signal<void, CompWindow *> window_shown;
sigc::signal<void, CompWindow *> window_hidden;
+ sigc::signal<void, CompWindow *> window_resized;
+ sigc::signal<void, CompWindow *> window_moved;
protected:
PluginAdapter(CompScreen *screen);
diff --git a/src/UBusMessages.h b/src/UBusMessages.h
new file mode 100644
index 000000000..a4b94ff34
--- /dev/null
+++ b/src/UBusMessages.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010 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: Gordon Allott <gord.allott@canonical.com>
+ */
+#ifndef UBUS_MESSAGES_H
+#define UBUS_MESSAGES_H
+
+
+// Add ubus messages here so we can easily export them around the place
+// keep ordered
+
+#define UBUS_HOME_BUTTON_ACTIVATED "PANEL_HOME_ACTIVATED"
+
+#endif // UBUS_MESSAGES_H
diff --git a/src/unity.cpp b/src/unity.cpp
index 2a92909a9..41e7e3991 100644
--- a/src/unity.cpp
+++ b/src/unity.cpp
@@ -289,38 +289,6 @@ void
UnityWindow::windowNotify (CompWindowNotify n)
{
PluginAdapter::Default ()->Notify (window, n);
-
- switch (n)
- {
- case CompWindowNotifyMinimize:
- uScreen->controller->PresentIconOwningWindow (window->id ());
- uScreen->launcher->OnWindowDisappear (window);
- break;
- case CompWindowNotifyUnminimize:
- uScreen->launcher->OnWindowAppear (window);
- break;
- case CompWindowNotifyShade:
- uScreen->launcher->OnWindowDisappear (window);
- break;
- case CompWindowNotifyUnshade:
- uScreen->launcher->OnWindowAppear (window);
- break;
- case CompWindowNotifyHide:
- uScreen->launcher->OnWindowDisappear (window);
- break;
- case CompWindowNotifyShow:
- uScreen->launcher->OnWindowAppear (window);
- break;
- case CompWindowNotifyMap:
- uScreen->launcher->OnWindowAppear (window);
- break;
- case CompWindowNotifyUnmap:
- uScreen->launcher->OnWindowDisappear (window);
- break;
- default:
- break;
- }
-
window->windowNotify (n);
}
@@ -334,14 +302,14 @@ UnityWindow::stateChangeNotify (unsigned int lastState)
void
UnityWindow::moveNotify (int x, int y, bool immediate)
{
- uScreen->launcher->OnWindowMoved (window);
+ PluginAdapter::Default ()->NotifyMoved (window, x, y);
window->moveNotify (x, y, immediate);
}
void
UnityWindow::resizeNotify (int x, int y, int w, int h)
{
- uScreen->launcher->OnWindowResized (window);
+ PluginAdapter::Default ()->NotifyResized (window, x, y, w, h);
window->resizeNotify (x, y, w, h);
}
@@ -400,7 +368,7 @@ UnityScreen::optionChanged (CompOption *opt,
static gboolean
write_logger_data_to_disk (gpointer data)
{
- perf_timeline_logger_write_log (perf_timeline_logger_get_default (), "/tmp/unity-perf.log");
+ LOGGER_WRITE_LOG ("/tmp/unity-perf.log");
return FALSE;
}
@@ -448,6 +416,7 @@ UnityScreen::UnityScreen (CompScreen *screen) :
optionSetLauncherFloatNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
g_timeout_add (0, &UnityScreen::initPluginActions, this);
+ g_timeout_add (5000, (GSourceFunc) write_logger_data_to_disk, NULL);
END_FUNCTION ();
}
@@ -527,6 +496,10 @@ void UnityScreen::initLauncher (nux::NThread* thread, void* InitData)
self->panelWindow->EnableInputWindow(true);
self->panelWindow->InputWindowEnableStruts(true);
LOGGER_END_PROCESS ("initLauncher-Panel");
+
+ /* Setup Places */
+ self->placesController = new PlacesController ();
+
g_timeout_add (2000, &UnityScreen::strutHackTimeout, self);
END_FUNCTION ();
diff --git a/src/unity.h b/src/unity.h
index fb594188f..6062e16d5 100644
--- a/src/unity.h
+++ b/src/unity.h
@@ -30,12 +30,13 @@
#include "Launcher.h"
#include "LauncherController.h"
#include "PanelView.h"
+#include "PlacesController.h"
#include "IntrospectionDBusInterface.h"
#include <Nux/WindowThread.h>
#include <sigc++/sigc++.h>
/* base screen class */
-class UnityScreen :
+class UnityScreen :
public Introspectable,
public sigc::trackable,
public ScreenInterface,
@@ -58,7 +59,7 @@ class UnityScreen :
CompositeScreen *cScreen;
GLScreen *gScreen;
- /* prepares nux for drawing */
+ /* prepares nux for drawing */
void
nuxPrologue ();
@@ -102,36 +103,37 @@ class UnityScreen :
const gchar* GetName ();
void AddProperties (GVariantBuilder *builder);
-
+
private:
static gboolean
initPluginActions (gpointer data);
-
+
static void
initLauncher (nux::NThread* thread, void* InitData);
-
+
void
damageNuxRegions();
-
- void
+
+ void
onRedrawRequested ();
-
- static void
+
+ static void
launcherWindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void* user_data);
- static void
+ static void
panelWindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void* user_data);
- static void
+ static void
initUnity(nux::NThread* thread, void* InitData);
- static gboolean
+ static gboolean
strutHackTimeout (gpointer data);
-
+
Launcher *launcher;
LauncherController *controller;
PanelView *panelView;
+ PlacesController *placesController;
nux::WindowThread *wt;
nux::BaseWindow *launcherWindow;
nux::BaseWindow *panelWindow;
@@ -161,9 +163,9 @@ class UnityWindow :
CompWindow *window;
GLWindow *gWindow;
-
+
/* basic window draw function */
- bool
+ bool
glDraw (const GLMatrix &matrix,
GLFragment::Attrib &attrib,
const CompRegion &region,
@@ -172,7 +174,7 @@ class UnityWindow :
void windowNotify (CompWindowNotify n);
void moveNotify (int x, int y, bool immediate);
-
+
void resizeNotify (int x, int y, int w, int h);
void stateChangeNotify (unsigned int lastState);
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index e02c62e4e..f19e37520 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -58,6 +58,7 @@ add_executable (test-unit
../src/QuicklistMenuItemSeparator.h
../src/QuicklistView.cpp
../src/QuicklistView.h
+ ../src/
)
add_executable (test-panel
@@ -89,6 +90,21 @@ add_executable (test-panel
../src/WindowButtons.h
../src/WindowManager.cpp
../src/WindowManager.h
+ ../libunity/ubus-server.c
+ ../libunity/ubus-server.h
+ )
+
+add_executable (test-places
+ TestPlaces.cpp
+ ../src/PlacesController.cpp
+ ../src/PlacesController.h
+ ../src/PlacesView.cpp
+ ../src/PlacesView.h
+ ../src/UBusMessages.h
+ ../src/Introspectable.cpp
+ ../src/Introspectable.h
+ ../libunity/ubus-server.c
+ ../libunity/ubus-server.h
)
add_executable (test-quicklist
diff --git a/tests/TestPlaces.cpp b/tests/TestPlaces.cpp
new file mode 100644
index 000000000..aabae72b5
--- /dev/null
+++ b/tests/TestPlaces.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2010 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 warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY 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
+ * version 3 along with this program. If not, see
+ * <http://www.gnu.org/licenses/>
+ *
+ * Authored by: Gordon Allott <gord.allott@canonical.com>
+ *
+ */
+
+#include "Nux/Nux.h"
+#include "Nux/VLayout.h"
+#include "Nux/HLayout.h"
+#include "Nux/TextureArea.h"
+#include "Nux/WindowThread.h"
+#include "NuxGraphics/GraphicsEngine.h"
+#include <gtk/gtk.h>
+
+#include "../libunity/ubus-server.h"
+
+#include "PlacesView.h"
+#include "PlacesController.h"
+#include "UBusMessages.h"
+
+class TestRunner
+{
+public:
+ TestRunner ();
+ ~TestRunner ();
+
+ static void InitWindowThread (nux::NThread* thread, void* InitData);
+ void Init ();
+ PlacesController *controller;
+ nux::HLayout *layout;
+
+private:
+
+};
+
+TestRunner::TestRunner ()
+{
+}
+
+TestRunner::~TestRunner ()
+{
+}
+
+void TestRunner::Init ()
+{
+ controller = new PlacesController ();
+}
+
+void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
+{
+ TestRunner *self = (TestRunner *) InitData;
+ self->Init ();
+}
+
+void
+ControlThread (nux::NThread* thread,
+ void* data)
+{
+ // sleep for 3 seconds
+ nux::SleepForMilliseconds (3000);
+ printf ("ControlThread successfully started\n");
+
+ nux::WindowThread* mainWindowThread = NUX_STATIC_CAST (nux::WindowThread*,
+ data);
+
+ mainWindowThread->SetFakeEventMode (true);
+ Display* display = mainWindowThread->GetWindow ().GetX11Display ();
+
+ // assemble first button-click event
+ XEvent buttonPressEvent;
+ buttonPressEvent.xbutton.type = ButtonPress;
+ buttonPressEvent.xbutton.serial = 0;
+ buttonPressEvent.xbutton.send_event = False;
+ buttonPressEvent.xbutton.display = display;
+ buttonPressEvent.xbutton.window = 0;
+ buttonPressEvent.xbutton.root = 0;
+ buttonPressEvent.xbutton.subwindow = 0;
+ buttonPressEvent.xbutton.time = CurrentTime;
+ buttonPressEvent.xbutton.x = 1000;
+ buttonPressEvent.xbutton.y = 300;
+ buttonPressEvent.xbutton.x_root = 0;
+ buttonPressEvent.xbutton.y_root = 0;
+ buttonPressEvent.xbutton.state = 0;
+ buttonPressEvent.xbutton.button = Button1;
+ buttonPressEvent.xbutton.same_screen = True;
+
+ mainWindowThread->PumpFakeEventIntoPipe (mainWindowThread,
+ (XEvent*) &buttonPressEvent);
+
+ while (!mainWindowThread->ReadyForNextFakeEvent ())
+ nux::SleepForMilliseconds (10);
+
+ mainWindowThread->SetFakeEventMode (false);
+}
+
+
+int main(int argc, char **argv)
+{
+ UBusServer *ubus;
+ nux::SystemThread* st = NULL;
+ nux::WindowThread* wt = NULL;
+
+ g_type_init ();
+ g_thread_init (NULL);
+ gtk_init (&argc, &argv);
+
+ nux::NuxInitialize(0);
+
+ g_setenv ("UNITY_ENABLE_PLACES", "1", FALSE);
+
+ TestRunner *test_runner = new TestRunner ();
+ wt = nux::CreateGUIThread(TEXT("Unity Places"),
+ 1024, 600,
+ 0,
+ &TestRunner::InitWindowThread,
+ test_runner);
+
+ st = nux::CreateSystemThread (NULL, ControlThread, wt);
+
+ ubus = ubus_server_get_default ();
+ ubus_server_send_message (ubus, UBUS_HOME_BUTTON_ACTIVATED, NULL);
+
+ if (st)
+ st->Start (NULL);
+
+ wt->Run (NULL);
+ delete st;
+ delete wt;
+ return 0;
+}