bug 932520. Give MetroWidget an nsNativeDragTarget to maintain, and implement IWidget::EnableDragDrop through the use of that member. r=jimm

This commit is contained in:
Tim Abraldes 2013-11-18 22:43:13 -08:00
parent 57aabc0270
commit 61947e0719
2 changed files with 28 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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
@ -26,6 +26,7 @@
#include "BasicLayers.h"
#include "FrameMetrics.h"
#include "Windows.Graphics.Display.h"
#include "nsNativeDragTarget.h"
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
#endif
@ -332,6 +333,28 @@ MetroWidget::IsVisible() const
return mView->IsVisible();
}
NS_IMETHODIMP
MetroWidget::EnableDragDrop(bool aEnable) {
if (aEnable) {
if (nullptr == mNativeDragTarget) {
mNativeDragTarget = new nsNativeDragTarget(this);
if (!mNativeDragTarget) {
return NS_ERROR_FAILURE;
}
}
HRESULT hr = ::RegisterDragDrop(mWnd, static_cast<LPDROPTARGET>(mNativeDragTarget));
return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
} else {
if (nullptr == mNativeDragTarget) {
return NS_OK;
}
HRESULT hr = ::RevokeDragDrop(mWnd);
return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
}
}
NS_IMETHODIMP
MetroWidget::IsEnabled(bool *aState)
{

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
@ -34,6 +34,7 @@
#include <Windows.ApplicationModel.h>
#include <Windows.Applicationmodel.Activation.h>
class nsNativeDragTarget;
namespace mozilla {
namespace widget {
@ -94,6 +95,7 @@ public:
nsDeviceContext *aContext,
nsWidgetInitData *aInitData = nullptr);
NS_IMETHOD Destroy();
NS_IMETHOD EnableDragDrop(bool aEnable);
NS_IMETHOD SetParent(nsIWidget *aNewParent);
NS_IMETHOD Show(bool bState);
NS_IMETHOD IsVisible(bool & aState);
@ -260,4 +262,5 @@ protected:
nsDeque mEventQueue;
nsDeque mKeyEventQueue;
nsRefPtr<APZController> mController;
nsRefPtr<nsNativeDragTarget> mNativeDragTarget;
};