summaryrefslogtreecommitdiffstats
path: root/ash/launcher
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 05:10:28 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 05:10:28 +0000
commit90e1812936e25a1cee7298a850dfb71505ab5db2 (patch)
tree808054695725567c1bc447cab40e988855400449 /ash/launcher
parent2322dc718e6a9f119ab549a6358c6043b3671007 (diff)
downloadchromium_src-90e1812936e25a1cee7298a850dfb71505ab5db2.zip
chromium_src-90e1812936e25a1cee7298a850dfb71505ab5db2.tar.gz
chromium_src-90e1812936e25a1cee7298a850dfb71505ab5db2.tar.bz2
Move the panel to the root window where the mouse click occurred.
* Change the LauncherDelegate::ItemClicked's argument from int flag to const ui::Event& * temporarily set the view's event target to RV. Sadrul is working on real solution in crbug.com/173235. I tried to add interactive_ui_tests for chrome, but turns out it's require more work as there is no interactive ui tests for extensions. I'd rather refactor launcher code so that we can test the same behavior in ash_unittests. I'll work on it and add more tests once @skuhne finished new launcher (could be 26 or 27) BUG=166195 TEST=covered by tests. Also tested on device (clicking panel icon on other display should move the panel to that display) Review URL: https://chromiumcodereview.appspot.com/12093075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180080 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/launcher')
-rw-r--r--ash/launcher/launcher.cc6
-rw-r--r--ash/launcher/launcher_delegate.h8
-rw-r--r--ash/launcher/launcher_util.cc20
-rw-r--r--ash/launcher/launcher_util.h14
-rw-r--r--ash/launcher/launcher_view.cc2
5 files changed, 46 insertions, 4 deletions
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc
index 09af40c..3c9a2d9 100644
--- a/ash/launcher/launcher.cc
+++ b/ash/launcher/launcher.cc
@@ -361,7 +361,11 @@ gfx::Rect Launcher::GetScreenBoundsOfItemIconForWindow(aura::Window* window) {
void Launcher::ActivateLauncherItem(int index) {
const ash::LauncherItems& items =
launcher_view_->model()->items();
- delegate_->ItemClicked(items[index], ui::EF_NONE);
+ ui::MouseEvent event(ui::ET_MOUSE_PRESSED,
+ gfx::Point(),
+ gfx::Point(),
+ ui::EF_NONE);
+ delegate_->ItemClicked(items[index], event);
}
void Launcher::CycleWindowLinear(CycleDirection direction) {
diff --git a/ash/launcher/launcher_delegate.h b/ash/launcher/launcher_delegate.h
index 1e3288f..e10c5dc 100644
--- a/ash/launcher/launcher_delegate.h
+++ b/ash/launcher/launcher_delegate.h
@@ -14,6 +14,7 @@ class RootWindow;
}
namespace ui {
+class Event;
class MenuModel;
}
@@ -31,8 +32,11 @@ class ASH_EXPORT LauncherDelegate {
virtual void OnBrowserShortcutClicked(int event_flags) = 0;
// Invoked when the user clicks on a window entry in the launcher.
- // |event_flags| is the flags of the click event.
- virtual void ItemClicked(const LauncherItem& item, int event_flags) = 0;
+ // |event| is the click event. The |event| is dispatched by a view
+ // and has an instance of |views::View| as the event target
+ // but not |aura::Window|.
+ virtual void ItemClicked(const LauncherItem& item,
+ const ui::Event& event) = 0;
// Returns the resource id of the image to show on the browser shortcut
// button.
diff --git a/ash/launcher/launcher_util.cc b/ash/launcher/launcher_util.cc
index f7ba77f..f41ac7d 100644
--- a/ash/launcher/launcher_util.cc
+++ b/ash/launcher/launcher_util.cc
@@ -6,6 +6,11 @@
#include "ash/launcher/launcher_model.h"
#include "ash/launcher/launcher_types.h"
+#include "ash/shell.h"
+#include "ui/aura/client/window_types.h"
+#include "ui/aura/window.h"
+#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
namespace ash {
namespace launcher {
@@ -18,5 +23,20 @@ int GetBrowserItemIndex(const LauncherModel& launcher_model) {
return -1;
}
+void MoveToEventRootIfPanel(aura::Window* maybe_panel,
+ const ui::Event& event) {
+ if (maybe_panel->type() != aura::client::WINDOW_TYPE_PANEL)
+ return;
+ views::View* target = static_cast<views::View*>(event.target());
+ aura::RootWindow* target_root =
+ target ? target->GetWidget()->GetNativeView()->GetRootWindow() : NULL;
+ if (target_root && target_root != maybe_panel->GetRootWindow()) {
+ aura::Window* panel_container =
+ ash::Shell::GetContainer(target_root, maybe_panel->parent()->id());
+ // Move the panel to the target launcher.
+ panel_container->AddChild(maybe_panel);
+ }
+}
+
} // namespace launcher
} // namespace ash
diff --git a/ash/launcher/launcher_util.h b/ash/launcher/launcher_util.h
index 89551f0..7cdd1f2 100644
--- a/ash/launcher/launcher_util.h
+++ b/ash/launcher/launcher_util.h
@@ -7,6 +7,14 @@
#include "ash/ash_export.h"
+namespace aura {
+class Window;
+}
+
+namespace ui {
+class Event;
+}
+
namespace ash {
class LauncherModel;
@@ -15,6 +23,12 @@ namespace launcher {
// Return the index of the browser item from a given |launcher_model|.
ASH_EXPORT int GetBrowserItemIndex(const LauncherModel& launcher_model);
+// Move the |maybe_panel| to the root window where the |event| occured if
+// |maybe_panel| is of aura::client::WINDOW_TYPE_PANEL and it's not
+// in the same root window.
+ASH_EXPORT void MoveToEventRootIfPanel(aura::Window* maybe_panel,
+ const ui::Event& event);
+
} // namespace launcher
} // namespace ash
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index 53225fa..d0c68af 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -1241,7 +1241,7 @@ void LauncherView::ButtonPressed(views::Button* sender,
case TYPE_APP_PANEL:
case TYPE_APP_SHORTCUT:
case TYPE_PLATFORM_APP:
- delegate_->ItemClicked(model_->items()[view_index], event.flags());
+ delegate_->ItemClicked(model_->items()[view_index], event);
break;
case TYPE_APP_LIST:
Shell::GetInstance()->ToggleAppList(GetWidget()->GetNativeView());