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

Side by Side Diff: ui/views/mus/native_widget_mus.cc

Issue 2412593002: IME for Mus: Send ack for key events after IME driver processes the event. (Closed)
Patch Set: Addressed feedback. Created 4 years, 2 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
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | ui/views/mus/text_input_client_impl.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This has to be before any other includes, else default is picked up. 5 // This has to be before any other includes, else default is picked up.
6 // See base/logging for details on this. 6 // See base/logging for details on this.
7 #define NOTIMPLEMENTED_POLICY 5 7 #define NOTIMPLEMENTED_POLICY 5
8 8
9 #include "ui/views/mus/native_widget_mus.h" 9 #include "ui/views/mus/native_widget_mus.h"
10 10
(...skipping 28 matching lines...) Expand all
39 #include "ui/gfx/canvas.h" 39 #include "ui/gfx/canvas.h"
40 #include "ui/gfx/path.h" 40 #include "ui/gfx/path.h"
41 #include "ui/native_theme/native_theme_aura.h" 41 #include "ui/native_theme/native_theme_aura.h"
42 #include "ui/platform_window/platform_window_delegate.h" 42 #include "ui/platform_window/platform_window_delegate.h"
43 #include "ui/views/corewm/tooltip.h" 43 #include "ui/views/corewm/tooltip.h"
44 #include "ui/views/corewm/tooltip_aura.h" 44 #include "ui/views/corewm/tooltip_aura.h"
45 #include "ui/views/corewm/tooltip_controller.h" 45 #include "ui/views/corewm/tooltip_controller.h"
46 #include "ui/views/drag_utils.h" 46 #include "ui/views/drag_utils.h"
47 #include "ui/views/mus/drag_drop_client_mus.h" 47 #include "ui/views/mus/drag_drop_client_mus.h"
48 #include "ui/views/mus/drop_target_mus.h" 48 #include "ui/views/mus/drop_target_mus.h"
49 #include "ui/views/mus/input_method_mus.h"
49 #include "ui/views/mus/window_manager_connection.h" 50 #include "ui/views/mus/window_manager_connection.h"
50 #include "ui/views/mus/window_manager_constants_converters.h" 51 #include "ui/views/mus/window_manager_constants_converters.h"
51 #include "ui/views/mus/window_manager_frame_values.h" 52 #include "ui/views/mus/window_manager_frame_values.h"
52 #include "ui/views/mus/window_tree_host_mus.h" 53 #include "ui/views/mus/window_tree_host_mus.h"
53 #include "ui/views/widget/drop_helper.h" 54 #include "ui/views/widget/drop_helper.h"
54 #include "ui/views/widget/native_widget_aura.h" 55 #include "ui/views/widget/native_widget_aura.h"
55 #include "ui/views/widget/tooltip_manager_aura.h" 56 #include "ui/views/widget/tooltip_manager_aura.h"
56 #include "ui/views/widget/widget_delegate.h" 57 #include "ui/views/widget/widget_delegate.h"
57 #include "ui/views/window/custom_frame_view.h" 58 #include "ui/views/window/custom_frame_view.h"
58 #include "ui/wm/core/base_focus_rules.h" 59 #include "ui/wm/core/base_focus_rules.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 content_(new aura::Window(this)), 542 content_(new aura::Window(this)),
542 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), 543 last_drop_operation_(ui::DragDropTypes::DRAG_NONE),
543 close_widget_factory_(this) { 544 close_widget_factory_(this) {
544 window_->set_input_event_handler(this); 545 window_->set_input_event_handler(this);
545 mus_window_observer_ = base::MakeUnique<MusWindowObserver>(this); 546 mus_window_observer_ = base::MakeUnique<MusWindowObserver>(this);
546 547
547 // TODO(fsamuel): Figure out lifetime of |window_|. 548 // TODO(fsamuel): Figure out lifetime of |window_|.
548 aura::SetMusWindow(content_, window_); 549 aura::SetMusWindow(content_, window_);
549 window->SetLocalProperty(kNativeWidgetMusKey, this); 550 window->SetLocalProperty(kNativeWidgetMusKey, this);
550 window_tree_host_ = base::MakeUnique<WindowTreeHostMus>(this, window_); 551 window_tree_host_ = base::MakeUnique<WindowTreeHostMus>(this, window_);
552 input_method_ =
553 base::MakeUnique<InputMethodMus>(window_tree_host_.get(), window_);
554 window_tree_host_->SetSharedInputMethod(input_method_.get());
551 } 555 }
552 556
553 NativeWidgetMus::~NativeWidgetMus() { 557 NativeWidgetMus::~NativeWidgetMus() {
554 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { 558 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) {
555 DCHECK(!window_); 559 DCHECK(!window_);
556 delete native_widget_delegate_; 560 delete native_widget_delegate_;
557 } else { 561 } else {
558 if (window_) 562 if (window_)
559 window_->set_input_event_handler(nullptr); 563 window_->set_input_event_handler(nullptr);
560 CloseNow(); 564 CloseNow();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 window_->SetCanFocus(params.activatable == 712 window_->SetCanFocus(params.activatable ==
709 Widget::InitParams::ACTIVATABLE_YES); 713 Widget::InitParams::ACTIVATABLE_YES);
710 window_->SetCanAcceptEvents(params.accept_events); 714 window_->SetCanAcceptEvents(params.accept_events);
711 715
712 window_tree_host_->AddObserver(this); 716 window_tree_host_->AddObserver(this);
713 window_tree_host_->InitHost(); 717 window_tree_host_->InitHost();
714 hosted_window->SetProperty(kMusWindow, window_); 718 hosted_window->SetProperty(kMusWindow, window_);
715 719
716 // TODO(moshayedi): crbug.com/641039. Investigate whether there are any cases 720 // TODO(moshayedi): crbug.com/641039. Investigate whether there are any cases
717 // where we need input method but don't have the WindowManagerConnection here. 721 // where we need input method but don't have the WindowManagerConnection here.
718 if (WindowManagerConnection::Exists()) { 722 if (WindowManagerConnection::Exists())
719 window_tree_host_->InitInputMethod( 723 input_method_->Init(WindowManagerConnection::Get()->connector());
720 WindowManagerConnection::Get()->connector());
721 }
722 724
723 focus_client_ = 725 focus_client_ =
724 base::MakeUnique<FocusControllerMus>(new FocusRulesImpl(hosted_window)); 726 base::MakeUnique<FocusControllerMus>(new FocusRulesImpl(hosted_window));
725 727
726 aura::client::SetFocusClient(hosted_window, focus_client_.get()); 728 aura::client::SetFocusClient(hosted_window, focus_client_.get());
727 aura::client::SetActivationClient(hosted_window, focus_client_.get()); 729 aura::client::SetActivationClient(hosted_window, focus_client_.get());
728 screen_position_client_ = base::MakeUnique<ScreenPositionClientMus>(window_); 730 screen_position_client_ = base::MakeUnique<ScreenPositionClientMus>(window_);
729 aura::client::SetScreenPositionClient(hosted_window, 731 aura::client::SetScreenPositionClient(hosted_window,
730 screen_position_client_.get()); 732 screen_position_client_.get());
731 733
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 last_drop_operation_); 1506 last_drop_operation_);
1505 } 1507 }
1506 1508
1507 //////////////////////////////////////////////////////////////////////////////// 1509 ////////////////////////////////////////////////////////////////////////////////
1508 // NativeWidgetMus, ui::InputEventHandler implementation: 1510 // NativeWidgetMus, ui::InputEventHandler implementation:
1509 1511
1510 void NativeWidgetMus::OnWindowInputEvent( 1512 void NativeWidgetMus::OnWindowInputEvent(
1511 ui::Window* view, 1513 ui::Window* view,
1512 const ui::Event& event_in, 1514 const ui::Event& event_in,
1513 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { 1515 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) {
1516 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in);
1517
1518 if (event->IsKeyEvent()) {
1519 input_method_->DispatchKeyEvent(event->AsKeyEvent(),
1520 std::move(*ack_callback));
1521 return;
1522 }
1523
1514 // Take ownership of the callback, indicating that we will handle it. 1524 // Take ownership of the callback, indicating that we will handle it.
1515 EventAckHandler ack_handler(std::move(*ack_callback)); 1525 EventAckHandler ack_handler(std::move(*ack_callback));
1516 1526
1517 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in);
1518 // TODO(markdittmer): This should be this->OnEvent(event.get()), but that 1527 // TODO(markdittmer): This should be this->OnEvent(event.get()), but that
1519 // can't happen until IME is refactored out of in WindowTreeHostMus. 1528 // can't happen until IME is refactored out of in WindowTreeHostMus.
1520 platform_window_delegate()->DispatchEvent(event.get()); 1529 platform_window_delegate()->DispatchEvent(event.get());
1521 // NOTE: |this| may be deleted. 1530 // NOTE: |this| may be deleted.
1522 1531
1523 ack_handler.set_handled(event->handled()); 1532 ack_handler.set_handled(event->handled());
1524 // |ack_handler| acks the event on destruction if necessary. 1533 // |ack_handler| acks the event on destruction if necessary.
1525 } 1534 }
1526 1535
1527 void NativeWidgetMus::OnMusWindowVisibilityChanging(ui::Window* window, 1536 void NativeWidgetMus::OnMusWindowVisibilityChanging(ui::Window* window,
(...skipping 30 matching lines...) Expand all
1558 1567
1559 gfx::Path mask_path; 1568 gfx::Path mask_path;
1560 native_widget_delegate_->GetHitTestMask(&mask_path); 1569 native_widget_delegate_->GetHitTestMask(&mask_path);
1561 // TODO(jamescook): Use the full path for the mask. 1570 // TODO(jamescook): Use the full path for the mask.
1562 gfx::Rect mask_rect = 1571 gfx::Rect mask_rect =
1563 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); 1572 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
1564 window_->SetHitTestMask(mask_rect); 1573 window_->SetHitTestMask(mask_rect);
1565 } 1574 }
1566 1575
1567 } // namespace views 1576 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | ui/views/mus/text_input_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698