mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 952324 - Don't block native events for more than 50ms [r=jimm]
This commit is contained in:
parent
8ba68170dd
commit
40c57cd5b3
@ -12,6 +12,7 @@
|
|||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "mozilla/AutoRestore.h"
|
#include "mozilla/AutoRestore.h"
|
||||||
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "WinUtils.h"
|
#include "WinUtils.h"
|
||||||
#include "nsIAppStartup.h"
|
#include "nsIAppStartup.h"
|
||||||
#include "nsToolkitCompsCID.h"
|
#include "nsToolkitCompsCID.h"
|
||||||
@ -49,6 +50,7 @@ static ComPtr<ICoreWindowStatic> sCoreStatic;
|
|||||||
static bool sIsDispatching = false;
|
static bool sIsDispatching = false;
|
||||||
static bool sShouldPurgeThreadQueue = false;
|
static bool sShouldPurgeThreadQueue = false;
|
||||||
static bool sBlockNativeEvents = false;
|
static bool sBlockNativeEvents = false;
|
||||||
|
static TimeStamp sPurgeThreadQueueStart;
|
||||||
|
|
||||||
MetroAppShell::~MetroAppShell()
|
MetroAppShell::~MetroAppShell()
|
||||||
{
|
{
|
||||||
@ -283,6 +285,7 @@ MetroAppShell::DispatchAllGeckoEvents()
|
|||||||
NS_ASSERTION(NS_IsMainThread(), "DispatchAllGeckoEvents should be called on the main thread");
|
NS_ASSERTION(NS_IsMainThread(), "DispatchAllGeckoEvents should be called on the main thread");
|
||||||
|
|
||||||
sShouldPurgeThreadQueue = false;
|
sShouldPurgeThreadQueue = false;
|
||||||
|
sPurgeThreadQueueStart = TimeStamp::Now();
|
||||||
|
|
||||||
sBlockNativeEvents = true;
|
sBlockNativeEvents = true;
|
||||||
nsIThread *thread = NS_GetCurrentThread();
|
nsIThread *thread = NS_GetCurrentThread();
|
||||||
@ -335,13 +338,17 @@ MetroAppShell::ProcessOneNativeEventIfPresent()
|
|||||||
bool
|
bool
|
||||||
MetroAppShell::ProcessNextNativeEvent(bool mayWait)
|
MetroAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||||
{
|
{
|
||||||
// NS_ProcessPendingEvents will process thread events *and* call
|
// NS_ProcessPendingEvents will process thread events *and* call
|
||||||
// nsBaseAppShell::OnProcessNextEvent to process native events. However
|
// nsBaseAppShell::OnProcessNextEvent to process native events. However
|
||||||
// we do not want native events getting dispatched while we are trying
|
// we do not want native events getting dispatched while we are trying
|
||||||
// to dispatch pending input in DispatchAllGeckoEvents since a native
|
// to dispatch pending input in DispatchAllGeckoEvents since a native
|
||||||
// event may be a UIA Automation call coming in to check focus.
|
// event may be a UIA Automation call coming in to check focus.
|
||||||
if (sBlockNativeEvents) {
|
if (sBlockNativeEvents) {
|
||||||
return false;
|
if ((TimeStamp::Now() - sPurgeThreadQueueStart).ToMilliseconds()
|
||||||
|
< PURGE_MAX_TIMEOUT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
sBlockNativeEvents = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ProcessOneNativeEventIfPresent()) {
|
if (ProcessOneNativeEventIfPresent()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user