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

Side by Side Diff: ui/views/win/fullscreen_handler.cc

Issue 2972963004: Another attempt at fixing the fullscreen issues with Chrome. (Closed)
Patch Set: Rephrase comment Created 3 years, 5 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
« no previous file with comments | « ui/views/win/fullscreen_handler.h ('k') | no next file » | no next file with comments »
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 "ui/views/win/fullscreen_handler.h" 5 #include "ui/views/win/fullscreen_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/win/win_util.h" 10 #include "base/win/win_util.h"
11 #include "ui/base/win/shell.h" 11 #include "ui/base/win/shell.h"
12 #include "ui/gfx/geometry/rect.h" 12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/views/win/scoped_fullscreen_visibility.h" 13 #include "ui/views/win/scoped_fullscreen_visibility.h"
14 14
15 namespace views { 15 namespace views {
16 16
17 //////////////////////////////////////////////////////////////////////////////// 17 ////////////////////////////////////////////////////////////////////////////////
18 // FullscreenHandler, public: 18 // FullscreenHandler, public:
19 19
20 FullscreenHandler::FullscreenHandler() : hwnd_(NULL), fullscreen_(false) {} 20 FullscreenHandler::FullscreenHandler() : hwnd_(NULL), fullscreen_(false) {}
21 21
22 FullscreenHandler::~FullscreenHandler() { 22 FullscreenHandler::~FullscreenHandler() {
23 } 23 }
24 24
25 void FullscreenHandler::SetFullscreen(bool fullscreen) { 25 void FullscreenHandler::SetFullscreen(bool fullscreen) {
26 if (fullscreen_ == fullscreen) 26 if (fullscreen_ == fullscreen)
27 return; 27 return;
28 28
29 if (!task_bar_list_) {
msw 2017/07/06 18:32:55 It's a little odd to init the value here and use i
ananta 2017/07/06 18:44:51 Thanks. I moved this block to the SetFullscreenImp
30 HRESULT hr = ::CoCreateInstance(CLSID_TaskbarList, NULL,
31 CLSCTX_INPROC_SERVER,
32 IID_PPV_ARGS(&task_bar_list_));
33 CHECK(SUCCEEDED(hr));
34 }
35
29 SetFullscreenImpl(fullscreen); 36 SetFullscreenImpl(fullscreen);
30 } 37 }
31 38
32 gfx::Rect FullscreenHandler::GetRestoreBounds() const { 39 gfx::Rect FullscreenHandler::GetRestoreBounds() const {
33 return gfx::Rect(saved_window_info_.window_rect); 40 return gfx::Rect(saved_window_info_.window_rect);
34 } 41 }
35 42
36 //////////////////////////////////////////////////////////////////////////////// 43 ////////////////////////////////////////////////////////////////////////////////
37 // FullscreenHandler, private: 44 // FullscreenHandler, private:
38 45
(...skipping 25 matching lines...) Expand all
64 71
65 // On expand, if we're given a window_rect, grow to it, otherwise do 72 // On expand, if we're given a window_rect, grow to it, otherwise do
66 // not resize. 73 // not resize.
67 MONITORINFO monitor_info; 74 MONITORINFO monitor_info;
68 monitor_info.cbSize = sizeof(monitor_info); 75 monitor_info.cbSize = sizeof(monitor_info);
69 GetMonitorInfo(MonitorFromWindow(hwnd_, MONITOR_DEFAULTTONEAREST), 76 GetMonitorInfo(MonitorFromWindow(hwnd_, MONITOR_DEFAULTTONEAREST),
70 &monitor_info); 77 &monitor_info);
71 gfx::Rect window_rect(monitor_info.rcMonitor); 78 gfx::Rect window_rect(monitor_info.rcMonitor);
72 SetWindowPos(hwnd_, NULL, window_rect.x(), window_rect.y(), 79 SetWindowPos(hwnd_, NULL, window_rect.x(), window_rect.y(),
73 window_rect.width(), window_rect.height(), 80 window_rect.width(), window_rect.height(),
74 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); 81 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
msw 2017/07/06 18:32:55 q: Maybe these args let windows enter fullscreen w
ananta 2017/07/06 18:44:51 The window should be active when we enter this fun
75 } else { 82 } else {
76 // Reset original window style and size. The multiple window size/moves 83 // Reset original window style and size. The multiple window size/moves
77 // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be 84 // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
78 // repainted. Better-looking methods welcome. 85 // repainted. Better-looking methods welcome.
79 SetWindowLong(hwnd_, GWL_STYLE, saved_window_info_.style); 86 SetWindowLong(hwnd_, GWL_STYLE, saved_window_info_.style);
80 SetWindowLong(hwnd_, GWL_EXSTYLE, saved_window_info_.ex_style); 87 SetWindowLong(hwnd_, GWL_EXSTYLE, saved_window_info_.ex_style);
81 88
82 // On restore, resize to the previous saved rect size. 89 // On restore, resize to the previous saved rect size.
83 gfx::Rect new_rect(saved_window_info_.window_rect); 90 gfx::Rect new_rect(saved_window_info_.window_rect);
84 SetWindowPos(hwnd_, NULL, new_rect.x(), new_rect.y(), new_rect.width(), 91 SetWindowPos(hwnd_, NULL, new_rect.x(), new_rect.y(), new_rect.width(),
85 new_rect.height(), 92 new_rect.height(),
86 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); 93 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
87 } 94 }
msw 2017/07/06 18:32:55 nit: add a blank line after this
ananta 2017/07/06 18:44:51 Done.
95 // As per msdn marking the window as fullscreen should ensure that the
msw 2017/07/06 18:32:55 nit: capitalize 'MSDN'
ananta 2017/07/06 18:44:51 Done.
96 // taskbar is moved to the bottom of the Z order when the fullscreen window
msw 2017/07/06 18:32:55 nit: hyphenate 'Z-order'
ananta 2017/07/06 18:44:51 Done.
97 // is activated. If the window is not fullscreen the Shell fallsback to
msw 2017/07/06 18:32:55 nits: comma after 'fullscreen,' and split words 'f
ananta 2017/07/06 18:44:51 Done.
98 // heuristics to determine how the window should be treated, which means
99 // that it could still consider the window as fullscreen. :(
100 task_bar_list_->MarkFullscreenWindow(hwnd_, !!fullscreen);
msw 2017/07/06 18:32:55 As this only moves the taskbar to the bottom of th
ananta 2017/07/06 18:44:51 I think the reason we use SWP_NOACTIVATE is to avo
88 } 101 }
89 102
90 } // namespace views 103 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/win/fullscreen_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698