2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#include "nsToolkit.h"
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsAppShell.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsWindow.h"
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsWidgetsCID.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "prmon.h"
|
|
|
|
#include "prtime.h"
|
2002-09-28 19:04:47 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2005-02-27 20:52:44 +03:00
|
|
|
#include "nsComponentManagerUtils.h"
|
2005-08-28 22:42:57 +04:00
|
|
|
#include <objbase.h>
|
2013-08-15 08:25:12 +04:00
|
|
|
#include "WinUtils.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2009-01-05 21:17:44 +03:00
|
|
|
#include "nsUXThemeData.h"
|
|
|
|
|
2002-10-17 10:47:01 +04:00
|
|
|
// unknwn.h is needed to build with WIN32_LEAN_AND_MEAN
|
|
|
|
#include <unknwn.h>
|
|
|
|
|
2013-08-15 08:25:12 +04:00
|
|
|
using namespace mozilla::widget;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsToolkit* nsToolkit::gToolkit = nullptr;
|
1998-04-14 00:24:54 +04:00
|
|
|
HINSTANCE nsToolkit::mDllInstance = 0;
|
2010-12-07 05:06:31 +03:00
|
|
|
static const unsigned long kD3DUsageDelay = 5000;
|
|
|
|
|
|
|
|
static void
|
|
|
|
StartAllowingD3D9(nsITimer *aTimer, void *aClosure)
|
|
|
|
{
|
2012-11-02 15:54:44 +04:00
|
|
|
if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop) {
|
|
|
|
nsWindow::StartAllowingD3D9(true);
|
|
|
|
}
|
2010-12-07 05:06:31 +03:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// constructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-23 23:19:23 +04:00
|
|
|
nsToolkit::nsToolkit()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2011-10-06 03:54:07 +04:00
|
|
|
MOZ_COUNT_CTOR(nsToolkit);
|
2000-01-07 03:34:34 +03:00
|
|
|
|
2011-04-25 07:10:12 +04:00
|
|
|
#if defined(MOZ_STATIC_COMPONENT_LIBS)
|
2013-10-08 22:48:20 +04:00
|
|
|
nsToolkit::Startup(GetModuleHandle(nullptr));
|
2001-06-21 00:21:49 +04:00
|
|
|
#endif
|
2006-02-23 00:08:40 +03:00
|
|
|
|
2012-11-02 15:54:44 +04:00
|
|
|
if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop) {
|
|
|
|
mD3D9Timer = do_CreateInstance("@mozilla.org/timer;1");
|
|
|
|
mD3D9Timer->InitWithFuncCallback(::StartAllowingD3D9,
|
2013-10-08 22:48:20 +04:00
|
|
|
nullptr,
|
2012-11-02 15:54:44 +04:00
|
|
|
kD3DUsageDelay,
|
|
|
|
nsITimer::TYPE_ONE_SHOT);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// destructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsToolkit::~nsToolkit()
|
|
|
|
{
|
2011-10-06 03:54:07 +04:00
|
|
|
MOZ_COUNT_DTOR(nsToolkit);
|
2001-06-21 00:21:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsToolkit::Startup(HMODULE hModule)
|
|
|
|
{
|
2002-09-10 03:58:39 +04:00
|
|
|
nsToolkit::mDllInstance = hModule;
|
2013-08-15 08:25:12 +04:00
|
|
|
WinUtils::Initialize();
|
2013-08-16 06:02:09 +04:00
|
|
|
nsUXThemeData::Initialize();
|
2001-06-21 00:21:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsToolkit::Shutdown()
|
|
|
|
{
|
2011-10-25 19:05:32 +04:00
|
|
|
delete gToolkit;
|
2012-07-30 18:20:58 +04:00
|
|
|
gToolkit = nullptr;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2010-12-07 05:06:31 +03:00
|
|
|
void
|
|
|
|
nsToolkit::StartAllowingD3D9()
|
|
|
|
{
|
2012-11-02 15:54:44 +04:00
|
|
|
if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop) {
|
|
|
|
nsToolkit::GetToolkit()->mD3D9Timer->Cancel();
|
|
|
|
nsWindow::StartAllowingD3D9(false);
|
|
|
|
}
|
2010-12-07 05:06:31 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-10-15 04:49:11 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
2011-10-25 19:05:32 +04:00
|
|
|
// Return the nsToolkit for the current thread. If a toolkit does not
|
1999-10-15 04:49:11 +04:00
|
|
|
// yet exist, then one will be created...
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2011-10-25 19:05:32 +04:00
|
|
|
// static
|
|
|
|
nsToolkit* nsToolkit::GetToolkit()
|
1999-10-15 04:49:11 +04:00
|
|
|
{
|
2011-10-25 19:05:32 +04:00
|
|
|
if (!gToolkit) {
|
|
|
|
gToolkit = new nsToolkit();
|
1999-10-15 04:49:11 +04:00
|
|
|
}
|
|
|
|
|
2011-10-25 19:05:32 +04:00
|
|
|
return gToolkit;
|
1999-10-15 04:49:11 +04:00
|
|
|
}
|