fune/widget/android/GeckoScreenOrientation.h
Makoto Kato f8c3f43487 Bug 1747677 - Add utility method to convert to ScreenConfiguration. r=gsvelto,geckoview-reviewers,calu
Gecko uses the redundant code from nsIScreen to SCreenConfiguration. So we
should add a convert method for newer platform implementations.

Differential Revision: https://phabricator.services.mozilla.com/D134698
2021-12-30 05:09:40 +00:00

38 lines
1.2 KiB
C++

/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
* 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/. */
#ifndef GeckoScreenOrientation_h
#define GeckoScreenOrientation_h
#include "nsAppShell.h"
#include "nsCOMPtr.h"
#include "mozilla/Hal.h"
#include "mozilla/java/GeckoScreenOrientationNatives.h"
#include "mozilla/widget/ScreenManager.h"
namespace mozilla {
class GeckoScreenOrientation final
: public java::GeckoScreenOrientation::Natives<GeckoScreenOrientation> {
GeckoScreenOrientation() = delete;
public:
static void OnOrientationChange(int16_t aOrientation, int16_t aAngle) {
RefPtr<widget::Screen> screen =
widget::ScreenManager::GetSingleton().GetPrimaryScreen();
hal::ScreenConfiguration screenConfiguration =
screen->ToScreenConfiguration();
screenConfiguration.orientation() =
static_cast<hal::ScreenOrientation>(aOrientation);
screenConfiguration.angle() = aAngle;
hal::NotifyScreenConfigurationChange(screenConfiguration);
}
};
} // namespace mozilla
#endif // GeckoScreenOrientation_h