Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: ash/system/palette/palette_utils.cc

Issue 2825383003: Fix stylus tools palette. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/system/palette/palette_utils.h" 5 #include "ash/system/palette/palette_utils.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/shelf/wm_shelf.h" 8 #include "ash/shelf/wm_shelf.h"
9 #include "ash/shell_port.h" 9 #include "ash/shell_port.h"
10 #include "ash/system/palette/palette_tray.h" 10 #include "ash/system/palette/palette_tray.h"
11 #include "ash/system/status_area_widget.h" 11 #include "ash/system/status_area_widget.h"
12 #include "ash/wm_window.h" 12 #include "ash/wm_window.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "ui/display/display.h"
14 #include "ui/events/devices/input_device_manager.h" 15 #include "ui/events/devices/input_device_manager.h"
15 #include "ui/events/devices/touchscreen_device.h" 16 #include "ui/events/devices/touchscreen_device.h"
16 #include "ui/gfx/geometry/point.h" 17 #include "ui/gfx/geometry/point.h"
17 18
18 namespace ash { 19 namespace ash {
19 namespace palette_utils { 20 namespace palette_utils {
20 21
21 bool HasStylusInput() { 22 bool HasStylusInput() {
22 // Allow the user to force enable or disable by passing a switch. If both are 23 // Allow the user to force enable or disable by passing a switch. If both are
23 // present, enabling takes precedence over disabling. 24 // present, enabling takes precedence over disabling.
24 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 25 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
25 switches::kAshForceEnablePalette)) { 26 switches::kAshForceEnableStylusTools)) {
26 return true; 27 return true;
27 } 28 }
28 29
29 // Check to see if the hardware reports it is stylus capable. 30 // Check to see if the hardware reports it is stylus capable.
30 for (const ui::TouchscreenDevice& device : 31 for (const ui::TouchscreenDevice& device :
31 ui::InputDeviceManager::GetInstance()->GetTouchscreenDevices()) { 32 ui::InputDeviceManager::GetInstance()->GetTouchscreenDevices()) {
32 if (device.is_stylus && 33 if (device.is_stylus &&
33 device.type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) { 34 device.type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) {
34 return true; 35 return true;
35 } 36 }
36 } 37 }
37 38
38 return false; 39 return false;
39 } 40 }
40 41
41 bool IsPaletteEnabledOnEveryDisplay() { 42 bool IsPaletteEnabledOnEveryDisplay() {
42 return base::CommandLine::ForCurrentProcess()->HasSwitch( 43 return base::CommandLine::ForCurrentProcess()->HasSwitch(
43 switches::kAshEnablePaletteOnAllDisplays); 44 switches::kAshEnablePaletteOnAllDisplays);
44 } 45 }
45 46
47 bool ShouldCreatePalette() {
48 return HasStylusInput() && (display::Display::HasInternalDisplay() ||
49 IsPaletteEnabledOnEveryDisplay());
50 }
51
46 bool PaletteContainsPointInScreen(const gfx::Point& point) { 52 bool PaletteContainsPointInScreen(const gfx::Point& point) {
47 for (WmWindow* window : ShellPort::Get()->GetAllRootWindows()) { 53 for (WmWindow* window : ShellPort::Get()->GetAllRootWindows()) {
48 PaletteTray* palette_tray = 54 PaletteTray* palette_tray =
49 WmShelf::ForWindow(window)->GetStatusAreaWidget()->palette_tray(); 55 WmShelf::ForWindow(window)->GetStatusAreaWidget()->palette_tray();
50 if (palette_tray && palette_tray->ContainsPointInScreen(point)) 56 if (palette_tray && palette_tray->ContainsPointInScreen(point))
51 return true; 57 return true;
52 } 58 }
53 59
54 return false; 60 return false;
55 } 61 }
56 62
57 } // namespace palette_utils 63 } // namespace palette_utils
58 } // namespace ash 64 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698