xpcom/system/nsIDeviceSensors.idl
author Mook <mook.moz+hg@gmail.com>
Sat, 20 Oct 2012 21:40:56 -0700
changeset 119257 888ac1c4683084aaea58aeba89dbb50074b4008a
parent 101131 b7f3236f127b6f8d455efa6ad75f82a3a3c5f3d4
permissions -rw-r--r--
bug 782549 - check if the window has device sensor listeners, instead of global listener count (r=dougt)

/* 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/. */

#include "nsISupports.idl"

interface nsIDOMWindow;

[scriptable, uuid(1B406E32-CF42-471E-A470-6FD600BF4C7B)]
interface nsIDeviceSensorData : nsISupports
{
  // Keep in sync with hal/HalSensor.h
  const unsigned long TYPE_ORIENTATION = 0;
  const unsigned long TYPE_ACCELERATION = 1;
  const unsigned long TYPE_PROXIMITY = 2;
  const unsigned long TYPE_LINEAR_ACCELERATION = 3;
  const unsigned long TYPE_GYROSCOPE = 4;
  const unsigned long TYPE_LIGHT = 5;

  readonly attribute unsigned long type;

  readonly attribute double x;
  readonly attribute double y;
  readonly attribute double z;
};

[scriptable, uuid(e46e47c7-55ff-44c4-abce-21b14ba07f86)]
interface nsIDeviceSensors : nsISupports
{
  /**
   * Returns true if the given window has any listeners of the given type
   */
  bool hasWindowListener(in unsigned long aType, in nsIDOMWindow aWindow);

  // Holds pointers, not AddRef objects -- it is up to the caller
  // to call RemoveWindowListener before the window is deleted.

  [noscript] void addWindowListener(in unsigned long aType, in nsIDOMWindow aWindow);
  [noscript] void removeWindowListener(in unsigned long aType, in nsIDOMWindow aWindow);
  [noscript] void removeWindowAsListener(in nsIDOMWindow aWindow);
};