/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// A window procedure that logs when an input event is received to the gfx /// error log /// /// This is done because this window is supposed to be WM_DISABLED, but /// malfunctioning software may still end up targetting this window. If that /// happens, it's almost-certainly a bug and should be brought to the attention /// of the developers that are debugging the issue. static LRESULT CALLBACK InputEventRejectingWindowProc(HWND window, UINT msg,
WPARAM wparam,
LPARAM lparam) { switch (msg) { case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MOUSEWHEEL: case WM_MOUSEHWHEEL: case WM_MOUSEMOVE: case WM_KEYDOWN: case WM_KEYUP: case WM_SYSKEYDOWN: case WM_SYSKEYUP:
gfxCriticalNoteOnce
<< "The compositor window received an input event even though it's " "disabled. There is likely malfunctioning " "software on the user's machine.";
if (sWinCompositorWindowThread) { // Try to reuse the thread, which involves stopping and restarting it.
sWinCompositorWindowThread->mThread->Stop(); if (sWinCompositorWindowThread->mThread->StartWithOptions(options)) { // Success!
sWinCompositorWindowThread->mHasAttemptedShutdown = false; return;
} // Restart failed, so null out our sWinCompositorWindowThread and // try again with a new thread. This will cause the old singleton // instance to be deallocated, which will destroy its mThread as well.
sWinCompositorWindowThread = nullptr;
}
base::Thread* thread = new base::Thread("WinCompositor"); if (!thread->StartWithOptions(options)) { delete thread; return;
}
sWinCompositorWindowThread = new WinCompositorWindowThread(thread);
}
// Our thread could hang while we're waiting for it to stop. // Since we're shutting down, that's not a critical problem. // We set a reasonable amount of time to wait for shutdown, // and if it succeeds within that time, we correctly stop // our thread by nulling out the refptr, which will cause it // to be deallocated and join the thread. If it times out, // we do nothing, which means that the thread will not be // joined and sWinCompositorWindowThread memory will leak.
CVStatus status;
{ // It's important to hold the lock before posting the // runnable. This ensures that the runnable can't begin // until we've started our Wait, which prevents us from // Waiting on a monitor that has already been notified.
MonitorAutoLock lock(sWinCompositorWindowThread->mMonitor);
// Monitor uses SleepConditionVariableSRW, which can have // spurious wakeups which are reported as timeouts, so we // check timestamps to ensure that we've waited as long we // intended to. If we wake early, we don't bother calculating // a precise amount for the next wait; we just wait the same // amount of time. This means timeout might happen after as // much as 2x the TIMEOUT time.
TimeStamp timeStart = TimeStamp::NowLoRes(); do {
status = sWinCompositorWindowThread->mMonitor.Wait(TIMEOUT);
} while ((status == CVStatus::Timeout) &&
((TimeStamp::NowLoRes() - timeStart) < TIMEOUT));
}
if (status == CVStatus::NoTimeout) {
sWinCompositorWindowThread = nullptr;
}
}
// Create initial parent window. // We could not directly create a compositor window with a main window // as parent window, so instead create it with a temporary placeholder // parent. Its parent is set as main window in UI process.
initialParentWnd =
::CreateWindowEx(WS_EX_TOOLWINDOW, kClassNameCompositorInitalParent,
nullptr, WS_POPUP | WS_DISABLED, 0, 0, 1, 1,
nullptr, 0, GetModuleHandle(nullptr), 0); if (!initialParentWnd) {
gfxCriticalNoteOnce << "Inital parent window failed "
<< ::GetLastError(); return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.