| Index: ui/views/widget/native_widget_win.cc
|
| diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
|
| index a9499f3467f34035d046443bdd2739386e7adf2b..c7c11aaae241925b8ae9870822f3ff86f15a7f78 100644
|
| --- a/ui/views/widget/native_widget_win.cc
|
| +++ b/ui/views/widget/native_widget_win.cc
|
| @@ -984,7 +984,40 @@ void NativeWidgetWin::Restore() {
|
|
|
| void NativeWidgetWin::SetFullscreen(bool fullscreen) {
|
| if (fullscreen_ == fullscreen)
|
| - return; // Nothing to do.
|
| + return;
|
| +
|
| + gfx::Rect window_rect;
|
| + if (fullscreen) {
|
| + MONITORINFO monitor_info;
|
| + monitor_info.cbSize = sizeof(monitor_info);
|
| + GetMonitorInfo(MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST),
|
| + &monitor_info);
|
| + window_rect = monitor_info.rcMonitor;
|
| + }
|
| +
|
| + SetFullscreenInternal(fullscreen, window_rect);
|
| +}
|
| +
|
| +void NativeWidgetWin::SetMetroSnapFullscreen(bool metro_snap) {
|
| + if (metro_snap_ == metro_snap)
|
| + return;
|
| +
|
| + metro_snap_ = metro_snap;
|
| +
|
| + gfx::Rect window_rect;
|
| + if (!metro_snap) {
|
| + MONITORINFO monitor_info;
|
| + monitor_info.cbSize = sizeof(monitor_info);
|
| + GetMonitorInfo(MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST),
|
| + &monitor_info);
|
| + window_rect = monitor_info.rcMonitor;
|
| + }
|
| +
|
| + SetFullscreenInternal(metro_snap, window_rect);
|
| +}
|
| +
|
| +void NativeWidgetWin::SetFullscreenInternal(bool fullscreen,
|
| + const gfx::Rect& window_rect) {
|
|
|
| // Reduce jankiness during the following position changes by hiding the window
|
| // until it's in the final position.
|
| @@ -1007,26 +1040,35 @@ void NativeWidgetWin::SetFullscreen(bool fullscreen) {
|
|
|
| if (fullscreen_) {
|
| // Set new window style and size.
|
| - MONITORINFO monitor_info;
|
| - monitor_info.cbSize = sizeof(monitor_info);
|
| - GetMonitorInfo(MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST),
|
| - &monitor_info);
|
| - gfx::Rect monitor_rect(monitor_info.rcMonitor);
|
| SetWindowLong(GWL_STYLE,
|
| saved_window_info_.style & ~(WS_CAPTION | WS_THICKFRAME));
|
| SetWindowLong(GWL_EXSTYLE,
|
| saved_window_info_.ex_style & ~(WS_EX_DLGMODALFRAME |
|
| WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
|
| - SetWindowPos(NULL, monitor_rect.x(), monitor_rect.y(),
|
| - monitor_rect.width(), monitor_rect.height(),
|
| - SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
| +
|
| + // On expand, if we're given a window_rect, grow to it, otherwise do
|
| + // not resize.
|
| + if (window_rect.width() > 0) {
|
| + SetWindowPos(NULL, window_rect.x(), window_rect.y(),
|
| + window_rect.width(), window_rect.height(),
|
| + SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
| + }
|
| } else {
|
| // Reset original window style and size. The multiple window size/moves
|
| // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
|
| // repainted. Better-looking methods welcome.
|
| - gfx::Rect new_rect(saved_window_info_.window_rect);
|
| SetWindowLong(GWL_STYLE, saved_window_info_.style);
|
| SetWindowLong(GWL_EXSTYLE, saved_window_info_.ex_style);
|
| +
|
| + // On restore, if we're given a window_rect resize to that, otherwise
|
| + // resize to the previous saved rect size.
|
| + gfx::Rect new_rect;
|
| + if (window_rect.width() > 0) {
|
| + new_rect = window_rect;
|
| + } else {
|
| + new_rect = saved_window_info_.window_rect;
|
| + }
|
| +
|
| SetWindowPos(NULL, new_rect.x(), new_rect.y(), new_rect.width(),
|
| new_rect.height(),
|
| SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
| @@ -2101,9 +2143,10 @@ void NativeWidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) {
|
| gfx::Rect monitor_rect, work_area;
|
| if (GetWindowRect(&window_rect) &&
|
| GetMonitorAndRects(window_rect, &monitor, &monitor_rect, &work_area)) {
|
| + bool work_area_changed = (monitor_rect == last_monitor_rect_) &&
|
| + (work_area != last_work_area_);
|
| if (monitor && (monitor == last_monitor_) &&
|
| - (IsFullscreen() || ((monitor_rect == last_monitor_rect_) &&
|
| - (work_area != last_work_area_)))) {
|
| + ((IsFullscreen() && !metro_snap_) || work_area_changed)) {
|
| // A rect for the monitor we're on changed. Normally Windows notifies
|
| // us about this (and thus we're reaching here due to the SetWindowPos()
|
| // call in OnSettingChange() above), but with some software (e.g.
|
|
|