Commit 10065941 authored by flackr@chromium.org's avatar flackr@chromium.org

Add double click and tap handler to minimize attached panels.

BUG=246603
TEST=Open a panel (i.e. hangouts) and double click and tap on header. Panel should minimize.

Review URL: https://chromiumcodereview.appspot.com/17175019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207949 0039d316-1c4b-4281-b951-d872f2087c98
parent be86704c
...@@ -412,6 +412,8 @@ ...@@ -412,6 +412,8 @@
'wm/panels/panel_frame_view.h', 'wm/panels/panel_frame_view.h',
'wm/panels/panel_layout_manager.cc', 'wm/panels/panel_layout_manager.cc',
'wm/panels/panel_layout_manager.h', 'wm/panels/panel_layout_manager.h',
'wm/panels/panel_window_event_handler.cc',
'wm/panels/panel_window_event_handler.h',
'wm/panels/panel_window_resizer.cc', 'wm/panels/panel_window_resizer.cc',
'wm/panels/panel_window_resizer.h', 'wm/panels/panel_window_resizer.h',
'wm/partial_screenshot_view.cc', 'wm/partial_screenshot_view.cc',
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "ash/wm/boot_splash_screen.h" #include "ash/wm/boot_splash_screen.h"
#include "ash/wm/dock/docked_window_layout_manager.h" #include "ash/wm/dock/docked_window_layout_manager.h"
#include "ash/wm/panels/panel_layout_manager.h" #include "ash/wm/panels/panel_layout_manager.h"
#include "ash/wm/panels/panel_window_event_handler.h"
#include "ash/wm/property_util.h" #include "ash/wm/property_util.h"
#include "ash/wm/root_window_layout_manager.h" #include "ash/wm/root_window_layout_manager.h"
#include "ash/wm/screen_dimmer.h" #include "ash/wm/screen_dimmer.h"
...@@ -289,7 +290,7 @@ void RootWindowController::InitForPrimaryDisplay() { ...@@ -289,7 +290,7 @@ void RootWindowController::InitForPrimaryDisplay() {
panel_layout_manager_ = panel_layout_manager_ =
new internal::PanelLayoutManager(panel_container); new internal::PanelLayoutManager(panel_container);
panel_container_handler_.reset( panel_container_handler_.reset(
new ToplevelWindowEventHandler(panel_container)); new PanelWindowEventHandler(panel_container));
panel_container->SetLayoutManager(panel_layout_manager_); panel_container->SetLayoutManager(panel_layout_manager_);
// TODO(stevenjb/oshima): Remove this call to CreateLauncher() and call // TODO(stevenjb/oshima): Remove this call to CreateLauncher() and call
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/panels/panel_window_event_handler.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/events/event.h"
#include "ui/base/hit_test.h"
namespace ash {
namespace internal {
PanelWindowEventHandler::PanelWindowEventHandler(aura::Window* owner)
: ToplevelWindowEventHandler(owner) {
}
PanelWindowEventHandler::~PanelWindowEventHandler() {
}
void PanelWindowEventHandler::OnMouseEvent(ui::MouseEvent* event) {
aura::Window* target = static_cast<aura::Window*>(event->target());
if (event->type() == ui::ET_MOUSE_PRESSED &&
event->flags() & ui::EF_IS_DOUBLE_CLICK &&
target->delegate()->GetNonClientComponent(event->location()) ==
HTCAPTION) {
target->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
return;
}
ToplevelWindowEventHandler::OnMouseEvent(event);
}
void PanelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
aura::Window* target = static_cast<aura::Window*>(event->target());
if (event->type() == ui::ET_GESTURE_TAP &&
event->details().tap_count() == 2 &&
target->delegate()->GetNonClientComponent(event->location()) ==
HTCAPTION) {
target->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
event->StopPropagation();
return;
}
ToplevelWindowEventHandler::OnGestureEvent(event);
}
} // namespace internal
} // namespace ash
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_PANELS_PANEL_WINDOW_EVENT_HANDLER_H_
#define ASH_WM_PANELS_PANEL_WINDOW_EVENT_HANDLER_H_
#include "ash/wm/toplevel_window_event_handler.h"
namespace aura {
class Window;
}
namespace ash {
namespace internal {
// PanelWindowEventHandler minimizes panels when the user double clicks or
// double taps on the panel header.
class PanelWindowEventHandler : public ToplevelWindowEventHandler {
public:
explicit PanelWindowEventHandler(aura::Window* owner);
virtual ~PanelWindowEventHandler();
// TopLevelWindowEventHandler:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(PanelWindowEventHandler);
};
} // namespace internal
} // namespace ash
#endif // ASH_WM_PANELS_PANEL_WINDOW_EVENT_HANDLER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment