summaryrefslogtreecommitdiff
diff options
authorJay Taoko <jay.taoko@canonical.com>2012-02-03 19:32:18 -0500
committerJay Taoko <jay.taoko@canonical.com>2012-02-03 19:32:18 -0500
commitf18693f08bb903273d7a9aff7ad9a027c1ff88b3 (patch)
tree97e43d02387494b1e2a4bd1dfa94604a7064c7d5
parente07a6bd5df36fb911a51a422f1c2702da78aa92b (diff)
parentad44770e572b286dcbea614637415a0ac03f5d64 (diff)
* Merged with Unity trunk
(bzr r1893.1.1)
-rw-r--r--plugins/unityshell/src/PlacesGroup.cpp8
-rw-r--r--plugins/unityshell/src/PlacesGroup.h2
-rw-r--r--plugins/unityshell/src/PlacesTile.cpp6
-rw-r--r--plugins/unityshell/src/PlacesTile.h2
-rw-r--r--plugins/unityshell/src/ResultViewGrid.cpp32
-rw-r--r--plugins/unityshell/src/ResultViewGrid.h2
-rw-r--r--plugins/unityshell/src/nux-area-accessible.cpp6
7 files changed, 41 insertions, 17 deletions
diff --git a/plugins/unityshell/src/PlacesGroup.cpp b/plugins/unityshell/src/PlacesGroup.cpp
index 5da93b3ce..fae8bdc63 100644
--- a/plugins/unityshell/src/PlacesGroup.cpp
+++ b/plugins/unityshell/src/PlacesGroup.cpp
@@ -100,8 +100,8 @@ PlacesGroup::PlacesGroup()
_expand_label->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_LEFT);
_expand_label->SetTextColor(kExpandDefaultTextColor);
_expand_label->SetAcceptKeyNavFocus(true);
- _expand_label->OnKeyNavFocusActivate.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelActivated));
- _expand_label->OnKeyNavFocusChange.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
+ _expand_label->key_nav_focus_activate.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelActivated));
+ _expand_label->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
_expand_layout->AddView(_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
@@ -144,7 +144,7 @@ PlacesGroup::OnLabelActivated(nux::Area* label)
}
void
-PlacesGroup::OnLabelFocusChanged(nux::Area* label)
+PlacesGroup::OnLabelFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction)
{
if (_expand_label->HasKeyFocus() || _expand_icon->HasKeyFocus())
{
@@ -255,7 +255,7 @@ PlacesGroup::RefreshLabel()
if (_expand_icon->IsVisible())
{
_expand_icon->SetAcceptKeyNavFocus(true);
- _expand_icon->OnKeyNavFocusChange.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
+ _expand_icon->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
}
}
diff --git a/plugins/unityshell/src/PlacesGroup.h b/plugins/unityshell/src/PlacesGroup.h
index 91b5f8671..9f4c6295a 100644
--- a/plugins/unityshell/src/PlacesGroup.h
+++ b/plugins/unityshell/src/PlacesGroup.h
@@ -82,7 +82,7 @@ private:
void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
void OnLabelActivated(nux::Area* label);
- void OnLabelFocusChanged(nux::Area* label);
+ void OnLabelFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction);
void RefreshLabel();
private:
diff --git a/plugins/unityshell/src/PlacesTile.cpp b/plugins/unityshell/src/PlacesTile.cpp
index 40f05c971..ec8531001 100644
--- a/plugins/unityshell/src/PlacesTile.cpp
+++ b/plugins/unityshell/src/PlacesTile.cpp
@@ -48,8 +48,8 @@ PlacesTile::PlacesTile(NUX_FILE_LINE_DECL, const void* id) :
mouse_click.connect(sigc::mem_fun(this, &PlacesTile::RecvMouseClick));
mouse_enter.connect(sigc::mem_fun(this, &PlacesTile::RecvMouseEnter));
mouse_leave.connect(sigc::mem_fun(this, &PlacesTile::RecvMouseLeave));
- OnKeyNavFocusChange.connect(sigc::mem_fun(this, &PlacesTile::OnFocusChanged));
- OnKeyNavFocusActivate.connect(sigc::mem_fun(this, &PlacesTile::OnFocusActivated));
+ key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesTile::OnFocusChanged));
+ key_nav_focus_activate.connect(sigc::mem_fun(this, &PlacesTile::OnFocusActivated));
}
PlacesTile::~PlacesTile()
@@ -68,7 +68,7 @@ PlacesTile::GetId()
}
void
-PlacesTile::OnFocusChanged(nux::Area* label)
+PlacesTile::OnFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction)
{
QueueDraw();
}
diff --git a/plugins/unityshell/src/PlacesTile.h b/plugins/unityshell/src/PlacesTile.h
index be7ddff7e..115399eef 100644
--- a/plugins/unityshell/src/PlacesTile.h
+++ b/plugins/unityshell/src/PlacesTile.h
@@ -62,7 +62,7 @@ private:
nux::ObjectPtr<nux::BaseTexture> _hilight_background;
nux::TextureLayer* _hilight_layer;
- void OnFocusChanged(nux::Area* label);
+ void OnFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction);
void OnFocusActivated(nux::Area* label);
int _last_width;
int _last_height;
diff --git a/plugins/unityshell/src/ResultViewGrid.cpp b/plugins/unityshell/src/ResultViewGrid.cpp
index 0511b8f53..0c96d7aec 100644
--- a/plugins/unityshell/src/ResultViewGrid.cpp
+++ b/plugins/unityshell/src/ResultViewGrid.cpp
@@ -72,8 +72,8 @@ ResultViewGrid::ResultViewGrid(NUX_FILE_LINE_DECL)
vertical_spacing.changed.connect(needredraw_lambda);
padding.changed.connect(needredraw_lambda);
- OnKeyNavFocusChange.connect (sigc::mem_fun (this, &ResultViewGrid::OnOnKeyNavFocusChange));
- OnKeyNavFocusActivate.connect ([&] (nux::Area *area) { UriActivated.emit (focused_uri_); });
+ key_nav_focus_change.connect (sigc::mem_fun (this, &ResultViewGrid::OnOnKeyNavFocusChange));
+ key_nav_focus_activate.connect ([&] (nux::Area *area) { UriActivated.emit (focused_uri_); });
key_down.connect (sigc::mem_fun (this, &ResultViewGrid::OnKeyDown));
mouse_move.connect(sigc::mem_fun(this, &ResultViewGrid::MouseMove));
mouse_click.connect(sigc::mem_fun(this, &ResultViewGrid::MouseClick));
@@ -489,7 +489,7 @@ nux::Area* ResultViewGrid::KeyNavIteration(nux::KeyNavDirection direction)
}
// crappy name.
-void ResultViewGrid::OnOnKeyNavFocusChange(nux::Area *area)
+void ResultViewGrid::OnOnKeyNavFocusChange(nux::Area *area, bool has_focus, nux::KeyNavDirection direction)
{
if (HasKeyFocus())
{
@@ -499,9 +499,29 @@ void ResultViewGrid::OnOnKeyNavFocusChange(nux::Area *area)
selected_index_ = 0;
}
+ int focused_x = 0;
+ int focused_y = 0;
+
int items_per_row = GetItemsPerRow();
- int focused_x = (renderer_->width + horizontal_spacing) * (selected_index_ % items_per_row);
- int focused_y = (renderer_->height + vertical_spacing) * (selected_index_ / items_per_row);
+
+ if (direction == nux::KEY_NAV_UP)
+ {
+ // This View just got focused through keyboard navigation and the
+ // focus is comming from the bottom. We want to focus the
+ // first item (on the left) of the last row in this grid.
+
+ int total_rows = std::ceil(results_.size() / (double)items_per_row);
+ selected_index_ = items_per_row * (total_rows-1);
+
+ focused_x = (renderer_->width + horizontal_spacing) * (selected_index_ % items_per_row);
+ focused_y = (renderer_->height + vertical_spacing) * (selected_index_ / items_per_row);
+
+ }
+ else
+ {
+ focused_x = (renderer_->width + horizontal_spacing) * (selected_index_ % items_per_row);
+ focused_y = (renderer_->height + vertical_spacing) * (selected_index_ / items_per_row);
+ }
ubus_.SendMessage(UBUS_RESULT_VIEW_KEYNAV_CHANGED,
g_variant_new("(iiii)", focused_x, focused_y, renderer_->width(), renderer_->height()));
@@ -717,7 +737,7 @@ uint ResultViewGrid::GetIndexAtPosition(int x, int y)
int x_bound = items_per_row * column_size + padding;
- if (x < padding || x > x_bound)
+ if ((x < padding) || (x >= x_bound))
return -1;
if (y < padding)
diff --git a/plugins/unityshell/src/ResultViewGrid.h b/plugins/unityshell/src/ResultViewGrid.h
index e440438e6..7eea40425 100644
--- a/plugins/unityshell/src/ResultViewGrid.h
+++ b/plugins/unityshell/src/ResultViewGrid.h
@@ -69,7 +69,7 @@ protected:
virtual bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
virtual bool AcceptKeyNavFocus();
virtual nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
- virtual void OnOnKeyNavFocusChange(nux::Area *);
+ virtual void OnOnKeyNavFocusChange(nux::Area* area, bool has_focus, nux::KeyNavDirection direction);
void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);
virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);;
diff --git a/plugins/unityshell/src/nux-area-accessible.cpp b/plugins/unityshell/src/nux-area-accessible.cpp
index 2c13fdfc8..ca4d02696 100644
--- a/plugins/unityshell/src/nux-area-accessible.cpp
+++ b/plugins/unityshell/src/nux-area-accessible.cpp
@@ -83,6 +83,8 @@ static void nux_area_accessible_focus_handler(AtkObject* accessible,
gboolean focus_in);
/* private */
static void on_focus_changed_cb(nux::Area* area,
+ bool has_focus,
+ nux::KeyNavDirection direction,
AtkObject* accessible);
static void on_parent_window_activate_cb(AtkObject* parent_window,
NuxAreaAccessible* self);
@@ -172,7 +174,7 @@ nux_area_accessible_initialize(AtkObject* accessible,
area = dynamic_cast<nux::Area*>(nux_object);
/* focus support based on Focusable, used on the Dash */
- area->OnKeyNavFocusChange.connect(sigc::bind(sigc::ptr_fun(on_focus_changed_cb), accessible));
+ area->key_nav_focus_change.connect(sigc::bind(sigc::ptr_fun(on_focus_changed_cb), accessible));
atk_component_add_focus_handler(ATK_COMPONENT(accessible),
nux_area_accessible_focus_handler);
@@ -457,6 +459,8 @@ nux_area_accessible_parent_window_active(NuxAreaAccessible* self)
static void
on_focus_changed_cb(nux::Area* area,
+ bool has_focus,
+ nux::KeyNavDirection direction,
AtkObject* accessible)
{
check_focus(NUX_AREA_ACCESSIBLE(accessible));