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

Side by Side Diff: ui/views/cocoa/cocoa_mouse_capture.h

Issue 789763002: MacViews: Implement capture using NSEvent local+global monitors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20140812-MacViews-LAYERS2-PRESQUASH
Patch Set: fix sorting Created 6 years 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
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.mm ('k') | ui/views/cocoa/cocoa_mouse_capture.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_
6 #define UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/views/views_export.h"
11
12 namespace views {
13
14 class CocoaMouseCaptureDelegate;
15
16 // Basic mouse capture to simulate ::SetCapture() from Windows. This is used to
17 // support menu widgets (e.g. on Combo boxes). Clicking anywhere other than the
18 // menu should dismiss the menu and "swallow" the mouse event. All events are
19 // forwarded, but only events to the same application are "swallowed", which is
20 // consistent with how native NSMenus behave.
21 class VIEWS_EXPORT CocoaMouseCapture {
22 public:
23 explicit CocoaMouseCapture(CocoaMouseCaptureDelegate* delegate);
24 ~CocoaMouseCapture();
25
26 // True if the event tap is active (i.e. not stolen by a later instance).
27 bool IsActive() const { return active_handle_; }
28
29 private:
30 class ActiveEventTap;
31
32 // Deactivates the event tap if still active.
33 void OnOtherClientGotCapture();
34
35 CocoaMouseCaptureDelegate* delegate_; // Weak. Owns this.
36
37 // The active event tap for this capture. Owned by this, but can be cleared
38 // out early if another instance of CocoaMouseCapture is created.
39 scoped_ptr<ActiveEventTap> active_handle_;
40
41 DISALLOW_COPY_AND_ASSIGN(CocoaMouseCapture);
42 };
43
44 } // namespace views
45
46 #endif // UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.mm ('k') | ui/views/cocoa/cocoa_mouse_capture.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698