OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/common/system/chromeos/palette/palette_utils.h" | 5 #include "ash/common/system/chromeos/palette/palette_utils.h" |
6 | 6 |
7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
8 #include "ash/common/shelf/wm_shelf.h" | 8 #include "ash/common/shelf/wm_shelf.h" |
9 #include "ash/common/system/chromeos/palette/palette_tray.h" | 9 #include "ash/common/system/chromeos/palette/palette_tray.h" |
10 #include "ash/common/system/status_area_widget.h" | 10 #include "ash/common/system/status_area_widget.h" |
11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
12 #include "ash/common/wm_window.h" | 12 #include "ash/common/wm_window.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "ui/events/devices/input_device_manager.h" | |
15 #include "ui/events/devices/touchscreen_device.h" | |
14 #include "ui/gfx/geometry/point.h" | 16 #include "ui/gfx/geometry/point.h" |
15 | 17 |
16 namespace ash { | 18 namespace ash { |
17 | 19 |
18 bool IsPaletteFeatureEnabled() { | 20 bool HasStylusInput() { |
19 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 21 // Allow the user to force-enable by passing a switch. |
20 switches::kAshEnablePalette); | 22 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
23 switches::kAshEnablePalette)) { | |
stevenjb
2017/01/21 00:23:50
This switch name is now a bit unfortunate, it seem
jdufault
2017/01/25 00:53:15
I've renamed the switch.
| |
24 return true; | |
25 } | |
26 | |
27 for (const ui::TouchscreenDevice& device : | |
28 ui::InputDeviceManager::GetInstance()->GetTouchscreenDevices()) { | |
29 if (device.is_stylus && | |
30 device.type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) { | |
31 return true; | |
32 } | |
33 } | |
34 | |
35 return false; | |
21 } | 36 } |
22 | 37 |
23 bool IsPaletteEnabledOnEveryDisplay() { | 38 bool IsPaletteEnabledOnEveryDisplay() { |
24 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 39 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
25 switches::kAshEnablePaletteOnAllDisplays); | 40 switches::kAshEnablePaletteOnAllDisplays); |
26 } | 41 } |
27 | 42 |
28 bool PaletteContainsPointInScreen(const gfx::Point& point) { | 43 bool PaletteContainsPointInScreen(const gfx::Point& point) { |
29 for (WmWindow* window : WmShell::Get()->GetAllRootWindows()) { | 44 for (WmWindow* window : WmShell::Get()->GetAllRootWindows()) { |
30 PaletteTray* palette_tray = | 45 PaletteTray* palette_tray = |
31 WmShelf::ForWindow(window)->GetStatusAreaWidget()->palette_tray(); | 46 WmShelf::ForWindow(window)->GetStatusAreaWidget()->palette_tray(); |
32 if (palette_tray && palette_tray->ContainsPointInScreen(point)) | 47 if (palette_tray && palette_tray->ContainsPointInScreen(point)) |
33 return true; | 48 return true; |
34 } | 49 } |
35 | 50 |
36 return false; | 51 return false; |
37 } | 52 } |
38 | 53 |
39 } // namespace ash | 54 } // namespace ash |
OLD | NEW |