2006-01-12 00:27:48 +03:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2006-01-12 00:27:48 +03:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
2016-10-03 11:23:23 +03:00
|
|
|
%{C++
|
2022-12-27 01:49:46 +03:00
|
|
|
#include "mozilla/dom/ScreenBinding.h"
|
2022-02-17 19:22:57 +03:00
|
|
|
#include "Units.h"
|
|
|
|
|
2016-10-03 11:23:23 +03:00
|
|
|
/**
|
|
|
|
* The display type of nsIScreen belongs to.
|
|
|
|
*/
|
|
|
|
enum class DisplayType: int32_t {
|
|
|
|
DISPLAY_PRIMARY, // primary screen
|
|
|
|
DISPLAY_EXTERNAL, // wired displays, such as HDMI, DisplayPort, etc.
|
|
|
|
DISPLAY_VIRTUAL // wireless displays, such as Chromecast, WiFi-Display, etc.
|
|
|
|
};
|
|
|
|
%}
|
|
|
|
|
2022-12-27 01:49:46 +03:00
|
|
|
native ScreenColorGamut(mozilla::dom::ScreenColorGamut);
|
|
|
|
|
2022-02-17 19:22:57 +03:00
|
|
|
[scriptable, builtinclass, uuid(826e80c8-d70f-42e2-8aa9-82c05f2a370a)]
|
2006-01-12 00:27:48 +03:00
|
|
|
interface nsIScreen : nsISupports
|
|
|
|
{
|
2012-10-16 23:41:19 +04:00
|
|
|
/**
|
|
|
|
* These report screen dimensions in (screen-specific) device pixels
|
|
|
|
*/
|
2012-01-05 06:12:48 +04:00
|
|
|
void GetRect(out long left, out long top, out long width, out long height);
|
|
|
|
void GetAvailRect(out long left, out long top, out long width, out long height);
|
|
|
|
|
2022-02-17 19:22:57 +03:00
|
|
|
%{C++
|
|
|
|
mozilla::LayoutDeviceIntRect GetRect() {
|
|
|
|
int32_t left = 0, top = 0, width = 0, height = 0;
|
|
|
|
GetRect(&left, &top, &width, &height);
|
|
|
|
return {left, top, width, height};
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::LayoutDeviceIntRect GetAvailRect() {
|
|
|
|
int32_t left = 0, top = 0, width = 0, height = 0;
|
|
|
|
GetAvailRect(&left, &top, &width, &height);
|
|
|
|
return {left, top, width, height};
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
2012-10-16 23:41:19 +04:00
|
|
|
/**
|
2015-11-25 22:11:58 +03:00
|
|
|
* And these report in desktop pixels
|
2012-10-16 23:41:19 +04:00
|
|
|
*/
|
|
|
|
void GetRectDisplayPix(out long left, out long top, out long width, out long height);
|
|
|
|
void GetAvailRectDisplayPix(out long left, out long top, out long width, out long height);
|
|
|
|
|
2022-02-17 19:22:57 +03:00
|
|
|
%{C++
|
|
|
|
mozilla::DesktopIntRect GetRectDisplayPix() {
|
|
|
|
int32_t left = 0, top = 0, width = 0, height = 0;
|
|
|
|
GetRectDisplayPix(&left, &top, &width, &height);
|
|
|
|
return {left, top, width, height};
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::DesktopIntRect GetAvailRectDisplayPix() {
|
|
|
|
int32_t left = 0, top = 0, width = 0, height = 0;
|
|
|
|
GetAvailRectDisplayPix(&left, &top, &width, &height);
|
|
|
|
return {left, top, width, height};
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
2022-05-07 02:37:25 +03:00
|
|
|
[infallible] readonly attribute long pixelDepth;
|
|
|
|
[infallible] readonly attribute long colorDepth;
|
2022-12-27 01:49:46 +03:00
|
|
|
/**
|
|
|
|
* ScreenColorGamut is native type, which cannot be declared [infallible].
|
|
|
|
*/
|
|
|
|
readonly attribute ScreenColorGamut colorGamut;
|
2012-10-02 23:48:05 +04:00
|
|
|
|
|
|
|
/**
|
2016-02-05 19:29:33 +03:00
|
|
|
* The number of device pixels per desktop pixel for this screen (for
|
|
|
|
* hidpi configurations where there may be multiple device pixels per
|
|
|
|
* desktop px and/or per CSS px).
|
|
|
|
*
|
|
|
|
* This seems poorly named (something like devicePixelsPerDesktopPixel
|
|
|
|
* would be more accurate/explicit), but given that it is exposed to
|
|
|
|
* front-end code and may also be used by add-ons, it's probably not
|
|
|
|
* worth the disruption of changing it.
|
|
|
|
*
|
|
|
|
* Returns 1.0 if HiDPI mode is disabled or unsupported, or if the
|
2017-06-06 13:09:34 +03:00
|
|
|
* host OS uses device pixels as its desktop pixel units (e.g. Windows 7 or
|
|
|
|
* GTK/X11). Per-monitor DPI is available in Windows 8.1+, GTK/Wayland or
|
|
|
|
* macOS.
|
2012-10-02 23:48:05 +04:00
|
|
|
*/
|
2022-02-17 19:22:57 +03:00
|
|
|
[infallible] readonly attribute double contentsScaleFactor;
|
2016-02-05 19:29:33 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The default number of device pixels per unscaled CSS pixel for this
|
|
|
|
* screen. This is probably what contentsScaleFactor originally meant
|
|
|
|
* to be, prior to confusion between CSS pixels and desktop pixel units.
|
|
|
|
*/
|
2022-02-17 19:22:57 +03:00
|
|
|
[infallible] readonly attribute double defaultCSSScaleFactor;
|
|
|
|
|
|
|
|
%{C++
|
|
|
|
|
|
|
|
mozilla::DesktopToLayoutDeviceScale GetDesktopToLayoutDeviceScale() {
|
|
|
|
return mozilla::DesktopToLayoutDeviceScale(GetContentsScaleFactor());
|
|
|
|
}
|
2017-06-06 13:09:34 +03:00
|
|
|
|
2022-02-17 19:22:57 +03:00
|
|
|
mozilla::CSSToLayoutDeviceScale GetCSSToLayoutDeviceScale() {
|
|
|
|
return mozilla::CSSToLayoutDeviceScale(GetDefaultCSSScaleFactor());
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::CSSToDesktopScale GetCSSToDesktopScale() {
|
|
|
|
return GetCSSToLayoutDeviceScale() / GetDesktopToLayoutDeviceScale();
|
|
|
|
}
|
|
|
|
|
|
|
|
%}
|
2017-06-06 13:09:34 +03:00
|
|
|
/**
|
|
|
|
* The DPI of the screen.
|
|
|
|
*/
|
2022-05-07 02:37:25 +03:00
|
|
|
[infallible] readonly attribute float dpi;
|
|
|
|
|
|
|
|
/** The target screen refresh rate, in Hz, or 0 if unknown */
|
|
|
|
[infallible] readonly attribute long refreshRate;
|
|
|
|
[infallible] readonly attribute boolean isPseudoDisplay;
|
2010-12-22 01:33:48 +03:00
|
|
|
};
|