widget/windows/winrt/WakeLockListener.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/windows/winrt/WakeLockListener.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,29 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "WakeLockListener.h"
     1.9 +#include "MetroUtils.h"
    1.10 +
    1.11 +using namespace mozilla::widget::winrt;
    1.12 +
    1.13 +NS_IMPL_ISUPPORTS(WakeLockListener, nsIDOMMozWakeLockListener)
    1.14 +
    1.15 +NS_IMETHODIMP
    1.16 +WakeLockListener::Callback(const nsAString& aTopic, const nsAString& aState)
    1.17 +{
    1.18 +  if (!mDisplayRequest) {
    1.19 +    if (FAILED(ActivateGenericInstance(RuntimeClass_Windows_System_Display_DisplayRequest, mDisplayRequest))) {
    1.20 +      NS_WARNING("Failed to instantiate IDisplayRequest, wakelocks will be broken!");
    1.21 +      return NS_OK;
    1.22 +    }
    1.23 +  }
    1.24 +
    1.25 +  if (aState.Equals(NS_LITERAL_STRING("locked-foreground"))) {
    1.26 +    mDisplayRequest->RequestActive();
    1.27 +  } else {
    1.28 +    mDisplayRequest->RequestRelease();
    1.29 +  }
    1.30 +
    1.31 +  return NS_OK;
    1.32 +}

mercurial