| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" | 5 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" |
| 6 | 6 |
| 7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
| 8 #include "ui/aura/window_event_dispatcher.h" | 8 #include "ui/aura/window_event_dispatcher.h" |
| 9 | 9 |
| 10 namespace views { | 10 namespace views { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // distinction between the touches/gestures that were in the window all | 45 // distinction between the touches/gestures that were in the window all |
| 46 // along (and so shouldn't be canceled) and those that got moved, so | 46 // along (and so shouldn't be canceled) and those that got moved, so |
| 47 // just leave them all where they are. | 47 // just leave them all where they are. |
| 48 if (new_capture_window) { | 48 if (new_capture_window) { |
| 49 ui::GestureRecognizer::Get()->TransferEventsTo(old_capture_window, | 49 ui::GestureRecognizer::Get()->TransferEventsTo(old_capture_window, |
| 50 new_capture_window); | 50 new_capture_window); |
| 51 } | 51 } |
| 52 | 52 |
| 53 capture_window_ = new_capture_window; | 53 capture_window_ = new_capture_window; |
| 54 | 54 |
| 55 aura::client::CaptureDelegate* delegate = root_->GetDispatcher(); | 55 aura::client::CaptureDelegate* delegate = root_->GetHost()->dispatcher(); |
| 56 delegate->UpdateCapture(old_capture_window, new_capture_window); | 56 delegate->UpdateCapture(old_capture_window, new_capture_window); |
| 57 | 57 |
| 58 // Initiate native capture updating. | 58 // Initiate native capture updating. |
| 59 if (!capture_window_) { | 59 if (!capture_window_) { |
| 60 delegate->ReleaseNativeCapture(); | 60 delegate->ReleaseNativeCapture(); |
| 61 } else if (!old_capture_window) { | 61 } else if (!old_capture_window) { |
| 62 delegate->SetNativeCapture(); | 62 delegate->SetNativeCapture(); |
| 63 | 63 |
| 64 // Notify the other roots that we got capture. This is important so that | 64 // Notify the other roots that we got capture. This is important so that |
| 65 // they reset state. | 65 // they reset state. |
| 66 CaptureClients capture_clients(*capture_clients_); | 66 CaptureClients capture_clients(*capture_clients_); |
| 67 for (CaptureClients::iterator i = capture_clients.begin(); | 67 for (CaptureClients::iterator i = capture_clients.begin(); |
| 68 i != capture_clients.end(); ++i) { | 68 i != capture_clients.end(); ++i) { |
| 69 if (*i != this) { | 69 if (*i != this) { |
| 70 aura::client::CaptureDelegate* delegate = (*i)->root_->GetDispatcher(); | 70 aura::client::CaptureDelegate* delegate = |
| 71 (*i)->root_->GetHost()->dispatcher(); |
| 71 delegate->OnOtherRootGotCapture(); | 72 delegate->OnOtherRootGotCapture(); |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 } // else case is capture is remaining in our root, nothing to do. | 75 } // else case is capture is remaining in our root, nothing to do. |
| 75 } | 76 } |
| 76 | 77 |
| 77 void DesktopCaptureClient::ReleaseCapture(aura::Window* window) { | 78 void DesktopCaptureClient::ReleaseCapture(aura::Window* window) { |
| 78 if (capture_window_ != window) | 79 if (capture_window_ != window) |
| 79 return; | 80 return; |
| 80 SetCapture(NULL); | 81 SetCapture(NULL); |
| 81 } | 82 } |
| 82 | 83 |
| 83 aura::Window* DesktopCaptureClient::GetCaptureWindow() { | 84 aura::Window* DesktopCaptureClient::GetCaptureWindow() { |
| 84 return capture_window_; | 85 return capture_window_; |
| 85 } | 86 } |
| 86 | 87 |
| 87 aura::Window* DesktopCaptureClient::GetGlobalCaptureWindow() { | 88 aura::Window* DesktopCaptureClient::GetGlobalCaptureWindow() { |
| 88 for (CaptureClients::iterator i = capture_clients_->begin(); | 89 for (CaptureClients::iterator i = capture_clients_->begin(); |
| 89 i != capture_clients_->end(); ++i) { | 90 i != capture_clients_->end(); ++i) { |
| 90 if ((*i)->capture_window_) | 91 if ((*i)->capture_window_) |
| 91 return (*i)->capture_window_; | 92 return (*i)->capture_window_; |
| 92 } | 93 } |
| 93 return NULL; | 94 return NULL; |
| 94 } | 95 } |
| 95 | 96 |
| 96 } // namespace views | 97 } // namespace views |
| OLD | NEW |