namespace {
-bool ShouldHideCursorOnKeyEvent(const ui::KeyEvent& event) {
-#if defined(OS_CHROMEOS)
- // All alt and control key commands are ignored.
- if (event.IsAltDown() || event.IsControlDown())
- return false;
-
- static bool inited = false;
- static base::hash_set<int32> ignored_keys;
- if (!inited) {
- // Modifiers.
- ignored_keys.insert(ui::VKEY_SHIFT);
- ignored_keys.insert(ui::VKEY_CONTROL);
- ignored_keys.insert(ui::VKEY_MENU);
-
- // Search key == VKEY_LWIN.
- ignored_keys.insert(ui::VKEY_LWIN);
-
- // Function keys.
- for (int key = ui::VKEY_F1; key <= ui::VKEY_F24; ++key)
- ignored_keys.insert(key);
-
- // Media keys.
- for (int key = ui::VKEY_BROWSER_BACK; key <= ui::VKEY_MEDIA_LAUNCH_APP2;
- ++key) {
- ignored_keys.insert(key);
- }
-
-#if defined(OS_POSIX)
- ignored_keys.insert(ui::VKEY_WLAN);
- ignored_keys.insert(ui::VKEY_POWER);
- ignored_keys.insert(ui::VKEY_BRIGHTNESS_DOWN);
- ignored_keys.insert(ui::VKEY_BRIGHTNESS_UP);
- ignored_keys.insert(ui::VKEY_KBD_BRIGHTNESS_DOWN);
- ignored_keys.insert(ui::VKEY_KBD_BRIGHTNESS_UP);
-#endif
-
- inited = true;
- }
-
- if (ignored_keys.count(event.key_code()) > 0)
- return false;
-
- return true;
-#else // !defined(OS_CHROMEOS)
- return false;
-#endif // defined(OS_CHROMEOS)
-}
-
// Returns true if the cursor should be hidden on touch events.
+// TODO(tdanderson|rsadam): Move this function into CursorClient.
bool ShouldHideCursorOnTouch(const ui::TouchEvent& event) {
-#if defined(OS_CHROMEOS)
+#if defined(OS_WIN)
+ return true;
+#elif defined(OS_CHROMEOS)
#if defined(USE_X11)
int device_id = event.source_device_id();
if (device_id >= 0 &&
#endif // defined(USE_X11)
return true;
#else
- // Windows hides the cursor on touch, but we cannot track the cursor
- // visibility or enabledness state reliably until we are able to
- // properly flag all incoming mouse messages in HWNDMessageHandler.
- // TODO(ananta|tdanderson): crbug.com/332430
+ // Linux Aura does not hide the cursor on touch by default.
+ // TODO(tdanderson): Change this if having consistency across
+ // all platforms which use Aura is desired.
return false;
#endif
}
// CompoundEventFilter, ui::EventHandler implementation:
void CompoundEventFilter::OnKeyEvent(ui::KeyEvent* event) {
- if (ShouldHideCursorOnKeyEvent(*event)) {
- SetCursorVisibilityOnEvent(
- static_cast<aura::Window*>(event->target()), event, false);
- }
+ aura::Window* target = static_cast<aura::Window*>(event->target());
+ aura::client::CursorClient* client =
+ aura::client::GetCursorClient(target->GetRootWindow());
+ if (client && client->ShouldHideCursorOnKeyEvent(*event))
+ SetCursorVisibilityOnEvent(target, event, false);
FilterKeyEvent(event);
}
// We also update the cursor for mouse enter in case a mouse cursor is sent to
// outside of the root window and moved back for some reasons (e.g. running on
// on Desktop for testing, or a bug in pointer barrier).
- if (event->type() == ui::ET_MOUSE_ENTERED ||
- event->type() == ui::ET_MOUSE_MOVED ||
- event->type() == ui::ET_MOUSE_PRESSED ||
- event->type() == ui::ET_MOUSEWHEEL) {
+ if (!(event->flags() & ui::EF_FROM_TOUCH) &&
+ (event->type() == ui::ET_MOUSE_ENTERED ||
+ event->type() == ui::ET_MOUSE_MOVED ||
+ event->type() == ui::ET_MOUSE_PRESSED ||
+ event->type() == ui::ET_MOUSEWHEEL)) {
SetMouseEventsEnableStateOnEvent(window, event, true);
SetCursorVisibilityOnEvent(window, event, true);
UpdateCursor(window, event);
while (!event->stopped_propagation() && (handler = it.GetNext()) != NULL)
handler->OnGestureEvent(event);
}
+
+#if defined(OS_WIN)
+ // A Win8 edge swipe event is a special event that does not have location
+ // information associated with it, and is not preceeded by an ET_TOUCH_PRESSED
+ // event. So we treat it specially here.
+ if (!event->handled() && event->type() == ui::ET_GESTURE_WIN8_EDGE_SWIPE &&
+ !aura::Env::GetInstance()->IsMouseButtonDown()) {
+ SetMouseEventsEnableStateOnEvent(
+ static_cast<aura::Window*>(event->target()), event, false);
+ }
+#endif
}
} // namespace wm