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

Side by Side Diff: ash/host/ash_window_tree_host_win.cc

Issue 201573015: Introdcue AshWindowTreeHost and move ash/chrome specific code in WTH to ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 8 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
OLDNEW
(Empty)
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.
4
5 #include "ash/host/ash_window_tree_host.h"
6
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/root_window_transformer.h"
11 #include "ash/host/transformer_helper.h"
12 #include "base/command_line.h"
13 #include "base/win/windows_version.h"
14 #include "ui/aura/window_tree_host_win.h"
15 #include "ui/gfx/geometry/insets.h"
16 #include "ui/gfx/transform.h"
17
18 namespace ash {
19 namespace {
20
21 class ASH_EXPORT AshWindowTreeHostWin : public AshWindowTreeHost,
22 public aura::WindowTreeHostWin {
23 public:
24 explicit AshWindowTreeHostWin(const gfx::Rect& initial_bounds)
25 : aura::WindowTreeHostWin(initial_bounds),
26 fullscreen_(false),
27 saved_window_style_(0),
28 saved_window_ex_style_(0),
29 transformer_helper_(this) {}
30 virtual ~AshWindowTreeHostWin() {}
31
32 // AshWindowTreeHost:
Ben Goodger (Google) 2014/04/09 22:41:49 since you never refer to this type directly, these
oshima 2014/04/09 23:52:15 Done.
33 virtual void ToggleFullScreen() OVERRIDE {
34 gfx::Rect target_rect;
35 if (!fullscreen_) {
36 fullscreen_ = true;
37 saved_window_style_ = GetWindowLong(hwnd(), GWL_STYLE);
38 saved_window_ex_style_ = GetWindowLong(hwnd(), GWL_EXSTYLE);
39 GetWindowRect(hwnd(), &saved_window_rect_);
40 SetWindowLong(hwnd(),
41 GWL_STYLE,
42 saved_window_style_ & ~(WS_CAPTION | WS_THICKFRAME));
43 SetWindowLong(
44 hwnd(),
45 GWL_EXSTYLE,
46 saved_window_ex_style_ & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE |
47 WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
48
49 MONITORINFO mi;
50 mi.cbSize = sizeof(mi);
51 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST), &mi);
52 target_rect = gfx::Rect(mi.rcMonitor);
53 } else {
54 fullscreen_ = false;
55 SetWindowLong(hwnd(), GWL_STYLE, saved_window_style_);
56 SetWindowLong(hwnd(), GWL_EXSTYLE, saved_window_ex_style_);
57 target_rect = gfx::Rect(saved_window_rect_);
58 }
59 SetWindowPos(hwnd(),
60 NULL,
61 target_rect.x(),
62 target_rect.y(),
63 target_rect.width(),
64 target_rect.height(),
65 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
66 }
67 virtual bool ConfineCursorToRootWindow() OVERRIDE { return false; }
68 virtual void UnConfineCursor() OVERRIDE { NOTIMPLEMENTED(); }
69 virtual void SetRootWindowTransformer(
70 scoped_ptr<RootWindowTransformer> transformer) {
71 transformer_helper_.SetRootWindowTransformer(transformer.Pass());
72 }
73 virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE { return this; }
74
75 // WindowTreeHostWin:
76 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE {
77 if (fullscreen_) {
78 saved_window_rect_.right = saved_window_rect_.left + bounds.width();
79 saved_window_rect_.bottom = saved_window_rect_.top + bounds.height();
80 return;
81 }
82 WindowTreeHostWin::SetBounds(bounds);
83 }
84 virtual void SetRootTransform(const gfx::Transform& transform) OVERRIDE {
85 transformer_helper_.SetTransform(transform);
86 }
87 gfx::Transform GetRootTransform() const {
88 return transformer_helper_.GetTransform();
89 }
90 virtual gfx::Transform GetInverseRootTransform() const OVERRIDE {
91 return transformer_helper_.GetInverseTransform();
92 }
93 virtual void UpdateRootWindowSize(const gfx::Size& host_size) OVERRIDE {
94 transformer_helper_.UpdateWindowSize(host_size);
95 }
96
97 private:
98 bool fullscreen_;
99 RECT saved_window_rect_;
100 DWORD saved_window_style_;
101 DWORD saved_window_ex_style_;
102
103 TransformerHelper transformer_helper_;
104
105 DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostWin);
106 };
107
108 } // namespace
109
110 AshWindowTreeHost* AshWindowTreeHost::Create(const gfx::Rect& initial_bounds) {
111 if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
112 !CommandLine::ForCurrentProcess()->HasSwitch(
113 ash::switches::kForceAshToDesktop))
114 return AshRemoteWindowTreeHostWin::GetInstance();
115
116 return new AshWindowTreeHostWin(initial_bounds);
117 }
118
119 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698