OLD | NEW |
| (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_win.h" | |
6 | |
7 #include "base/win/windows_version.h" | |
8 | |
9 namespace ash { | |
10 | |
11 AshWindowTreeHostWin::AshWindowTreeHostWin(const gfx::Rect& initial_bounds) | |
12 : AshWindowTreeHostPlatform(initial_bounds), | |
13 fullscreen_(false), | |
14 saved_window_style_(0), | |
15 saved_window_ex_style_(0) {} | |
16 | |
17 AshWindowTreeHostWin::~AshWindowTreeHostWin() {} | |
18 | |
19 void AshWindowTreeHostWin::ToggleFullScreen() { | |
20 gfx::Rect target_rect; | |
21 gfx::AcceleratedWidget hwnd = GetAcceleratedWidget(); | |
22 if (!fullscreen_) { | |
23 fullscreen_ = true; | |
24 saved_window_style_ = GetWindowLong(hwnd, GWL_STYLE); | |
25 saved_window_ex_style_ = GetWindowLong(hwnd, GWL_EXSTYLE); | |
26 GetWindowRect(hwnd, &saved_window_rect_); | |
27 SetWindowLong(hwnd, GWL_STYLE, | |
28 saved_window_style_ & ~(WS_CAPTION | WS_THICKFRAME)); | |
29 SetWindowLong(hwnd, GWL_EXSTYLE, | |
30 saved_window_ex_style_ & | |
31 ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | | |
32 WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); | |
33 | |
34 MONITORINFO mi; | |
35 mi.cbSize = sizeof(mi); | |
36 GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), &mi); | |
37 target_rect = gfx::Rect(mi.rcMonitor); | |
38 } else { | |
39 fullscreen_ = false; | |
40 SetWindowLong(hwnd, GWL_STYLE, saved_window_style_); | |
41 SetWindowLong(hwnd, GWL_EXSTYLE, saved_window_ex_style_); | |
42 target_rect = gfx::Rect(saved_window_rect_); | |
43 } | |
44 SetWindowPos(hwnd, NULL, target_rect.x(), target_rect.y(), | |
45 target_rect.width(), target_rect.height(), | |
46 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); | |
47 } | |
48 | |
49 void AshWindowTreeHostWin::SetBoundsInPixels(const gfx::Rect& bounds) { | |
50 if (fullscreen_) { | |
51 saved_window_rect_.right = saved_window_rect_.left + bounds.width(); | |
52 saved_window_rect_.bottom = saved_window_rect_.top + bounds.height(); | |
53 return; | |
54 } | |
55 AshWindowTreeHostPlatform::SetBoundsInPixels(bounds); | |
56 } | |
57 | |
58 } // namespace ash | |
OLD | NEW |