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

Side by Side Diff: ui/wm/core/capture_controller.h

Issue 780273003: Fix releasing capture in Ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/wm/BUILD.gn ('k') | ui/wm/core/capture_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_WM_CORE_CAPTURE_CONTROLLER_H_ 5 #ifndef UI_WM_CORE_CAPTURE_CONTROLLER_H_
6 #define UI_WM_CORE_CAPTURE_CONTROLLER_H_ 6 #define UI_WM_CORE_CAPTURE_CONTROLLER_H_
7 7
8 #include <set> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "ui/aura/client/capture_client.h" 12 #include "ui/aura/client/capture_client.h"
13 #include "ui/aura/window_observer.h" 13 #include "ui/aura/window_observer.h"
14 #include "ui/wm/wm_export.h" 14 #include "ui/wm/wm_export.h"
15 15
16 namespace aura {
17 namespace client {
18 class CaptureDelegate;
19 }
20 }
21
16 namespace wm { 22 namespace wm {
17 23
18 // Internal CaptureClient implementation. See ScopedCaptureClient for details. 24 // Internal CaptureClient implementation. See ScopedCaptureClient for details.
19 class WM_EXPORT CaptureController : public aura::client::CaptureClient { 25 class WM_EXPORT CaptureController : public aura::client::CaptureClient {
20 public: 26 public:
21 // Adds |root| to the list of RootWindows notified when capture changes. 27 // Adds |root| to the list of root windows notified when capture changes.
22 void Attach(aura::Window* root); 28 void Attach(aura::Window* root);
23 29
24 // Removes |root| from the list of RootWindows notified when capture changes. 30 // Removes |root| from the list of root windows notified when capture changes.
25 void Detach(aura::Window* root); 31 void Detach(aura::Window* root);
26 32
27 // Returns true if this CaptureController is installed on at least one 33 // Returns true if this CaptureController is installed on at least one
28 // RootWindow. 34 // root window.
29 bool is_active() const { return !root_windows_.empty(); } 35 bool is_active() const { return !delegates_.empty(); }
30 36
31 // Overridden from aura::client::CaptureClient: 37 // Overridden from aura::client::CaptureClient:
32 void SetCapture(aura::Window* window) override; 38 void SetCapture(aura::Window* window) override;
33 void ReleaseCapture(aura::Window* window) override; 39 void ReleaseCapture(aura::Window* window) override;
34 aura::Window* GetCaptureWindow() override; 40 aura::Window* GetCaptureWindow() override;
35 aura::Window* GetGlobalCaptureWindow() override; 41 aura::Window* GetGlobalCaptureWindow() override;
36 42
37 private: 43 private:
38 friend class ScopedCaptureClient; 44 friend class ScopedCaptureClient;
39 typedef std::set<aura::Window*> RootWindows;
40 45
41 CaptureController(); 46 CaptureController();
42 ~CaptureController() override; 47 ~CaptureController() override;
43 48
44 // The current capture window. NULL if there is no capture window. 49 // The current capture window. NULL if there is no capture window.
45 aura::Window* capture_window_; 50 aura::Window* capture_window_;
46 51
47 // Set of RootWindows notified when capture changes. 52 // The capture delegate for the root window with native capture. The root
48 RootWindows root_windows_; 53 // window with native capture may not contain |capture_window_|. This occurs
54 // if |capture_window_| is reparented to a different root window while it has
55 // capture.
56 aura::client::CaptureDelegate* capture_delegate_;
57
58 // The delegates notified when capture changes.
59 std::map<aura::Window*, aura::client::CaptureDelegate*> delegates_;
49 60
50 DISALLOW_COPY_AND_ASSIGN(CaptureController); 61 DISALLOW_COPY_AND_ASSIGN(CaptureController);
51 }; 62 };
52 63
53 // ScopedCaptureClient is responsible for creating a CaptureClient for a 64 // ScopedCaptureClient is responsible for creating a CaptureClient for a
54 // RootWindow. Specifically it creates a single CaptureController that is shared 65 // RootWindow. Specifically it creates a single CaptureController that is shared
55 // among all ScopedCaptureClients and adds the RootWindow to it. 66 // among all ScopedCaptureClients and adds the RootWindow to it.
56 class WM_EXPORT ScopedCaptureClient : public aura::WindowObserver { 67 class WM_EXPORT ScopedCaptureClient : public aura::WindowObserver {
57 public: 68 public:
69 class WM_EXPORT TestApi {
70 public:
71 explicit TestApi(ScopedCaptureClient* client) : client_(client) {}
72 ~TestApi() {}
73
74 // Sets the delegate.
75 void SetDelegate(aura::client::CaptureDelegate* delegate);
76
77 private:
78 // Not owned.
79 ScopedCaptureClient* client_;
80
81 DISALLOW_COPY_AND_ASSIGN(TestApi);
82 };
83
58 explicit ScopedCaptureClient(aura::Window* root); 84 explicit ScopedCaptureClient(aura::Window* root);
59 ~ScopedCaptureClient() override; 85 ~ScopedCaptureClient() override;
60 86
61 // Returns true if there is a CaptureController with at least one RootWindow. 87 // Returns true if there is a CaptureController with at least one RootWindow.
62 static bool IsActive(); 88 static bool IsActive();
63 89
64 aura::client::CaptureClient* capture_client() { 90 aura::client::CaptureClient* capture_client() {
65 return capture_controller_; 91 return capture_controller_;
66 } 92 }
67 93
68 // Overridden from aura::WindowObserver: 94 // Overridden from aura::WindowObserver:
69 void OnWindowDestroyed(aura::Window* window) override; 95 void OnWindowDestroyed(aura::Window* window) override;
70 96
71 private: 97 private:
72 // Invoked from destructor and OnWindowDestroyed() to cleanup. 98 // Invoked from destructor and OnWindowDestroyed() to cleanup.
73 void Shutdown(); 99 void Shutdown();
74 100
75 // The single CaptureController instance. 101 // The single CaptureController instance.
76 static CaptureController* capture_controller_; 102 static CaptureController* capture_controller_;
77 103
78 // RootWindow this ScopedCaptureClient was create for. 104 // RootWindow this ScopedCaptureClient was create for.
79 aura::Window* root_window_; 105 aura::Window* root_window_;
80 106
81 DISALLOW_COPY_AND_ASSIGN(ScopedCaptureClient); 107 DISALLOW_COPY_AND_ASSIGN(ScopedCaptureClient);
82 }; 108 };
83 109
84 } // namespace wm 110 } // namespace wm
85 111
86 #endif // UI_WM_CORE_CAPTURE_CONTROLLER_H_ 112 #endif // UI_WM_CORE_CAPTURE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ui/wm/BUILD.gn ('k') | ui/wm/core/capture_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698