mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 745145, part 0c: Only use nsIScreen on the main thread. r=mwu
This commit is contained in:
parent
7ff1bfb2f8
commit
a17a6a7858
@ -517,18 +517,27 @@ GeckoInputDispatcher::unregisterInputChannel(const sp<InputChannel>& inputChanne
|
||||
return OK;
|
||||
}
|
||||
|
||||
static already_AddRefed<nsIScreen>
|
||||
Screen()
|
||||
{
|
||||
nsCOMPtr<nsIScreenManager> screenMgr =
|
||||
do_GetService("@mozilla.org/gfx/screenmanager;1");
|
||||
nsCOMPtr<nsIScreen> screen;
|
||||
screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
|
||||
return screen.forget();
|
||||
}
|
||||
|
||||
class ScreenRotateEvent : public nsRunnable {
|
||||
public:
|
||||
ScreenRotateEvent(nsIScreen* aScreen, PRUint32 aRotation)
|
||||
: mScreen(aScreen),
|
||||
mRotation(aRotation) {
|
||||
ScreenRotateEvent(PRUint32 aRotation)
|
||||
: mRotation(aRotation) {
|
||||
}
|
||||
NS_IMETHOD Run() {
|
||||
return mScreen->SetRotation(mRotation);
|
||||
nsCOMPtr<nsIScreen> screen = Screen();
|
||||
return screen->SetRotation(mRotation);
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIScreen> mScreen;
|
||||
PRUint32 mRotation;
|
||||
};
|
||||
|
||||
@ -538,11 +547,6 @@ public:
|
||||
: mLastUpdate(0) {
|
||||
}
|
||||
void Notify(const SensorData& aSensorData) {
|
||||
nsCOMPtr<nsIScreenManager> screenMgr =
|
||||
do_GetService("@mozilla.org/gfx/screenmanager;1");
|
||||
nsCOMPtr<nsIScreen> screen;
|
||||
screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
|
||||
|
||||
MOZ_ASSERT(aSensorData.sensor() == SensorType::SENSOR_ORIENTATION);
|
||||
InfallibleTArray<float> values = aSensorData.values();
|
||||
// float azimuth = values[0]; // unused
|
||||
@ -560,10 +564,8 @@ public:
|
||||
else
|
||||
return; // don't rotate if undecidable
|
||||
|
||||
PRUint32 currRotation;
|
||||
nsresult res;
|
||||
res = screen->GetRotation(&currRotation);
|
||||
if (NS_FAILED(res) || rotation == currRotation)
|
||||
// This check is racy, but that's OK.
|
||||
if (rotation == nsScreenGonk::GetRotation())
|
||||
return;
|
||||
|
||||
PRTime now = PR_Now();
|
||||
@ -572,9 +574,9 @@ public:
|
||||
return;
|
||||
|
||||
mLastUpdate = now;
|
||||
NS_DispatchToMainThread(new ScreenRotateEvent(screen, rotation));
|
||||
|
||||
NS_DispatchToMainThread(new ScreenRotateEvent(rotation));
|
||||
}
|
||||
|
||||
private:
|
||||
PRTime mLastUpdate;
|
||||
static const PRTime sMinUpdateInterval = 500 * 1000; // 500 ms
|
||||
|
Loading…
Reference in New Issue
Block a user