gfx: Remove dead-code related to color-profile.
[chromium-blink-merge.git] / ash / host / ash_window_tree_host_win.cc
blobe058599aa91737172485319164019880b2fb78c5
1 // Copyright 2014 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.
5 #include "ash/host/ash_window_tree_host.h"
7 #include "ash/ash_export.h"
8 #include "ash/ash_switches.h"
9 #include "ash/host/ash_remote_window_tree_host_win.h"
10 #include "ash/host/ash_window_tree_host_init_params.h"
11 #include "ash/host/root_window_transformer.h"
12 #include "ash/host/transformer_helper.h"
13 #include "base/command_line.h"
14 #include "base/win/windows_version.h"
15 #include "ui/aura/window_tree_host_win.h"
16 #include "ui/gfx/geometry/insets.h"
17 #include "ui/gfx/transform.h"
19 namespace ash {
20 namespace {
22 class AshWindowTreeHostWin : public AshWindowTreeHost,
23 public aura::WindowTreeHostWin {
24 public:
25 explicit AshWindowTreeHostWin(const gfx::Rect& initial_bounds)
26 : aura::WindowTreeHostWin(initial_bounds),
27 fullscreen_(false),
28 saved_window_style_(0),
29 saved_window_ex_style_(0),
30 transformer_helper_(this) {
31 transformer_helper_.Init();
33 ~AshWindowTreeHostWin() override {}
35 private:
36 // AshWindowTreeHost:
37 void ToggleFullScreen() override {
38 gfx::Rect target_rect;
39 if (!fullscreen_) {
40 fullscreen_ = true;
41 saved_window_style_ = GetWindowLong(hwnd(), GWL_STYLE);
42 saved_window_ex_style_ = GetWindowLong(hwnd(), GWL_EXSTYLE);
43 GetWindowRect(hwnd(), &saved_window_rect_);
44 SetWindowLong(hwnd(),
45 GWL_STYLE,
46 saved_window_style_ & ~(WS_CAPTION | WS_THICKFRAME));
47 SetWindowLong(
48 hwnd(),
49 GWL_EXSTYLE,
50 saved_window_ex_style_ & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE |
51 WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
53 MONITORINFO mi;
54 mi.cbSize = sizeof(mi);
55 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST), &mi);
56 target_rect = gfx::Rect(mi.rcMonitor);
57 } else {
58 fullscreen_ = false;
59 SetWindowLong(hwnd(), GWL_STYLE, saved_window_style_);
60 SetWindowLong(hwnd(), GWL_EXSTYLE, saved_window_ex_style_);
61 target_rect = gfx::Rect(saved_window_rect_);
63 SetWindowPos(hwnd(),
64 NULL,
65 target_rect.x(),
66 target_rect.y(),
67 target_rect.width(),
68 target_rect.height(),
69 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
71 bool ConfineCursorToRootWindow() override { return false; }
72 void UnConfineCursor() override { NOTIMPLEMENTED(); }
73 void SetRootWindowTransformer(
74 scoped_ptr<RootWindowTransformer> transformer) override {
75 transformer_helper_.SetRootWindowTransformer(transformer.Pass());
77 gfx::Insets GetHostInsets() const override {
78 return transformer_helper_.GetHostInsets();
80 aura::WindowTreeHost* AsWindowTreeHost() override { return this; }
82 // WindowTreeHostWin:
83 void SetBounds(const gfx::Rect& bounds) override {
84 if (fullscreen_) {
85 saved_window_rect_.right = saved_window_rect_.left + bounds.width();
86 saved_window_rect_.bottom = saved_window_rect_.top + bounds.height();
87 return;
89 WindowTreeHostWin::SetBounds(bounds);
91 void SetRootTransform(const gfx::Transform& transform) override {
92 transformer_helper_.SetTransform(transform);
94 gfx::Transform GetRootTransform() const override {
95 return transformer_helper_.GetTransform();
97 gfx::Transform GetInverseRootTransform() const override {
98 return transformer_helper_.GetInverseTransform();
100 void UpdateRootWindowSize(const gfx::Size& host_size) override {
101 transformer_helper_.UpdateWindowSize(host_size);
104 bool fullscreen_;
105 RECT saved_window_rect_;
106 DWORD saved_window_style_;
107 DWORD saved_window_ex_style_;
109 TransformerHelper transformer_helper_;
111 DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostWin);
114 } // namespace
116 AshWindowTreeHost* AshWindowTreeHost::Create(
117 const AshWindowTreeHostInitParams& init_params) {
118 if (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
119 !base::CommandLine::ForCurrentProcess()->HasSwitch(
120 ash::switches::kForceAshToDesktop))
121 return new AshRemoteWindowTreeHostWin(init_params.remote_hwnd);
123 return new AshWindowTreeHostWin(init_params.initial_bounds);
126 } // namespace ash