OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/host/desktop_resizer.h" |
| 6 |
| 7 namespace remoting { |
| 8 |
| 9 DesktopResizer::~DesktopResizer() { |
| 10 } |
| 11 |
| 12 DesktopResizer::HostStatusObserver::HostStatusObserver( |
| 13 DesktopResizer* desktop_resizer) |
| 14 : desktop_resizer_(desktop_resizer), |
| 15 original_size_(SkISize::Make(0, 0)) { |
| 16 } |
| 17 |
| 18 DesktopResizer::HostStatusObserver::~HostStatusObserver() { |
| 19 } |
| 20 |
| 21 void DesktopResizer::HostStatusObserver::OnClientAuthenticated( |
| 22 const std::string& jid) { |
| 23 original_size_ = desktop_resizer_->GetSize(); |
| 24 } |
| 25 |
| 26 void DesktopResizer::HostStatusObserver::OnClientDisconnected( |
| 27 const std::string& jid) { |
| 28 if (!original_size_.isZero()) { |
| 29 desktop_resizer_->SetSize(original_size_); |
| 30 original_size_.set(0, 0); |
| 31 } |
| 32 } |
| 33 |
| 34 void DesktopResizer::HostStatusObserver::OnClientDimensionsChanged( |
| 35 const SkISize& size) { |
| 36 // Set a sensible minimum size for the host desktop. Note that the |
| 37 // implementation is free to impose a stricter minimum size and/or |
| 38 // a maximum size in addition to this. |
| 39 const int kMinWidth = 640; |
| 40 const int kMinHeight = 480; |
| 41 SkISize new_size(SkISize::Make(std::max(kMinWidth, size.width()), |
| 42 std::max(kMinHeight, size.height()))); |
| 43 desktop_resizer_->SetSize(new_size); |
| 44 } |
| 45 |
| 46 } // namespace remoting |
OLD | NEW |