| 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 "remoting/host/desktop_resizer.h" | 5 #include "remoting/host/desktop_resizer.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return; | 140 return; |
| 141 | 141 |
| 142 DEVMODE new_mode = best_mode_for_resolution_[resolution]; | 142 DEVMODE new_mode = best_mode_for_resolution_[resolution]; |
| 143 DWORD result = ChangeDisplaySettings(&new_mode, CDS_FULLSCREEN); | 143 DWORD result = ChangeDisplaySettings(&new_mode, CDS_FULLSCREEN); |
| 144 if (result != DISP_CHANGE_SUCCESSFUL) | 144 if (result != DISP_CHANGE_SUCCESSFUL) |
| 145 LOG(ERROR) << "SetResolution failed: " << result; | 145 LOG(ERROR) << "SetResolution failed: " << result; |
| 146 } | 146 } |
| 147 | 147 |
| 148 void DesktopResizerWin::RestoreResolution(const ScreenResolution& original) { | 148 void DesktopResizerWin::RestoreResolution(const ScreenResolution& original) { |
| 149 // Restore the display mode based on the registry configuration. | 149 // Restore the display mode based on the registry configuration. |
| 150 DWORD result = ChangeDisplaySettings(NULL, 0); | 150 DWORD result = ChangeDisplaySettings(nullptr, 0); |
| 151 if (result != DISP_CHANGE_SUCCESSFUL) | 151 if (result != DISP_CHANGE_SUCCESSFUL) |
| 152 LOG(ERROR) << "RestoreResolution failed: " << result; | 152 LOG(ERROR) << "RestoreResolution failed: " << result; |
| 153 } | 153 } |
| 154 | 154 |
| 155 // static | 155 // static |
| 156 bool DesktopResizerWin::IsResizeSupported() { | 156 bool DesktopResizerWin::IsResizeSupported() { |
| 157 // Resize is supported only on single-monitor systems. | 157 // Resize is supported only on single-monitor systems. |
| 158 return GetSystemMetrics(SM_CMONITORS) == 1; | 158 return GetSystemMetrics(SM_CMONITORS) == 1; |
| 159 } | 159 } |
| 160 | 160 |
| 161 // static | 161 // static |
| 162 bool DesktopResizerWin::GetPrimaryDisplayMode( | 162 bool DesktopResizerWin::GetPrimaryDisplayMode( |
| 163 DWORD mode_number, DWORD flags, DEVMODE* mode) { | 163 DWORD mode_number, DWORD flags, DEVMODE* mode) { |
| 164 memset(mode, 0, sizeof(DEVMODE)); | 164 memset(mode, 0, sizeof(DEVMODE)); |
| 165 mode->dmSize = sizeof(DEVMODE); | 165 mode->dmSize = sizeof(DEVMODE); |
| 166 if (!EnumDisplaySettingsEx(NULL, mode_number, mode, flags)) | 166 if (!EnumDisplaySettingsEx(nullptr, mode_number, mode, flags)) |
| 167 return false; | 167 return false; |
| 168 return true; | 168 return true; |
| 169 } | 169 } |
| 170 | 170 |
| 171 // static | 171 // static |
| 172 bool DesktopResizerWin::IsModeValid(const DEVMODE& mode) { | 172 bool DesktopResizerWin::IsModeValid(const DEVMODE& mode) { |
| 173 const DWORD kRequiredFields = | 173 const DWORD kRequiredFields = |
| 174 DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | | 174 DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | |
| 175 DM_DISPLAYFREQUENCY | DM_DISPLAYORIENTATION; | 175 DM_DISPLAYFREQUENCY | DM_DISPLAYORIENTATION; |
| 176 return (mode.dmFields & kRequiredFields) == kRequiredFields; | 176 return (mode.dmFields & kRequiredFields) == kRequiredFields; |
| 177 } | 177 } |
| 178 | 178 |
| 179 // static | 179 // static |
| 180 ScreenResolution DesktopResizerWin::GetModeResolution(const DEVMODE& mode) { | 180 ScreenResolution DesktopResizerWin::GetModeResolution(const DEVMODE& mode) { |
| 181 DCHECK(IsModeValid(mode)); | 181 DCHECK(IsModeValid(mode)); |
| 182 return ScreenResolution( | 182 return ScreenResolution( |
| 183 webrtc::DesktopSize(mode.dmPelsWidth, mode.dmPelsHeight), | 183 webrtc::DesktopSize(mode.dmPelsWidth, mode.dmPelsHeight), |
| 184 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); | 184 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); |
| 185 } | 185 } |
| 186 | 186 |
| 187 scoped_ptr<DesktopResizer> DesktopResizer::Create() { | 187 scoped_ptr<DesktopResizer> DesktopResizer::Create() { |
| 188 return make_scoped_ptr(new DesktopResizerWin); | 188 return make_scoped_ptr(new DesktopResizerWin); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace remoting | 191 } // namespace remoting |
| OLD | NEW |