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

Unified Diff: base/win/text_services_message_filter.cc

Issue 10826223: Replace PeekMessage for TSF awareness (Closed) Base URL: http://git.chromium.org/chromium/src.git@yukawa
Patch Set: change BOOL to bool, rename variables. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« base/message_pump_win.cc ('K') | « base/win/text_services_message_filter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/text_services_message_filter.cc
diff --git a/base/win/text_services_message_filter.cc b/base/win/text_services_message_filter.cc
new file mode 100755
index 0000000000000000000000000000000000000000..b56497ad10cbc3d55846e4d2aa79a5be8cd9c283
--- /dev/null
+++ b/base/win/text_services_message_filter.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/win/text_services_message_filter.h"
+
+namespace base {
+namespace win {
+
+TextServicesMessageFilter::TextServicesMessageFilter()
+ : client_id_(TF_CLIENTID_NULL),
+ is_initialized_(false) {
+}
+
+TextServicesMessageFilter::~TextServicesMessageFilter() {
+ if (is_initialized_)
+ thread_mgr_->Deactivate();
+}
+
+bool TextServicesMessageFilter::Init() {
+ if (!scoped_com_initialiser_.succeeded())
+ return false;
+
+ if (FAILED(thread_mgr_.CreateInstance(CLSID_TF_ThreadMgr)))
+ return false;
+
+ if (FAILED(message_pump_.QueryFrom(thread_mgr_)))
+ return false;
+
+ if (FAILED(keystroke_mgr_.QueryFrom(thread_mgr_)))
+ return false;
+
+ if (FAILED(thread_mgr_->Activate(&client_id_)))
+ return false;
+
+ is_initialized_ = true;
+ return is_initialized_;
+}
+
+// Wraps for ITfMessagePump::PeekMessage with win32 PeekMessage signature.
+// Obtains messages from application message queue.
+bool TextServicesMessageFilter::DoPeekMessage(MSG* message,
+ HWND window_handle,
+ UINT msg_filter_min,
+ UINT msg_filter_max,
+ UINT remove_msg) {
+ BOOL result = FALSE;
+ if (FAILED(message_pump_->PeekMessage(message, window_handle,
+ msg_filter_min, msg_filter_max,
+ remove_msg, &result))) {
+ result = FALSE;
+ }
+
+ return !!result;
rvargas (doing something else) 2012/08/24 01:21:06 nit: Between this and having a BOOL i'd go with th
+}
+
+// Sends msg to Text Service Manager.
rvargas (doing something else) 2012/08/24 01:21:06 s/msg/message
+// The msg will be used to input composition text.
rvargas (doing something else) 2012/08/24 01:21:06 s/msg/message
+// Returns true if|message| was consumed by text service manager.
rvargas (doing something else) 2012/08/24 01:21:06 nit: space before |message|
+bool TextServicesMessageFilter::ProcessMessage(const MSG& message) {
+ if (message.message == WM_KEYDOWN) {
+ BOOL eaten = FALSE;
+ HRESULT hr = keystroke_mgr_->TestKeyDown(message.wParam, message.lParam,
+ &eaten);
+ if (FAILED(hr) && !eaten)
+ return false;
+ eaten = FALSE;
+ hr = keystroke_mgr_->KeyDown(message.wParam, message.lParam, &eaten);
+ return (SUCCEEDED(hr) && !!eaten);
+ }
+
+ if (message.message == WM_KEYUP) {
+ BOOL eaten = FALSE;
+ HRESULT hr = keystroke_mgr_->TestKeyUp(message.wParam, message.lParam,
+ &eaten);
+ if (FAILED(hr) && !eaten)
+ return false;
+ eaten = FALSE;
+ hr = keystroke_mgr_->KeyUp(message.wParam, message.lParam, &eaten);
+ return (SUCCEEDED(hr) && !!eaten);
+ }
+
+ return false;
+}
+
+} // namespace win
+} // namespace base
« base/message_pump_win.cc ('K') | « base/win/text_services_message_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698