OLD | NEW |
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 #include "ui/gfx/screen.h" | 5 #include "ui/gfx/screen.h" |
6 | 6 |
7 #import <ApplicationServices/ApplicationServices.h> | 7 #import <ApplicationServices/ApplicationServices.h> |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 void HandleDisplayReconfiguration() { | 186 void HandleDisplayReconfiguration() { |
187 // Given that we need to rebuild the list of displays, we want to coalesce | 187 // Given that we need to rebuild the list of displays, we want to coalesce |
188 // the events. For that, we use a timer that will be reset every time we get | 188 // the events. For that, we use a timer that will be reset every time we get |
189 // a new event and will be fulfilled kConfigureDelayMs after the latest. | 189 // a new event and will be fulfilled kConfigureDelayMs after the latest. |
190 if (configure_timer_.get() && configure_timer_->IsRunning()) { | 190 if (configure_timer_.get() && configure_timer_->IsRunning()) { |
191 configure_timer_->Reset(); | 191 configure_timer_->Reset(); |
192 return; | 192 return; |
193 } | 193 } |
194 | 194 |
195 configure_timer_.reset(new base::OneShotTimer<ScreenMac>()); | 195 configure_timer_.reset(new base::OneShotTimer()); |
196 configure_timer_->Start( | 196 configure_timer_->Start( |
197 FROM_HERE, | 197 FROM_HERE, |
198 base::TimeDelta::FromMilliseconds(kConfigureDelayMs), | 198 base::TimeDelta::FromMilliseconds(kConfigureDelayMs), |
199 this, | 199 this, |
200 &ScreenMac::ConfigureTimerFired); | 200 &ScreenMac::ConfigureTimerFired); |
201 } | 201 } |
202 | 202 |
203 private: | 203 private: |
204 void ConfigureTimerFired() { | 204 void ConfigureTimerFired() { |
205 std::vector<gfx::Display> old_displays = displays_; | 205 std::vector<gfx::Display> old_displays = displays_; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 return std::vector<gfx::Display>(1, GetPrimaryDisplay()); | 255 return std::vector<gfx::Display>(1, GetPrimaryDisplay()); |
256 | 256 |
257 return displays; | 257 return displays; |
258 } | 258 } |
259 | 259 |
260 // The displays currently attached to the device. | 260 // The displays currently attached to the device. |
261 std::vector<gfx::Display> displays_; | 261 std::vector<gfx::Display> displays_; |
262 | 262 |
263 // The timer to delay configuring outputs. See also the comments in | 263 // The timer to delay configuring outputs. See also the comments in |
264 // HandleDisplayReconfiguration(). | 264 // HandleDisplayReconfiguration(). |
265 scoped_ptr<base::OneShotTimer<ScreenMac> > configure_timer_; | 265 scoped_ptr<base::OneShotTimer> configure_timer_; |
266 | 266 |
267 gfx::DisplayChangeNotifier change_notifier_; | 267 gfx::DisplayChangeNotifier change_notifier_; |
268 | 268 |
269 DISALLOW_COPY_AND_ASSIGN(ScreenMac); | 269 DISALLOW_COPY_AND_ASSIGN(ScreenMac); |
270 }; | 270 }; |
271 | 271 |
272 } // namespace | 272 } // namespace |
273 | 273 |
274 namespace gfx { | 274 namespace gfx { |
275 | 275 |
276 #if !defined(USE_AURA) | 276 #if !defined(USE_AURA) |
277 Screen* CreateNativeScreen() { | 277 Screen* CreateNativeScreen() { |
278 return new ScreenMac; | 278 return new ScreenMac; |
279 } | 279 } |
280 #endif | 280 #endif |
281 | 281 |
282 } | 282 } |
OLD | NEW |