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

Side by Side Diff: chrome/browser/views/constrained_window_impl.cc

Issue 125148: Making FocusManager portable to toolkit_views (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/views/constrained_window_impl.h" 5 #include "chrome/browser/views/constrained_window_impl.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/font.h" 8 #include "app/gfx/font.h"
9 #include "app/gfx/path.h" 9 #include "app/gfx/path.h"
10 #include "app/gfx/text_elider.h" 10 #include "app/gfx/text_elider.h"
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 WS_THICKFRAME | WS_SYSMENU); 632 WS_THICKFRAME | WS_SYSMENU);
633 set_focus_on_creation(false); 633 set_focus_on_creation(false);
634 634
635 WindowWin::Init(owner_->GetNativeView(), gfx::Rect()); 635 WindowWin::Init(owner_->GetNativeView(), gfx::Rect());
636 ActivateConstrainedWindow(); 636 ActivateConstrainedWindow();
637 } 637 }
638 638
639 void ConstrainedWindowImpl::ActivateConstrainedWindow() { 639 void ConstrainedWindowImpl::ActivateConstrainedWindow() {
640 // Other pop-ups are simply moved to the front of the z-order. 640 // Other pop-ups are simply moved to the front of the z-order.
641 SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); 641 SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
642
643 // Store the focus of our parent focus manager so we can restore it when we
644 // close.
645 views::FocusManager* focus_manager =
646 views::FocusManager::GetFocusManager(GetNativeView());
647 DCHECK(focus_manager);
648 focus_manager = focus_manager->GetParentFocusManager();
649 if (focus_manager) {
650 // We could not have a parent focus manager if the ConstrainedWindow is
651 // displayed in a tab that is not currently selected.
652 // TODO(jcampan): we should store the ConstrainedWindow active events in
653 // that case and replay them when the TabContents becomes selected.
654 focus_manager->StoreFocusedView();
655
656 // Give our window the focus so we get keyboard messages.
657 ::SetFocus(GetNativeView());
658 }
659 } 642 }
660 643
661 //////////////////////////////////////////////////////////////////////////////// 644 ////////////////////////////////////////////////////////////////////////////////
662 // ConstrainedWindowImpl, views::WidgetWin overrides: 645 // ConstrainedWindowImpl, views::WidgetWin overrides:
663 646
664 void ConstrainedWindowImpl::OnDestroy() { 647 void ConstrainedWindowImpl::OnDestroy() {
665 // We do this here, rather than |Close|, since the window may be destroyed in 648 // TODO(jcampan): figure out focus restoration
666 // a way other than by some other component calling Close, e.g. by the native
667 // window hierarchy closing. We are guaranteed to receive a WM_DESTROY
668 // message regardless of how the window is closed.
669 // Note that when we get this message, the focus manager of the
670 // ConstrainedWindow has already been destroyed (by the processing of
671 // WM_DESTROY in FocusManager). So the FocusManager we retrieve here is the
672 // parent one (the one from the top window).
673 views::FocusManager* focus_manager =
674 views::FocusManager::GetFocusManager(GetNativeView());
675 if (focus_manager) {
676 // We may not have a focus manager if:
677 // - we are hidden when closed (the TabContent would be detached).
678 // - the tab has been closed and we are closed as a result.
679 // TODO(jcampan): when hidden, we should modify the stored focus of the tab
680 // so when it becomes visible again we retrieve the focus appropriately.
681 if (!focus_restoration_disabled_)
682 focus_manager->RestoreFocusedView();
683 }
684 649
685 // Make sure we call super so that it can do its cleanup. 650 // Make sure we call super so that it can do its cleanup.
686 WindowWin::OnDestroy(); 651 WindowWin::OnDestroy();
687 } 652 }
688 653
689 void ConstrainedWindowImpl::OnFinalMessage(HWND window) { 654 void ConstrainedWindowImpl::OnFinalMessage(HWND window) {
690 // Tell our constraining TabContents that we've gone so it can update its 655 // Tell our constraining TabContents that we've gone so it can update its
691 // list. 656 // list.
692 owner_->WillClose(this); 657 owner_->WillClose(this);
693 658
(...skipping 23 matching lines...) Expand all
717 682
718 683
719 // static 684 // static
720 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( 685 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog(
721 TabContents* parent, 686 TabContents* parent,
722 views::WindowDelegate* window_delegate) { 687 views::WindowDelegate* window_delegate) {
723 ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent, 688 ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent,
724 window_delegate); 689 window_delegate);
725 return window; 690 return window;
726 } 691 }
OLDNEW
« no previous file with comments | « chrome/browser/views/browser_bubble_win.cc ('k') | chrome/browser/views/download_started_animation_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698