Commit d8d4991f authored by jdufault's avatar jdufault Committed by Commit bot

cros/ash: If the partial magnifier is active, do not consume input events if over palette views.

This allows the user to disable the magnifier and use the palette while the magnifier is active.

TEST=ash_unittests
BUG=642535

Review-Url: https://codereview.chromium.org/2303963002
Cr-Commit-Position: refs/heads/master@{#417124}
parent 0ed371b0
...@@ -220,6 +220,13 @@ bool PaletteTray::ShowPalette() { ...@@ -220,6 +220,13 @@ bool PaletteTray::ShowPalette() {
return true; return true;
} }
bool PaletteTray::ContainsPointInScreen(const gfx::Point& point) {
if (icon_ && icon_->GetBoundsInScreen().Contains(point))
return true;
return bubble_ && bubble_->bubble_view()->GetBoundsInScreen().Contains(point);
}
void PaletteTray::AddToolsToView(views::View* host) { void PaletteTray::AddToolsToView(views::View* host) {
std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews(); std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews();
for (const PaletteToolView& view : views) for (const PaletteToolView& view : views)
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
namespace gfx {
class Point;
}
namespace views { namespace views {
class ImageView; class ImageView;
class Widget; class Widget;
...@@ -65,6 +69,10 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView, ...@@ -65,6 +69,10 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView,
// was opened. // was opened.
bool ShowPalette(); bool ShowPalette();
// Returns true if the palette tray contains the given point. This is useful
// for determining if an event should be propagated through to the palette.
bool ContainsPointInScreen(const gfx::Point& point);
private: private:
// views::TrayBubbleView::Delegate: // views::TrayBubbleView::Delegate:
void BubbleViewDestroyed() override; void BubbleViewDestroyed() override;
......
...@@ -5,7 +5,13 @@ ...@@ -5,7 +5,13 @@
#include "ash/common/system/chromeos/palette/palette_utils.h" #include "ash/common/system/chromeos/palette/palette_utils.h"
#include "ash/common/ash_switches.h" #include "ash/common/ash_switches.h"
#include "ash/common/shelf/wm_shelf.h"
#include "ash/common/system/chromeos/palette/palette_tray.h"
#include "ash/common/system/status_area_widget.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "ui/gfx/geometry/point.h"
namespace ash { namespace ash {
...@@ -24,4 +30,15 @@ bool IsPaletteEnabledOnEveryDisplay() { ...@@ -24,4 +30,15 @@ bool IsPaletteEnabledOnEveryDisplay() {
switches::kAshEnablePaletteOnAllDisplays); switches::kAshEnablePaletteOnAllDisplays);
} }
bool PaletteContainsPointInScreen(const gfx::Point& point) {
for (WmWindow* window : WmShell::Get()->GetAllRootWindows()) {
PaletteTray* palette_tray =
WmShelf::ForWindow(window)->GetStatusAreaWidget()->palette_tray();
if (palette_tray && palette_tray->ContainsPointInScreen(point))
return true;
}
return false;
}
} // namespace ash } // namespace ash
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
namespace gfx {
class Point;
}
namespace ash { namespace ash {
// Returns true if the palette feature is enabled. The palette itself may have // Returns true if the palette feature is enabled. The palette itself may have
...@@ -19,6 +23,10 @@ ASH_EXPORT bool ArePaletteExperimentalFeaturesEnabled(); ...@@ -19,6 +23,10 @@ ASH_EXPORT bool ArePaletteExperimentalFeaturesEnabled();
// Returns true if the palette should be shown on every display. // Returns true if the palette should be shown on every display.
ASH_EXPORT bool IsPaletteEnabledOnEveryDisplay(); ASH_EXPORT bool IsPaletteEnabledOnEveryDisplay();
// Returns true if either the palette icon or the palette widget contain the
// given point (in screen space).
ASH_EXPORT bool PaletteContainsPointInScreen(const gfx::Point& point);
} // namespace ash } // namespace ash
#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_UTILS_H_ #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_UTILS_H_
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h" #include "ui/wm/core/coordinate_conversion.h"
#if defined(OS_CHROMEOS)
#include "ash/common/system/chromeos/palette/palette_utils.h"
#endif
namespace ash { namespace ash {
namespace { namespace {
...@@ -54,6 +58,16 @@ aura::Window* GetCurrentRootWindow() { ...@@ -54,6 +58,16 @@ aura::Window* GetCurrentRootWindow() {
return nullptr; return nullptr;
} }
// Returns true if the event should be processed normally, ie, the stylus is
// over the palette icon or widget.
bool ShouldSkipEventFiltering(const gfx::Point& point) {
#if defined(OS_CHROMEOS)
return PaletteContainsPointInScreen(point);
#else
return false;
#endif
}
} // namespace } // namespace
// The content mask provides a clipping layer for the magnification window so we // The content mask provides a clipping layer for the magnification window so we
...@@ -178,8 +192,16 @@ void PartialMagnificationController::OnLocatedEvent( ...@@ -178,8 +192,16 @@ void PartialMagnificationController::OnLocatedEvent(
if (pointer_details.pointer_type != ui::EventPointerType::POINTER_TYPE_PEN) if (pointer_details.pointer_type != ui::EventPointerType::POINTER_TYPE_PEN)
return; return;
if (event->type() == ui::ET_MOUSE_PRESSED) // Compute the event location in screen space.
aura::Window* target = static_cast<aura::Window*>(event->target());
aura::Window* event_root = target->GetRootWindow();
gfx::Point screen_point = event->root_location();
wm::ConvertPointToScreen(event_root, &screen_point);
if (event->type() == ui::ET_MOUSE_PRESSED &&
!ShouldSkipEventFiltering(screen_point)) {
SetActive(true); SetActive(true);
}
if (event->type() == ui::ET_MOUSE_RELEASED) if (event->type() == ui::ET_MOUSE_RELEASED)
SetActive(false); SetActive(false);
...@@ -198,16 +220,13 @@ void PartialMagnificationController::OnLocatedEvent( ...@@ -198,16 +220,13 @@ void PartialMagnificationController::OnLocatedEvent(
return; return;
} }
gfx::Point point = event->root_location();
// Remap point from where it was captured to the display it is actually on. // Remap point from where it was captured to the display it is actually on.
aura::Window* target = static_cast<aura::Window*>(event->target()); gfx::Point point = event->root_location();
aura::Window* event_root = target->GetRootWindow();
aura::Window::ConvertPointToTarget( aura::Window::ConvertPointToTarget(
event_root, host_widget_->GetNativeView()->GetRootWindow(), &point); event_root, host_widget_->GetNativeView()->GetRootWindow(), &point);
host_widget_->SetBounds(GetBounds(point)); host_widget_->SetBounds(GetBounds(point));
if (!ShouldSkipEventFiltering(screen_point))
event->StopPropagation(); event->StopPropagation();
} }
......
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