summaryrefslogtreecommitdiffstats
path: root/chromium/ui/base/menu_source_utils.cc
blob: a9f4fbc329c5e06798ac3649c25f88161905f7ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/base/menu_source_utils.h"

#include "ui/events/event.h"

namespace ui {

MenuSourceType GetMenuSourceTypeForEvent(const Event& event) {
  if (event.IsKeyEvent())
    return MENU_SOURCE_KEYBOARD;
  if (event.IsTouchEvent() || event.IsGestureEvent())
    return MENU_SOURCE_TOUCH;
  return MENU_SOURCE_MOUSE;
}

#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(GOOGLE_CHROME_BRANDING)
MenuSourceType GetMenuSourceType(int event_flags) {
  if (event_flags & EF_MOUSE_BUTTON) {
    return MENU_SOURCE_MOUSE;
  }
  if (event_flags & EF_FROM_TOUCH) {
    return MENU_SOURCE_TOUCH;
  }
  return MENU_SOURCE_KEYBOARD;
}
#endif  // BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(GOOGLE_CHROME_BRANDING)

}  // namespace ui