2012-07-20 13:10:44 +04: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-11 04:17:46 +04:00
|
|
|
|
2016-04-19 23:51:25 +03:00
|
|
|
#include "nsWindow.h"
|
|
|
|
|
2012-12-15 03:58:45 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2012-04-05 10:03:00 +04:00
|
|
|
#include <fcntl.h>
|
2011-12-24 11:13:33 +04:00
|
|
|
|
|
|
|
#include "android/log.h"
|
2012-09-12 00:05:52 +04:00
|
|
|
#include "mozilla/dom/TabParent.h"
|
2012-04-05 20:15:19 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2016-04-19 23:51:25 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2014-07-05 22:19:12 +04:00
|
|
|
#include "mozilla/Services.h"
|
2012-04-05 10:03:00 +04:00
|
|
|
#include "mozilla/FileUtils.h"
|
2013-07-02 03:03:17 +04:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2011-12-24 11:13:33 +04:00
|
|
|
#include "gfxContext.h"
|
2012-08-19 23:33:25 +04:00
|
|
|
#include "gfxPlatform.h"
|
2011-11-11 04:17:46 +04:00
|
|
|
#include "GLContextProvider.h"
|
2013-09-04 16:14:52 +04:00
|
|
|
#include "GLContext.h"
|
2015-04-17 19:28:41 +03:00
|
|
|
#include "GLContextEGL.h"
|
2011-12-24 11:13:33 +04:00
|
|
|
#include "nsAppShell.h"
|
2012-02-07 02:47:11 +04:00
|
|
|
#include "nsScreenManagerGonk.h"
|
|
|
|
#include "nsTArray.h"
|
2012-08-15 22:52:42 +04:00
|
|
|
#include "nsIWidgetListener.h"
|
2013-05-01 09:03:25 +04:00
|
|
|
#include "ClientLayerManager.h"
|
2012-07-31 04:42:26 +04:00
|
|
|
#include "BasicLayers.h"
|
2013-05-08 07:58:22 +04:00
|
|
|
#include "libdisplay/GonkDisplay.h"
|
2015-04-15 12:45:18 +03:00
|
|
|
#include "mozilla/TextEvents.h"
|
2014-10-17 00:57:10 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-03-09 22:48:20 +03:00
|
|
|
#include "mozilla/gfx/Logging.h"
|
2014-01-24 01:34:31 +04:00
|
|
|
#include "mozilla/layers/APZCTreeManager.h"
|
2015-02-10 16:24:23 +03:00
|
|
|
#include "mozilla/layers/APZThreadUtils.h"
|
2016-03-22 21:08:38 +03:00
|
|
|
#include "mozilla/layers/CompositorBridgeParent.h"
|
2016-05-18 19:47:58 +03:00
|
|
|
#include "mozilla/layers/CompositorThread.h"
|
2016-05-18 08:33:22 +03:00
|
|
|
#include "mozilla/layers/CompositorSession.h"
|
2015-01-15 18:37:54 +03:00
|
|
|
#include "mozilla/TouchEvents.h"
|
2013-05-08 07:58:22 +04:00
|
|
|
#include "HwcComposer2D.h"
|
2011-11-11 04:17:46 +04:00
|
|
|
|
|
|
|
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
|
2012-07-07 18:07:00 +04: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-11 04:17:46 +04:00
|
|
|
|
|
|
|
#define IS_TOPLEVEL() (mWindowType == eWindowType_toplevel || mWindowType == eWindowType_dialog)
|
|
|
|
|
2011-12-24 11:13:33 +04:00
|
|
|
using namespace mozilla;
|
2012-05-09 01:36:07 +04:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
using namespace mozilla::hal;
|
2014-10-17 00:57:10 +04:00
|
|
|
using namespace mozilla::gfx;
|
2011-11-11 04:17:46 +04:00
|
|
|
using namespace mozilla::gl;
|
|
|
|
using namespace mozilla::layers;
|
2011-12-16 03:38:45 +04:00
|
|
|
using namespace mozilla::widget;
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
static nsWindow *gFocusedWindow = nullptr;
|
2012-04-05 10:03:00 +04:00
|
|
|
|
2015-02-18 09:27:53 +03:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget)
|
2015-02-09 21:50:51 +03:00
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
nsWindow::nsWindow()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsScreenManagerGonk> screenManager = nsScreenManagerGonk::GetInstance();
|
2015-04-30 06:17:57 +03:00
|
|
|
screenManager->Initialize();
|
2014-07-23 00:46:27 +04: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-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsWindow::~nsWindow()
|
|
|
|
{
|
2015-04-30 09:38:26 +03:00
|
|
|
if (mScreen->IsPrimaryScreen()) {
|
2016-03-22 21:08:38 +03:00
|
|
|
mComposer2D->SetCompositorBridgeParent(nullptr);
|
2015-04-30 09:38:26 +03:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::DoDraw(void)
|
|
|
|
{
|
2012-01-17 14:55:25 +04:00
|
|
|
if (!hal::GetScreenEnabled()) {
|
|
|
|
gDrawRequest = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsScreenGonk> screen = nsScreenManagerGonk::GetPrimaryScreen();
|
2015-04-30 06:17:57 +03:00
|
|
|
const nsTArray<nsWindow*>& windows = screen->GetTopWindows();
|
|
|
|
|
|
|
|
if (windows.IsEmpty()) {
|
2011-12-24 11:13:33 +04:00
|
|
|
LOG(" no window to draw, bailing");
|
2011-11-11 04:17:46 +04:00
|
|
|
return;
|
2011-12-24 11:13:33 +04:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2016-05-11 06:58:47 +03:00
|
|
|
RefPtr<nsWindow> targetWindow = (nsWindow *)windows[0];
|
2015-04-30 06:17:57 +03:00
|
|
|
while (targetWindow->GetLastChild()) {
|
2014-04-11 06:21:36 +04:00
|
|
|
targetWindow = (nsWindow *)targetWindow->GetLastChild();
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2011-12-24 11:13:33 +04:00
|
|
|
|
2014-04-11 06:21:36 +04:00
|
|
|
nsIWidgetListener* listener = targetWindow->GetWidgetListener();
|
2013-01-28 23:34:03 +04:00
|
|
|
if (listener) {
|
2014-04-11 06:21:36 +04:00
|
|
|
listener->WillPaintWindow(targetWindow);
|
2013-01-28 23:34:03 +04:00
|
|
|
}
|
|
|
|
|
2014-04-11 06:21:36 +04:00
|
|
|
listener = targetWindow->GetWidgetListener();
|
2013-01-28 23:34:03 +04:00
|
|
|
if (listener) {
|
2016-05-11 06:58:47 +03:00
|
|
|
LayerManager* lm = targetWindow->GetLayerManager();
|
|
|
|
if (mozilla::layers::LayersBackend::LAYERS_CLIENT == lm->GetBackendType()) {
|
|
|
|
// No need to do anything, the compositor will handle drawing
|
|
|
|
} else {
|
|
|
|
NS_RUNTIMEABORT("Unexpected layer manager type");
|
|
|
|
}
|
|
|
|
|
2013-01-28 23:34:03 +04:00
|
|
|
listener->DidPaintWindow();
|
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
2015-03-27 00:23:02 +03:00
|
|
|
void
|
|
|
|
nsWindow::ConfigureAPZControllerThread()
|
|
|
|
{
|
2016-05-18 19:47:58 +03:00
|
|
|
APZThreadUtils::SetControllerThread(CompositorThreadHolder::Loop());
|
2015-03-27 00:23:02 +03:00
|
|
|
}
|
|
|
|
|
2015-01-15 18:37:54 +03:00
|
|
|
/*static*/ nsEventStatus
|
2015-04-15 12:45:18 +03:00
|
|
|
nsWindow::DispatchKeyInput(WidgetKeyboardEvent& aEvent)
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
2012-09-12 00:05:52 +04:00
|
|
|
if (!gFocusedWindow) {
|
2011-11-11 04:17:46 +04:00
|
|
|
return nsEventStatus_eIgnore;
|
2012-09-12 00:05:52 +04:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2012-01-11 06:07:00 +04:00
|
|
|
gFocusedWindow->UserActivity();
|
2012-08-15 22:53:09 +04:00
|
|
|
|
2015-01-15 18:37:54 +03:00
|
|
|
nsEventStatus status;
|
2016-04-14 11:03:14 +03:00
|
|
|
aEvent.mWidget = gFocusedWindow;
|
2015-01-15 18:37:54 +03:00
|
|
|
gFocusedWindow->DispatchEvent(&aEvent, status);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
nsWindow::DispatchTouchInput(MultiTouchInput& aInput)
|
|
|
|
{
|
2015-02-10 16:24:23 +03:00
|
|
|
APZThreadUtils::AssertOnControllerThread();
|
|
|
|
|
2015-01-15 18:37:54 +03:00
|
|
|
if (!gFocusedWindow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gFocusedWindow->DispatchTouchInputViaAPZ(aInput);
|
|
|
|
}
|
|
|
|
|
2016-04-27 13:05:40 +03:00
|
|
|
class DispatchTouchInputOnMainThread : public mozilla::Runnable
|
2015-02-10 16:24:23 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DispatchTouchInputOnMainThread(const MultiTouchInput& aInput,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
2015-03-25 19:20:20 +03:00
|
|
|
const uint64_t& aInputBlockId,
|
|
|
|
nsEventStatus aApzResponse)
|
2015-02-10 16:24:23 +03:00
|
|
|
: mInput(aInput)
|
|
|
|
, mGuid(aGuid)
|
|
|
|
, mInputBlockId(aInputBlockId)
|
2015-03-25 19:20:20 +03:00
|
|
|
, mApzResponse(aApzResponse)
|
2015-02-10 16:24:23 +03:00
|
|
|
{}
|
|
|
|
|
|
|
|
NS_IMETHOD Run() {
|
|
|
|
if (gFocusedWindow) {
|
2015-03-25 19:20:20 +03:00
|
|
|
gFocusedWindow->DispatchTouchEventForAPZ(mInput, mGuid, mInputBlockId, mApzResponse);
|
2015-02-10 16:24:23 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MultiTouchInput mInput;
|
|
|
|
ScrollableLayerGuid mGuid;
|
|
|
|
uint64_t mInputBlockId;
|
2015-03-25 19:20:20 +03:00
|
|
|
nsEventStatus mApzResponse;
|
2015-02-10 16:24:23 +03:00
|
|
|
};
|
|
|
|
|
2015-01-15 18:37:54 +03:00
|
|
|
void
|
|
|
|
nsWindow::DispatchTouchInputViaAPZ(MultiTouchInput& aInput)
|
|
|
|
{
|
2015-02-10 16:24:23 +03:00
|
|
|
APZThreadUtils::AssertOnControllerThread();
|
|
|
|
|
2015-01-15 18:37:54 +03: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 19:20:20 +03:00
|
|
|
nsEventStatus result = mAPZC->ReceiveInputEvent(aInput, &guid, &inputBlockId);
|
2015-01-15 18:37:54 +03:00
|
|
|
// If the APZ says to drop it, then we drop it
|
2015-03-25 19:20:20 +03:00
|
|
|
if (result == nsEventStatus_eConsumeNoDefault) {
|
2015-01-15 18:37:54 +03:00
|
|
|
return;
|
|
|
|
}
|
2012-09-12 00:05:52 +04:00
|
|
|
|
2015-02-10 16:24:23 +03: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 19:20:20 +03:00
|
|
|
aInput, guid, inputBlockId, result));
|
2015-02-10 16:24:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::DispatchTouchEventForAPZ(const MultiTouchInput& aInput,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
2015-03-25 19:20:20 +03:00
|
|
|
const uint64_t aInputBlockId,
|
|
|
|
nsEventStatus aApzResponse)
|
2015-02-10 16:24:23 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
UserActivity();
|
|
|
|
|
2015-01-15 18:37:54 +03:00
|
|
|
// Convert it to an event we can send to Gecko
|
|
|
|
WidgetTouchEvent event = aInput.ToWidgetTouchEvent(this);
|
|
|
|
|
2015-03-16 19:32:17 +03:00
|
|
|
// Dispatch the event into the gecko root process for "normal" flow.
|
2015-03-25 19:20:20 +03: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-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
2016-05-02 20:27:15 +03:00
|
|
|
class DispatchTouchInputOnControllerThread : public Runnable
|
2015-02-10 16:24:23 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DispatchTouchInputOnControllerThread(const MultiTouchInput& aInput)
|
2016-05-02 20:27:15 +03:00
|
|
|
: mInput(aInput)
|
2015-02-10 16:24:23 +03:00
|
|
|
{}
|
|
|
|
|
2016-05-02 20:27:15 +03:00
|
|
|
NS_IMETHOD Run() override {
|
2015-02-10 16:24:23 +03:00
|
|
|
if (gFocusedWindow) {
|
|
|
|
gFocusedWindow->DispatchTouchInputViaAPZ(mInput);
|
|
|
|
}
|
2016-05-02 20:27:15 +03:00
|
|
|
return NS_OK;
|
2015-02-10 16:24:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MultiTouchInput mInput;
|
|
|
|
};
|
2015-01-20 02:38:00 +03:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|
|
|
TouchPointerState aPointerState,
|
2016-04-15 13:39:36 +03:00
|
|
|
LayoutDeviceIntPoint aPoint,
|
2015-01-20 02:38:00 +03:00
|
|
|
double aPointerPressure,
|
2015-04-14 18:36:36 +03:00
|
|
|
uint32_t aPointerOrientation,
|
|
|
|
nsIObserver* aObserver)
|
2015-01-20 02:38:00 +03:00
|
|
|
{
|
2015-04-14 18:36:36 +03:00
|
|
|
AutoObserverNotifier notifier(aObserver, "touchpoint");
|
|
|
|
|
2015-01-20 02:38:00 +03:00
|
|
|
if (aPointerState == TOUCH_HOVER) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mSynthesizedTouchInput) {
|
2016-04-19 23:51:25 +03:00
|
|
|
mSynthesizedTouchInput = MakeUnique<MultiTouchInput>();
|
2015-01-20 02:38:00 +03:00
|
|
|
}
|
|
|
|
|
2016-04-15 13:39:36 +03:00
|
|
|
ScreenIntPoint pointerScreenPoint = ViewAs<ScreenPixel>(aPoint,
|
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForBounds);
|
|
|
|
|
2015-01-20 02:38:00 +03:00
|
|
|
// 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];
|
2016-04-15 13:39:36 +03:00
|
|
|
point.mScreenPoint = pointerScreenPoint;
|
2015-01-20 02:38:00 +03:00
|
|
|
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,
|
2016-04-15 13:39:36 +03:00
|
|
|
pointerScreenPoint,
|
2015-01-20 02:38:00 +03:00
|
|
|
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,
|
2016-04-15 13:39:36 +03:00
|
|
|
pointerScreenPoint,
|
2015-01-20 02:38:00 +03:00
|
|
|
ScreenSize(0, 0),
|
|
|
|
(float)aPointerOrientation,
|
|
|
|
(float)aPointerPressure));
|
|
|
|
}
|
|
|
|
|
2015-02-10 16:24:23 +03: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.
|
2016-05-02 20:27:15 +03:00
|
|
|
APZThreadUtils::RunOnControllerThread(
|
|
|
|
MakeAndAddRef<DispatchTouchInputOnControllerThread>(inputToDispatch));
|
2015-02-10 16:24:23 +03:00
|
|
|
|
2015-01-20 02:38:00 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
NS_IMETHODIMP
|
2015-11-16 11:35:18 +03:00
|
|
|
nsWindow::Create(nsIWidget* aParent,
|
|
|
|
void* aNativeParent,
|
|
|
|
const LayoutDeviceIntRect& aRect,
|
|
|
|
nsWidgetInitData* aInitData)
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
2016-01-13 10:32:55 +03:00
|
|
|
BaseCreate(aParent, aInitData);
|
2015-04-30 09:38:26 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIScreen> screen;
|
|
|
|
|
|
|
|
uint32_t screenId = aParent ? ((nsWindow*)aParent)->mScreen->GetId() :
|
|
|
|
aInitData->mScreenId;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsScreenManagerGonk> screenManager = nsScreenManagerGonk::GetInstance();
|
2015-04-30 09:38:26 +03:00
|
|
|
screenManager->ScreenForId(screenId, getter_AddRefs(screen));
|
|
|
|
|
|
|
|
mScreen = static_cast<nsScreenGonk*>(screen.get());
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2015-11-23 07:32:29 +03:00
|
|
|
mBounds = aRect;
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2014-04-11 06:21:36 +04:00
|
|
|
mParent = (nsWindow *)aParent;
|
2012-06-12 12:00:21 +04:00
|
|
|
mVisible = false;
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2014-04-11 06:21:36 +04:00
|
|
|
if (!aParent) {
|
2015-11-23 07:32:29 +03:00
|
|
|
mBounds = mScreen->GetRect();
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
2015-06-24 18:51:00 +03:00
|
|
|
mComposer2D = HwcComposer2D::GetInstance();
|
|
|
|
|
2015-04-30 06:17:57 +03:00
|
|
|
if (!IS_TOPLEVEL()) {
|
2011-11-11 04:17:46 +04:00
|
|
|
return NS_OK;
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2015-04-30 06:17:57 +03:00
|
|
|
mScreen->RegisterWindow(this);
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2015-04-30 09:38:26 +03:00
|
|
|
Resize(0, 0, mBounds.width, mBounds.height, false);
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Destroy(void)
|
|
|
|
{
|
2014-01-10 10:48:18 +04:00
|
|
|
mOnDestroyCalled = true;
|
2015-04-30 06:17:57 +03:00
|
|
|
mScreen->UnregisterWindow(this);
|
|
|
|
if (this == gFocusedWindow) {
|
2012-07-30 18:20:58 +04:00
|
|
|
gFocusedWindow = nullptr;
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2014-01-10 10:48:18 +04:00
|
|
|
nsBaseWidget::OnDestroy();
|
2011-11-11 04:17:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Show(bool aState)
|
|
|
|
{
|
2015-04-30 06:17:57 +03:00
|
|
|
if (mWindowType == eWindowType_invisible) {
|
2011-11-11 04:17:46 +04:00
|
|
|
return NS_OK;
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2015-04-30 06:17:57 +03:00
|
|
|
if (mVisible == aState) {
|
2012-01-06 01:23:34 +04:00
|
|
|
return NS_OK;
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2012-01-06 01:23:34 +04:00
|
|
|
|
2011-11-22 23:51:52 +04:00
|
|
|
mVisible = aState;
|
2015-04-30 06:17:57 +03:00
|
|
|
if (!IS_TOPLEVEL()) {
|
2011-11-22 23:51:52 +04:00
|
|
|
return mParent ? mParent->Show(aState) : NS_OK;
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2011-11-22 23:51:52 +04:00
|
|
|
|
2012-01-06 01:23:34 +04:00
|
|
|
if (aState) {
|
2011-11-11 04:17:46 +04:00
|
|
|
BringToTop();
|
2012-01-06 01:23:34 +04:00
|
|
|
} else {
|
2015-04-30 06:17:57 +03: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-06 01:23:34 +04:00
|
|
|
continue;
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2012-01-06 01:23:34 +04:00
|
|
|
win->BringToTop();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-19 12:57:50 +04:00
|
|
|
bool
|
|
|
|
nsWindow::IsVisible() const
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
2012-07-19 12:57:50 +04:00
|
|
|
return mVisible;
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::ConstrainPosition(bool aAllowSlop,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t *aX,
|
|
|
|
int32_t *aY)
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-12 13:57:38 +04:00
|
|
|
nsWindow::Move(double aX,
|
|
|
|
double aY)
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-12 13:57:38 +04:00
|
|
|
nsWindow::Resize(double aWidth,
|
|
|
|
double aHeight,
|
|
|
|
bool aRepaint)
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
|
|
|
return Resize(0, 0, aWidth, aHeight, aRepaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-12 13:57:38 +04:00
|
|
|
nsWindow::Resize(double aX,
|
|
|
|
double aY,
|
|
|
|
double aWidth,
|
|
|
|
double aHeight,
|
|
|
|
bool aRepaint)
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
2015-11-23 07:32:29 +03:00
|
|
|
mBounds = LayoutDeviceIntRect(NSToIntRound(aX), NSToIntRound(aY),
|
|
|
|
NSToIntRound(aWidth), NSToIntRound(aHeight));
|
2015-04-30 06:17:57 +03:00
|
|
|
if (mWidgetListener) {
|
2012-12-12 13:57:38 +04:00
|
|
|
mWidgetListener->WindowResized(this, mBounds.width, mBounds.height);
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2015-04-30 06:17:57 +03:00
|
|
|
if (aRepaint) {
|
2015-11-23 07:32:29 +03:00
|
|
|
Invalidate(mBounds);
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2012-02-22 12:50:44 +04:00
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Enable(bool aState)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-23 09:19:08 +04:00
|
|
|
bool
|
|
|
|
nsWindow::IsEnabled() const
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
2012-07-23 09:19:08 +04:00
|
|
|
return true;
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::SetFocus(bool aRaise)
|
|
|
|
{
|
2015-04-30 06:17:57 +03:00
|
|
|
if (aRaise) {
|
2011-11-11 04:17:46 +04:00
|
|
|
BringToTop();
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2015-04-30 09:38:26 +03:00
|
|
|
|
|
|
|
if (!IS_TOPLEVEL() && mScreen->IsPrimaryScreen()) {
|
|
|
|
// We should only set focused window on non-toplevel primary window.
|
|
|
|
gFocusedWindow = this;
|
|
|
|
}
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::ConfigureChildren(const nsTArray<nsIWidget::Configuration>&)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-11-17 08:18:31 +03:00
|
|
|
nsWindow::Invalidate(const LayoutDeviceIntRect& aRect)
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
2014-04-11 06:21:36 +04:00
|
|
|
nsWindow *top = mParent;
|
2015-04-30 06:17:57 +03:00
|
|
|
while (top && top->mParent) {
|
2014-04-11 06:21:36 +04:00
|
|
|
top = top->mParent;
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
|
|
|
const nsTArray<nsWindow*>& windows = mScreen->GetTopWindows();
|
|
|
|
if (top != windows[0] && this != windows[0]) {
|
2011-11-22 23:51:52 +04:00
|
|
|
return NS_OK;
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2011-11-22 23:51:52 +04:00
|
|
|
|
2012-01-19 01:22:12 +04:00
|
|
|
gDrawRequest = true;
|
|
|
|
mozilla::NotifyEvent();
|
2011-11-11 04:17:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-04 23:21:03 +03:00
|
|
|
LayoutDeviceIntPoint
|
2011-11-11 04:17:46 +04:00
|
|
|
nsWindow::WidgetToScreenOffset()
|
|
|
|
{
|
2015-02-04 23:21:03 +03:00
|
|
|
LayoutDeviceIntPoint p(0, 0);
|
2011-11-11 04:17:46 +04: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 19:56:38 +04:00
|
|
|
nsWindow::GetNativeData(uint32_t aDataType)
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
|
|
|
switch (aDataType) {
|
|
|
|
case NS_NATIVE_WINDOW:
|
2015-04-17 19:28:41 +03:00
|
|
|
// Called before primary display's EGLSurface creation.
|
2015-04-30 09:38:26 +03:00
|
|
|
return mScreen->GetNativeWindow();
|
2015-11-13 13:18:14 +03:00
|
|
|
case NS_NATIVE_OPENGL_CONTEXT:
|
|
|
|
return mScreen->GetGLContext().take();
|
2016-03-16 07:47:47 +03:00
|
|
|
case NS_RAW_NATIVE_IME_CONTEXT: {
|
|
|
|
void* pseudoIMEContext = GetPseudoIMEContext();
|
|
|
|
if (pseudoIMEContext) {
|
|
|
|
return pseudoIMEContext;
|
|
|
|
}
|
2015-12-11 09:15:57 +03:00
|
|
|
// There is only one IME context on Gonk.
|
|
|
|
return NS_ONLY_ONE_NATIVE_IME_CONTEXT;
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
2016-03-16 07:47:47 +03:00
|
|
|
}
|
2015-11-13 13:18:14 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
2015-04-17 19:28:41 +03:00
|
|
|
void
|
|
|
|
nsWindow::SetNativeData(uint32_t aDataType, uintptr_t aVal)
|
|
|
|
{
|
|
|
|
switch (aDataType) {
|
|
|
|
case NS_NATIVE_OPENGL_CONTEXT:
|
|
|
|
GLContext* context = reinterpret_cast<GLContext*>(aVal);
|
2015-07-24 20:56:05 +03:00
|
|
|
if (!context) {
|
|
|
|
mScreen->SetEGLInfo(EGL_NO_DISPLAY,
|
|
|
|
EGL_NO_SURFACE,
|
|
|
|
nullptr);
|
|
|
|
return;
|
|
|
|
}
|
2015-06-05 06:29:30 +03:00
|
|
|
mScreen->SetEGLInfo(GLContextEGL::Cast(context)->GetEGLDisplay(),
|
|
|
|
GLContextEGL::Cast(context)->GetEGLSurface(),
|
|
|
|
context);
|
2015-04-17 19:28:41 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
NS_IMETHODIMP
|
2013-10-02 07:46:03 +04:00
|
|
|
nsWindow::DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus)
|
2011-11-11 04:17:46 +04:00
|
|
|
{
|
2015-04-30 06:17:57 +03:00
|
|
|
if (mWidgetListener) {
|
2012-08-15 22:53:09 +04:00
|
|
|
aStatus = mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents);
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-16 03:38:45 +04:00
|
|
|
NS_IMETHODIMP_(void)
|
|
|
|
nsWindow::SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction)
|
|
|
|
{
|
2012-01-05 23:17:14 +04:00
|
|
|
mInputContext = aContext;
|
2011-12-16 03:38:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(InputContext)
|
|
|
|
nsWindow::GetInputContext()
|
|
|
|
{
|
2012-01-05 23:17:14 +04:00
|
|
|
return mInputContext;
|
2011-12-16 03:38:45 +04:00
|
|
|
}
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::ReparentNativeWidget(nsIWidget* aNewParent)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-15 10:13:48 +04:00
|
|
|
NS_IMETHODIMP
|
2014-07-09 23:29:28 +04:00
|
|
|
nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen*)
|
2012-08-15 10:13:48 +04: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-30 06:17:57 +03:00
|
|
|
nsIntRect virtualBounds;
|
|
|
|
mScreen->GetRect(&virtualBounds.x, &virtualBounds.y,
|
|
|
|
&virtualBounds.width, &virtualBounds.height);
|
|
|
|
Resize(virtualBounds.x, virtualBounds.y,
|
|
|
|
virtualBounds.width, virtualBounds.height,
|
2012-08-15 10:13:48 +04:00
|
|
|
/*repaint*/true);
|
|
|
|
}
|
2015-06-10 14:13:12 +03:00
|
|
|
|
|
|
|
if (nsIWidgetListener* listener = GetWidgetListener()) {
|
|
|
|
listener->FullscreenChanged(aFullScreen);
|
|
|
|
}
|
2012-08-15 10:13:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<DrawTarget>
|
2014-10-17 00:57:10 +04:00
|
|
|
nsWindow::StartRemoteDrawing()
|
|
|
|
{
|
2016-01-14 07:37:56 +03:00
|
|
|
RefPtr<DrawTarget> buffer = mScreen->StartRemoteDrawing();
|
2015-05-01 16:14:16 +03:00
|
|
|
return buffer.forget();
|
2014-10-17 00:57:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::EndRemoteDrawing()
|
|
|
|
{
|
2016-01-14 07:37:56 +03:00
|
|
|
mScreen->EndRemoteDrawing();
|
2014-10-17 00:57:10 +04:00
|
|
|
}
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
float
|
|
|
|
nsWindow::GetDPI()
|
|
|
|
{
|
2015-04-30 09:38:26 +03:00
|
|
|
return mScreen->GetDpi();
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
2013-05-02 00:04:56 +04:00
|
|
|
double
|
|
|
|
nsWindow::GetDefaultScaleInternal()
|
|
|
|
{
|
2013-06-03 16:30:28 +04: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.
|
|
|
|
}
|
2015-11-24 16:45:00 +03:00
|
|
|
if (dpi < 280.0) {
|
2013-06-03 16:30:28 +04:00
|
|
|
return 1.5; // hdpi devices.
|
|
|
|
}
|
2013-11-22 01:03:24 +04:00
|
|
|
// xhdpi devices and beyond.
|
2014-01-25 16:21:01 +04:00
|
|
|
return floor(dpi / 150.0 + 0.5);
|
2013-05-02 00:04:56 +04:00
|
|
|
}
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
LayerManager *
|
2013-04-24 22:42:40 +04:00
|
|
|
nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager,
|
2011-11-11 04:17:46 +04:00
|
|
|
LayersBackend aBackendHint,
|
|
|
|
LayerManagerPersistence aPersistence,
|
|
|
|
bool* aAllowRetaining)
|
|
|
|
{
|
2015-04-30 06:17:57 +03:00
|
|
|
if (aAllowRetaining) {
|
2011-11-11 04:17:46 +04:00
|
|
|
*aAllowRetaining = true;
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2012-08-15 05:10:40 +04: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-04 06:36:22 +04:00
|
|
|
if (mLayerManager->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
2013-05-01 09:03:25 +04:00
|
|
|
ClientLayerManager* manager =
|
|
|
|
static_cast<ClientLayerManager*>(mLayerManager.get());
|
2015-04-30 06:17:57 +03:00
|
|
|
uint32_t rotation = mScreen->EffectiveScreenRotation();
|
2014-01-23 22:26:41 +04:00
|
|
|
manager->SetDefaultTargetConfiguration(mozilla::layers::BufferMode::BUFFER_NONE,
|
2015-04-30 06:17:57 +03:00
|
|
|
ScreenRotation(rotation));
|
2012-08-15 05:10:40 +04:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
return mLayerManager;
|
2012-08-15 05:10:40 +04:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2015-04-30 06:17:57 +03:00
|
|
|
const nsTArray<nsWindow*>& windows = mScreen->GetTopWindows();
|
|
|
|
nsWindow *topWindow = windows[0];
|
2011-11-11 04:17:46 +04:00
|
|
|
|
|
|
|
if (!topWindow) {
|
2012-07-07 18:07:00 +04:00
|
|
|
LOGW(" -- no topwindow\n");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
2014-07-04 06:36:22 +04:00
|
|
|
CreateCompositor();
|
2016-05-18 08:33:22 +03:00
|
|
|
if (RefPtr<CompositorBridgeParent> bridge = GetCompositorBridgeParent()) {
|
|
|
|
mScreen->SetCompositorBridgeParent(bridge);
|
2016-01-21 11:21:50 +03:00
|
|
|
if (mScreen->IsPrimaryScreen()) {
|
2016-05-18 08:33:22 +03:00
|
|
|
mComposer2D->SetCompositorBridgeParent(bridge);
|
2016-01-21 11:21:50 +03:00
|
|
|
}
|
2011-12-24 11:13:33 +04:00
|
|
|
}
|
2014-07-04 06:36:22 +04:00
|
|
|
MOZ_ASSERT(mLayerManager);
|
2011-11-11 04:17:46 +04:00
|
|
|
return mLayerManager;
|
|
|
|
}
|
|
|
|
|
2015-07-24 21:28:28 +03:00
|
|
|
void
|
|
|
|
nsWindow::DestroyCompositor()
|
|
|
|
{
|
2016-05-18 08:33:22 +03:00
|
|
|
if (RefPtr<CompositorBridgeParent> bridge = GetCompositorBridgeParent()) {
|
2016-03-22 21:08:38 +03:00
|
|
|
mScreen->SetCompositorBridgeParent(nullptr);
|
2016-01-21 11:21:50 +03:00
|
|
|
if (mScreen->IsPrimaryScreen()) {
|
2016-03-22 21:08:38 +03:00
|
|
|
// Unset CompositorBridgeParent
|
|
|
|
mComposer2D->SetCompositorBridgeParent(nullptr);
|
2016-01-21 11:21:50 +03:00
|
|
|
}
|
2015-07-24 21:28:28 +03:00
|
|
|
}
|
|
|
|
nsBaseWidget::DestroyCompositor();
|
|
|
|
}
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
void
|
|
|
|
nsWindow::BringToTop()
|
|
|
|
{
|
2015-04-30 06:17:57 +03:00
|
|
|
const nsTArray<nsWindow*>& windows = mScreen->GetTopWindows();
|
|
|
|
if (!windows.IsEmpty()) {
|
|
|
|
if (nsIWidgetListener* listener = windows[0]->GetWidgetListener()) {
|
2012-08-15 22:52:42 +04:00
|
|
|
listener->WindowDeactivated();
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
2015-04-30 06:17:57 +03:00
|
|
|
mScreen->BringToTop(this);
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2015-04-30 06:17:57 +03:00
|
|
|
if (mWidgetListener) {
|
2012-08-15 22:52:42 +04:00
|
|
|
mWidgetListener->WindowActivated();
|
2015-04-30 06:17:57 +03:00
|
|
|
}
|
|
|
|
|
2015-11-23 07:32:29 +03:00
|
|
|
Invalidate(mBounds);
|
2011-11-11 04:17:46 +04:00
|
|
|
}
|
|
|
|
|
2012-01-11 06:07:00 +04:00
|
|
|
void
|
|
|
|
nsWindow::UserActivity()
|
|
|
|
{
|
|
|
|
if (!mIdleService) {
|
|
|
|
mIdleService = do_GetService("@mozilla.org/widget/idleservice;1");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mIdleService) {
|
2012-06-29 12:32:21 +04:00
|
|
|
mIdleService->ResetIdleTimeOut(0);
|
2012-01-11 06:07:00 +04:00
|
|
|
}
|
|
|
|
}
|
2012-01-26 06:05:34 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2012-01-26 06:05:34 +04:00
|
|
|
nsWindow::GetGLFrameBufferFormat()
|
|
|
|
{
|
|
|
|
if (mLayerManager &&
|
2014-01-23 22:26:41 +04:00
|
|
|
mLayerManager->GetBackendType() == mozilla::layers::LayersBackend::LAYERS_OPENGL) {
|
2012-01-26 06:05:34 +04: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-07 02:47:11 +04:00
|
|
|
|
2015-11-13 12:37:02 +03:00
|
|
|
LayoutDeviceIntRect
|
|
|
|
nsWindow::GetNaturalBounds()
|
2012-07-24 23:01:09 +04:00
|
|
|
{
|
2015-11-13 12:37:02 +03:00
|
|
|
return mScreen->GetNaturalBounds();
|
2012-07-24 23:01:09 +04:00
|
|
|
}
|
|
|
|
|
2015-06-05 06:29:30 +03:00
|
|
|
nsScreenGonk*
|
|
|
|
nsWindow::GetScreen()
|
|
|
|
{
|
|
|
|
return mScreen;
|
|
|
|
}
|
|
|
|
|
2012-08-14 06:41:09 +04:00
|
|
|
bool
|
|
|
|
nsWindow::NeedsPaint()
|
|
|
|
{
|
|
|
|
if (!mLayerManager) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return nsIWidget::NeedsPaint();
|
|
|
|
}
|
|
|
|
|
2012-11-19 21:58:38 +04:00
|
|
|
Composer2D*
|
|
|
|
nsWindow::GetComposer2D()
|
|
|
|
{
|
2015-06-05 06:29:30 +03:00
|
|
|
if (mScreen->GetDisplayType() == GonkDisplay::DISPLAY_VIRTUAL) {
|
2015-04-30 09:38:26 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-06-24 18:51:00 +03:00
|
|
|
return mComposer2D;
|
2012-11-19 21:58:38 +04:00
|
|
|
}
|
2016-05-18 08:33:22 +03:00
|
|
|
|
|
|
|
CompositorBridgeParent*
|
|
|
|
nsWindow::GetCompositorBridgeParent() const
|
|
|
|
{
|
|
|
|
return mCompositorSession ? mCompositorSession->GetInProcessBridge() : nullptr;
|
|
|
|
}
|