Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: ash/accelerators/accelerator_controller.cc

Issue 21297003: Add ability to set resolution on external display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | ash/display/display_change_observer_x11.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/accelerators/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <iostream> 9 #include <iostream>
10 #include <string> 10 #include <string>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "ui/oak/oak.h" 64 #include "ui/oak/oak.h"
65 #include "ui/views/controls/webview/webview.h" 65 #include "ui/views/controls/webview/webview.h"
66 #include "ui/views/debug_utils.h" 66 #include "ui/views/debug_utils.h"
67 #include "ui/views/widget/widget.h" 67 #include "ui/views/widget/widget.h"
68 68
69 #if defined(OS_CHROMEOS) 69 #if defined(OS_CHROMEOS)
70 #include "ash/system/chromeos/keyboard_brightness_controller.h" 70 #include "ash/system/chromeos/keyboard_brightness_controller.h"
71 #include "base/chromeos/chromeos_version.h" 71 #include "base/chromeos/chromeos_version.h"
72 #endif // defined(OS_CHROMEOS) 72 #endif // defined(OS_CHROMEOS)
73 73
74 #include "ash/display/display_info.h"
oshima 2013/07/31 16:39:11 Changes in this file is just for my testing and I'
Daniel Erat 2013/07/31 17:34:05 am i misunderstanding? the change in e.g. HandleSc
oshima 2013/07/31 21:59:49 Sorry if it wasn't clear enough. It was for me to
75
74 namespace ash { 76 namespace ash {
75 namespace { 77 namespace {
76 78
77 using internal::DisplayInfo; 79 using internal::DisplayInfo;
78 80
79 bool DebugShortcutsEnabled() { 81 bool DebugShortcutsEnabled() {
80 #if defined(NDEBUG) 82 #if defined(NDEBUG)
81 return CommandLine::ForCurrentProcess()->HasSwitch( 83 return CommandLine::ForCurrentProcess()->HasSwitch(
82 switches::kAshDebugShortcuts); 84 switches::kAshDebugShortcuts);
83 #else 85 #else
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 switch (current) { 188 switch (current) {
187 case gfx::Display::ROTATE_0: 189 case gfx::Display::ROTATE_0:
188 return gfx::Display::ROTATE_90; 190 return gfx::Display::ROTATE_90;
189 case gfx::Display::ROTATE_90: 191 case gfx::Display::ROTATE_90:
190 return gfx::Display::ROTATE_180; 192 return gfx::Display::ROTATE_180;
191 case gfx::Display::ROTATE_180: 193 case gfx::Display::ROTATE_180:
192 return gfx::Display::ROTATE_270; 194 return gfx::Display::ROTATE_270;
193 case gfx::Display::ROTATE_270: 195 case gfx::Display::ROTATE_270:
194 return gfx::Display::ROTATE_0; 196 return gfx::Display::ROTATE_0;
195 } 197 }
196 NOTREACHED() << "Unknown rotation:" << current; 198 NOTREACHED() << "Unknown rotatgion:" << current;
Daniel Erat 2013/07/31 17:34:05 nit: s/rotatgion/rotation/
197 return gfx::Display::ROTATE_0; 199 return gfx::Display::ROTATE_0;
198 } 200 }
199 201
202 const gfx::Size& FindNextResolution(
203 const std::vector<internal::Resolution>& resolutions,
204 const gfx::Size& current_resolution) {
205 std::vector<internal::Resolution>::const_iterator iter =
206 resolutions.begin();
207 for (; iter != resolutions.end(); ++iter) {
208 if (iter->size == current_resolution) {
209 ++iter;
210 break;
211 }
212 }
213 if (iter == resolutions.end())
214 return resolutions[0].size;
215 else
216 return iter->size;
217 }
218
200 bool HandleScaleUI(bool up) { 219 bool HandleScaleUI(bool up) {
201 internal::DisplayManager* display_manager = 220 internal::DisplayManager* display_manager =
202 Shell::GetInstance()->display_manager(); 221 Shell::GetInstance()->display_manager();
222
223 gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint();
224 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point);
225 if (!display.IsInternal()) {
226 const DisplayInfo& info = display_manager->GetDisplayInfo(display.id());
227 if (info.resolutions().empty()) {
228 LOG(ERROR) << "No resolution found:";
229 return false;
230 }
231 const gfx::Size& next_resolution =
232 FindNextResolution(info.resolutions(), info.bounds_in_pixel().size());
233 display_manager->SetDisplayResolution(display.id(), next_resolution);
234 return true;
235 }
236
203 int64 display_id = display_manager->GetDisplayIdForUIScaling(); 237 int64 display_id = display_manager->GetDisplayIdForUIScaling();
204 if (display_id == gfx::Display::kInvalidDisplayID) 238 if (display_id == gfx::Display::kInvalidDisplayID)
205 return false; 239 return false;
206 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); 240 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id);
207 float next_scale = 241 float next_scale =
208 internal::DisplayManager::GetNextUIScale(display_info, up); 242 internal::DisplayManager::GetNextUIScale(display_info, up);
209 display_manager->SetDisplayUIScale(display_id, next_scale); 243 display_manager->SetDisplayUIScale(display_id, next_scale);
210 return true; 244 return true;
211 } 245 }
212 246
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 keyboard_brightness_control_delegate) { 1002 keyboard_brightness_control_delegate) {
969 keyboard_brightness_control_delegate_ = 1003 keyboard_brightness_control_delegate_ =
970 keyboard_brightness_control_delegate.Pass(); 1004 keyboard_brightness_control_delegate.Pass();
971 } 1005 }
972 1006
973 bool AcceleratorController::CanHandleAccelerators() const { 1007 bool AcceleratorController::CanHandleAccelerators() const {
974 return true; 1008 return true;
975 } 1009 }
976 1010
977 } // namespace ash 1011 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | ash/display/display_change_observer_x11.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698