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

Unified Diff: base/message_pump_win.cc

Issue 10826223: Replace PeekMessage for TSF awareness (Closed) Base URL: http://git.chromium.org/chromium/src.git@yukawa
Patch Set: nitpick Created 8 years, 3 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
« no previous file with comments | « base/message_pump_win.h ('k') | base/win/text_services_message_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_win.cc
diff --git a/base/message_pump_win.cc b/base/message_pump_win.cc
index 40118dab657c5d6675311ddf74b090a3ee4d19b7..03af7d145b0a1519d47fafe8fd2693befcfb0307 100644
--- a/base/message_pump_win.cc
+++ b/base/message_pump_win.cc
@@ -95,7 +95,9 @@ int MessagePumpWin::GetCurrentDelay() const {
//-----------------------------------------------------------------------------
// MessagePumpForUI public:
-MessagePumpForUI::MessagePumpForUI() : instance_(NULL) {
+MessagePumpForUI::MessagePumpForUI()
+ : instance_(NULL),
+ message_filter_(new MessageFilter) {
InitMessageWnd();
}
@@ -295,16 +297,17 @@ void MessagePumpForUI::WaitForWork() {
// If a parent child relationship exists between windows across threads
// then their thread inputs are implicitly attached.
// This causes the MsgWaitForMultipleObjectsEx API to return indicating
- // that messages are ready for processing (specifically mouse messages
- // intended for the child window. Occurs if the child window has capture)
- // The subsequent PeekMessages call fails to return any messages thus
+ // that messages are ready for processing (Specifically, mouse messages
+ // intended for the child window may appear if the child window has
+ // capture).
+ // The subsequent PeekMessages call may fail to return any messages thus
// causing us to enter a tight loop at times.
// The WaitMessage call below is a workaround to give the child window
- // sometime to process its input messages.
+ // some time to process its input messages.
MSG msg = {0};
DWORD queue_status = GetQueueStatus(QS_MOUSE);
if (HIWORD(queue_status) & QS_MOUSE &&
- !PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE)) {
+ !PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE)) {
WaitMessage();
}
return;
@@ -361,7 +364,7 @@ bool MessagePumpForUI::ProcessNextWindowsMessage() {
sent_messages_in_queue = true;
MSG msg;
- if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ if (message_filter_->DoPeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
return ProcessMessageHelper(msg);
return sent_messages_in_queue;
@@ -387,12 +390,14 @@ bool MessagePumpForUI::ProcessMessageHelper(const MSG& msg) {
WillProcessMessage(msg);
- if (state_->dispatcher) {
- if (!state_->dispatcher->Dispatch(msg))
- state_->should_quit = true;
- } else {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+ if (!message_filter_->ProcessMessage(msg)) {
+ if (state_->dispatcher) {
+ if (!state_->dispatcher->Dispatch(msg))
+ state_->should_quit = true;
+ } else {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
}
DidProcessMessage(msg);
@@ -419,7 +424,8 @@ bool MessagePumpForUI::ProcessPumpReplacementMessage() {
have_message = PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_REMOVE) ||
PeekMessage(&msg, NULL, WM_TIMER, WM_TIMER, PM_REMOVE);
} else {
- have_message = (0 != PeekMessage(&msg, NULL, 0, 0, PM_REMOVE));
+ have_message = !!message_filter_->DoPeekMessage(&msg, NULL, 0, 0,
+ PM_REMOVE);
}
DCHECK(!have_message || kMsgHaveWork != msg.message ||
@@ -441,6 +447,11 @@ bool MessagePumpForUI::ProcessPumpReplacementMessage() {
return ProcessMessageHelper(msg);
}
+void MessagePumpForUI::SetMessageFilter(
+ scoped_ptr<MessageFilter> message_filter) {
+ message_filter_ = message_filter.Pass();
+}
+
//-----------------------------------------------------------------------------
// MessagePumpForIO public:
« no previous file with comments | « base/message_pump_win.h ('k') | base/win/text_services_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698