2012-07-20 02:10:44 -07:00
|
|
|
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2012-12-14 15:58:45 -08:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2012-04-04 23:03:00 -07:00
|
|
|
#include <fcntl.h>
|
2011-12-23 23:13:33 -08:00
|
|
|
|
|
|
|
#include "android/log.h"
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2012-09-11 13:05:52 -07:00
|
|
|
#include "mozilla/dom/TabParent.h"
|
2012-01-17 02:55:25 -08:00
|
|
|
#include "mozilla/Hal.h"
|
2012-04-05 09:15:19 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2015-03-09 08:33:33 -07:00
|
|
|
#include "mozilla/ProcessPriorityManager.h"
|
2014-07-05 11:19:12 -07:00
|
|
|
#include "mozilla/Services.h"
|
2012-04-04 23:03:00 -07:00
|
|
|
#include "mozilla/FileUtils.h"
|
2013-07-01 16:03:17 -07:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2011-12-23 23:13:33 -08:00
|
|
|
#include "gfxContext.h"
|
2012-08-19 12:33:25 -07:00
|
|
|
#include "gfxPlatform.h"
|
2011-12-23 23:13:33 -08:00
|
|
|
#include "gfxUtils.h"
|
2011-11-10 16:17:46 -08:00
|
|
|
#include "GLContextProvider.h"
|
2013-09-04 05:14:52 -07:00
|
|
|
#include "GLContext.h"
|
2015-04-17 09:28:41 -07:00
|
|
|
#include "GLContextEGL.h"
|
2011-12-23 23:13:33 -08:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsAppShell.h"
|
2012-01-10 18:07:00 -08:00
|
|
|
#include "nsIdleService.h"
|
2014-07-05 11:19:12 -07:00
|
|
|
#include "nsIObserverService.h"
|
2012-02-06 14:47:11 -08:00
|
|
|
#include "nsScreenManagerGonk.h"
|
|
|
|
#include "nsTArray.h"
|
2011-12-23 23:13:33 -08:00
|
|
|
#include "nsWindow.h"
|
2012-08-15 11:52:42 -07:00
|
|
|
#include "nsIWidgetListener.h"
|
2012-05-23 12:35:13 -07:00
|
|
|
#include "cutils/properties.h"
|
2013-04-30 22:03:25 -07:00
|
|
|
#include "ClientLayerManager.h"
|
2012-07-30 17:42:26 -07:00
|
|
|
#include "BasicLayers.h"
|
2013-05-07 20:58:22 -07:00
|
|
|
#include "libdisplay/GonkDisplay.h"
|
|
|
|
#include "pixelflinger/format.h"
|
2013-10-01 09:55:42 -07:00
|
|
|
#include "mozilla/BasicEvents.h"
|
2014-10-16 13:57:10 -07:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-03-09 12:48:20 -07:00
|
|
|
#include "mozilla/gfx/Logging.h"
|
2014-01-23 13:34:31 -08:00
|
|
|
#include "mozilla/layers/APZCTreeManager.h"
|
2015-02-10 05:24:23 -08:00
|
|
|
#include "mozilla/layers/APZThreadUtils.h"
|
2013-09-16 14:45:31 -07:00
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
2015-01-15 07:37:54 -08:00
|
|
|
#include "mozilla/layers/InputAPZContext.h"
|
|
|
|
#include "mozilla/MouseEvents.h"
|
|
|
|
#include "mozilla/TouchEvents.h"
|
2013-11-26 14:15:17 -08:00
|
|
|
#include "nsThreadUtils.h"
|
2013-05-07 20:58:22 -07:00
|
|
|
#include "HwcComposer2D.h"
|
2011-11-10 16:17:46 -08:00
|
|
|
|
|
|
|
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
|
2012-07-07 07:07:00 -07:00
|
|
|
#define LOGW(args...) __android_log_print(ANDROID_LOG_WARN, "Gonk", ## args)
|
|
|
|
#define LOGE(args...) __android_log_print(ANDROID_LOG_ERROR, "Gonk", ## args)
|
2011-11-10 16:17:46 -08:00
|
|
|
|
|
|
|
#define IS_TOPLEVEL() (mWindowType == eWindowType_toplevel || mWindowType == eWindowType_dialog)
|
|
|
|
|
2011-12-23 23:13:33 -08:00
|
|
|
using namespace mozilla;
|
2012-05-08 14:36:07 -07:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
using namespace mozilla::hal;
|
2014-10-16 13:57:10 -07:00
|
|
|
using namespace mozilla::gfx;
|
2011-11-10 16:17:46 -08:00
|
|
|
using namespace mozilla::gl;
|
|
|
|
using namespace mozilla::layers;
|
2011-12-15 15:38:45 -08:00
|
|
|
using namespace mozilla::widget;
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
static nsWindow *gFocusedWindow = nullptr;
|
2012-04-04 23:03:00 -07:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class ScreenOnOffEvent : public nsRunnable {
|
|
|
|
public:
|
|
|
|
ScreenOnOffEvent(bool on)
|
|
|
|
: mIsOn(on)
|
|
|
|
{}
|
|
|
|
|
|
|
|
NS_IMETHOD Run() {
|
2015-03-09 08:33:33 -07:00
|
|
|
// When the screen is off prevent priority changes.
|
|
|
|
if (mIsOn) {
|
|
|
|
ProcessPriorityManager::Unfreeze();
|
|
|
|
} else {
|
|
|
|
ProcessPriorityManager::Freeze();
|
|
|
|
}
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
nsRefPtr<nsScreenGonk> screen = nsScreenManagerGonk::GetPrimaryScreen();
|
|
|
|
const nsTArray<nsWindow*>& windows = screen->GetTopWindows();
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < windows.Length(); i++) {
|
|
|
|
nsWindow *win = windows[i];
|
2012-08-15 11:52:42 -07:00
|
|
|
|
|
|
|
if (nsIWidgetListener* listener = win->GetWidgetListener()) {
|
|
|
|
listener->SizeModeChanged(mIsOn ? nsSizeMode_Fullscreen : nsSizeMode_Minimized);
|
|
|
|
}
|
2012-04-04 23:03:00 -07:00
|
|
|
}
|
|
|
|
|
2013-06-06 00:28:59 -07:00
|
|
|
// Notify observers that the screen state has just changed.
|
|
|
|
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
|
|
|
if (observerService) {
|
|
|
|
observerService->NotifyObservers(
|
|
|
|
nullptr, "screen-state-changed",
|
2013-12-12 17:50:01 -08:00
|
|
|
mIsOn ? MOZ_UTF16("on") : MOZ_UTF16("off")
|
2013-06-06 00:28:59 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-04-04 23:03:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool mIsOn;
|
|
|
|
};
|
|
|
|
|
2013-07-01 16:03:17 -07:00
|
|
|
static void
|
|
|
|
displayEnabledCallback(bool enabled)
|
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
nsRefPtr<nsScreenManagerGonk> screenManager = nsScreenManagerGonk::GetInstance();
|
|
|
|
screenManager->DisplayEnabled(enabled);
|
2012-04-26 01:46:52 -07:00
|
|
|
}
|
2012-04-04 23:03:00 -07:00
|
|
|
|
|
|
|
} // anonymous namespace
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2015-02-17 22:27:53 -08:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget)
|
2015-02-09 10:50:51 -08:00
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
nsWindow::nsWindow()
|
|
|
|
{
|
2014-10-16 13:57:10 -07:00
|
|
|
mFramebuffer = nullptr;
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
nsRefPtr<nsScreenManagerGonk> screenManager = nsScreenManagerGonk::GetInstance();
|
|
|
|
screenManager->Initialize();
|
|
|
|
mScreen = nsScreenManagerGonk::GetPrimaryScreen();
|
2014-07-22 13:46:27 -07:00
|
|
|
|
|
|
|
// This is a hack to force initialization of the compositor
|
|
|
|
// resources, if we're going to use omtc.
|
|
|
|
//
|
|
|
|
// NB: GetPlatform() will create the gfxPlatform, which wants
|
|
|
|
// to know the color depth, which asks our native window.
|
|
|
|
// This has to happen after other init has finished.
|
|
|
|
gfxPlatform::GetPlatform();
|
|
|
|
if (!ShouldUseOffMainThreadCompositing()) {
|
|
|
|
MOZ_CRASH("How can we render apps, then?");
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsWindow::~nsWindow()
|
|
|
|
{
|
2014-09-24 06:50:45 -07:00
|
|
|
HwcComposer2D::GetInstance()->SetCompositorParent(nullptr);
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::DoDraw(void)
|
|
|
|
{
|
2012-01-17 02:55:25 -08:00
|
|
|
if (!hal::GetScreenEnabled()) {
|
|
|
|
gDrawRequest = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
nsRefPtr<nsScreenGonk> screen = nsScreenManagerGonk::GetPrimaryScreen();
|
|
|
|
const nsTArray<nsWindow*>& windows = screen->GetTopWindows();
|
|
|
|
|
|
|
|
if (windows.IsEmpty()) {
|
2011-12-23 23:13:33 -08:00
|
|
|
LOG(" no window to draw, bailing");
|
2011-11-10 16:17:46 -08:00
|
|
|
return;
|
2011-12-23 23:13:33 -08:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
nsWindow *targetWindow = (nsWindow *)windows[0];
|
|
|
|
while (targetWindow->GetLastChild()) {
|
2014-04-10 19:21:36 -07:00
|
|
|
targetWindow = (nsWindow *)targetWindow->GetLastChild();
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2011-12-23 23:13:33 -08:00
|
|
|
|
2014-04-10 19:21:36 -07:00
|
|
|
nsIWidgetListener* listener = targetWindow->GetWidgetListener();
|
2013-01-28 11:34:03 -08:00
|
|
|
if (listener) {
|
2014-04-10 19:21:36 -07:00
|
|
|
listener->WillPaintWindow(targetWindow);
|
2013-01-28 11:34:03 -08:00
|
|
|
}
|
|
|
|
|
2014-04-10 19:21:36 -07:00
|
|
|
LayerManager* lm = targetWindow->GetLayerManager();
|
2014-01-23 10:26:41 -08:00
|
|
|
if (mozilla::layers::LayersBackend::LAYERS_CLIENT == lm->GetBackendType()) {
|
2015-04-29 20:17:57 -07:00
|
|
|
// No need to do anything, the compositor will handle drawing
|
2011-12-23 23:13:33 -08:00
|
|
|
} else {
|
|
|
|
NS_RUNTIMEABORT("Unexpected layer manager type");
|
|
|
|
}
|
2013-01-28 11:34:03 -08:00
|
|
|
|
2014-04-10 19:21:36 -07:00
|
|
|
listener = targetWindow->GetWidgetListener();
|
2013-01-28 11:34:03 -08:00
|
|
|
if (listener) {
|
|
|
|
listener->DidPaintWindow();
|
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
2015-03-26 14:23:02 -07:00
|
|
|
void
|
|
|
|
nsWindow::ConfigureAPZControllerThread()
|
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
APZThreadUtils::SetControllerThread(CompositorParent::CompositorLoop());
|
2015-03-26 14:23:02 -07:00
|
|
|
}
|
|
|
|
|
2015-01-15 07:37:54 -08:00
|
|
|
/*static*/ nsEventStatus
|
|
|
|
nsWindow::DispatchInputEvent(WidgetGUIEvent& aEvent)
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
2012-09-11 13:05:52 -07:00
|
|
|
if (!gFocusedWindow) {
|
2011-11-10 16:17:46 -08:00
|
|
|
return nsEventStatus_eIgnore;
|
2012-09-11 13:05:52 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2012-01-10 18:07:00 -08:00
|
|
|
gFocusedWindow->UserActivity();
|
2012-08-15 11:53:09 -07:00
|
|
|
|
2015-01-15 07:37:54 -08:00
|
|
|
nsEventStatus status;
|
2012-08-15 17:54:18 -07:00
|
|
|
aEvent.widget = gFocusedWindow;
|
2015-01-15 07:37:54 -08:00
|
|
|
gFocusedWindow->DispatchEvent(&aEvent, status);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
nsWindow::DispatchTouchInput(MultiTouchInput& aInput)
|
|
|
|
{
|
2015-02-10 05:24:23 -08:00
|
|
|
APZThreadUtils::AssertOnControllerThread();
|
|
|
|
|
2015-01-15 07:37:54 -08:00
|
|
|
if (!gFocusedWindow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gFocusedWindow->DispatchTouchInputViaAPZ(aInput);
|
|
|
|
}
|
|
|
|
|
2015-02-10 05:24:23 -08:00
|
|
|
class DispatchTouchInputOnMainThread : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DispatchTouchInputOnMainThread(const MultiTouchInput& aInput,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
2015-03-25 09:20:20 -07:00
|
|
|
const uint64_t& aInputBlockId,
|
|
|
|
nsEventStatus aApzResponse)
|
2015-02-10 05:24:23 -08:00
|
|
|
: mInput(aInput)
|
|
|
|
, mGuid(aGuid)
|
|
|
|
, mInputBlockId(aInputBlockId)
|
2015-03-25 09:20:20 -07:00
|
|
|
, mApzResponse(aApzResponse)
|
2015-02-10 05:24:23 -08:00
|
|
|
{}
|
|
|
|
|
|
|
|
NS_IMETHOD Run() {
|
|
|
|
if (gFocusedWindow) {
|
2015-03-25 09:20:20 -07:00
|
|
|
gFocusedWindow->DispatchTouchEventForAPZ(mInput, mGuid, mInputBlockId, mApzResponse);
|
2015-02-10 05:24:23 -08:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MultiTouchInput mInput;
|
|
|
|
ScrollableLayerGuid mGuid;
|
|
|
|
uint64_t mInputBlockId;
|
2015-03-25 09:20:20 -07:00
|
|
|
nsEventStatus mApzResponse;
|
2015-02-10 05:24:23 -08:00
|
|
|
};
|
|
|
|
|
2015-01-15 07:37:54 -08:00
|
|
|
void
|
|
|
|
nsWindow::DispatchTouchInputViaAPZ(MultiTouchInput& aInput)
|
|
|
|
{
|
2015-02-10 05:24:23 -08:00
|
|
|
APZThreadUtils::AssertOnControllerThread();
|
|
|
|
|
2015-01-15 07:37:54 -08:00
|
|
|
if (!mAPZC) {
|
|
|
|
// In general mAPZC should not be null, but during initial setup
|
|
|
|
// it might be, so we handle that case by ignoring touch input there.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// First send it through the APZ code
|
|
|
|
mozilla::layers::ScrollableLayerGuid guid;
|
|
|
|
uint64_t inputBlockId;
|
2015-03-25 09:20:20 -07:00
|
|
|
nsEventStatus result = mAPZC->ReceiveInputEvent(aInput, &guid, &inputBlockId);
|
2015-01-15 07:37:54 -08:00
|
|
|
// If the APZ says to drop it, then we drop it
|
2015-03-25 09:20:20 -07:00
|
|
|
if (result == nsEventStatus_eConsumeNoDefault) {
|
2015-01-15 07:37:54 -08:00
|
|
|
return;
|
|
|
|
}
|
2012-09-11 13:05:52 -07:00
|
|
|
|
2015-02-10 05:24:23 -08:00
|
|
|
// Can't use NS_NewRunnableMethod because it only takes up to one arg and
|
|
|
|
// we need more. Also we can't pass in |this| to the task because nsWindow
|
|
|
|
// refcounting is not threadsafe. Instead we just use the gFocusedWindow
|
|
|
|
// static ptr inside the task.
|
|
|
|
NS_DispatchToMainThread(new DispatchTouchInputOnMainThread(
|
2015-03-25 09:20:20 -07:00
|
|
|
aInput, guid, inputBlockId, result));
|
2015-02-10 05:24:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::DispatchTouchEventForAPZ(const MultiTouchInput& aInput,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
2015-03-25 09:20:20 -07:00
|
|
|
const uint64_t aInputBlockId,
|
|
|
|
nsEventStatus aApzResponse)
|
2015-02-10 05:24:23 -08:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
UserActivity();
|
|
|
|
|
2015-01-15 07:37:54 -08:00
|
|
|
// Convert it to an event we can send to Gecko
|
|
|
|
WidgetTouchEvent event = aInput.ToWidgetTouchEvent(this);
|
|
|
|
|
2015-03-16 09:32:17 -07:00
|
|
|
// Dispatch the event into the gecko root process for "normal" flow.
|
2015-03-25 09:20:20 -07:00
|
|
|
// The event might get sent to a child process,
|
|
|
|
// but if it doesn't we need to notify the APZ of various things.
|
|
|
|
// All of that happens in ProcessUntransformedAPZEvent
|
|
|
|
ProcessUntransformedAPZEvent(&event, aGuid, aInputBlockId, aApzResponse);
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
2015-02-10 05:24:23 -08:00
|
|
|
class DispatchTouchInputOnControllerThread : public Task
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DispatchTouchInputOnControllerThread(const MultiTouchInput& aInput)
|
|
|
|
: Task()
|
|
|
|
, mInput(aInput)
|
|
|
|
{}
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void Run() override {
|
2015-02-10 05:24:23 -08:00
|
|
|
if (gFocusedWindow) {
|
|
|
|
gFocusedWindow->DispatchTouchInputViaAPZ(mInput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MultiTouchInput mInput;
|
|
|
|
};
|
2015-01-19 15:38:00 -08:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|
|
|
TouchPointerState aPointerState,
|
|
|
|
nsIntPoint aPointerScreenPoint,
|
|
|
|
double aPointerPressure,
|
2015-04-14 08:36:36 -07:00
|
|
|
uint32_t aPointerOrientation,
|
|
|
|
nsIObserver* aObserver)
|
2015-01-19 15:38:00 -08:00
|
|
|
{
|
2015-04-14 08:36:36 -07:00
|
|
|
AutoObserverNotifier notifier(aObserver, "touchpoint");
|
|
|
|
|
2015-01-19 15:38:00 -08:00
|
|
|
if (aPointerState == TOUCH_HOVER) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mSynthesizedTouchInput) {
|
|
|
|
mSynthesizedTouchInput = new MultiTouchInput();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We can't dispatch mSynthesizedTouchInput directly because (a) dispatching
|
|
|
|
// it might inadvertently modify it and (b) in the case of touchend or
|
|
|
|
// touchcancel events mSynthesizedTouchInput will hold the touches that are
|
|
|
|
// still down whereas the input dispatched needs to hold the removed
|
|
|
|
// touch(es). We use |inputToDispatch| for this purpose.
|
|
|
|
MultiTouchInput inputToDispatch;
|
|
|
|
inputToDispatch.mInputType = MULTITOUCH_INPUT;
|
|
|
|
|
|
|
|
int32_t index = mSynthesizedTouchInput->IndexOfTouch((int32_t)aPointerId);
|
|
|
|
if (aPointerState == TOUCH_CONTACT) {
|
|
|
|
if (index >= 0) {
|
|
|
|
// found an existing touch point, update it
|
|
|
|
SingleTouchData& point = mSynthesizedTouchInput->mTouches[index];
|
|
|
|
point.mScreenPoint = ScreenIntPoint::FromUntyped(aPointerScreenPoint);
|
|
|
|
point.mRotationAngle = (float)aPointerOrientation;
|
|
|
|
point.mForce = (float)aPointerPressure;
|
|
|
|
inputToDispatch.mType = MultiTouchInput::MULTITOUCH_MOVE;
|
|
|
|
} else {
|
|
|
|
// new touch point, add it
|
|
|
|
mSynthesizedTouchInput->mTouches.AppendElement(SingleTouchData(
|
|
|
|
(int32_t)aPointerId,
|
|
|
|
ScreenIntPoint::FromUntyped(aPointerScreenPoint),
|
|
|
|
ScreenSize(0, 0),
|
|
|
|
(float)aPointerOrientation,
|
|
|
|
(float)aPointerPressure));
|
|
|
|
inputToDispatch.mType = MultiTouchInput::MULTITOUCH_START;
|
|
|
|
}
|
|
|
|
inputToDispatch.mTouches = mSynthesizedTouchInput->mTouches;
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(aPointerState == TOUCH_REMOVE || aPointerState == TOUCH_CANCEL);
|
|
|
|
// a touch point is being lifted, so remove it from the stored list
|
|
|
|
if (index >= 0) {
|
|
|
|
mSynthesizedTouchInput->mTouches.RemoveElementAt(index);
|
|
|
|
}
|
|
|
|
inputToDispatch.mType = (aPointerState == TOUCH_REMOVE
|
|
|
|
? MultiTouchInput::MULTITOUCH_END
|
|
|
|
: MultiTouchInput::MULTITOUCH_CANCEL);
|
|
|
|
inputToDispatch.mTouches.AppendElement(SingleTouchData(
|
|
|
|
(int32_t)aPointerId,
|
|
|
|
ScreenIntPoint::FromUntyped(aPointerScreenPoint),
|
|
|
|
ScreenSize(0, 0),
|
|
|
|
(float)aPointerOrientation,
|
|
|
|
(float)aPointerPressure));
|
|
|
|
}
|
|
|
|
|
2015-02-10 05:24:23 -08:00
|
|
|
// Can't use NewRunnableMethod here because that will pass a const-ref
|
|
|
|
// argument to DispatchTouchInputViaAPZ whereas that function takes a
|
|
|
|
// non-const ref. At this callsite we don't care about the mutations that
|
|
|
|
// the function performs so this is fine. Also we can't pass |this| to the
|
|
|
|
// task because nsWindow refcounting is not threadsafe. Instead we just use
|
|
|
|
// the gFocusedWindow static ptr instead the task.
|
|
|
|
APZThreadUtils::RunOnControllerThread(new DispatchTouchInputOnControllerThread(inputToDispatch));
|
|
|
|
|
2015-01-19 15:38:00 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Create(nsIWidget *aParent,
|
|
|
|
void *aNativeParent,
|
|
|
|
const nsIntRect &aRect,
|
|
|
|
nsWidgetInitData *aInitData)
|
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
nsIntRect virtualBounds;
|
|
|
|
mScreen->GetRect(&virtualBounds.x, &virtualBounds.y,
|
|
|
|
&virtualBounds.width, &virtualBounds.height);
|
|
|
|
BaseCreate(aParent, IS_TOPLEVEL() ? virtualBounds : aRect,
|
2015-02-04 21:18:30 -08:00
|
|
|
aInitData);
|
2011-11-10 16:17:46 -08:00
|
|
|
|
|
|
|
mBounds = aRect;
|
|
|
|
|
2014-04-10 19:21:36 -07:00
|
|
|
mParent = (nsWindow *)aParent;
|
2012-06-12 01:00:21 -07:00
|
|
|
mVisible = false;
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2014-04-10 19:21:36 -07:00
|
|
|
if (!aParent) {
|
2015-04-29 20:17:57 -07:00
|
|
|
mBounds = virtualBounds;
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
if (!IS_TOPLEVEL()) {
|
2011-11-10 16:17:46 -08:00
|
|
|
return NS_OK;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
mScreen->RegisterWindow(this);
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
Resize(0, 0, virtualBounds.width, virtualBounds.height, false);
|
2011-11-10 16:17:46 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Destroy(void)
|
|
|
|
{
|
2014-01-09 22:48:18 -08:00
|
|
|
mOnDestroyCalled = true;
|
2015-04-29 20:17:57 -07:00
|
|
|
mScreen->UnregisterWindow(this);
|
|
|
|
if (this == gFocusedWindow) {
|
2012-07-30 07:20:58 -07:00
|
|
|
gFocusedWindow = nullptr;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2014-01-09 22:48:18 -08:00
|
|
|
nsBaseWidget::OnDestroy();
|
2011-11-10 16:17:46 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Show(bool aState)
|
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
if (mWindowType == eWindowType_invisible) {
|
2011-11-10 16:17:46 -08:00
|
|
|
return NS_OK;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
if (mVisible == aState) {
|
2012-01-05 13:23:34 -08:00
|
|
|
return NS_OK;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2012-01-05 13:23:34 -08:00
|
|
|
|
2011-11-22 11:51:52 -08:00
|
|
|
mVisible = aState;
|
2015-04-29 20:17:57 -07:00
|
|
|
if (!IS_TOPLEVEL()) {
|
2011-11-22 11:51:52 -08:00
|
|
|
return mParent ? mParent->Show(aState) : NS_OK;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2011-11-22 11:51:52 -08:00
|
|
|
|
2012-01-05 13:23:34 -08:00
|
|
|
if (aState) {
|
2011-11-10 16:17:46 -08:00
|
|
|
BringToTop();
|
2012-01-05 13:23:34 -08:00
|
|
|
} else {
|
2015-04-29 20:17:57 -07:00
|
|
|
const nsTArray<nsWindow*>& windows =
|
|
|
|
mScreen->GetTopWindows();
|
|
|
|
for (unsigned int i = 0; i < windows.Length(); i++) {
|
|
|
|
nsWindow *win = windows[i];
|
|
|
|
if (!win->mVisible) {
|
2012-01-05 13:23:34 -08:00
|
|
|
continue;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2012-01-05 13:23:34 -08:00
|
|
|
win->BringToTop();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-19 01:57:50 -07:00
|
|
|
bool
|
|
|
|
nsWindow::IsVisible() const
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
2012-07-19 01:57:50 -07:00
|
|
|
return mVisible;
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::ConstrainPosition(bool aAllowSlop,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t *aX,
|
|
|
|
int32_t *aY)
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-12 01:57:38 -08:00
|
|
|
nsWindow::Move(double aX,
|
|
|
|
double aY)
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-12 01:57:38 -08:00
|
|
|
nsWindow::Resize(double aWidth,
|
|
|
|
double aHeight,
|
|
|
|
bool aRepaint)
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
|
|
|
return Resize(0, 0, aWidth, aHeight, aRepaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-12 01:57:38 -08:00
|
|
|
nsWindow::Resize(double aX,
|
|
|
|
double aY,
|
|
|
|
double aWidth,
|
|
|
|
double aHeight,
|
|
|
|
bool aRepaint)
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
2012-12-12 01:57:38 -08:00
|
|
|
mBounds = nsIntRect(NSToIntRound(aX), NSToIntRound(aY),
|
|
|
|
NSToIntRound(aWidth), NSToIntRound(aHeight));
|
2015-04-29 20:17:57 -07:00
|
|
|
if (mWidgetListener) {
|
2012-12-12 01:57:38 -08:00
|
|
|
mWidgetListener->WindowResized(this, mBounds.width, mBounds.height);
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
if (aRepaint) {
|
|
|
|
nsIntRect virtualBounds;
|
|
|
|
mScreen->GetRect(&virtualBounds.x, &virtualBounds.y,
|
|
|
|
&virtualBounds.width, &virtualBounds.height);
|
|
|
|
Invalidate(virtualBounds);
|
|
|
|
}
|
2012-02-22 00:50:44 -08:00
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Enable(bool aState)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-22 22:19:08 -07:00
|
|
|
bool
|
|
|
|
nsWindow::IsEnabled() const
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
2012-07-22 22:19:08 -07:00
|
|
|
return true;
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::SetFocus(bool aRaise)
|
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
if (aRaise) {
|
2011-11-10 16:17:46 -08:00
|
|
|
BringToTop();
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
gFocusedWindow = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::ConfigureChildren(const nsTArray<nsIWidget::Configuration>&)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-01-18 13:22:12 -08:00
|
|
|
nsWindow::Invalidate(const nsIntRect &aRect)
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
2014-04-10 19:21:36 -07:00
|
|
|
nsWindow *top = mParent;
|
2015-04-29 20:17:57 -07:00
|
|
|
while (top && top->mParent) {
|
2014-04-10 19:21:36 -07:00
|
|
|
top = top->mParent;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
|
|
|
const nsTArray<nsWindow*>& windows = mScreen->GetTopWindows();
|
|
|
|
if (top != windows[0] && this != windows[0]) {
|
2011-11-22 11:51:52 -08:00
|
|
|
return NS_OK;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2011-11-22 11:51:52 -08:00
|
|
|
|
2012-01-18 13:22:12 -08:00
|
|
|
gDrawRequest = true;
|
|
|
|
mozilla::NotifyEvent();
|
2011-11-10 16:17:46 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-04 12:21:03 -08:00
|
|
|
LayoutDeviceIntPoint
|
2011-11-10 16:17:46 -08:00
|
|
|
nsWindow::WidgetToScreenOffset()
|
|
|
|
{
|
2015-02-04 12:21:03 -08:00
|
|
|
LayoutDeviceIntPoint p(0, 0);
|
2011-11-10 16:17:46 -08:00
|
|
|
nsWindow *w = this;
|
|
|
|
|
|
|
|
while (w && w->mParent) {
|
|
|
|
p.x += w->mBounds.x;
|
|
|
|
p.y += w->mBounds.y;
|
|
|
|
|
|
|
|
w = w->mParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2012-08-22 08:56:38 -07:00
|
|
|
nsWindow::GetNativeData(uint32_t aDataType)
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
|
|
|
switch (aDataType) {
|
|
|
|
case NS_NATIVE_WINDOW:
|
2015-04-17 09:28:41 -07:00
|
|
|
// Called before primary display's EGLSurface creation.
|
2013-05-07 20:58:22 -07:00
|
|
|
return GetGonkDisplay()->GetNativeWindow();
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
2015-04-17 09:28:41 -07:00
|
|
|
void
|
|
|
|
nsWindow::SetNativeData(uint32_t aDataType, uintptr_t aVal)
|
|
|
|
{
|
|
|
|
switch (aDataType) {
|
|
|
|
case NS_NATIVE_OPENGL_CONTEXT:
|
|
|
|
// Called after primary display's GLContextEGL creation.
|
|
|
|
GLContext* context = reinterpret_cast<GLContext*>(aVal);
|
|
|
|
|
|
|
|
HwcComposer2D* hwc = HwcComposer2D::GetInstance();
|
|
|
|
hwc->SetEGLInfo(GLContextEGL::Cast(context)->GetEGLDisplay(),
|
|
|
|
GLContextEGL::Cast(context)->GetEGLSurface(),
|
|
|
|
context);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
NS_IMETHODIMP
|
2013-10-01 20:46:03 -07:00
|
|
|
nsWindow::DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus)
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
if (mWidgetListener) {
|
2012-08-15 11:53:09 -07:00
|
|
|
aStatus = mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents);
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-15 15:38:45 -08:00
|
|
|
NS_IMETHODIMP_(void)
|
|
|
|
nsWindow::SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction)
|
|
|
|
{
|
2012-01-05 11:17:14 -08:00
|
|
|
mInputContext = aContext;
|
2011-12-15 15:38:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(InputContext)
|
|
|
|
nsWindow::GetInputContext()
|
|
|
|
{
|
2012-10-26 16:35:21 -07:00
|
|
|
// There is only one IME context on Gonk.
|
|
|
|
mInputContext.mNativeIMEContext = nullptr;
|
2012-01-05 11:17:14 -08:00
|
|
|
return mInputContext;
|
2011-12-15 15:38:45 -08:00
|
|
|
}
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::ReparentNativeWidget(nsIWidget* aNewParent)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-14 23:13:48 -07:00
|
|
|
NS_IMETHODIMP
|
2014-07-09 12:29:28 -07:00
|
|
|
nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen*)
|
2012-08-14 23:13:48 -07:00
|
|
|
{
|
|
|
|
if (mWindowType != eWindowType_toplevel) {
|
|
|
|
// Ignore fullscreen request for non-toplevel windows.
|
|
|
|
NS_WARNING("MakeFullScreen() on a dialog or child widget?");
|
|
|
|
return nsBaseWidget::MakeFullScreen(aFullScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aFullScreen) {
|
|
|
|
// Fullscreen is "sticky" for toplevel widgets on gonk: we
|
|
|
|
// must paint the entire screen, and should only have one
|
|
|
|
// toplevel widget, so it doesn't make sense to ever "exit"
|
|
|
|
// fullscreen. If we do, we can leave parts of the screen
|
|
|
|
// unpainted.
|
2015-04-29 20:17:57 -07:00
|
|
|
nsIntRect virtualBounds;
|
|
|
|
mScreen->GetRect(&virtualBounds.x, &virtualBounds.y,
|
|
|
|
&virtualBounds.width, &virtualBounds.height);
|
|
|
|
Resize(virtualBounds.x, virtualBounds.y,
|
|
|
|
virtualBounds.width, virtualBounds.height,
|
2012-08-14 23:13:48 -07:00
|
|
|
/*repaint*/true);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-16 13:57:10 -07:00
|
|
|
static gralloc_module_t const*
|
|
|
|
gralloc_module()
|
|
|
|
{
|
|
|
|
hw_module_t const *module;
|
|
|
|
if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return reinterpret_cast<gralloc_module_t const*>(module);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SurfaceFormat
|
|
|
|
HalFormatToSurfaceFormat(int aHalFormat, int* bytepp)
|
|
|
|
{
|
|
|
|
switch (aHalFormat) {
|
|
|
|
case HAL_PIXEL_FORMAT_RGBA_8888:
|
|
|
|
*bytepp = 4;
|
|
|
|
return SurfaceFormat::R8G8B8A8;
|
|
|
|
case HAL_PIXEL_FORMAT_RGBX_8888:
|
|
|
|
*bytepp = 4;
|
|
|
|
return SurfaceFormat::R8G8B8X8;
|
|
|
|
case HAL_PIXEL_FORMAT_BGRA_8888:
|
|
|
|
*bytepp = 4;
|
|
|
|
return SurfaceFormat::B8G8R8A8;
|
|
|
|
case HAL_PIXEL_FORMAT_RGB_565:
|
|
|
|
*bytepp = 2;
|
|
|
|
return SurfaceFormat::R5G6B5;
|
|
|
|
default:
|
|
|
|
MOZ_CRASH("Unhandled HAL pixel format");
|
|
|
|
return SurfaceFormat::UNKNOWN; // not reached
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<DrawTarget>
|
|
|
|
nsWindow::StartRemoteDrawing()
|
|
|
|
{
|
|
|
|
GonkDisplay* display = GetGonkDisplay();
|
|
|
|
mFramebuffer = display->DequeueBuffer();
|
|
|
|
int width = mFramebuffer->width, height = mFramebuffer->height;
|
|
|
|
void *vaddr;
|
|
|
|
if (gralloc_module()->lock(gralloc_module(), mFramebuffer->handle,
|
|
|
|
GRALLOC_USAGE_SW_READ_NEVER |
|
|
|
|
GRALLOC_USAGE_SW_WRITE_OFTEN |
|
|
|
|
GRALLOC_USAGE_HW_FB,
|
|
|
|
0, 0, width, height, &vaddr)) {
|
|
|
|
EndRemoteDrawing();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
int bytepp;
|
|
|
|
SurfaceFormat format = HalFormatToSurfaceFormat(display->surfaceformat,
|
|
|
|
&bytepp);
|
2014-11-06 11:39:48 -08:00
|
|
|
mFramebufferTarget = Factory::CreateDrawTargetForData(
|
|
|
|
BackendType::CAIRO, (uint8_t*)vaddr,
|
|
|
|
IntSize(width, height), mFramebuffer->stride * bytepp, format);
|
2015-03-09 12:48:20 -07:00
|
|
|
if (!mFramebufferTarget) {
|
|
|
|
MOZ_CRASH("nsWindow::StartRemoteDrawing failed in CreateDrawTargetForData");
|
|
|
|
}
|
2014-11-06 11:39:48 -08:00
|
|
|
if (!mBackBuffer ||
|
|
|
|
mBackBuffer->GetSize() != mFramebufferTarget->GetSize() ||
|
|
|
|
mBackBuffer->GetFormat() != mFramebufferTarget->GetFormat()) {
|
|
|
|
mBackBuffer = mFramebufferTarget->CreateSimilarDrawTarget(
|
|
|
|
mFramebufferTarget->GetSize(), mFramebufferTarget->GetFormat());
|
|
|
|
}
|
|
|
|
return mBackBuffer;
|
2014-10-16 13:57:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::EndRemoteDrawing()
|
|
|
|
{
|
|
|
|
if (mFramebufferTarget) {
|
2014-11-06 11:39:48 -08:00
|
|
|
IntSize size = mFramebufferTarget->GetSize();
|
|
|
|
Rect rect(0, 0, size.width, size.height);
|
|
|
|
RefPtr<SourceSurface> source = mBackBuffer->Snapshot();
|
|
|
|
mFramebufferTarget->DrawSurface(source, rect, rect);
|
2014-10-16 13:57:10 -07:00
|
|
|
gralloc_module()->unlock(gralloc_module(), mFramebuffer->handle);
|
|
|
|
}
|
|
|
|
if (mFramebuffer) {
|
|
|
|
GetGonkDisplay()->QueueBuffer(mFramebuffer);
|
|
|
|
}
|
|
|
|
mFramebuffer = nullptr;
|
|
|
|
mFramebufferTarget = nullptr;
|
|
|
|
}
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
float
|
|
|
|
nsWindow::GetDPI()
|
|
|
|
{
|
2013-05-07 20:58:22 -07:00
|
|
|
return GetGonkDisplay()->xdpi;
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
2013-05-01 13:04:56 -07:00
|
|
|
double
|
|
|
|
nsWindow::GetDefaultScaleInternal()
|
|
|
|
{
|
2013-06-03 05:30:28 -07:00
|
|
|
float dpi = GetDPI();
|
|
|
|
// The mean pixel density for mdpi devices is 160dpi, 240dpi for hdpi,
|
|
|
|
// and 320dpi for xhdpi, respectively.
|
|
|
|
// We'll take the mid-value between these three numbers as the boundary.
|
|
|
|
if (dpi < 200.0) {
|
|
|
|
return 1.0; // mdpi devices.
|
|
|
|
}
|
2013-11-21 13:03:24 -08:00
|
|
|
if (dpi < 300.0) {
|
2013-06-03 05:30:28 -07:00
|
|
|
return 1.5; // hdpi devices.
|
|
|
|
}
|
2013-11-21 13:03:24 -08:00
|
|
|
// xhdpi devices and beyond.
|
2014-01-25 04:21:01 -08:00
|
|
|
return floor(dpi / 150.0 + 0.5);
|
2013-05-01 13:04:56 -07:00
|
|
|
}
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
LayerManager *
|
2013-04-24 11:42:40 -07:00
|
|
|
nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager,
|
2011-11-10 16:17:46 -08:00
|
|
|
LayersBackend aBackendHint,
|
|
|
|
LayerManagerPersistence aPersistence,
|
|
|
|
bool* aAllowRetaining)
|
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
if (aAllowRetaining) {
|
2011-11-10 16:17:46 -08:00
|
|
|
*aAllowRetaining = true;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2012-08-14 18:10:40 -07:00
|
|
|
if (mLayerManager) {
|
|
|
|
// This layer manager might be used for painting outside of DoDraw(), so we need
|
|
|
|
// to set the correct rotation on it.
|
2014-07-03 19:36:22 -07:00
|
|
|
if (mLayerManager->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
2013-04-30 22:03:25 -07:00
|
|
|
ClientLayerManager* manager =
|
|
|
|
static_cast<ClientLayerManager*>(mLayerManager.get());
|
2015-04-29 20:17:57 -07:00
|
|
|
uint32_t rotation = mScreen->EffectiveScreenRotation();
|
2014-01-23 10:26:41 -08:00
|
|
|
manager->SetDefaultTargetConfiguration(mozilla::layers::BufferMode::BUFFER_NONE,
|
2015-04-29 20:17:57 -07:00
|
|
|
ScreenRotation(rotation));
|
2012-08-14 18:10:40 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
return mLayerManager;
|
2012-08-14 18:10:40 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2012-11-15 10:55:15 -08:00
|
|
|
// Set mUseLayersAcceleration here to make it consistent with
|
2012-07-04 05:30:59 -07:00
|
|
|
// nsBaseWidget::GetLayerManager
|
2012-11-15 10:55:15 -08:00
|
|
|
mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
|
2015-04-29 20:17:57 -07:00
|
|
|
|
|
|
|
const nsTArray<nsWindow*>& windows = mScreen->GetTopWindows();
|
|
|
|
nsWindow *topWindow = windows[0];
|
2011-11-10 16:17:46 -08:00
|
|
|
|
|
|
|
if (!topWindow) {
|
2012-07-07 07:07:00 -07:00
|
|
|
LOGW(" -- no topwindow\n");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
2014-07-03 19:36:22 -07:00
|
|
|
CreateCompositor();
|
|
|
|
if (mCompositorParent) {
|
2014-09-24 06:50:45 -07:00
|
|
|
HwcComposer2D::GetInstance()->SetCompositorParent(mCompositorParent);
|
2011-12-23 23:13:33 -08:00
|
|
|
}
|
2014-07-03 19:36:22 -07:00
|
|
|
MOZ_ASSERT(mLayerManager);
|
2011-11-10 16:17:46 -08:00
|
|
|
return mLayerManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::BringToTop()
|
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
const nsTArray<nsWindow*>& windows = mScreen->GetTopWindows();
|
|
|
|
if (!windows.IsEmpty()) {
|
|
|
|
if (nsIWidgetListener* listener = windows[0]->GetWidgetListener()) {
|
2012-08-15 11:52:42 -07:00
|
|
|
listener->WindowDeactivated();
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
mScreen->BringToTop(this);
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
if (mWidgetListener) {
|
2012-08-15 11:52:42 -07:00
|
|
|
mWidgetListener->WindowActivated();
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect virtualBounds;
|
|
|
|
mScreen->GetRect(&virtualBounds.x, &virtualBounds.y,
|
|
|
|
&virtualBounds.width, &virtualBounds.height);
|
|
|
|
Invalidate(virtualBounds);
|
2011-11-10 16:17:46 -08:00
|
|
|
}
|
|
|
|
|
2012-01-10 18:07:00 -08:00
|
|
|
void
|
|
|
|
nsWindow::UserActivity()
|
|
|
|
{
|
|
|
|
if (!mIdleService) {
|
|
|
|
mIdleService = do_GetService("@mozilla.org/widget/idleservice;1");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mIdleService) {
|
2012-06-29 01:32:21 -07:00
|
|
|
mIdleService->ResetIdleTimeOut(0);
|
2012-01-10 18:07:00 -08:00
|
|
|
}
|
|
|
|
}
|
2012-01-25 18:05:34 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2012-01-25 18:05:34 -08:00
|
|
|
nsWindow::GetGLFrameBufferFormat()
|
|
|
|
{
|
|
|
|
if (mLayerManager &&
|
2014-01-23 10:26:41 -08:00
|
|
|
mLayerManager->GetBackendType() == mozilla::layers::LayersBackend::LAYERS_OPENGL) {
|
2012-01-25 18:05:34 -08:00
|
|
|
// We directly map the hardware fb on Gonk. The hardware fb
|
|
|
|
// has RGB format.
|
|
|
|
return LOCAL_GL_RGB;
|
|
|
|
}
|
|
|
|
return LOCAL_GL_NONE;
|
|
|
|
}
|
2012-02-06 14:47:11 -08:00
|
|
|
|
2012-07-24 12:01:09 -07:00
|
|
|
nsIntRect
|
|
|
|
nsWindow::GetNaturalBounds()
|
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
return mScreen->GetNaturalBounds();
|
2012-07-24 12:01:09 -07:00
|
|
|
}
|
|
|
|
|
2012-08-13 19:41:09 -07:00
|
|
|
bool
|
|
|
|
nsWindow::NeedsPaint()
|
|
|
|
{
|
|
|
|
if (!mLayerManager) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return nsIWidget::NeedsPaint();
|
|
|
|
}
|
|
|
|
|
2012-11-19 09:58:38 -08:00
|
|
|
Composer2D*
|
|
|
|
nsWindow::GetComposer2D()
|
|
|
|
{
|
2015-04-17 09:28:41 -07:00
|
|
|
return HwcComposer2D::GetInstance();
|
2012-11-19 09:58:38 -08:00
|
|
|
}
|
|
|
|
|
2012-02-06 14:47:11 -08:00
|
|
|
// nsScreenGonk.cpp
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
nsScreenGonk::nsScreenGonk()
|
|
|
|
: mScreenRotation(nsIScreen::ROTATION_0_DEG)
|
|
|
|
, mPhysicalScreenRotation(nsIScreen::ROTATION_0_DEG)
|
2012-02-06 14:47:11 -08:00
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
nsIntSize screenSize;
|
|
|
|
|
|
|
|
ANativeWindow *win = GetGonkDisplay()->GetNativeWindow();
|
|
|
|
if (win->query(win, NATIVE_WINDOW_WIDTH, &screenSize.width) ||
|
|
|
|
win->query(win, NATIVE_WINDOW_HEIGHT, &screenSize.height)) {
|
|
|
|
NS_RUNTIMEABORT("Failed to get native window size, aborting...");
|
|
|
|
}
|
|
|
|
mScreenBounds = gfx::IntRect(gfx::IntPoint(0, 0), screenSize);
|
|
|
|
|
|
|
|
char propValue[PROPERTY_VALUE_MAX];
|
|
|
|
property_get("ro.sf.hwrotation", propValue, "0");
|
|
|
|
mPhysicalScreenRotation = atoi(propValue) / 90;
|
|
|
|
|
|
|
|
mVirtualBounds = mScreenBounds;
|
2012-02-06 14:47:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsScreenGonk::~nsScreenGonk()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-07-14 10:22:26 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenGonk::GetId(uint32_t *outId)
|
|
|
|
{
|
|
|
|
*outId = 1;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-02-06 14:47:11 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScreenGonk::GetRect(int32_t *outLeft, int32_t *outTop,
|
|
|
|
int32_t *outWidth, int32_t *outHeight)
|
2012-02-06 14:47:11 -08:00
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
*outLeft = mVirtualBounds.x;
|
|
|
|
*outTop = mVirtualBounds.y;
|
2012-02-06 14:47:11 -08:00
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
*outWidth = mVirtualBounds.width;
|
|
|
|
*outHeight = mVirtualBounds.height;
|
2012-02-06 14:47:11 -08:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScreenGonk::GetAvailRect(int32_t *outLeft, int32_t *outTop,
|
|
|
|
int32_t *outWidth, int32_t *outHeight)
|
2012-02-06 14:47:11 -08:00
|
|
|
{
|
|
|
|
return GetRect(outLeft, outTop, outWidth, outHeight);
|
|
|
|
}
|
|
|
|
|
2012-05-08 14:36:07 -07:00
|
|
|
static uint32_t
|
|
|
|
ColorDepth()
|
|
|
|
{
|
2013-05-07 20:58:22 -07:00
|
|
|
switch (GetGonkDisplay()->surfaceformat) {
|
2012-06-22 01:18:54 -07:00
|
|
|
case GGL_PIXEL_FORMAT_RGB_565:
|
|
|
|
return 16;
|
|
|
|
case GGL_PIXEL_FORMAT_RGBA_8888:
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
return 24; // GGL_PIXEL_FORMAT_RGBX_8888
|
2012-05-08 14:36:07 -07:00
|
|
|
}
|
2012-02-06 14:47:11 -08:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScreenGonk::GetPixelDepth(int32_t *aPixelDepth)
|
2012-02-06 14:47:11 -08:00
|
|
|
{
|
2012-05-08 14:36:07 -07:00
|
|
|
// XXX: this should actually return 32 when we're using 24-bit
|
|
|
|
// color, because we use RGBX.
|
|
|
|
*aPixelDepth = ColorDepth();
|
2012-02-06 14:47:11 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScreenGonk::GetColorDepth(int32_t *aColorDepth)
|
2012-02-06 14:47:11 -08:00
|
|
|
{
|
|
|
|
return GetPixelDepth(aColorDepth);
|
|
|
|
}
|
|
|
|
|
2012-02-06 17:47:11 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScreenGonk::GetRotation(uint32_t* aRotation)
|
2012-02-06 17:47:11 -08:00
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
*aRotation = mScreenRotation;
|
2012-02-06 17:47:11 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScreenGonk::SetRotation(uint32_t aRotation)
|
2012-02-06 17:47:11 -08:00
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
if (!(aRotation <= ROTATION_270_DEG)) {
|
2012-02-06 17:47:11 -08:00
|
|
|
return NS_ERROR_ILLEGAL_VALUE;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2012-02-06 17:47:11 -08:00
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
if (mScreenRotation == aRotation) {
|
2012-02-06 17:47:11 -08:00
|
|
|
return NS_OK;
|
2015-04-29 20:17:57 -07:00
|
|
|
}
|
2012-02-06 17:47:11 -08:00
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
mScreenRotation = aRotation;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t rotation = EffectiveScreenRotation();
|
2012-07-24 12:01:09 -07:00
|
|
|
if (rotation == nsIScreen::ROTATION_90_DEG ||
|
|
|
|
rotation == nsIScreen::ROTATION_270_DEG) {
|
2015-04-29 20:17:57 -07:00
|
|
|
mVirtualBounds = nsIntRect(0, 0,
|
|
|
|
mScreenBounds.height,
|
|
|
|
mScreenBounds.width);
|
2012-07-24 12:01:09 -07:00
|
|
|
} else {
|
2015-04-29 20:17:57 -07:00
|
|
|
mVirtualBounds = mScreenBounds;
|
2012-02-06 17:47:11 -08:00
|
|
|
}
|
|
|
|
|
2014-04-10 19:21:36 -07:00
|
|
|
nsAppShell::NotifyScreenRotation();
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
for (unsigned int i = 0; i < mTopWindows.Length(); i++) {
|
|
|
|
mTopWindows[i]->Resize(mVirtualBounds.width,
|
|
|
|
mVirtualBounds.height,
|
|
|
|
true);
|
|
|
|
}
|
2012-04-24 20:59:01 -07:00
|
|
|
|
2012-02-06 17:47:11 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
nsIntRect
|
|
|
|
nsScreenGonk::GetNaturalBounds()
|
|
|
|
{
|
|
|
|
return mScreenBounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
nsScreenGonk::EffectiveScreenRotation()
|
|
|
|
{
|
|
|
|
return (mScreenRotation + mPhysicalScreenRotation) % (360 / 90);
|
|
|
|
}
|
|
|
|
|
2012-05-08 14:36:07 -07:00
|
|
|
// NB: This isn't gonk-specific, but gonk is the only widget backend
|
|
|
|
// that does this calculation itself, currently.
|
|
|
|
static ScreenOrientation
|
|
|
|
ComputeOrientation(uint32_t aRotation, const nsIntSize& aScreenSize)
|
|
|
|
{
|
|
|
|
bool naturallyPortrait = (aScreenSize.height > aScreenSize.width);
|
|
|
|
switch (aRotation) {
|
|
|
|
case nsIScreen::ROTATION_0_DEG:
|
2015-04-29 20:17:57 -07:00
|
|
|
return (naturallyPortrait ? eScreenOrientation_PortraitPrimary :
|
2012-05-08 14:36:07 -07:00
|
|
|
eScreenOrientation_LandscapePrimary);
|
|
|
|
case nsIScreen::ROTATION_90_DEG:
|
|
|
|
// Arbitrarily choosing 90deg to be primary "unnatural"
|
|
|
|
// rotation.
|
2015-04-29 20:17:57 -07:00
|
|
|
return (naturallyPortrait ? eScreenOrientation_LandscapePrimary :
|
2012-05-08 14:36:07 -07:00
|
|
|
eScreenOrientation_PortraitPrimary);
|
|
|
|
case nsIScreen::ROTATION_180_DEG:
|
2015-04-29 20:17:57 -07:00
|
|
|
return (naturallyPortrait ? eScreenOrientation_PortraitSecondary :
|
2012-05-08 14:36:07 -07:00
|
|
|
eScreenOrientation_LandscapeSecondary);
|
|
|
|
case nsIScreen::ROTATION_270_DEG:
|
2015-04-29 20:17:57 -07:00
|
|
|
return (naturallyPortrait ? eScreenOrientation_LandscapeSecondary :
|
2012-05-08 14:36:07 -07:00
|
|
|
eScreenOrientation_PortraitSecondary);
|
|
|
|
default:
|
2013-06-28 18:38:30 -07:00
|
|
|
MOZ_CRASH("Gonk screen must always have a known rotation");
|
2012-05-08 14:36:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
ScreenConfiguration
|
2012-05-08 14:36:07 -07:00
|
|
|
nsScreenGonk::GetConfiguration()
|
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
ScreenOrientation orientation = ComputeOrientation(mScreenRotation,
|
|
|
|
mScreenBounds.Size());
|
2012-05-08 14:36:07 -07:00
|
|
|
uint32_t colorDepth = ColorDepth();
|
|
|
|
// NB: perpetuating colorDepth == pixelDepth illusion here, for
|
|
|
|
// consistency.
|
2015-04-29 20:17:57 -07:00
|
|
|
return ScreenConfiguration(mVirtualBounds, orientation,
|
2012-05-08 14:36:07 -07:00
|
|
|
colorDepth, colorDepth);
|
|
|
|
}
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
void
|
|
|
|
nsScreenGonk::RegisterWindow(nsWindow* aWindow)
|
|
|
|
{
|
|
|
|
mTopWindows.AppendElement(aWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsScreenGonk::UnregisterWindow(nsWindow* aWindow)
|
|
|
|
{
|
|
|
|
mTopWindows.RemoveElement(aWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsScreenGonk::BringToTop(nsWindow* aWindow)
|
|
|
|
{
|
|
|
|
mTopWindows.RemoveElement(aWindow);
|
|
|
|
mTopWindows.InsertElementAt(0, aWindow);
|
|
|
|
}
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(nsScreenManagerGonk, nsIScreenManager)
|
2012-02-06 14:47:11 -08:00
|
|
|
|
|
|
|
nsScreenManagerGonk::nsScreenManagerGonk()
|
2015-04-29 20:17:57 -07:00
|
|
|
: mInitialized(false)
|
2012-02-06 14:47:11 -08:00
|
|
|
{
|
2015-04-29 20:17:57 -07:00
|
|
|
mOneScreen = new nsScreenGonk();
|
2012-02-06 14:47:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsScreenManagerGonk::~nsScreenManagerGonk()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
/* static */ already_AddRefed<nsScreenManagerGonk>
|
|
|
|
nsScreenManagerGonk::GetInstance()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIScreenManager> manager;
|
|
|
|
manager = do_GetService("@mozilla.org/gfx/screenmanager;1");
|
|
|
|
MOZ_ASSERT(manager);
|
|
|
|
return already_AddRefed<nsScreenManagerGonk>(
|
|
|
|
static_cast<nsScreenManagerGonk*>(manager.forget().take()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ already_AddRefed< nsScreenGonk>
|
|
|
|
nsScreenManagerGonk::GetPrimaryScreen()
|
|
|
|
{
|
|
|
|
nsRefPtr<nsScreenManagerGonk> manager = nsScreenManagerGonk::GetInstance();
|
|
|
|
nsCOMPtr<nsIScreen> screen;
|
|
|
|
manager->GetPrimaryScreen(getter_AddRefs(screen));
|
|
|
|
MOZ_ASSERT(screen);
|
|
|
|
return already_AddRefed<nsScreenGonk>(
|
|
|
|
static_cast<nsScreenGonk*>(screen.forget().take()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsScreenManagerGonk::Initialize()
|
|
|
|
{
|
|
|
|
if (mInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mScreenOnEvent = new ScreenOnOffEvent(true);
|
|
|
|
mScreenOffEvent = new ScreenOnOffEvent(false);
|
|
|
|
GetGonkDisplay()->OnEnabled(displayEnabledCallback);
|
|
|
|
|
|
|
|
nsAppShell::NotifyScreenInitialized();
|
|
|
|
mInitialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsScreenManagerGonk::DisplayEnabled(bool aEnabled)
|
|
|
|
{
|
|
|
|
HwcComposer2D::GetInstance()->EnableVsync(aEnabled);
|
|
|
|
NS_DispatchToMainThread(aEnabled ? mScreenOnEvent : mScreenOffEvent);
|
|
|
|
}
|
|
|
|
|
2012-02-06 14:47:11 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenManagerGonk::GetPrimaryScreen(nsIScreen **outScreen)
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(*outScreen = mOneScreen.get());
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-14 10:22:26 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenManagerGonk::ScreenForId(uint32_t aId,
|
|
|
|
nsIScreen **outScreen)
|
|
|
|
{
|
|
|
|
return GetPrimaryScreen(outScreen);
|
|
|
|
}
|
|
|
|
|
2012-02-06 14:47:11 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScreenManagerGonk::ScreenForRect(int32_t inLeft,
|
|
|
|
int32_t inTop,
|
|
|
|
int32_t inWidth,
|
|
|
|
int32_t inHeight,
|
2012-02-06 14:47:11 -08:00
|
|
|
nsIScreen **outScreen)
|
|
|
|
{
|
|
|
|
return GetPrimaryScreen(outScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenManagerGonk::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
|
|
|
|
{
|
|
|
|
return GetPrimaryScreen(outScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScreenManagerGonk::GetNumberOfScreens(uint32_t *aNumberOfScreens)
|
2012-02-06 14:47:11 -08:00
|
|
|
{
|
|
|
|
*aNumberOfScreens = 1;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-04-09 14:07:02 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenManagerGonk::GetSystemDefaultScale(float *aDefaultScale)
|
|
|
|
{
|
|
|
|
*aDefaultScale = 1.0f;
|
|
|
|
return NS_OK;
|
|
|
|
}
|