Index: ash/common/shelf/shelf_window_watcher_item_delegate.cc |
diff --git a/ash/common/shelf/shelf_window_watcher_item_delegate.cc b/ash/common/shelf/shelf_window_watcher_item_delegate.cc |
index a1450e171d42059cb1f0af117e2f9180ea446c36..02361d6c2a7f55d45dda8f18876ae07cd33abfe8 100644 |
--- a/ash/common/shelf/shelf_window_watcher_item_delegate.cc |
+++ b/ash/common/shelf/shelf_window_watcher_item_delegate.cc |
@@ -4,18 +4,41 @@ |
#include "ash/common/shelf/shelf_window_watcher_item_delegate.h" |
+#include "ash/common/shelf/shelf_controller.h" |
+#include "ash/common/shelf/shelf_model.h" |
+#include "ash/common/wm/window_state.h" |
+#include "ash/common/wm_shell.h" |
#include "ash/common/wm_window.h" |
#include "ui/events/event.h" |
namespace ash { |
-ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(WmWindow* window) |
- : window_(window) {} |
+namespace { |
+ |
+ShelfItemType GetShelfItemType(ShelfID id) { |
+ ShelfModel* model = WmShell::Get()->shelf_controller()->model(); |
+ ShelfItems::const_iterator item = model->ItemByID(id); |
+ return item == model->items().end() ? TYPE_UNDEFINED : item->type; |
+} |
+ |
+} // namespace |
+ |
+ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(ShelfID id, |
+ WmWindow* window) |
+ : id_(id), window_(window) {} |
James Cook
2016/11/10 22:32:46
DCHECK that id is valid and window isn't null
msw
2016/11/10 23:30:52
Done.
|
ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} |
ShelfItemDelegate::PerformedAction ShelfWindowWatcherItemDelegate::ItemSelected( |
const ui::Event& event) { |
+ // Move panels attached on another display to the current display. |
+ if (GetShelfItemType(id_) == TYPE_APP_PANEL && |
+ window_->GetWindowState()->panel_attached() && |
+ window_->MoveToEventRoot(event)) { |
+ window_->Activate(); |
+ return kExistingWindowActivated; |
+ } |
+ |
if (window_->IsActive()) { |
if (event.type() & ui::ET_KEY_RELEASED) { |
window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
@@ -42,11 +65,13 @@ bool ShelfWindowWatcherItemDelegate::IsDraggable() { |
} |
bool ShelfWindowWatcherItemDelegate::CanPin() const { |
- return true; |
+ return GetShelfItemType(id_) != TYPE_APP_PANEL; |
} |
bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() { |
- return true; |
+ // Do not show tooltips for visible attached app panel windows. |
+ return GetShelfItemType(id_) != TYPE_APP_PANEL || !window_->IsVisible() || |
+ !window_->GetWindowState()->panel_attached(); |
} |
void ShelfWindowWatcherItemDelegate::Close() { |