summaryrefslogtreecommitdiffstats
path: root/chromium/ui/views/pointer_watcher.h
blob: 74159af12aa289b7f18c8d1f0a846b1e47b4b699 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_VIEWS_POINTER_WATCHER_H_
#define UI_VIEWS_POINTER_WATCHER_H_

#include "base/macros.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/views_export.h"

namespace gfx {
class Point;
}

namespace ui {
class PointerEvent;
}

namespace views {

// When a PointerWatcher is added the types of events desired is specified by
// way of PointerWatcherEventTypes.
enum class PointerWatcherEventTypes {
  // The PointerWatcher is interested in press, release, capture and mouse
  // wheel.
  BASIC,
  // The PointerWatcher is interested in BASIC events, as well as move
  // events.
  MOVES,
  // The PointerWatcher is interested in MOVE events, as well as drag
  // events.
  DRAGS
};

// An interface for read-only observation of pointer events (in particular, the
// events cannot be marked as handled). Only certain event types are supported.
// The |target| is the native window that will receive the event, if any.
// To reduce IPC traffic from the window server, move events are not provided
// unless the app specifically requests them.
// NOTE: On mus this allows observation of events outside of windows owned
// by the current process, in which case the |target| will be null. On mus
// event.target() is always null.
// NOTE: Mouse capture change events are sent through OnPointerEventObserved and
// its |target| is always null.
// NOTE: |target| may or may not have an associated views::Widget that may not
// be a top-level Widget.
class VIEWS_EXPORT PointerWatcher {
 public:
  PointerWatcher() {}

  virtual void OnPointerEventObserved(const ui::PointerEvent& event,
                                      const gfx::Point& location_in_screen,
                                      gfx::NativeView target) = 0;

 protected:
  virtual ~PointerWatcher() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(PointerWatcher);
};

}  // namespace views

#endif  // UI_VIEWS_POINTER_WATCHER_H_