Chromium Code Reviews| Index: remoting/host/desktop_resizer.cc |
| diff --git a/remoting/host/desktop_resizer.cc b/remoting/host/desktop_resizer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..16ad67b50c16bfb50d864b096b0df10f70c191c0 |
| --- /dev/null |
| +++ b/remoting/host/desktop_resizer.cc |
| @@ -0,0 +1,46 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "remoting/host/desktop_resizer.h" |
| + |
| +namespace remoting { |
| + |
| +DesktopResizer::~DesktopResizer() { |
| +} |
| + |
| +DesktopResizer::HostStatusObserver::HostStatusObserver( |
| + DesktopResizer* desktop_resizer) |
| + : desktop_resizer_(desktop_resizer), |
| + original_size_(SkISize::Make(0, 0)) { |
| +} |
| + |
| +DesktopResizer::HostStatusObserver::~HostStatusObserver() { |
| +} |
| + |
| +void DesktopResizer::HostStatusObserver::OnClientAuthenticated( |
| + const std::string& jid) { |
| + original_size_ = desktop_resizer_->GetSize(); |
| +} |
| + |
| +void DesktopResizer::HostStatusObserver::OnClientDisconnected( |
| + const std::string& jid) { |
| + if (!original_size_.isZero()) { |
| + desktop_resizer_->SetSize(original_size_); |
|
Wez
2012/09/15 22:39:08
What happens if the user resizes the desktop thems
Jamie
2012/09/19 22:35:07
I think it makes more sense to restore the pre-con
|
| + original_size_.set(0, 0); |
| + } |
| +} |
| + |
| +void DesktopResizer::HostStatusObserver::OnClientDimensionsChanged( |
| + const SkISize& size) { |
|
Wez
2012/09/15 22:39:08
nit: With the client JID passed to this function y
Jamie
2012/09/19 22:35:07
Done.
|
| + // Set a sensible minimum size for the host desktop. Note that the |
| + // implementation is free to impose a stricter minimum size and/or |
| + // a maximum size in addition to this. |
| + const int kMinWidth = 640; |
| + const int kMinHeight = 480; |
| + SkISize new_size(SkISize::Make(std::max(kMinWidth, size.width()), |
| + std::max(kMinHeight, size.height()))); |
| + desktop_resizer_->SetSize(new_size); |
| +} |
| + |
| +} // namespace remoting |