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

Side by Side Diff: ui/base/ime/input_method_win.cc

Issue 158313002: Remove non-Aura stuff from InputMethodWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 | « no previous file | no next file » | 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/base/ime/input_method_win.h" 5 #include "ui/base/ime/input_method_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "ui/base/ime/text_input_client.h" 8 #include "ui/base/ime/text_input_client.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/events/event_constants.h" 10 #include "ui/events/event_constants.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 char_positon->cLineHeight = rect.height(); 312 char_positon->cLineHeight = rect.height();
313 return 1; // returns non-zero value when succeeded. 313 return 1; // returns non-zero value when succeeded.
314 } 314 }
315 315
316 HWND InputMethodWin::GetAttachedWindowHandle( 316 HWND InputMethodWin::GetAttachedWindowHandle(
317 const TextInputClient* text_input_client) const { 317 const TextInputClient* text_input_client) const {
318 // On Aura environment, we can assume that |toplevel_window_handle_| always 318 // On Aura environment, we can assume that |toplevel_window_handle_| always
319 // represents the valid top-level window handle because each top-level window 319 // represents the valid top-level window handle because each top-level window
320 // is responsible for lifecycle management of corresponding InputMethod 320 // is responsible for lifecycle management of corresponding InputMethod
321 // instance. 321 // instance.
322 #if defined(USE_AURA)
323 return toplevel_window_handle_; 322 return toplevel_window_handle_;
324 #else
325 // On Non-Aura environment, TextInputClient::GetAttachedWindow() returns
326 // window handle to which each input method is bound.
327 if (!text_input_client)
328 return NULL;
329 return text_input_client->GetAttachedWindow();
330 #endif
331 } 323 }
332 324
333 bool InputMethodWin::IsWindowFocused(const TextInputClient* client) const { 325 bool InputMethodWin::IsWindowFocused(const TextInputClient* client) const {
334 if (!client) 326 if (!client)
335 return false; 327 return false;
336 HWND attached_window_handle = GetAttachedWindowHandle(client); 328 HWND attached_window_handle = GetAttachedWindowHandle(client);
337 #if defined(USE_AURA)
338 // When Aura is enabled, |attached_window_handle| should always be a top-level 329 // When Aura is enabled, |attached_window_handle| should always be a top-level
339 // window. So we can safely assume that |attached_window_handle| is ready for 330 // window. So we can safely assume that |attached_window_handle| is ready for
340 // receiving keyboard input as long as it is an active window. This works well 331 // receiving keyboard input as long as it is an active window. This works well
341 // even when the |attached_window_handle| becomes active but has not received 332 // even when the |attached_window_handle| becomes active but has not received
342 // WM_FOCUS yet. 333 // WM_FOCUS yet.
343 return attached_window_handle && GetActiveWindow() == attached_window_handle; 334 return attached_window_handle && GetActiveWindow() == attached_window_handle;
344 #else
345 return attached_window_handle && GetFocus() == attached_window_handle;
346 #endif
347 } 335 }
348 336
349 bool InputMethodWin::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) { 337 bool InputMethodWin::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) {
350 // TODO(ananta)
351 // Support IMEs and RTL layout in Windows 8 metro Ash. The code below won't
352 // work with IMEs.
353 // Bug: https://code.google.com/p/chromium/issues/detail?id=164964
354 if (event.is_char()) { 338 if (event.is_char()) {
355 if (GetTextInputClient()) { 339 if (GetTextInputClient()) {
356 GetTextInputClient()->InsertChar(event.key_code(), 340 GetTextInputClient()->InsertChar(event.key_code(),
357 ui::GetModifiersFromKeyState()); 341 ui::GetModifiersFromKeyState());
358 return true; 342 return true;
359 } 343 }
360 } 344 }
361 return DispatchKeyEventPostIME(event); 345 return DispatchKeyEventPostIME(event);
362 } 346 }
363 347
364 } // namespace ui 348 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698