Index: ash/common/system/chromeos/palette/palette_utils.cc |
diff --git a/ash/common/system/chromeos/palette/palette_utils.cc b/ash/common/system/chromeos/palette/palette_utils.cc |
index 6a76068e90e36ebb1cf76aeeedba22767956d69a..179095729f8edced3eb9cd7cf6ab44659c51ef6b 100644 |
--- a/ash/common/system/chromeos/palette/palette_utils.cc |
+++ b/ash/common/system/chromeos/palette/palette_utils.cc |
@@ -5,7 +5,16 @@ |
#include "ash/common/system/chromeos/palette/palette_utils.h" |
#include "ash/common/ash_switches.h" |
+#include "ash/common/shelf/shelf_widget.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_root_window_controller.h" |
+#include "ash/common/wm_shell.h" |
+#include "ash/common/wm_window.h" |
#include "base/command_line.h" |
+#include "ui/events/event.h" |
+#include "ui/gfx/geometry/point.h" |
namespace ash { |
@@ -19,4 +28,24 @@ bool ArePaletteExperimentalFeaturesEnabled() { |
switches::kAshEnableExperimentalPaletteFeatures); |
} |
+bool PaletteContainsEvent(ui::LocatedEvent* event) { |
+ ash::WmWindow* primary = ash::WmShell::Get()->GetPrimaryRootWindow(); |
James Cook
2016/09/01 23:16:02
no need for ash:: in this function
jdufault
2016/09/02 20:20:38
Done.
|
+ |
+ for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { |
jdufault
2016/09/01 22:31:31
Is there a better way to figure out if an event is
James Cook
2016/09/01 23:16:02
This seems reasonable to me.
|
+ // Convert point so that it is relative to the primary display, which is how |
+ // the view screen coordinates (for PaletteTray) are setup. Normally |
+ // root_location() is relative to the window that generated it. |
+ gfx::Point point = |
+ window->ConvertPointToTarget(primary, event->root_location()); |
+ |
+ ash::WmShelf* shelf = window->GetRootWindowController()->GetShelf(); |
James Cook
2016/09/01 23:16:02
WmShelf::ForWindow() is useful here, lets you skip
jdufault
2016/09/02 20:20:38
Done.
|
+ ash::PaletteTray* palette_tray = |
+ shelf->shelf_widget()->status_area_widget()->palette_tray(); |
James Cook
2016/09/01 23:16:02
nit: shelf->GetStatusAreaWidget() will let you ski
jdufault
2016/09/02 20:20:38
Done.
|
+ if (palette_tray && palette_tray->ContainsPointInScreen(point)) |
+ return true; |
+ } |
+ |
+ return false; |
+} |
+ |
} // namespace ash |