OLD | NEW |
---|---|
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/hwnd_message_handler.h" | 5 #include "ui/views/win/hwnd_message_handler.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <oleacc.h> | 8 #include <oleacc.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <wtsapi32.h> | 10 #include <wtsapi32.h> |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 switch (show_state) { | 591 switch (show_state) { |
592 case ui::SHOW_STATE_INACTIVE: | 592 case ui::SHOW_STATE_INACTIVE: |
593 native_show_state = SW_SHOWNOACTIVATE; | 593 native_show_state = SW_SHOWNOACTIVATE; |
594 break; | 594 break; |
595 case ui::SHOW_STATE_MAXIMIZED: | 595 case ui::SHOW_STATE_MAXIMIZED: |
596 native_show_state = SW_SHOWMAXIMIZED; | 596 native_show_state = SW_SHOWMAXIMIZED; |
597 break; | 597 break; |
598 case ui::SHOW_STATE_MINIMIZED: | 598 case ui::SHOW_STATE_MINIMIZED: |
599 native_show_state = SW_SHOWMINIMIZED; | 599 native_show_state = SW_SHOWMINIMIZED; |
600 break; | 600 break; |
601 case ui::SHOW_STATE_NORMAL: | |
602 native_show_state = SW_SHOWNORMAL; | |
603 break; | |
601 default: | 604 default: |
602 native_show_state = delegate_->GetInitialShowState(); | 605 native_show_state = delegate_->GetInitialShowState(); |
603 break; | 606 break; |
604 } | 607 } |
605 | 608 |
606 ShowWindow(hwnd(), native_show_state); | 609 ShowWindow(hwnd(), native_show_state); |
607 // When launched from certain programs like bash and Windows Live Messenger, | 610 // When launched from certain programs like bash and Windows Live Messenger, |
608 // show_state is set to SW_HIDE, so we need to correct that condition. We | 611 // show_state is set to SW_HIDE, so we need to correct that condition. We |
609 // don't just change show_state to SW_SHOWNORMAL because MSDN says we must | 612 // don't just change show_state to SW_SHOWNORMAL because MSDN says we must |
610 // always first call ShowWindow with the specified value from STARTUPINFO, | 613 // always first call ShowWindow with the specified value from STARTUPINFO, |
(...skipping 15 matching lines...) Expand all Loading... | |
626 if (!delegate_->HandleInitialFocus(show_state)) | 629 if (!delegate_->HandleInitialFocus(show_state)) |
627 SetInitialFocus(); | 630 SetInitialFocus(); |
628 } | 631 } |
629 | 632 |
630 void HWNDMessageHandler::ShowMaximizedWithBounds(const gfx::Rect& bounds) { | 633 void HWNDMessageHandler::ShowMaximizedWithBounds(const gfx::Rect& bounds) { |
631 WINDOWPLACEMENT placement = { 0 }; | 634 WINDOWPLACEMENT placement = { 0 }; |
632 placement.length = sizeof(WINDOWPLACEMENT); | 635 placement.length = sizeof(WINDOWPLACEMENT); |
633 placement.showCmd = SW_SHOWMAXIMIZED; | 636 placement.showCmd = SW_SHOWMAXIMIZED; |
634 placement.rcNormalPosition = bounds.ToRECT(); | 637 placement.rcNormalPosition = bounds.ToRECT(); |
635 SetWindowPlacement(hwnd(), &placement); | 638 SetWindowPlacement(hwnd(), &placement); |
639 | |
640 // We need to explicitly activate the window, because if we're opened from a | |
641 // desktop shortcut while an existing window is already running it doesn't | |
642 // seem to be enough to use SW_SHOWMAXIMIZED to activate the window. | |
643 Activate(); | |
sky
2014/11/24 16:23:07
I think you're working around a problem that may b
Tomasz Moniuszko
2014/11/27 15:35:50
No it doesn't because Activate() is being called f
sky
2014/12/01 17:11:45
Ah, ok, I get it.
| |
636 } | 644 } |
637 | 645 |
638 void HWNDMessageHandler::Hide() { | 646 void HWNDMessageHandler::Hide() { |
639 if (IsWindow(hwnd())) { | 647 if (IsWindow(hwnd())) { |
640 // NOTE: Be careful not to activate any windows here (for example, calling | 648 // NOTE: Be careful not to activate any windows here (for example, calling |
641 // ShowWindow(SW_HIDE) will automatically activate another window). This | 649 // ShowWindow(SW_HIDE) will automatically activate another window). This |
642 // code can be called while a window is being deactivated, and activating | 650 // code can be called while a window is being deactivated, and activating |
643 // another window will screw up the activation that is already in progress. | 651 // another window will screw up the activation that is already in progress. |
644 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, | 652 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, |
645 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | | 653 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | |
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2498 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); | 2506 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); |
2499 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); | 2507 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); |
2500 } | 2508 } |
2501 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 2509 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
2502 // to notify our children too, since we can have MDI child windows who need to | 2510 // to notify our children too, since we can have MDI child windows who need to |
2503 // update their appearance. | 2511 // update their appearance. |
2504 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); | 2512 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
2505 } | 2513 } |
2506 | 2514 |
2507 } // namespace views | 2515 } // namespace views |
OLD | NEW |