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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc

Issue 1707233002: Reduce the fullscreen window height by 1px on activation loss. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments Created 4 years, 10 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
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/widget/desktop_aura/desktop_window_tree_host_win.h" 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
6 6
7 #include "third_party/skia/include/core/SkPath.h" 7 #include "third_party/skia/include/core/SkPath.h"
8 #include "third_party/skia/include/core/SkRegion.h" 8 #include "third_party/skia/include/core/SkRegion.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/cursor_client.h" 10 #include "ui/aura/client/cursor_client.h"
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 689 }
690 690
691 bool DesktopWindowTreeHostWin::ShouldHandleSystemCommands() const { 691 bool DesktopWindowTreeHostWin::ShouldHandleSystemCommands() const {
692 return GetWidget()->widget_delegate()->ShouldHandleSystemCommands(); 692 return GetWidget()->widget_delegate()->ShouldHandleSystemCommands();
693 } 693 }
694 694
695 void DesktopWindowTreeHostWin::HandleAppDeactivated() { 695 void DesktopWindowTreeHostWin::HandleAppDeactivated() {
696 native_widget_delegate_->EnableInactiveRendering(); 696 native_widget_delegate_->EnableInactiveRendering();
697 } 697 }
698 698
699 void DesktopWindowTreeHostWin::HandleActivationChanged(bool active) { 699 void DesktopWindowTreeHostWin::HandleActivationChanged(
700 bool active,
701 HWND window_gaining_or_losing_activation) {
700 // This can be invoked from HWNDMessageHandler::Init(), at which point we're 702 // This can be invoked from HWNDMessageHandler::Init(), at which point we're
701 // not in a good state and need to ignore it. 703 // not in a good state and need to ignore it.
702 // TODO(beng): Do we need this still now the host owns the dispatcher? 704 // TODO(beng): Do we need this still now the host owns the dispatcher?
703 if (!dispatcher()) 705 if (!dispatcher())
704 return; 706 return;
705 707
706 if (active) 708 if (active)
707 OnHostActivated(); 709 OnHostActivated();
708 desktop_native_widget_aura_->HandleActivationChanged(active); 710 desktop_native_widget_aura_->HandleActivationChanged(active);
711
712 if (!::IsWindow(window_gaining_or_losing_activation))
sky 2016/02/19 21:17:00 Is there a reason not to put all this logic in HWN
ananta 2016/02/19 21:24:18 I did not want to add state to HWNDMessageHandler.
713 window_gaining_or_losing_activation = ::GetForegroundWindow();
714
715 // If the window losing activation is a fullscreen window, we reduce the size
716 // of the window by 1px. i.e. Not fullscreen. This is to work around an
717 // apparent bug in the Windows taskbar where in it tracks fullscreen state on
718 // a per thread basis. This causes it not be a topmost window when any
719 // maximized window on a thread which has a fullscreen window is active. This
720 // affects the way these windows interact with the taskbar, they obscure it
721 // when maximized, autohide does not work correctly, etc.
722 // By reducing the size of the fullscreen window by 1px, we ensure that the
723 // taskbar no longer treats the window and in turn the thread as a fullscreen
724 // thread. This in turn ensures that maximized windows on the same thread
725 /// don't obscure the taskbar, etc.
726 if (!active) {
727 if (IsFullscreen() && ::IsWindow(window_gaining_or_losing_activation)) {
728 // Reduce the bounds of the window by 1px to ensure that Windows does
729 // not treat this like a fullscreen window.
730 MONITORINFO monitor_info = {sizeof(monitor_info)};
731 GetMonitorInfo(MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTOPRIMARY),
732 &monitor_info);
733 gfx::Rect shrunk_rect(monitor_info.rcMonitor);
734 shrunk_rect.set_height(shrunk_rect.height() - 1);
735 // The message handler needs to allow this bounds change to occur.
736 message_handler_->set_background_fullscreen_hack(true);
737 SetBounds(shrunk_rect);
738 }
739 } else if (message_handler_->background_fullscreen_hack()) {
740 // Restore the bounds of the window to fullscreen.
741 DCHECK(IsFullscreen());
742 message_handler_->set_background_fullscreen_hack(false);
743 MONITORINFO monitor_info = {sizeof(monitor_info)};
744 GetMonitorInfo(MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTOPRIMARY),
745 &monitor_info);
746 SetBounds(gfx::Rect(monitor_info.rcMonitor));
747 }
709 } 748 }
710 749
711 bool DesktopWindowTreeHostWin::HandleAppCommand(short command) { 750 bool DesktopWindowTreeHostWin::HandleAppCommand(short command) {
712 // We treat APPCOMMAND ids as an extension of our command namespace, and just 751 // We treat APPCOMMAND ids as an extension of our command namespace, and just
713 // let the delegate figure out what to do... 752 // let the delegate figure out what to do...
714 return GetWidget()->widget_delegate() && 753 return GetWidget()->widget_delegate() &&
715 GetWidget()->widget_delegate()->ExecuteWindowsCommand(command); 754 GetWidget()->widget_delegate()->ExecuteWindowsCommand(command);
716 } 755 }
717 756
718 void DesktopWindowTreeHostWin::HandleCancelMode() { 757 void DesktopWindowTreeHostWin::HandleCancelMode() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 void DesktopWindowTreeHostWin::HandleVisibilityChanging(bool visible) { 821 void DesktopWindowTreeHostWin::HandleVisibilityChanging(bool visible) {
783 native_widget_delegate_->OnNativeWidgetVisibilityChanging(visible); 822 native_widget_delegate_->OnNativeWidgetVisibilityChanging(visible);
784 } 823 }
785 824
786 void DesktopWindowTreeHostWin::HandleVisibilityChanged(bool visible) { 825 void DesktopWindowTreeHostWin::HandleVisibilityChanged(bool visible) {
787 native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible); 826 native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible);
788 } 827 }
789 828
790 void DesktopWindowTreeHostWin::HandleClientSizeChanged( 829 void DesktopWindowTreeHostWin::HandleClientSizeChanged(
791 const gfx::Size& new_size) { 830 const gfx::Size& new_size) {
792 if (dispatcher()) 831 if (dispatcher() && !message_handler_->background_fullscreen_hack())
793 OnHostResized(new_size); 832 OnHostResized(new_size);
794 } 833 }
795 834
796 void DesktopWindowTreeHostWin::HandleFrameChanged() { 835 void DesktopWindowTreeHostWin::HandleFrameChanged() {
797 SetWindowTransparency(); 836 SetWindowTransparency();
798 // Replace the frame and layout the contents. 837 // Replace the frame and layout the contents.
799 GetWidget()->non_client_view()->UpdateFrame(); 838 GetWidget()->non_client_view()->UpdateFrame();
800 } 839 }
801 840
802 void DesktopWindowTreeHostWin::HandleNativeFocus(HWND last_focused_window) { 841 void DesktopWindowTreeHostWin::HandleNativeFocus(HWND last_focused_window) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 1000
962 // static 1001 // static
963 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( 1002 DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
964 internal::NativeWidgetDelegate* native_widget_delegate, 1003 internal::NativeWidgetDelegate* native_widget_delegate,
965 DesktopNativeWidgetAura* desktop_native_widget_aura) { 1004 DesktopNativeWidgetAura* desktop_native_widget_aura) {
966 return new DesktopWindowTreeHostWin(native_widget_delegate, 1005 return new DesktopWindowTreeHostWin(native_widget_delegate,
967 desktop_native_widget_aura); 1006 desktop_native_widget_aura);
968 } 1007 }
969 1008
970 } // namespace views 1009 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_win.h ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698