| Index: ash/system/palette/palette_utils.cc
|
| diff --git a/ash/system/palette/palette_utils.cc b/ash/system/palette/palette_utils.cc
|
| index 7181d6c5addf6bcfab86b78c472dfc6c2475d078..97338a90047c8ba24463bfec64e44b018f9778d8 100644
|
| --- a/ash/system/palette/palette_utils.cc
|
| +++ b/ash/system/palette/palette_utils.cc
|
| @@ -5,12 +5,16 @@
|
| #include "ash/system/palette/palette_utils.h"
|
|
|
| #include "ash/ash_switches.h"
|
| +#include "ash/palette_delegate.h"
|
| +#include "ash/public/cpp/config.h"
|
| #include "ash/shelf/wm_shelf.h"
|
| +#include "ash/shell.h"
|
| #include "ash/shell_port.h"
|
| #include "ash/system/palette/palette_tray.h"
|
| #include "ash/system/status_area_widget.h"
|
| #include "ash/wm_window.h"
|
| #include "base/command_line.h"
|
| +#include "ui/display/display.h"
|
| #include "ui/events/devices/input_device_manager.h"
|
| #include "ui/events/devices/touchscreen_device.h"
|
| #include "ui/gfx/geometry/point.h"
|
| @@ -22,11 +26,13 @@ bool HasStylusInput() {
|
| // Allow the user to force enable or disable by passing a switch. If both are
|
| // present, enabling takes precedence over disabling.
|
| if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kAshForceEnablePalette)) {
|
| + switches::kAshForceEnableStylusTools)) {
|
| return true;
|
| }
|
|
|
| - // Check to see if the hardware reports it is stylus capable.
|
| + // Returns true if the hardware reports it is stylus capable. This
|
| + // will return false even if there is a stylus input device until hardware
|
| + // probing is complete (see ui::InputDeviceEventObserver).
|
| for (const ui::TouchscreenDevice& device :
|
| ui::InputDeviceManager::GetInstance()->GetTouchscreenDevices()) {
|
| if (device.is_stylus &&
|
| @@ -43,6 +49,14 @@ bool IsPaletteEnabledOnEveryDisplay() {
|
| switches::kAshEnablePaletteOnAllDisplays);
|
| }
|
|
|
| +bool ShouldShowPalette() {
|
| + return HasStylusInput() &&
|
| + (display::Display::HasInternalDisplay() ||
|
| + IsPaletteEnabledOnEveryDisplay()) &&
|
| + Shell::Get()->palette_delegate() &&
|
| + Shell::Get()->palette_delegate()->ShouldShowPalette();
|
| +}
|
| +
|
| bool PaletteContainsPointInScreen(const gfx::Point& point) {
|
| for (WmWindow* window : ShellPort::Get()->GetAllRootWindows()) {
|
| PaletteTray* palette_tray =
|
|
|