2008-04-19 19:02:52 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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/. */
|
2008-04-19 19:02:52 +04:00
|
|
|
|
2010-03-05 00:51:42 +03:00
|
|
|
#include "nsWindow.h"
|
|
|
|
#include "nsAppShell.h"
|
|
|
|
|
2010-07-02 17:51:58 +04:00
|
|
|
#include "mozilla/ModuleUtils.h"
|
2008-04-19 19:02:52 +04:00
|
|
|
#include "nsIModule.h"
|
2008-04-19 19:05:49 +04:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
2008-04-19 19:11:21 +04:00
|
|
|
#include "nsHTMLFormatConverter.h"
|
|
|
|
#include "nsTransferable.h"
|
2008-04-19 19:13:35 +04:00
|
|
|
#include "nsLookAndFeel.h"
|
2008-04-19 19:13:59 +04:00
|
|
|
#include "nsAppShellSingleton.h"
|
2008-04-19 19:14:15 +04:00
|
|
|
#include "nsScreenManagerQt.h"
|
2008-04-19 19:44:21 +04:00
|
|
|
#include "nsFilePicker.h"
|
2008-04-19 19:40:33 +04:00
|
|
|
#include "nsClipboard.h"
|
|
|
|
#include "nsClipboardHelper.h"
|
2008-04-19 19:41:14 +04:00
|
|
|
#include "nsIdleServiceQt.h"
|
2008-04-19 19:41:02 +04:00
|
|
|
#include "nsDragService.h"
|
2008-04-19 19:43:36 +04:00
|
|
|
#include "nsSound.h"
|
2008-04-19 19:43:48 +04:00
|
|
|
#include "nsBidiKeyboard.h"
|
|
|
|
#include "nsNativeThemeQt.h"
|
2010-10-07 23:19:33 +04:00
|
|
|
#ifdef NS_PRINTING
|
|
|
|
#include "nsDeviceContextSpecQt.h"
|
|
|
|
#include "nsPrintSession.h"
|
|
|
|
#include "nsPrintOptionsQt.h"
|
|
|
|
#include "nsPrintDialogQt.h"
|
|
|
|
#endif
|
2010-10-20 19:19:24 +04:00
|
|
|
#include "nsFilePickerProxy.h"
|
|
|
|
#include "nsXULAppAPI.h"
|
|
|
|
|
2011-05-04 00:07:17 +04:00
|
|
|
#if defined(MOZ_X11)
|
|
|
|
#include "GfxInfoX11.h"
|
|
|
|
#endif
|
|
|
|
|
2010-03-07 14:04:40 +03:00
|
|
|
// from nsWindow.cpp
|
2011-09-29 10:19:26 +04:00
|
|
|
extern bool gDisableNativeTheme;
|
2008-04-19 19:05:49 +04:00
|
|
|
|
2008-04-19 19:11:13 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
|
2008-04-19 19:37:51 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildWindow)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPopupWindow)
|
2008-04-19 19:11:21 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
|
2008-04-19 19:14:15 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerQt)
|
2008-04-19 19:02:52 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
|
2008-04-19 19:41:02 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
2008-04-19 19:02:52 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
|
2012-06-29 12:32:21 +04:00
|
|
|
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceQt, nsIdleServiceQt::GetInstance)
|
2008-04-19 19:43:36 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
|
2010-10-20 19:19:24 +04:00
|
|
|
|
|
|
|
static nsresult
|
|
|
|
nsFilePickerConstructor(nsISupports *aOuter, REFNSIID aIID,
|
|
|
|
void **aResult)
|
|
|
|
{
|
|
|
|
*aResult = nsnull;
|
|
|
|
if (aOuter != nsnull) {
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIFilePicker> picker;
|
|
|
|
|
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Content)
|
|
|
|
picker = new nsFilePickerProxy();
|
|
|
|
else
|
|
|
|
picker = new nsFilePicker;
|
|
|
|
|
|
|
|
return picker->QueryInterface(aIID, aResult);
|
|
|
|
}
|
|
|
|
|
2008-04-19 19:40:58 +04:00
|
|
|
|
2010-10-07 23:19:33 +04:00
|
|
|
#ifdef NS_PRINTING
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecQt)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsQt, Init)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorQt)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceQt, Init)
|
|
|
|
#endif
|
|
|
|
|
2011-05-04 00:07:17 +04:00
|
|
|
#if defined(MOZ_X11)
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
// This constructor should really be shared with all platforms.
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-07-02 17:51:58 +04:00
|
|
|
static nsresult
|
2010-03-07 14:04:40 +03:00
|
|
|
nsNativeThemeQtConstructor(nsISupports *aOuter, REFNSIID aIID,
|
|
|
|
void **aResult)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsNativeThemeQt *inst;
|
|
|
|
|
|
|
|
if (gDisableNativeTheme)
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
|
|
|
|
*aResult = NULL;
|
|
|
|
if (NULL != aOuter)
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
2010-07-05 13:42:18 +04:00
|
|
|
inst = new nsNativeThemeQt();
|
2010-03-07 14:04:40 +03:00
|
|
|
if (NULL == inst)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(inst);
|
|
|
|
rv = inst->QueryInterface(aIID, aResult);
|
|
|
|
NS_RELEASE(inst);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2008-04-19 19:41:14 +04:00
|
|
|
|
2010-07-02 17:51:58 +04:00
|
|
|
NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_CHILD_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_SOUND_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_THEMERENDERER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_POPUP_CID);
|
2010-10-07 23:19:33 +04:00
|
|
|
#ifdef NS_PRINTING
|
|
|
|
NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
|
2011-05-04 00:07:17 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(MOZ_X11)
|
|
|
|
NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
|
|
|
|
#endif
|
2010-07-02 17:51:58 +04:00
|
|
|
|
|
|
|
static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
|
|
|
|
{ &kNS_WINDOW_CID, false, NULL, nsWindowConstructor },
|
|
|
|
{ &kNS_CHILD_CID, false, NULL, nsChildWindowConstructor },
|
|
|
|
{ &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor },
|
|
|
|
{ &kNS_FILEPICKER_CID, false, NULL, nsFilePickerConstructor },
|
|
|
|
{ &kNS_SOUND_CID, false, NULL, nsSoundConstructor },
|
|
|
|
{ &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor },
|
|
|
|
{ &kNS_CLIPBOARD_CID, false, NULL, nsClipboardConstructor },
|
|
|
|
{ &kNS_CLIPBOARDHELPER_CID, false, NULL, nsClipboardHelperConstructor },
|
|
|
|
{ &kNS_DRAGSERVICE_CID, false, NULL, nsDragServiceConstructor },
|
|
|
|
{ &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor },
|
|
|
|
{ &kNS_BIDIKEYBOARD_CID, false, NULL, nsBidiKeyboardConstructor },
|
|
|
|
{ &kNS_SCREENMANAGER_CID, false, NULL, nsScreenManagerQtConstructor },
|
|
|
|
{ &kNS_THEMERENDERER_CID, false, NULL, nsNativeThemeQtConstructor },
|
|
|
|
{ &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceQtConstructor },
|
|
|
|
{ &kNS_POPUP_CID, false, NULL, nsPopupWindowConstructor },
|
2010-10-07 23:19:33 +04:00
|
|
|
#ifdef NS_PRINTING
|
|
|
|
{ &kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintOptionsQtConstructor },
|
|
|
|
{ &kNS_PRINTER_ENUMERATOR_CID, false, NULL, nsPrinterEnumeratorQtConstructor },
|
|
|
|
{ &kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor },
|
|
|
|
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecQtConstructor },
|
|
|
|
{ &kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceQtConstructor },
|
2011-05-04 00:07:17 +04:00
|
|
|
#endif
|
|
|
|
#if defined(MOZ_X11)
|
|
|
|
{ &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
|
|
|
|
#endif
|
2010-07-02 17:51:58 +04:00
|
|
|
{ NULL }
|
|
|
|
};
|
2008-04-19 19:44:21 +04:00
|
|
|
|
2010-07-02 17:51:58 +04:00
|
|
|
static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
|
|
|
|
{ "@mozilla.org/widget/window/qt;1", &kNS_WINDOW_CID },
|
|
|
|
{ "@mozilla.org/widgets/child_window/qt;1", &kNS_CHILD_CID },
|
|
|
|
{ "@mozilla.org/widget/appshell/qt;1", &kNS_APPSHELL_CID },
|
|
|
|
{ "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID },
|
|
|
|
{ "@mozilla.org/sound;1", &kNS_SOUND_CID },
|
|
|
|
{ "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
|
|
|
|
{ "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID },
|
|
|
|
{ "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID },
|
|
|
|
{ "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID },
|
|
|
|
{ "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
|
|
|
|
{ "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID },
|
|
|
|
{ "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
|
|
|
|
{ "@mozilla.org/chrome/chrome-native-theme;1", &kNS_THEMERENDERER_CID },
|
|
|
|
{ "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
|
|
|
|
{ "@mozilla.org/widgets/popup_window/qt;1", &kNS_POPUP_CID },
|
2010-10-07 23:19:33 +04:00
|
|
|
#ifdef NS_PRINTING
|
|
|
|
{ "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
|
|
|
|
{ "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID },
|
|
|
|
{ "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID },
|
|
|
|
{ "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
|
|
|
|
{ NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID },
|
2011-05-04 00:07:17 +04:00
|
|
|
#endif
|
|
|
|
#if defined(MOZ_X11)
|
|
|
|
{ "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
|
|
|
|
#endif
|
2010-07-02 17:51:58 +04:00
|
|
|
{ NULL }
|
2008-04-19 19:02:52 +04:00
|
|
|
};
|
|
|
|
|
2008-10-10 19:04:34 +04:00
|
|
|
static void
|
2010-07-02 17:51:58 +04:00
|
|
|
nsWidgetQtModuleDtor()
|
2008-04-19 19:13:59 +04:00
|
|
|
{
|
2011-09-09 06:27:11 +04:00
|
|
|
nsLookAndFeel::Shutdown();
|
2008-04-19 19:43:36 +04:00
|
|
|
nsSound::Shutdown();
|
2010-07-02 17:51:58 +04:00
|
|
|
nsWindow::ReleaseGlobals();
|
|
|
|
nsAppShellShutdown();
|
2008-04-19 19:13:59 +04:00
|
|
|
}
|
|
|
|
|
2010-07-02 17:51:58 +04:00
|
|
|
static const mozilla::Module kWidgetModule = {
|
|
|
|
mozilla::Module::kVersion,
|
|
|
|
kWidgetCIDs,
|
|
|
|
kWidgetContracts,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
nsAppShellInit,
|
|
|
|
nsWidgetQtModuleDtor
|
|
|
|
};
|
2008-04-19 19:13:59 +04:00
|
|
|
|
2010-07-02 17:51:58 +04:00
|
|
|
NSMODULE_DEFN(nsWidgetQtModule) = &kWidgetModule;
|