OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/host/ash_window_tree_host.h" | 5 #include "ash/host/ash_window_tree_host.h" |
6 | 6 |
7 #include "ash/ash_export.h" | 7 #include "ash/ash_export.h" |
8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
9 #include "ash/host/ash_remote_window_tree_host_win.h" | 9 #include "ash/host/ash_remote_window_tree_host_win.h" |
10 #include "ash/host/ash_window_tree_host_init_params.h" | 10 #include "ash/host/ash_window_tree_host_init_params.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class AshWindowTreeHostWin : public AshWindowTreeHost, | 22 class AshWindowTreeHostWin : public AshWindowTreeHost, |
23 public aura::WindowTreeHostWin { | 23 public aura::WindowTreeHostWin { |
24 public: | 24 public: |
25 explicit AshWindowTreeHostWin(const gfx::Rect& initial_bounds) | 25 explicit AshWindowTreeHostWin(const gfx::Rect& initial_bounds) |
26 : aura::WindowTreeHostWin(initial_bounds), | 26 : aura::WindowTreeHostWin(initial_bounds), |
27 fullscreen_(false), | 27 fullscreen_(false), |
28 saved_window_style_(0), | 28 saved_window_style_(0), |
29 saved_window_ex_style_(0), | 29 saved_window_ex_style_(0), |
30 transformer_helper_(this) {} | 30 transformer_helper_(this) {} |
31 virtual ~AshWindowTreeHostWin() {} | 31 ~AshWindowTreeHostWin() override {} |
32 | 32 |
33 private: | 33 private: |
34 // AshWindowTreeHost: | 34 // AshWindowTreeHost: |
35 virtual void ToggleFullScreen() override { | 35 void ToggleFullScreen() override { |
36 gfx::Rect target_rect; | 36 gfx::Rect target_rect; |
37 if (!fullscreen_) { | 37 if (!fullscreen_) { |
38 fullscreen_ = true; | 38 fullscreen_ = true; |
39 saved_window_style_ = GetWindowLong(hwnd(), GWL_STYLE); | 39 saved_window_style_ = GetWindowLong(hwnd(), GWL_STYLE); |
40 saved_window_ex_style_ = GetWindowLong(hwnd(), GWL_EXSTYLE); | 40 saved_window_ex_style_ = GetWindowLong(hwnd(), GWL_EXSTYLE); |
41 GetWindowRect(hwnd(), &saved_window_rect_); | 41 GetWindowRect(hwnd(), &saved_window_rect_); |
42 SetWindowLong(hwnd(), | 42 SetWindowLong(hwnd(), |
43 GWL_STYLE, | 43 GWL_STYLE, |
44 saved_window_style_ & ~(WS_CAPTION | WS_THICKFRAME)); | 44 saved_window_style_ & ~(WS_CAPTION | WS_THICKFRAME)); |
45 SetWindowLong( | 45 SetWindowLong( |
(...skipping 13 matching lines...) Expand all Loading... |
59 target_rect = gfx::Rect(saved_window_rect_); | 59 target_rect = gfx::Rect(saved_window_rect_); |
60 } | 60 } |
61 SetWindowPos(hwnd(), | 61 SetWindowPos(hwnd(), |
62 NULL, | 62 NULL, |
63 target_rect.x(), | 63 target_rect.x(), |
64 target_rect.y(), | 64 target_rect.y(), |
65 target_rect.width(), | 65 target_rect.width(), |
66 target_rect.height(), | 66 target_rect.height(), |
67 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); | 67 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); |
68 } | 68 } |
69 virtual bool ConfineCursorToRootWindow() override { return false; } | 69 bool ConfineCursorToRootWindow() override { return false; } |
70 virtual void UnConfineCursor() override { NOTIMPLEMENTED(); } | 70 void UnConfineCursor() override { NOTIMPLEMENTED(); } |
71 virtual void SetRootWindowTransformer( | 71 void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer) { |
72 scoped_ptr<RootWindowTransformer> transformer) { | |
73 transformer_helper_.SetRootWindowTransformer(transformer.Pass()); | 72 transformer_helper_.SetRootWindowTransformer(transformer.Pass()); |
74 } | 73 } |
75 virtual gfx::Insets GetHostInsets() const override { | 74 gfx::Insets GetHostInsets() const override { |
76 return transformer_helper_.GetHostInsets(); | 75 return transformer_helper_.GetHostInsets(); |
77 } | 76 } |
78 virtual aura::WindowTreeHost* AsWindowTreeHost() override { return this; } | 77 aura::WindowTreeHost* AsWindowTreeHost() override { return this; } |
79 | 78 |
80 // WindowTreeHostWin: | 79 // WindowTreeHostWin: |
81 virtual void SetBounds(const gfx::Rect& bounds) override { | 80 void SetBounds(const gfx::Rect& bounds) override { |
82 if (fullscreen_) { | 81 if (fullscreen_) { |
83 saved_window_rect_.right = saved_window_rect_.left + bounds.width(); | 82 saved_window_rect_.right = saved_window_rect_.left + bounds.width(); |
84 saved_window_rect_.bottom = saved_window_rect_.top + bounds.height(); | 83 saved_window_rect_.bottom = saved_window_rect_.top + bounds.height(); |
85 return; | 84 return; |
86 } | 85 } |
87 WindowTreeHostWin::SetBounds(bounds); | 86 WindowTreeHostWin::SetBounds(bounds); |
88 } | 87 } |
89 virtual void SetRootTransform(const gfx::Transform& transform) override { | 88 void SetRootTransform(const gfx::Transform& transform) override { |
90 transformer_helper_.SetTransform(transform); | 89 transformer_helper_.SetTransform(transform); |
91 } | 90 } |
92 gfx::Transform GetRootTransform() const { | 91 gfx::Transform GetRootTransform() const { |
93 return transformer_helper_.GetTransform(); | 92 return transformer_helper_.GetTransform(); |
94 } | 93 } |
95 virtual gfx::Transform GetInverseRootTransform() const override { | 94 gfx::Transform GetInverseRootTransform() const override { |
96 return transformer_helper_.GetInverseTransform(); | 95 return transformer_helper_.GetInverseTransform(); |
97 } | 96 } |
98 virtual void UpdateRootWindowSize(const gfx::Size& host_size) override { | 97 void UpdateRootWindowSize(const gfx::Size& host_size) override { |
99 transformer_helper_.UpdateWindowSize(host_size); | 98 transformer_helper_.UpdateWindowSize(host_size); |
100 } | 99 } |
101 | 100 |
102 bool fullscreen_; | 101 bool fullscreen_; |
103 RECT saved_window_rect_; | 102 RECT saved_window_rect_; |
104 DWORD saved_window_style_; | 103 DWORD saved_window_style_; |
105 DWORD saved_window_ex_style_; | 104 DWORD saved_window_ex_style_; |
106 | 105 |
107 TransformerHelper transformer_helper_; | 106 TransformerHelper transformer_helper_; |
108 | 107 |
109 DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostWin); | 108 DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostWin); |
110 }; | 109 }; |
111 | 110 |
112 } // namespace | 111 } // namespace |
113 | 112 |
114 AshWindowTreeHost* AshWindowTreeHost::Create( | 113 AshWindowTreeHost* AshWindowTreeHost::Create( |
115 const AshWindowTreeHostInitParams& init_params) { | 114 const AshWindowTreeHostInitParams& init_params) { |
116 if (base::win::GetVersion() >= base::win::VERSION_WIN7 && | 115 if (base::win::GetVersion() >= base::win::VERSION_WIN7 && |
117 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 116 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
118 ash::switches::kForceAshToDesktop)) | 117 ash::switches::kForceAshToDesktop)) |
119 return new AshRemoteWindowTreeHostWin(init_params.remote_hwnd); | 118 return new AshRemoteWindowTreeHostWin(init_params.remote_hwnd); |
120 | 119 |
121 return new AshWindowTreeHostWin(init_params.initial_bounds); | 120 return new AshWindowTreeHostWin(init_params.initial_bounds); |
122 } | 121 } |
123 | 122 |
124 } // namespace ash | 123 } // namespace ash |
OLD | NEW |