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

Side by Side Diff: ui/aura/remote_root_window_host_win.cc

Issue 53553003: WIP: Ash IME support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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/aura/remote_root_window_host_win.h ('k') | ui/base/ime/input_method_factory.cc » ('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/aura/remote_root_window_host_win.h" 5 #include "ui/aura/remote_root_window_host_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "ipc/ipc_message.h" 12 #include "ipc/ipc_message.h"
13 #include "ipc/ipc_sender.h" 13 #include "ipc/ipc_sender.h"
14 #include "ui/aura/client/aura_constants.h"
14 #include "ui/aura/client/cursor_client.h" 15 #include "ui/aura/client/cursor_client.h"
15 #include "ui/aura/root_window.h" 16 #include "ui/aura/root_window.h"
17 #include "ui/aura/window_property.h"
16 #include "ui/base/cursor/cursor_loader_win.h" 18 #include "ui/base/cursor/cursor_loader_win.h"
19 #include "ui/base/ime/composition_text.h"
20 #include "ui/base/ime/input_method.h"
21 #include "ui/base/ime/remote_input_method_win.h"
22 #include "ui/base/ime/text_input_client.h"
17 #include "ui/events/event_utils.h" 23 #include "ui/events/event_utils.h"
18 #include "ui/events/keycodes/keyboard_code_conversion_win.h" 24 #include "ui/events/keycodes/keyboard_code_conversion_win.h"
19 #include "ui/base/view_prop.h" 25 #include "ui/base/view_prop.h"
20 #include "ui/gfx/insets.h" 26 #include "ui/gfx/insets.h"
21 #include "ui/metro_viewer/metro_viewer_messages.h" 27 #include "ui/metro_viewer/metro_viewer_messages.h"
22 28
23 namespace aura { 29 namespace aura {
24 30
25 namespace { 31 namespace {
26 32
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 150
145 void RemoteRootWindowHostWin::Connected(IPC::Sender* host, HWND remote_window) { 151 void RemoteRootWindowHostWin::Connected(IPC::Sender* host, HWND remote_window) {
146 CHECK(host_ == NULL); 152 CHECK(host_ == NULL);
147 host_ = host; 153 host_ = host;
148 remote_window_ = remote_window; 154 remote_window_ = remote_window;
149 } 155 }
150 156
151 void RemoteRootWindowHostWin::Disconnected() { 157 void RemoteRootWindowHostWin::Disconnected() {
152 // Don't CHECK here, Disconnected is called on a channel error which can 158 // Don't CHECK here, Disconnected is called on a channel error which can
153 // happen before we're successfully Connected. 159 // happen before we're successfully Connected.
160 ui::RemoteInputMethodPrivateWin* remote_input_method_private =
161 GetRemoteInputMethodPrivate();
162 if (remote_input_method_private)
163 remote_input_method_private->SetRemoteDelegate(NULL);
154 host_ = NULL; 164 host_ = NULL;
155 remote_window_ = NULL; 165 remote_window_ = NULL;
156 } 166 }
157 167
158 bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) { 168 bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) {
159 bool handled = true; 169 bool handled = true;
160 IPC_BEGIN_MESSAGE_MAP(RemoteRootWindowHostWin, message) 170 IPC_BEGIN_MESSAGE_MAP(RemoteRootWindowHostWin, message)
161 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseMoved, OnMouseMoved) 171 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseMoved, OnMouseMoved)
162 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseButton, OnMouseButton) 172 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseButton, OnMouseButton)
163 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyDown, OnKeyDown) 173 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyDown, OnKeyDown)
(...skipping 14 matching lines...) Expand all
178 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MultiFileOpenDone, 188 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MultiFileOpenDone,
179 OnMultiFileOpenDone) 189 OnMultiFileOpenDone)
180 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SelectFolderDone, 190 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SelectFolderDone,
181 OnSelectFolderDone) 191 OnSelectFolderDone)
182 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursorPosAck, 192 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursorPosAck,
183 OnSetCursorPosAck) 193 OnSetCursorPosAck)
184 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowSizeChanged, 194 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowSizeChanged,
185 OnWindowSizeChanged) 195 OnWindowSizeChanged)
186 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ActivateDesktopDone, 196 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ActivateDesktopDone,
187 OnDesktopActivated) 197 OnDesktopActivated)
198 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ImeCandidatePopupChanged,
199 OnImeCandidatePopupChanged)
200 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ImeCompositionChanged,
201 OnImeCompositionChanged)
202 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ImeTextCommitted,
203 OnImeTextCommitted)
204 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ImeInputSourceChanged,
205 OnImeInputSourceChanged)
188 IPC_MESSAGE_UNHANDLED(handled = false) 206 IPC_MESSAGE_UNHANDLED(handled = false)
189 IPC_END_MESSAGE_MAP() 207 IPC_END_MESSAGE_MAP()
190 return handled; 208 return handled;
191 } 209 }
192 210
193 void RemoteRootWindowHostWin::HandleOpenURLOnDesktop( 211 void RemoteRootWindowHostWin::HandleOpenURLOnDesktop(
194 const base::FilePath& shortcut, 212 const base::FilePath& shortcut,
195 const base::string16& url) { 213 const base::string16& url) {
196 if (!host_) 214 if (!host_)
197 return; 215 return;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 325 }
308 326
309 gfx::AcceleratedWidget RemoteRootWindowHostWin::GetAcceleratedWidget() { 327 gfx::AcceleratedWidget RemoteRootWindowHostWin::GetAcceleratedWidget() {
310 if (remote_window_) 328 if (remote_window_)
311 return remote_window_; 329 return remote_window_;
312 // Getting here should only happen for ash_unittests.exe and related code. 330 // Getting here should only happen for ash_unittests.exe and related code.
313 return ::GetDesktopWindow(); 331 return ::GetDesktopWindow();
314 } 332 }
315 333
316 void RemoteRootWindowHostWin::Show() { 334 void RemoteRootWindowHostWin::Show() {
335 ui::RemoteInputMethodPrivateWin* remote_input_method_private =
336 GetRemoteInputMethodPrivate();
337 if (remote_input_method_private)
338 remote_input_method_private->SetRemoteDelegate(this);
317 } 339 }
318 340
319 void RemoteRootWindowHostWin::Hide() { 341 void RemoteRootWindowHostWin::Hide() {
320 NOTIMPLEMENTED(); 342 NOTIMPLEMENTED();
321 } 343 }
322 344
323 void RemoteRootWindowHostWin::ToggleFullScreen() { 345 void RemoteRootWindowHostWin::ToggleFullScreen() {
324 } 346 }
325 347
326 gfx::Rect RemoteRootWindowHostWin::GetBounds() const { 348 gfx::Rect RemoteRootWindowHostWin::GetBounds() const {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 433 }
412 434
413 void RemoteRootWindowHostWin::OnDeviceScaleFactorChanged( 435 void RemoteRootWindowHostWin::OnDeviceScaleFactorChanged(
414 float device_scale_factor) { 436 float device_scale_factor) {
415 NOTIMPLEMENTED(); 437 NOTIMPLEMENTED();
416 } 438 }
417 439
418 void RemoteRootWindowHostWin::PrepareForShutdown() { 440 void RemoteRootWindowHostWin::PrepareForShutdown() {
419 } 441 }
420 442
443 void RemoteRootWindowHostWin::CancelComposition() {
444 host_->Send(new MetroViewerHostMsg_ImeCancelComposition);
445 }
446
447 void RemoteRootWindowHostWin::OnTextInputClientUpdated(
448 const std::vector<int32>& input_scopes,
449 const std::vector<gfx::Rect>& composition_character_bounds) {
450 std::vector<metro_viewer::CharacterBounds> character_bounds;
451 for (size_t i = 0; i < composition_character_bounds.size(); ++i) {
452 const gfx::Rect& rect = composition_character_bounds[i];
453 metro_viewer::CharacterBounds bounds;
454 bounds.left = rect.x();
455 bounds.top = rect.y();
456 bounds.right = rect.right();
457 bounds.bottom = rect.bottom();
458 character_bounds.push_back(bounds);
459 }
460 host_->Send(new MetroViewerHostMsg_ImeTextInputClientUpdated(
461 input_scopes, character_bounds));
462 }
463
421 void RemoteRootWindowHostWin::OnMouseMoved(int32 x, int32 y, int32 flags) { 464 void RemoteRootWindowHostWin::OnMouseMoved(int32 x, int32 y, int32 flags) {
422 if (ignore_mouse_moves_until_set_cursor_ack_) 465 if (ignore_mouse_moves_until_set_cursor_ack_)
423 return; 466 return;
424 467
425 gfx::Point location(x, y); 468 gfx::Point location(x, y);
426 ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, flags); 469 ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, flags);
427 delegate_->OnHostMouseEvent(&event); 470 delegate_->OnHostMouseEvent(&event);
428 } 471 }
429 472
430 void RemoteRootWindowHostWin::OnMouseButton( 473 void RemoteRootWindowHostWin::OnMouseButton(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 void RemoteRootWindowHostWin::OnWindowSizeChanged(uint32 width, uint32 height) { 617 void RemoteRootWindowHostWin::OnWindowSizeChanged(uint32 width, uint32 height) {
575 SetBounds(gfx::Rect(0, 0, width, height)); 618 SetBounds(gfx::Rect(0, 0, width, height));
576 } 619 }
577 620
578 void RemoteRootWindowHostWin::OnDesktopActivated() { 621 void RemoteRootWindowHostWin::OnDesktopActivated() {
579 ActivateDesktopCompleted temp = activate_completed_callback_; 622 ActivateDesktopCompleted temp = activate_completed_callback_;
580 activate_completed_callback_.Reset(); 623 activate_completed_callback_.Reset();
581 temp.Run(); 624 temp.Run();
582 } 625 }
583 626
627 ui::RemoteInputMethodPrivateWin*
628 RemoteRootWindowHostWin::GetRemoteInputMethodPrivate() {
629 ui::InputMethod* input_method = GetAshWindow()->GetProperty(
630 aura::client::kRootWindowInputMethodKey);
631 return ui::RemoteInputMethodPrivateWin::Get(input_method);
632 }
633
634 void RemoteRootWindowHostWin::OnImeCandidatePopupChanged(bool visible) {
635 ui::RemoteInputMethodPrivateWin* remote_input_method_private =
636 GetRemoteInputMethodPrivate();
637 if (remote_input_method_private)
638 remote_input_method_private->OnCandidatePopupChanged(visible);
639 }
640
641 void RemoteRootWindowHostWin::OnImeCompositionChanged(
642 const string16& text,
643 int32 selection_start,
644 int32 selection_end,
645 const std::vector<metro_viewer::UnderlineInfo>& underlines) {
646 ui::InputMethod* input_method = GetAshWindow()->GetProperty(
647 aura::client::kRootWindowInputMethodKey);
648 if (!input_method)
649 return;
650 ui::TextInputClient* text_input_client = input_method->GetTextInputClient();
651 if (!text_input_client)
652 return;
653 ui::CompositionText composition_text;
654 composition_text.text = text;
655 composition_text.selection.set_start(selection_start);
656 composition_text.selection.set_end(selection_end);
657 composition_text.underlines.reserve(underlines.size());
658 for (size_t i = 0; i < underlines.size(); ++i) {
659 ui::CompositionUnderline underline;
660 underline.start_offset = underlines[i].start_offset;
661 underline.end_offset = underlines[i].end_offset;
662 underline.color = SK_ColorBLACK;
663 underline.thick = underlines[i].thick;
664 composition_text.underlines.push_back(underline);
665 }
666 text_input_client->SetCompositionText(composition_text);
667 }
668
669 void RemoteRootWindowHostWin::OnImeTextCommitted(const string16& text) {
670 ui::InputMethod* input_method = GetAshWindow()->GetProperty(
671 aura::client::kRootWindowInputMethodKey);
672 if (!input_method)
673 return;
674 ui::TextInputClient* text_input_client = input_method->GetTextInputClient();
675 if (!text_input_client)
676 return;
677 text_input_client->InsertText(text);
678 }
679
680 void RemoteRootWindowHostWin::OnImeInputSourceChanged(uint16 language_id,
681 bool is_ime) {
682 ui::RemoteInputMethodPrivateWin* remote_input_method_private =
683 GetRemoteInputMethodPrivate();
684 if (remote_input_method_private)
685 remote_input_method_private->OnInputSourceChanged(language_id, is_ime);
686 }
687
584 void RemoteRootWindowHostWin::DispatchKeyboardMessage(ui::EventType type, 688 void RemoteRootWindowHostWin::DispatchKeyboardMessage(ui::EventType type,
585 uint32 vkey, 689 uint32 vkey,
586 uint32 repeat_count, 690 uint32 repeat_count,
587 uint32 scan_code, 691 uint32 scan_code,
588 uint32 flags, 692 uint32 flags,
589 bool is_character) { 693 bool is_character) {
590 SetEventFlags(flags | mouse_event_flags()); 694 SetEventFlags(flags | mouse_event_flags());
591 if (base::MessageLoop::current()->IsNested()) { 695 if (base::MessageLoop::current()->IsNested()) {
592 uint32 message = is_character ? WM_CHAR : 696 uint32 message = is_character ? WM_CHAR :
593 (type == ui::ET_KEY_PRESSED ? WM_KEYDOWN : WM_KEYUP); 697 (type == ui::ET_KEY_PRESSED ? WM_KEYDOWN : WM_KEYUP);
(...skipping 11 matching lines...) Expand all
605 } 709 }
606 710
607 void RemoteRootWindowHostWin::SetEventFlags(uint32 flags) { 711 void RemoteRootWindowHostWin::SetEventFlags(uint32 flags) {
608 if (flags == event_flags_) 712 if (flags == event_flags_)
609 return; 713 return;
610 event_flags_ = flags; 714 event_flags_ = flags;
611 SetVirtualKeyStates(event_flags_); 715 SetVirtualKeyStates(event_flags_);
612 } 716 }
613 717
614 } // namespace aura 718 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/remote_root_window_host_win.h ('k') | ui/base/ime/input_method_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698