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

Side by Side Diff: ui/views/widget/native_widget_aura.cc

Issue 8907029: AURA/X11: Handle VKEY_MENU accelerator on content area (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 11 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
« no previous file with comments | « ui/views/widget/native_widget_aura.h ('k') | ui/views/widget/native_widget_gtk.h » ('j') | 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/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "ui/aura/client/activation_client.h" 9 #include "ui/aura/client/activation_client.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 //////////////////////////////////////////////////////////////////////////////// 123 ////////////////////////////////////////////////////////////////////////////////
124 // NativeWidgetAura, public: 124 // NativeWidgetAura, public:
125 125
126 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) 126 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
127 : delegate_(delegate), 127 : delegate_(delegate),
128 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), 128 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
129 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 129 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
130 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), 130 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
131 can_activate_(true), 131 can_activate_(true),
132 #if defined(USE_X11)
133 should_handle_menu_key_release_(false),
134 #endif
135 cursor_(gfx::kNullCursor), 132 cursor_(gfx::kNullCursor),
136 saved_window_state_(ui::SHOW_STATE_DEFAULT) { 133 saved_window_state_(ui::SHOW_STATE_DEFAULT) {
137 } 134 }
138 135
139 NativeWidgetAura::~NativeWidgetAura() { 136 NativeWidgetAura::~NativeWidgetAura() {
140 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 137 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
141 delete delegate_; 138 delete delegate_;
142 else 139 else
143 CloseNow(); 140 CloseNow();
144 } 141 }
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 } 579 }
583 580
584 void NativeWidgetAura::SetVisibilityChangedAnimationsEnabled(bool value) { 581 void NativeWidgetAura::SetVisibilityChangedAnimationsEnabled(bool value) {
585 // Nothing needed on aura. 582 // Nothing needed on aura.
586 } 583 }
587 584
588 //////////////////////////////////////////////////////////////////////////////// 585 ////////////////////////////////////////////////////////////////////////////////
589 // NativeWidgetAura, views::InputMethodDelegate implementation: 586 // NativeWidgetAura, views::InputMethodDelegate implementation:
590 587
591 void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) { 588 void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) {
592 if (delegate_->OnKeyEvent(key) || !GetWidget()->GetFocusManager()) 589 FocusManager* focus_manager = GetWidget()->GetFocusManager();
590 if (focus_manager)
591 focus_manager->MaybeResetMenuKeyState(key);
592 if (delegate_->OnKeyEvent(key) || !focus_manager)
593 return; 593 return;
594 594 focus_manager->OnKeyEvent(key);
595 #if defined(USE_X11)
596 // TODO(oshima): This is copied from native_widget_gtk for now.
597 // RenderWidgetHostViewAura doesn't work and needs more work.
598 // oshima thinks this should be moved to focus manager (see
599 // crbug.com/106998), but beng believes that this should be done
600 // in RootWindowHosLinux for aura/linux.
601 const int key_code = key.key_code();
602
603 // Always reset |should_handle_menu_key_release_| unless we are handling a
604 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only
605 // be activated when handling a VKEY_MENU key release event which is preceded
606 // by an un-handled VKEY_MENU key press event.
607 if (key_code != ui::VKEY_MENU || key.type() != ui::ET_KEY_RELEASED)
608 should_handle_menu_key_release_ = false;
609
610 if (key.type() == ui::ET_KEY_PRESSED) {
611 // VKEY_MENU is triggered by key release event.
612 // FocusManager::OnKeyEvent() returns false when the key has been consumed.
613 if (key_code != ui::VKEY_MENU)
614 GetWidget()->GetFocusManager()->OnKeyEvent(key);
615 else
616 should_handle_menu_key_release_ = true;
617 } else if (key_code == ui::VKEY_MENU && should_handle_menu_key_release_ &&
618 (key.flags() & ~ui::EF_ALT_DOWN) == 0) {
619 // Trigger VKEY_MENU when only this key is pressed and released, and both
620 // press and release events are not handled by others.
621 ui::Accelerator accelerator(ui::VKEY_MENU, false, false, false);
622 GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator);
623 }
624 #else
625 if (key.type() == ui::ET_KEY_PRESSED)
626 GetWidget()->GetFocusManager()->OnKeyEvent(key);
627 #endif
628 } 595 }
629 596
630 //////////////////////////////////////////////////////////////////////////////// 597 ////////////////////////////////////////////////////////////////////////////////
631 // NativeWidgetAura, aura::WindowDelegate implementation: 598 // NativeWidgetAura, aura::WindowDelegate implementation:
632 599
633 gfx::Size NativeWidgetAura::GetMinimumSize() const { 600 gfx::Size NativeWidgetAura::GetMinimumSize() const {
634 return delegate_->GetMinimumSize(); 601 return delegate_->GetMinimumSize();
635 } 602 }
636 603
637 void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, 604 void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds,
638 const gfx::Rect& new_bounds) { 605 const gfx::Rect& new_bounds) {
639 if (old_bounds.origin() != new_bounds.origin()) 606 if (old_bounds.origin() != new_bounds.origin())
640 GetWidget()->widget_delegate()->OnWidgetMove(); 607 GetWidget()->widget_delegate()->OnWidgetMove();
641 if (old_bounds.size() != new_bounds.size()) 608 if (old_bounds.size() != new_bounds.size())
642 delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); 609 delegate_->OnNativeWidgetSizeChanged(new_bounds.size());
643 } 610 }
644 611
645 void NativeWidgetAura::OnFocus() { 612 void NativeWidgetAura::OnFocus() {
646 #if defined(USE_X11)
647 should_handle_menu_key_release_ = false;
648 #endif
649 Widget* widget = GetWidget(); 613 Widget* widget = GetWidget();
650 if (widget->is_top_level()) { 614 if (widget->is_top_level()) {
651 InputMethod* input_method = widget->GetInputMethod(); 615 InputMethod* input_method = widget->GetInputMethod();
652 input_method->OnFocus(); 616 input_method->OnFocus();
653 } 617 }
654 delegate_->OnNativeFocus(window_); 618 delegate_->OnNativeFocus(window_);
655 } 619 }
656 620
657 void NativeWidgetAura::OnBlur() { 621 void NativeWidgetAura::OnBlur() {
658 Widget* widget = GetWidget(); 622 Widget* widget = GetWidget();
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 } 857 }
894 } 858 }
895 859
896 // static 860 // static
897 bool NativeWidgetPrivate::IsMouseButtonDown() { 861 bool NativeWidgetPrivate::IsMouseButtonDown() {
898 return aura::RootWindow::GetInstance()->IsMouseButtonDown(); 862 return aura::RootWindow::GetInstance()->IsMouseButtonDown();
899 } 863 }
900 864
901 } // namespace internal 865 } // namespace internal
902 } // namespace views 866 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_aura.h ('k') | ui/views/widget/native_widget_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698