mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1689945
- Update display info when WM_DISPLAYCHANGE happens r=jrmuizel
GfxInfo::RefreshMonitors() could not be called in ScreenHelperWin::RefreshScreens(), since the RefreshScreens() is called within nsAppShell::Init(). Then GfxInfo::RefreshMonitors() is called during WM_DISPLAYCHANGE event handling. Differential Revision: https://phabricator.services.mozilla.com/D103661
This commit is contained in:
parent
c045cd7489
commit
ee841fc548
@ -93,6 +93,7 @@ class MockGfxInfo final : public nsIGfxInfo {
|
|||||||
JS::MutableHandleValue _retval) override {
|
JS::MutableHandleValue _retval) override {
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
NS_IMETHOD RefreshMonitors(void) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||||
NS_IMETHOD GetFailures(nsTArray<int32_t>& indices,
|
NS_IMETHOD GetFailures(nsTArray<int32_t>& indices,
|
||||||
nsTArray<nsCString>& failures) override {
|
nsTArray<nsCString>& failures) override {
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
@ -1473,6 +1473,9 @@ GfxInfoBase::GetMonitors(JSContext* aCx, JS::MutableHandleValue aResult) {
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
GfxInfoBase::RefreshMonitors() { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||||
|
|
||||||
static inline bool SetJSPropertyString(JSContext* aCx,
|
static inline bool SetJSPropertyString(JSContext* aCx,
|
||||||
JS::Handle<JSObject*> aObj,
|
JS::Handle<JSObject*> aObj,
|
||||||
const char* aProp, const char* aString) {
|
const char* aProp, const char* aString) {
|
||||||
|
@ -56,6 +56,7 @@ class GfxInfoBase : public nsIGfxInfo,
|
|||||||
|
|
||||||
NS_IMETHOD GetMonitors(JSContext* cx,
|
NS_IMETHOD GetMonitors(JSContext* cx,
|
||||||
JS::MutableHandleValue _retval) override;
|
JS::MutableHandleValue _retval) override;
|
||||||
|
NS_IMETHOD RefreshMonitors() override;
|
||||||
NS_IMETHOD GetFailures(nsTArray<int32_t>& indices,
|
NS_IMETHOD GetFailures(nsTArray<int32_t>& indices,
|
||||||
nsTArray<nsCString>& failures) override;
|
nsTArray<nsCString>& failures) override;
|
||||||
NS_IMETHOD_(void) LogFailure(const nsACString& failure) override;
|
NS_IMETHOD_(void) LogFailure(const nsACString& failure) override;
|
||||||
|
@ -98,6 +98,8 @@ interface nsIGfxInfo : nsISupports
|
|||||||
[implicit_jscontext]
|
[implicit_jscontext]
|
||||||
jsval getMonitors();
|
jsval getMonitors();
|
||||||
|
|
||||||
|
void refreshMonitors();
|
||||||
|
|
||||||
Array<ACString> getFailures(out Array<long> indices);
|
Array<ACString> getFailures(out Array<long> indices);
|
||||||
|
|
||||||
[noscript, notxpcom] void logFailure(in ACString failure);
|
[noscript, notxpcom] void logFailure(in ACString failure);
|
||||||
|
@ -867,36 +867,7 @@ nsresult GfxInfo::Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get monitor information
|
// Get monitor information
|
||||||
for (int deviceIndex = 0;; deviceIndex++) {
|
RefreshMonitors();
|
||||||
DISPLAY_DEVICEW device;
|
|
||||||
device.cb = sizeof(device);
|
|
||||||
if (!::EnumDisplayDevicesW(nullptr, deviceIndex, &device, 0)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(device.StateFlags & DISPLAY_DEVICE_ACTIVE)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEVMODEW mode;
|
|
||||||
mode.dmSize = sizeof(mode);
|
|
||||||
mode.dmDriverExtra = 0;
|
|
||||||
if (!::EnumDisplaySettingsW(device.DeviceName, ENUM_CURRENT_SETTINGS,
|
|
||||||
&mode)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DisplayInfo displayInfo;
|
|
||||||
|
|
||||||
displayInfo.mScreenWidth = mode.dmPelsWidth;
|
|
||||||
displayInfo.mScreenHeight = mode.dmPelsHeight;
|
|
||||||
displayInfo.mRefreshRate = mode.dmDisplayFrequency;
|
|
||||||
displayInfo.mIsPseudoDisplay =
|
|
||||||
!!(device.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER);
|
|
||||||
displayInfo.mDeviceString = device.DeviceString;
|
|
||||||
|
|
||||||
mDisplayInfo.AppendElement(displayInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* spoofedDriverVersionString =
|
const char* spoofedDriverVersionString =
|
||||||
PR_GetEnv("MOZ_GFX_SPOOF_DRIVER_VERSION");
|
PR_GetEnv("MOZ_GFX_SPOOF_DRIVER_VERSION");
|
||||||
@ -931,6 +902,43 @@ GfxInfo::GetAdapterDescription2(nsAString& aAdapterDescription) {
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
GfxInfo::RefreshMonitors() {
|
||||||
|
mDisplayInfo.Clear();
|
||||||
|
|
||||||
|
for (int deviceIndex = 0;; deviceIndex++) {
|
||||||
|
DISPLAY_DEVICEW device;
|
||||||
|
device.cb = sizeof(device);
|
||||||
|
if (!::EnumDisplayDevicesW(nullptr, deviceIndex, &device, 0)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(device.StateFlags & DISPLAY_DEVICE_ACTIVE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEVMODEW mode;
|
||||||
|
mode.dmSize = sizeof(mode);
|
||||||
|
mode.dmDriverExtra = 0;
|
||||||
|
if (!::EnumDisplaySettingsW(device.DeviceName, ENUM_CURRENT_SETTINGS,
|
||||||
|
&mode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayInfo displayInfo;
|
||||||
|
|
||||||
|
displayInfo.mScreenWidth = mode.dmPelsWidth;
|
||||||
|
displayInfo.mScreenHeight = mode.dmPelsHeight;
|
||||||
|
displayInfo.mRefreshRate = mode.dmDisplayFrequency;
|
||||||
|
displayInfo.mIsPseudoDisplay =
|
||||||
|
!!(device.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER);
|
||||||
|
displayInfo.mDeviceString = device.DeviceString;
|
||||||
|
|
||||||
|
mDisplayInfo.AppendElement(displayInfo);
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
GfxInfo::GetAdapterRAM(uint32_t* aAdapterRAM) {
|
GfxInfo::GetAdapterRAM(uint32_t* aAdapterRAM) {
|
||||||
uint32_t result = 0;
|
uint32_t result = 0;
|
||||||
|
@ -66,6 +66,8 @@ class GfxInfo : public GfxInfoBase {
|
|||||||
|
|
||||||
nsresult FindMonitors(JSContext* cx, JS::HandleObject array) override;
|
nsresult FindMonitors(JSContext* cx, JS::HandleObject array) override;
|
||||||
|
|
||||||
|
NS_IMETHOD RefreshMonitors() override;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
NS_DECL_NSIGFXINFODEBUG
|
NS_DECL_NSIGFXINFODEBUG
|
||||||
|
@ -5967,6 +5967,10 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
|
|||||||
|
|
||||||
case WM_DISPLAYCHANGE: {
|
case WM_DISPLAYCHANGE: {
|
||||||
ScreenHelperWin::RefreshScreens();
|
ScreenHelperWin::RefreshScreens();
|
||||||
|
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
||||||
|
if (gfxInfo) {
|
||||||
|
gfxInfo->RefreshMonitors();
|
||||||
|
}
|
||||||
if (mWidgetListener) {
|
if (mWidgetListener) {
|
||||||
mWidgetListener->UIResolutionChanged();
|
mWidgetListener->UIResolutionChanged();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user