add files for Xlib window service
This commit is contained in:
Родитель
439c0be759
Коммит
4c927725a1
|
@ -0,0 +1,49 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = xlib_window_service
|
||||
IS_COMPONENT=1
|
||||
|
||||
REQUIRES=xpcom
|
||||
|
||||
DEFINES += -D_IMPL_NS_TIMER
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/.. -I$(srcdir)/../../xpwidgets
|
||||
|
||||
CPPSRCS = \
|
||||
nsXlibWindowService.cpp \
|
||||
nsXlibWindowServiceFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(TOOLKIT_TK_LIBS)
|
||||
|
||||
#MKSHLIB =
|
||||
#override NO_SHARED_LIB=1
|
||||
#override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Christopher Blizzard.
|
||||
* Portions created by Christopher Blizzard are Copyright (C) 1999
|
||||
* Christopher Blizzard. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsXlibWindowService.h"
|
||||
// yes, these are from the parent directory.
|
||||
#include "nsWidget.h"
|
||||
#include "nsAppShell.h"
|
||||
|
||||
nsXlibWindowService::nsXlibWindowService()
|
||||
{
|
||||
}
|
||||
|
||||
nsXlibWindowService::~nsXlibWindowService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsXlibWindowService)
|
||||
NS_IMPL_RELEASE(nsXlibWindowService)
|
||||
NS_IMPL_QUERY_INTERFACE(nsXlibWindowService, nsCOMTypeInfo<nsIXlibWindowService>::GetIID())
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXlibWindowService::SetCreateCallback(nsXlibWindowCallback *aFunc)
|
||||
{
|
||||
nsWidget::SetXlibWindowCallback(aFunc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXlibWindowService::DispatchNativeXlibEvent(void *aNativeEvent)
|
||||
{
|
||||
nsAppShell::DispatchXEvent((XEvent *)aNativeEvent);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Christopher Blizzard.
|
||||
* Portions created by Christopher Blizzard are Copyright (C) 1999
|
||||
* Christopher Blizzard. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIXlibWindowService.h"
|
||||
|
||||
class nsXlibWindowService : public nsIXlibWindowService
|
||||
{
|
||||
public:
|
||||
nsXlibWindowService();
|
||||
virtual ~nsXlibWindowService();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD SetCreateCallback(nsXlibWindowCallback *aFunc);
|
||||
NS_IMETHOD DispatchNativeXlibEvent(void *aNativeEvent);
|
||||
};
|
|
@ -0,0 +1,156 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Christopher Blizzard.
|
||||
* Portions created by Christopher Blizzard are Copyright (C) 1999
|
||||
* Christopher Blizzard. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIXlibWindowService.h"
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsXlibWindowService.h"
|
||||
|
||||
static NS_DEFINE_CID(kCXlibWindowServiceCID, NS_XLIB_WINDOW_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
class nsXlibWindowServiceFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
nsXlibWindowServiceFactory(const nsCID &aClass);
|
||||
virtual ~nsXlibWindowServiceFactory();
|
||||
|
||||
private:
|
||||
nsCID mClassID;
|
||||
};
|
||||
|
||||
nsXlibWindowServiceFactory::nsXlibWindowServiceFactory(const nsCID &aClass) :
|
||||
mRefCnt(0),
|
||||
mClassID(aClass)
|
||||
{
|
||||
}
|
||||
|
||||
nsXlibWindowServiceFactory::~nsXlibWindowServiceFactory()
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsXlibWindowServiceFactory, nsIFactory::GetIID())
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXlibWindowServiceFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == nsnull)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
if (mClassID.Equals(kCXlibWindowServiceCID)) {
|
||||
inst = (nsISupports *)(nsXlibWindowService *) new nsXlibWindowService();
|
||||
}
|
||||
|
||||
if (inst == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = inst->QueryInterface(aIID, aResult);
|
||||
if (rv != NS_OK)
|
||||
delete inst;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsXlibWindowServiceFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSGetFactory(nsISupports *servMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
printf("NSGetFactory for xlib window service\n");
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aFactory = new nsXlibWindowServiceFactory(aClass);
|
||||
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return (*aFactory)->QueryInterface(nsIFactory::GetIID(),
|
||||
(void **)aFactory);
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT PRBool
|
||||
NSCanUnload(nsISupports *aServMgr)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSRegisterSelf(nsISupports* aServMgr, const char *fullpath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
printf("*** Registering XlibWindowService\n");
|
||||
|
||||
nsCOMPtr<nsIServiceManager>
|
||||
serviceManager(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kCXlibWindowServiceCID,
|
||||
"Xlib Window Service",
|
||||
NS_XLIB_WINDOW_SERVICE_PROGID,
|
||||
fullpath,
|
||||
PR_TRUE,
|
||||
PR_TRUE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSUnregisterSelf(nsISupports *aServMgr, const char *fullpath)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIServiceManager>
|
||||
serviceManager(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
compMgr->UnregisterComponent(kCXlibWindowServiceCID, fullpath);
|
||||
|
||||
return NS_OK;
|
||||
}
|
Загрузка…
Ссылка в новой задаче