Landing unix toolkit exorcism changes. #ifdef-ed OFF for now.

This commit is contained in:
ramiro%netscape.com 1999-08-02 13:53:49 +00:00
Родитель a365d0139b
Коммит deb7d3b582
29 изменённых файлов: 756 добавлений и 332 удалений

Просмотреть файл

@ -26,10 +26,22 @@ include $(topsrcdir)/config/config.mk
ifneq (,$(filter gtk xlib motif,$(MOZ_WIDGET_TOOLKIT)))
XLIB_RGB_DIRS = xlibrgb
else
ifdef TOOLKIT_EXORCISM
XLIB_RGB_DIRS = xlibrgb
endif
endif
DIRS = ps $(XLIB_RGB_DIRS) $(MOZ_GFX_TOOLKIT)
ifdef TOOLKIT_EXORCISM
DIRS = ps $(XLIB_RGB_DIRS) xlib gtk motif
else
DIRS = ps $(XLIB_RGB_DIRS) $(MOZ_GFX_TOOLKIT)
endif
LIBRARY_NAME = raptorgfx
MODULE=raptor

Просмотреть файл

@ -50,6 +50,10 @@ CPPSRCS = \
CSRCS = \
nsPrintdGTK.c
ifdef TOOLKIT_EXORCISM
EXTRA_DSO_LDOPTS += $(TK_LIBS)
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -36,6 +36,8 @@ CPPSRCS = \
nsImageMotif.cpp \
$(NULL)
EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lxlibrgb -L/usr/X11R6/lib -lXm -lXt -lXext -lX11
include $(topsrcdir)/config/rules.mk
LIBS += \

Просмотреть файл

@ -33,7 +33,8 @@ REQUIRES=util img xpcom raptor netlib ps
DEFINES += -D_IMPL_NS_GFXONXP -DUSE_MOZILLA_TYPES
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS)
EXTRA_DSO_LDOPTS += $(TOOLKIT_LIBS) $(XLDFLAGS) $(XLIBS)
EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lxlibrgb -L/usr/X11R6/lib -lXext -lX11
CPPSRCS =\
nsDeviceContextSpecFactoryX.cpp \

Просмотреть файл

@ -56,6 +56,10 @@
#include "nsISound.h"
#include "nsIFileSpecWithUI.h"
#if defined(XP_UNIX) && defined(TOOLKIT_EXORCISM)
#include "nsIUnixToolkitService.h"
#endif
#include "prprf.h"
#include "prmem.h"
#include "prlog.h" // PR_ASSERT
@ -208,6 +212,123 @@ static NS_DEFINE_CID(kCJVMManagerCID, NS_JVMMANAGER_CID);
extern "C" void
NS_SetupRegistry()
{
#if defined(XP_UNIX) && defined(TOOLKIT_EXORCISM)
// On unix, the widget and gfx toolkit are not linked into the app.
//
// Instead, they are loaded at runtime courtesy of xpcom.
//
// Loading the toolkit specific dlls at runtime has many benefits:
//
// o Simplifies linking of the "app" since it no longer needs to
// pull in the toolkit world.
//
// o Makes it possible to embed the xlib gfx/widget backends into
// other high level x toolkit such as motif and gtk. This is
// highly desirable in the long run as a means to increase code
// reuse and eyeball focus.
//
// o Makes it possible to run X Mozilla using different toolkits
// without having to hack the application bits. This in turn
// simplifies everyone's life, since only one binary is needed.
// The only platform specific bits are:
//
// mozilla/gfx/src
// mozilla/widget/src/
// mozilla/widget/timer/
//
// o It bypasses (yeah right) the toolkit inquisitions and crusades.
//
// o It makes you breakfast, lunch and dinner.
//
//
// Note1:
//
// The following code assumes that:
//
// + Some kind of auto registration has occurred for components.
// For example, NS_AutoRegister() or nsComponentManager::AutoRegister().
//
// -or-
//
// + The "app" was installed and a registry with information on the
// toolkit_service component has been populated. The master plan
// is that this occurs at install time. Otherwise bad things will
// happen.
//
// During the development of mozilla, this usually occurs in the
// main() of the "app" (viewer/apprunner). It is always the first
// thing that happens on the NS_SetupRegistry() function.
//
// If for some reason that changes in the future, the following code
// might have to be moved.
//
// Note2:
//
// The WIDGET_DLL and GFX_DLL macros will be redefined from the
// hard coded values set in this file above. They will point
// to strings valid only in the scope of this function.
//
// If for some reason, the nsComponentManager::RegisterComponentLib()
// calls below are moved to a different scope, this unix specific code
// will have to deal.
static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID);
nsresult rv;
nsIUnixToolkitService * unixToolkitService = nsnull;
rv = nsComponentManager::CreateInstance(kCUnixToolkitServiceCID,
nsnull,
nsIUnixToolkitService::GetIID(),
(void **) &unixToolkitService);
NS_ASSERTION(rv == NS_OK,"Cannot obtain unix toolkit service.");
nsString unixToolkitName = "error";
nsString unixWidgetDllName = "error";
nsString unixGfxDllName = "error";
if (NS_OK == rv && nsnull != unixToolkitService)
{
nsresult rv2;
rv2 = unixToolkitService->GetToolkitName(unixToolkitName);
NS_ASSERTION(rv2 == NS_OK,"Cannot get unix toolkit name context.");
rv2 = unixToolkitService->GetWidgetDllName(unixWidgetDllName);
NS_ASSERTION(rv2 == NS_OK,"Cannot get unix toolkit widget dll name.");
rv2 = unixToolkitService->GetGfxDllName(unixGfxDllName);
NS_ASSERTION(rv2 == NS_OK,"Cannot get unix toolkit gfx dll name.");
NS_RELEASE(unixToolkitService);
}
#ifdef NS_DEBUG
printf("NS_SetupRegistry() MOZ_TOOLKIT=%s, WIDGET_DLL=%s, GFX_DLL=%s\n",
(const char *) nsAutoCString(unixToolkitName),
(const char *) nsAutoCString(unixWidgetDllName),
(const char *) nsAutoCString(unixGfxDllName));
#endif
#undef WIDGET_DLL
#undef GFXWIN_DLL
#define WIDGET_DLL (const char *) nsAutoCString(unixWidgetDllName)
#define GFXWIN_DLL (const char *) nsAutoCString(unixGfxDllName)
#endif /* defined(XP_UNIX) && defined(TOOLKIT_EXORCISM) */
// WIDGET
nsComponentManager::RegisterComponentLib(kCLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponentLib(kCWindowCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE);
@ -289,3 +410,4 @@ NS_SetupRegistry()
nsComponentManager::RegisterComponentLib(kCJVMManagerCID, NULL, NULL, OJI_DLL, PR_FALSE, PR_FALSE);
#endif
}

Просмотреть файл

@ -1,86 +0,0 @@
/* -*- 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.
*/
#ifndef nsIXlibWindowService_h__
#define nsIXlibWindowService_h__
#include "nsISupports.h"
// Interface id for the XlibWindow service
// { bd39ccb0-3f08-11d3-b419-00805f6d4c2a }
#define NS_XLIB_WINDOW_SERVICE_IID \
{ 0xbd39ccb0, \
0x3f08, \
0x11d3, \
{ 0xb4, 0x19, 0x00, 0x80, 0x5f, 0x6d, 0x4c, 0x2a } }
// Class ID for our implementation
// { 285fb550-3af4-11d3-aeb9-0000f8e25c06 }
#define NS_XLIB_WINDOW_SERVICE_CID \
{ 0x285fb550, \
0x3af4, \
0x11d3, \
{ 0xae, 0xb9, 0x00, 0x00, 0xf8, 0xe2, 0x5c, 0x06 } }
#define NS_XLIB_WINDOW_SERVICE_PROGID "component://netscape/widget/xlib/window_service"
/**
* This is an interface for getting access to the construction
* and destruction of native windows in xlib.
* @created 20/Jul/1999
* @author Christopher Blizzard <blizzard@redhat.com>
*/
class nsXlibWindowCallback {
public:
virtual void WindowCreated (PRUint32 aID) = 0;
virtual void WindowDestroyed(PRUint32 aID) = 0;
};
class nsIXlibWindowService : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_XLIB_WINDOW_SERVICE_IID);
/**
* Register your function for window creation and destruction.
* This function will get called whenever a new native X window
* is created. or destroyed.
*
* @param [IN] the function that you would like to register
* @return NS_OK if ok, NS_ERROR_FAILURE if you pass in 0
*/
NS_IMETHOD SetCreateCallback(nsXlibWindowCallback *aFunc) = 0;
/**
* This function will dispatch a native X event ( cast to a void *
* here ) to the event handler on the inside of the widget
* toolkit
* @param [IN] a pointer to an XEvent, cast to a void *
* @return NS_OK if ok, NS_ERROR_FAILURE if you pass in an
* invalid window id
*/
NS_IMETHOD DispatchNativeXlibEvent(void *aNativeEvent) = 0;
};
#endif /* nsIXlibWindowService_h__ */

Просмотреть файл

@ -29,7 +29,11 @@ include $(DEPTH)/config/autoconf.mk
## multiple implementations of widget can be built on the same
## source tree.
##
ifdef TOOLKIT_EXORCISM
DIRS = xpwidgets gtk xlib motif unix_services
else
DIRS = xpwidgets $(MOZ_WIDGET_TOOLKIT)
endif
include $(topsrcdir)/config/config.mk

Просмотреть файл

@ -79,7 +79,9 @@ EXTRA_DSO_LDOPTS+= \
$(MKSHLIB_UNFORCE_ALL) \
$(NULL)
EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lxlibrgb $(TK_LIBS)
ifdef TOOLKIT_EXORCISM
EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lxlibrgb -L/usr/X11R6/lib -lXm -lXmu -lXt -lXext -lX11
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -65,6 +65,10 @@ ifdef DEBUG_ramiro
DEFINES += -DXLIB_WIDGET_NOISY
endif
DIRS =\
window_service \
$(NULL)
include $(topsrcdir)/config/config.mk
CXXFLAGS += $(TK_CFLAGS)
@ -80,7 +84,11 @@ EXTRA_DSO_LDOPTS+= \
$(MKSHLIB_UNFORCE_ALL) \
$(NULL)
ifdef TOOLKIT_EXORCISM
EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lxlibrgb -L/usr/X11R6/lib -lXext -lX11
else
EXTRA_DSO_LDOPTS += $(TK_LIBS)
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -29,6 +29,10 @@
#include "nsIServiceManager.h"
#include "nsITimer.h"
#ifdef TOOLKIT_EXORCISM
#include "nsIXlibWindowService.h"
#endif /* TOOLKIT_EXORCISM */
#include "xlibrgb.h"
#define CHAR_BUF_SIZE 40
@ -36,11 +40,18 @@
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
// this is so that we can get the timers in the base. most widget
// toolkits do this through some set of globals. not here though. we
// don't have that luxury
#ifdef TOOLKIT_EXORCISM
static NS_DEFINE_IID(kWindowServiceCID,NS_XLIB_WINDOW_SERVICE_CID);
static NS_DEFINE_IID(kWindowServiceIID,NS_XLIB_WINDOW_SERVICE_IID);
#endif /* TOOLKIT_EXORCISM */
#ifndef TOOLKIT_EXORCISM
// // this is so that we can get the timers in the base. most widget
// // toolkits do this through some set of globals. not here though. we
// // don't have that luxury
extern "C" int NS_TimeToNextTimeout(struct timeval *);
extern "C" void NS_ProcessTimeouts(void);
#endif /* TOOLKIT_EXORCISM */
PRBool nsAppShell::DieAppShellDie = PR_FALSE;
@ -83,6 +94,110 @@ static char *event_names[] = {
"MappingNotify"
};
#ifdef TOOLKIT_EXORCISM
static nsXlibTimeToNextTimeoutFunc GetTimeToNextTimeoutFunc(void)
{
static nsXlibTimeToNextTimeoutFunc sFunc = nsnull;
if (!sFunc)
{
nsIXlibWindowService * xlibWindowService = nsnull;
nsresult rv = nsServiceManager::GetService(kWindowServiceCID,
kWindowServiceIID,
(nsISupports **)&xlibWindowService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Couldn't obtain window service.");
if (NS_OK == rv && nsnull != xlibWindowService)
{
xlibWindowService->GetTimeToNextTimeoutFunc(&sFunc);
NS_ASSERTION(nsnull != sFunc,"Time to next timeout func is null.");
static int once = 1;
if (once && sFunc)
{
once = 0;
printf("YES! Time to next timeout func is good.\n");
}
NS_RELEASE(xlibWindowService);
}
}
return sFunc;
}
static nsXlibProcessTimeoutsProc GetProcessTimeoutsProc(void)
{
static nsXlibProcessTimeoutsProc sProc = nsnull;
if (!sProc)
{
nsIXlibWindowService * xlibWindowService = nsnull;
nsresult rv = nsServiceManager::GetService(kWindowServiceCID,
kWindowServiceIID,
(nsISupports **)&xlibWindowService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Couldn't obtain window service.");
if (NS_OK == rv && nsnull != xlibWindowService)
{
xlibWindowService->GetProcessTimeoutsProc(&sProc);
NS_ASSERTION(nsnull != sProc,"process timeout proc is null.");
static int once = 1;
if (once && sProc)
{
once = 0;
printf("YES! Process timeout proc is good.\n");
}
NS_RELEASE(xlibWindowService);
}
}
return sProc;
}
#endif
static int CallTimeToNextTimeoutFunc(struct timeval * aTimeval)
{
#ifndef TOOLKIT_EXORCISM
return NS_TimeToNextTimeout(aTimeval);
#else
nsXlibTimeToNextTimeoutFunc func = GetTimeToNextTimeoutFunc();
if (func)
{
return (*func)(aTimeval);
}
return 0;
#endif /* TOOLKIT_EXORCISM */
}
static void CallProcessTimeoutsProc(void)
{
#ifndef TOOLKIT_EXORCISM
NS_ProcessTimeouts();
#else
nsXlibProcessTimeoutsProc proc = GetProcessTimeoutsProc();
if (proc)
{
(*proc)();
}
#endif /* TOOLKIT_EXORCISM */
}
#define ALL_EVENTS ( KeyPressMask | KeyReleaseMask | ButtonPressMask | \
ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | \
PointerMotionMask | PointerMotionHintMask | Button1MotionMask | \
@ -208,7 +323,8 @@ nsresult nsAppShell::Run()
// add the queue and the xlib connection to the select set
FD_SET(queue_fd, &select_set);
FD_SET(xlib_fd, &select_set);
if (NS_TimeToNextTimeout(&cur_time) == 0) {
if (CallTimeToNextTimeoutFunc(&cur_time) == 0) {
cur_time_ptr = NULL;
}
else {
@ -246,7 +362,7 @@ nsresult nsAppShell::Run()
}
if (please_run_timer_queue) {
//printf("Running timer queue...\n");
NS_ProcessTimeouts();
CallProcessTimeoutsProc();
}
// make sure that any pending X requests are flushed.
XFlush(mDisplay);

Просмотреть файл

@ -16,10 +16,14 @@
* Reserved.
*/
#include <X11/cursorfont.h>
#include "nsIXlibWindowService.h"
#include "nsWidget.h"
#include "nsIServiceManager.h"
#include "nsAppShell.h"
#include <X11/cursorfont.h>
#include "nsIEventListener.h"
#include "nsIMenuListener.h"
#include "nsIMouseListener.h"
@ -31,7 +35,7 @@ PRLogModuleInfo *XlibWidgetsLM = PR_NewLogModule("XlibWidgets");
PRLogModuleInfo *XlibScrollingLM = PR_NewLogModule("XlibScrolling");
// set up our static members here.
nsHashtable *nsWidget::window_list = nsnull;
nsHashtable *nsWidget::gsWindowList = nsnull;
// this is a class for generating keys for
// the list of windows managed by mozilla.
@ -39,7 +43,11 @@ nsHashtable *nsWidget::window_list = nsnull;
// this is possibly the class impl that will be
// called whenever a new window is created/destroyed
nsXlibWindowCallback *nsWidget::mWindowCallback = nsnull;
//nsXlibWindowCallback *nsWidget::mWindowCallback = nsnull;
/* static */ nsXlibWindowCallback nsWidget::gsWindowCreateCallback = nsnull;
/* static */ nsXlibWindowCallback nsWidget::gsWindowDestroyCallback = nsnull;
/* static */ nsXlibEventDispatcher nsWidget::gsEventDispatcher = nsnull;
// this is for implemention the WM_PROTOCOL code
PRBool nsWidget::WMProtocolsInitialized = PR_FALSE;
@ -140,6 +148,9 @@ NS_IMETHODIMP nsWidget::Create(nsNativeWidget aParent,
aParent));
}
static NS_DEFINE_IID(kWindowServiceCID,NS_XLIB_WINDOW_SERVICE_CID);
static NS_DEFINE_IID(kWindowServiceIID,NS_XLIB_WINDOW_SERVICE_IID);
nsresult
nsWidget::StandardWidgetCreate(nsIWidget *aParent,
const nsRect &aRect,
@ -174,6 +185,31 @@ nsWidget::StandardWidgetCreate(nsIWidget *aParent,
}
// set the bounds
mBounds = aRect;
#ifdef TOOLKIT_EXORCISM
nsIXlibWindowService * xlibWindowService = nsnull;
nsresult rv = nsServiceManager::GetService(kWindowServiceCID,
kWindowServiceIID,
(nsISupports **)&xlibWindowService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Couldn't obtain window service.");
if (NS_OK == rv && nsnull != xlibWindowService)
{
xlibWindowService->GetWindowCreateCallback(&gsWindowCreateCallback);
xlibWindowService->GetWindowDestroyCallback(&gsWindowDestroyCallback);
// NS_ASSERTION(nsnull != gsWindowCreateCallback,"Window create callback is null.");
// NS_ASSERTION(nsnull != gsWindowDestroyCallback,"Window destroy callback is null.");
xlibWindowService->SetEventDispatcher((nsXlibEventDispatcher) nsAppShell::DispatchXEvent);
NS_RELEASE(xlibWindowService);
}
#endif /* TOOLKIT_EXORCISM */
// call the native create function
CreateNative(parent, mBounds);
// set up our wm hints if it's appropriate
@ -647,11 +683,11 @@ void nsWidget::CreateNativeWindow(Window aParent, nsRect aRect,
nsWidget *
nsWidget::GetWidgetForWindow(Window aWindow)
{
if (window_list == nsnull) {
if (gsWindowList == nsnull) {
return nsnull;
}
nsWindowKey *window_key = new nsWindowKey(aWindow);
nsWidget *retval = (nsWidget *)window_list->Get(window_key);
nsWidget *retval = (nsWidget *)gsWindowList->Get(window_key);
delete window_key;
return retval;
}
@ -660,18 +696,21 @@ void
nsWidget::AddWindowCallback(Window aWindow, nsWidget *aWidget)
{
// make sure that the list has been initialized
if (window_list == nsnull) {
window_list = new nsHashtable();
if (gsWindowList == nsnull) {
gsWindowList = new nsHashtable();
}
nsWindowKey *window_key = new nsWindowKey(aWindow);
window_list->Put(window_key, aWidget);
gsWindowList->Put(window_key, aWidget);
// add a new ref to this widget
NS_ADDREF(aWidget);
// make sure that if someone is listening that we inform
// them of the new window
if (mWindowCallback) {
mWindowCallback->WindowCreated(aWindow);
if (gsWindowCreateCallback)
{
(*gsWindowCreateCallback)(aWindow);
}
delete window_key;
}
@ -679,12 +718,15 @@ void
nsWidget::DeleteWindowCallback(Window aWindow)
{
nsWindowKey *window_key = new nsWindowKey(aWindow);
nsWidget *widget = (nsWidget *)window_list->Get(window_key);
nsWidget *widget = (nsWidget *)gsWindowList->Get(window_key);
NS_RELEASE(widget);
window_list->Remove(window_key);
if (mWindowCallback) {
mWindowCallback->WindowDestroyed(aWindow);
gsWindowList->Remove(window_key);
if (gsWindowDestroyCallback)
{
(*gsWindowDestroyCallback)(aWindow);
}
delete window_key;
}
@ -1020,33 +1062,33 @@ void nsWidget::SetMapStatus(PRBool aState)
mIsMapped = aState;
}
nsresult
nsWidget::SetXlibWindowCallback(nsXlibWindowCallback *aCallback)
{
if (aCallback == nsnull) {
return NS_ERROR_FAILURE;
}
else {
mWindowCallback = aCallback;
}
return NS_OK;
}
// nsresult
// nsWidget::SetXlibWindowCallback(nsXlibWindowCallback *aCallback)
// {
// if (aCallback == nsnull) {
// return NS_ERROR_FAILURE;
// }
// else {
// mWindowCallback = aCallback;
// }
// return NS_OK;
// }
nsresult
nsWidget::XWindowCreated(Window aWindow) {
if (mWindowCallback) {
mWindowCallback->WindowCreated(aWindow);
}
return NS_OK;
}
// nsresult
// nsWidget::XWindowCreated(Window aWindow) {
// if (mWindowCallback) {
// mWindowCallback->WindowCreated(aWindow);
// }
// return NS_OK;
// }
nsresult
nsWidget::XWindowDestroyed(Window aWindow) {
if (mWindowCallback) {
mWindowCallback->WindowDestroyed(aWindow);
}
return NS_OK;
}
// nsresult
// nsWidget::XWindowDestroyed(Window aWindow) {
// if (mWindowCallback) {
// mWindowCallback->WindowDestroyed(aWindow);
// }
// return NS_OK;
// }
void
nsWidget::SetUpWMHints(void) {

Просмотреть файл

@ -22,10 +22,12 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include "nsBaseWidget.h"
#include "nsHashtable.h"
#include "prlog.h"
#include <nsIXlibWindowService.h>
#include "nsIXlibWindowService.h"
#ifdef DEBUG_blizzard
#define XLIB_WIDGET_NOISY
@ -118,9 +120,9 @@ public:
PRBool DispatchWindowEvent(nsGUIEvent & aEvent);
static nsresult SetXlibWindowCallback(nsXlibWindowCallback *aCallback);
static nsresult XWindowCreated(Window aWindow);
static nsresult XWindowDestroyed(Window aWindow);
// static nsresult SetXlibWindowCallback(nsXlibWindowCallback *aCallback);
// static nsresult XWindowCreated(Window aWindow);
// static nsresult XWindowDestroyed(Window aWindow);
// these are for the wm protocols
static Atom WMDeleteWindow;
@ -148,8 +150,6 @@ protected:
// these will add and delete a window
static void AddWindowCallback (Window aWindow, nsWidget *aWidget);
static void DeleteWindowCallback(Window aWindow);
static nsHashtable *window_list;
static nsXlibWindowCallback *mWindowCallback;
// set up our wm hints
void SetUpWMHints(void);
@ -185,6 +185,13 @@ protected:
GC mGC; // until we get gc pooling working...
nsString mName; // name of the type of widget
PRBool mIsToplevel;
private:
static nsHashtable * gsWindowList;
static nsXlibWindowCallback gsWindowCreateCallback;
static nsXlibWindowCallback gsWindowDestroyCallback;
static nsXlibEventDispatcher gsEventDispatcher;
};
extern PRLogModuleInfo *XlibWidgetsLM;

Просмотреть файл

@ -18,9 +18,13 @@
*/
#include "nsXlibWindowService.h"
// yes, these are from the parent directory.
#include "nsWidget.h"
#include "nsAppShell.h"
//
// NO! This is evil. It creates a link time dependency with libwidget_xlib.so.
//
// // yes, these are from the parent directory.
// #include "nsWidget.h"
// #include "nsAppShell.h"
nsXlibWindowService::nsXlibWindowService()
{
@ -34,16 +38,123 @@ 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;
}
/* static */ nsXlibWindowCallback nsXlibWindowService::gsWindowCreateCallback = nsnull;
/* static */ nsXlibWindowCallback nsXlibWindowService::gsWindowDestroyCallback = nsnull;
/* static */ nsXlibEventDispatcher nsXlibWindowService::gsEventDispatcher = nsnull;
/* static */ nsXlibTimeToNextTimeoutFunc nsXlibWindowService::gsTimeToNextTimeoutFunc = nsnull;
/* static */ nsXlibProcessTimeoutsProc nsXlibWindowService::gsProcessTimeoutsProc = nsnull;
// 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;
// }
NS_IMETHODIMP
nsXlibWindowService::DispatchNativeXlibEvent(void *aNativeEvent)
nsXlibWindowService::SetWindowCreateCallback(nsXlibWindowCallback aCallback)
{
nsAppShell::DispatchXEvent((XEvent *)aNativeEvent);
NS_ASSERTION(nsnull != aCallback,"null in ptr.");
gsWindowCreateCallback = aCallback;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXlibWindowService::SetWindowDestroyCallback(nsXlibWindowCallback aCallback)
{
NS_ASSERTION(nsnull != aCallback,"null in ptr.");
gsWindowDestroyCallback = aCallback;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXlibWindowService::SetEventDispatcher(nsXlibEventDispatcher aDispatcher)
{
NS_ASSERTION(nsnull != aDispatcher,"null in ptr.");
gsEventDispatcher = aDispatcher;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXlibWindowService::GetWindowCreateCallback(nsXlibWindowCallback * aCallbackOut)
{
NS_ASSERTION(nsnull != aCallbackOut,"null out ptr.");
*aCallbackOut = gsWindowCreateCallback;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXlibWindowService::GetWindowDestroyCallback(nsXlibWindowCallback * aCallbackOut)
{
NS_ASSERTION(nsnull != aCallbackOut,"null out ptr.");
*aCallbackOut = gsWindowDestroyCallback;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXlibWindowService::GetEventDispatcher(nsXlibEventDispatcher * aDispatcherOut)
{
NS_ASSERTION(nsnull != aDispatcherOut,"null out ptr.");
*aDispatcherOut = gsEventDispatcher;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXlibWindowService::SetTimeToNextTimeoutFunc(nsXlibTimeToNextTimeoutFunc aFunc)
{
NS_ASSERTION(nsnull != aFunc,"null in ptr.");
gsTimeToNextTimeoutFunc = aFunc;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXlibWindowService::GetTimeToNextTimeoutFunc(nsXlibTimeToNextTimeoutFunc * aFuncOut)
{
NS_ASSERTION(nsnull != aFuncOut,"null out ptr.");
*aFuncOut = gsTimeToNextTimeoutFunc;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXlibWindowService::SetProcessTimeoutsProc(nsXlibProcessTimeoutsProc aProc)
{
NS_ASSERTION(nsnull != aProc,"null in ptr.");
gsProcessTimeoutsProc = aProc;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXlibWindowService::GetProcessTimeoutsProc(nsXlibProcessTimeoutsProc * aProcOut)
{
NS_ASSERTION(nsnull != aProcOut,"null out ptr.");
*aProcOut = gsProcessTimeoutsProc;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -27,6 +27,29 @@ class nsXlibWindowService : public nsIXlibWindowService
NS_DECL_ISUPPORTS
NS_IMETHOD SetCreateCallback(nsXlibWindowCallback *aFunc);
NS_IMETHOD DispatchNativeXlibEvent(void *aNativeEvent);
// NS_IMETHOD SetCreateCallback(nsXlibWindowCallback *aFunc);
// NS_IMETHOD DispatchNativeXlibEvent(void *aNativeEvent);
NS_IMETHOD SetWindowCreateCallback(nsXlibWindowCallback aCallback);
NS_IMETHOD SetWindowDestroyCallback(nsXlibWindowCallback aCallback);
NS_IMETHOD GetWindowCreateCallback(nsXlibWindowCallback * aCallbackOut);
NS_IMETHOD GetWindowDestroyCallback(nsXlibWindowCallback * aCallbackOut);
NS_IMETHOD SetEventDispatcher(nsXlibEventDispatcher aDispatcher);
NS_IMETHOD GetEventDispatcher(nsXlibEventDispatcher * aDispatcherOut);
NS_IMETHOD SetTimeToNextTimeoutFunc(nsXlibTimeToNextTimeoutFunc aFunc);
NS_IMETHOD GetTimeToNextTimeoutFunc(nsXlibTimeToNextTimeoutFunc * aFuncOut);
NS_IMETHOD SetProcessTimeoutsProc(nsXlibProcessTimeoutsProc aProc);
NS_IMETHOD GetProcessTimeoutsProc(nsXlibProcessTimeoutsProc * aProcOut);
private:
static nsXlibWindowCallback gsWindowCreateCallback;
static nsXlibWindowCallback gsWindowDestroyCallback;
static nsXlibEventDispatcher gsEventDispatcher;
static nsXlibTimeToNextTimeoutFunc gsTimeToNextTimeoutFunc;
static nsXlibProcessTimeoutsProc gsProcessTimeoutsProc;
};

Просмотреть файл

@ -24,19 +24,30 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
ifdef TOOLKIT_EXORCISM
DIRS = $(MOZ_WIDGET_TOOLKIT)
### XXX ### DIRS = gtk motif xlib
### XXX ###
### XXX ### LIBRARY_NAME = timer_s
### XXX ###
### XXX ### REQUIRES=xpcom
### XXX ###
### XXX ### CPPSRCS =\
### XXX ### nsNewTimer.cpp \
### XXX ### $(NULL)
### XXX ###
### XXX ### MKSHLIB =
### XXX ### override NO_SHARED_LIB=1
### XXX ### override NO_STATIC_LIB=
DIRS = gtk motif xlib
LIBRARY_NAME = timer_s
REQUIRES=xpcom
CPPSRCS =\
nsNewTimer.cpp \
$(NULL)
EXPORTS =\
nsUnixTimerCIID.h \
$(NULL)
MKSHLIB =
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
else
DIRS = $(MOZ_WIDGET_TOOLKIT)
endif # TOOLKIT_EXORCISM
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -24,24 +24,32 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
LIBRARY_NAME = $(TIMER_LIB_NAME)
### XXX ### IS_COMPONENT=1
ifdef TOOLKIT_EXORCISM
LIBRARY_NAME = timer_gtk
IS_COMPONENT=1
REQUIRES=xpcom
DEFINES += -D_IMPL_NS_TIMER
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = \
nsTimerGtk.cpp \
### XXX ### nsTimerGtkFactory.cpp \
nsTimerGtkFactory.cpp \
$(NULL)
### XXX ### EXTRA_DSO_LDOPTS += $(TK_LIBS)
EXTRA_DSO_LDOPTS += $(TK_LIBS)
else
LIBRARY_NAME = $(TIMER_LIB_NAME)
REQUIRES = xpcom
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = nsTimerGtk.cpp
MKSHLIB =
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
endif # TOOLKIT_EXORCISM
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -20,8 +20,8 @@
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
extern "C" int NS_TimeToNextTimeout(struct timeval *aTimer);
extern "C" void NS_ProcessTimeouts(void);
// extern "C" int NS_TimeToNextTimeout(struct timeval *aTimer);
// extern "C" void NS_ProcessTimeouts(void);
extern "C" gint nsTimerExpired(gpointer aCallData);
@ -146,6 +146,7 @@ gint nsTimerExpired(gpointer aCallData)
return 0;
}
#ifndef TOOLKIT_EXORCISM
nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
@ -161,8 +162,12 @@ nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
}
int NS_TimeToNextTimeout(struct timeval *aTimer) {
int NS_TimeToNextTimeout(struct timeval *aTimer)
{
return 0;
}
void NS_ProcessTimeouts(void) {
void NS_ProcessTimeouts(void)
{
}
#endif /* TOOLKIT_EXORCISM */

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 2; indentT-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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
@ -19,7 +19,7 @@
#include "nsTimerGtk.h"
#include "nsTimerCIID.h"
#include "nsUnixTimerCIID.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"

Просмотреть файл

@ -24,24 +24,33 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
LIBRARY_NAME = $(TIMER_LIB_NAME)
### XXX ### IS_COMPONENT=1
ifdef TOOLKIT_EXORCISM
LIBRARY_NAME = timer_motif
IS_COMPONENT=1
REQUIRES=xpcom
DEFINES += -D_IMPL_NS_TIMER
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = \
nsTimerMotif.cpp \
### XXX ### nsTimerMotifFactory.cpp \
nsTimerMotifFactory.cpp \
$(NULL)
### XXX ### EXTRA_DSO_LDOPTS += $(TK_LIBS)
#EXTRA_DSO_LDOPTS += $(TK_LIBS)
EXTRA_DSO_LDOPTS += -L/usr/X11R6/lib -lXt -lX11
else
LIBRARY_NAME = $(TIMER_LIB_NAME)
REQUIRES = xpcom
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = nsTimerMotif.cpp
MKSHLIB =
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
endif # TOOLKIT_EXORCISM
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -75,7 +75,7 @@ nsTimerMotif::Init(nsTimerCallbackFunc aFunc,
mClosure = aClosure;
// mRepeat = aRepeat;
InitAppContext();
EnsureAppContext();
mTimerId = XtAppAddTimeOut(mAppContext,
aDelay,
@ -92,7 +92,7 @@ nsTimerMotif::Init(nsITimerCallback *aCallback,
mCallback = aCallback;
// mRepeat = aRepeat;
InitAppContext();
EnsureAppContext();
mTimerId = XtAppAddTimeOut(mAppContext,
aDelay,
@ -105,7 +105,7 @@ nsTimerMotif::Init(nsITimerCallback *aCallback,
nsresult
nsTimerMotif::Init(PRUint32 aDelay)
{
InitAppContext();
EnsureAppContext();
mDelay = aDelay;
NS_ADDREF(this);
@ -129,7 +129,7 @@ void nsTimerExpired(XtPointer aCallData)
}
nsresult
nsTimerMotif::InitAppContext()
nsTimerMotif::EnsureAppContext()
{
static XtAppContext gsAppContext = nsnull;
@ -149,7 +149,7 @@ nsTimerMotif::InitAppContext()
if (ac_service)
{
printf("nsTimerMotif::InitAppContext() ac_service = %p\n",ac_service);
printf("nsTimerMotif::EnsureAppContext() ac_service = %p\n",ac_service);
nsresult rv2 = ac_service->GetAppContext(&gsAppContext);
@ -159,7 +159,7 @@ nsTimerMotif::InitAppContext()
NS_RELEASE(ac_service);
printf("nsTimerMotif::InitAppContext() gsAppContext = %p\n",gsAppContext);
printf("nsTimerMotif::EnsureAppContext() gsAppContext = %p\n",gsAppContext);
}
}
@ -168,6 +168,7 @@ nsTimerMotif::InitAppContext()
return NS_OK;
}
#ifndef TOOLKIT_EXORCISM
nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
@ -182,3 +183,4 @@ nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
}
#endif /* TOOLKIT_EXORCISM */

Просмотреть файл

@ -53,7 +53,7 @@ public:
private:
nsresult Init(PRUint32 aDelay);
nsresult InitAppContext();
nsresult EnsureAppContext();
PRUint32 mDelay;
nsTimerCallbackFunc mFunc;

Просмотреть файл

@ -19,7 +19,7 @@
#include "nsTimerMotif.h"
#include "nsTimerCIID.h"
#include "nsUnixTimerCIID.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"

Просмотреть файл

@ -18,6 +18,8 @@
#include "nsITimer.h"
#include "nsUnixTimerCIID.h"
#include "nsIComponentManager.h"
#include "nsIUnixToolkitService.h"
#include "nsCRT.h"
#include "prenv.h"
@ -51,7 +53,7 @@ static nsresult NewTimer(const nsCID & aClass,nsITimer ** aInstancePtrResult)
rv = nsComponentManager::CreateInstance(aClass,
nsnull,
nsITimer::GetIID(),
kITimerIID,
(void **)& timer);
@ -72,126 +74,48 @@ static nsresult NewTimer(const nsCID & aClass,nsITimer ** aInstancePtrResult)
NS_ASSERTION(NS_SUCCEEDED(rv), (const char *) nsAutoCString(message));
#endif
if (nsnull == timer)
return NS_ERROR_OUT_OF_MEMORY;
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
}
//////////////////////////////////////////////////////////////////////////
static nsAutoString GetToolkitName()
static const nsCID *
GetTimerCID()
{
static const char * sMozillaToolkit = nsnull;
static PRBool sFirstTime = PR_TRUE;
static const nsCID * sgTimerCID = nsnull;
// Execute the following code only once.
if ((nsnull == sMozillaToolkit) && !sFirstTime)
static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID);
// For obvious efficiency reasons, do this only once
if (nsnull == sgTimerCID)
{
sFirstTime = PR_FALSE;
nsIUnixToolkitService * unixToolkitService = nsnull;
// Look in the invironment for MOZ_TOOLKIT. A variable
// that controls the toolkit the user wants to use.
sMozillaToolkit = PR_GetEnv("MOZ_TOOLKIT");
nsresult rv =
nsComponentManager::CreateInstance(kCUnixToolkitServiceCID,
nsnull,
nsIUnixToolkitService::GetIID(),
(void **) &unixToolkitService);
NS_ASSERTION(rv == NS_OK,"Cannot obtain unix toolkit service.");
if (NS_OK == rv && nsnull != unixToolkitService)
{
nsresult rv2;
// If MOZ_TOOLKIT is not set, assume gtk
if (!sMozillaToolkit)
return nsAutoString("gtk");
// Gtk
if (nsCRT::strcasecmp(sMozillaToolkit,"gtk") == 0)
return nsAutoString("gtk");
// Motif
if (nsCRT::strcasecmp(sMozillaToolkit,"motif") == 0)
return nsAutoString("motif");
// Xlib
if (nsCRT::strcasecmp(sMozillaToolkit,"xlib") == 0)
return nsAutoString("xlib");
rv2 = unixToolkitService->GetTimerCID((nsCID **) &sgTimerCID);
NS_ASSERTION(rv2 == NS_OK,"Cannot get timer cid.");
NS_RELEASE(unixToolkitService);
}
}
#ifdef NS_DEBUG
printf("Toolkit '%s' is unknown. Assumming Gtk.\n",sMozillaToolkit);
#endif
return nsAutoString("gtk");
return sgTimerCID;
}
//////////////////////////////////////////////////////////////////////////
static const nsCID * GetTimerCID()
{
static const char * sMozillaToolkit = nsnull;
static const nsCID * sTimerClassID = 0;
static PRBool sDone = PR_FALSE;
// The following code should execute only once. If the environment
// variable is not set, then 'sMozillaToolkit' will still be null
// in the second iteration. So, we use the sDone flag to make
// sure it executes only once.
if ((nsnull == sMozillaToolkit) && !sDone)
{
sDone = PR_TRUE;
// Look in the invironment for MOZ_TOOLKIT. A variable
// that controls the toolkit the user wants to use.
sMozillaToolkit = PR_GetEnv("MOZ_TOOLKIT");
// If MOZ_TOOLKIT is not set, assume gtk
if (!sMozillaToolkit)
{
sTimerClassID = &kCTimerGtk;
#ifdef DEBUG_ramiro
sToolkitName = "gtk";
#endif
}
// Otherwise check MOZ_TOOLKIT for the toolkit name
else
{
// Gtk
if (nsCRT::strcasecmp(sMozillaToolkit,"gtk") == 0)
{
sTimerClassID = &kCTimerGtk;
#ifdef DEBUG_ramiro
sToolkitName = "gtk";
#endif
}
// Motif
else if (nsCRT::strcasecmp(sMozillaToolkit,"motif") == 0)
{
sTimerClassID = &kCTimerMotif;
#ifdef DEBUG_ramiro
sToolkitName = "motif";
#endif
}
// Xlib
else if (nsCRT::strcasecmp(sMozillaToolkit,"xlib") == 0)
{
sTimerClassID = &kCTimerXlib;
#ifdef DEBUG_ramiro
sToolkitName = "xlib";
#endif
}
// Default to Gtk
else
{
#ifdef NS_DEBUG
printf("Toolkit '%s' is unknown. Assumming Gtk.\n",
sMozillaToolkit);
#endif
sTimerClassID = &kCTimerGtk;
#ifdef DEBUG_ramiro
sToolkitName = "gtk";
#endif
}
}
#ifdef DEBUG_ramiro
printf("NS_NewTimer() - Using '%s' for the X toolkit.\n",
sMozillaToolkit);
#endif
}
return sTimerClassID;
}
static PRTime sStartTime = 0;
static PRTime sEndTime = 0;
@ -204,8 +128,6 @@ nsresult NS_NewTimer(nsITimer ** aInstancePtrResult)
NS_ASSERTION(nsnull != cid,"Dude! Trying to make a timer with a null CID.");
// printf("NS_NewTimer(%s)\n",(const char *) nsAutoCString(GetToolkitName()));
nsresult rv = NewTimer(*cid,aInstancePtrResult);
sEndTime = PR_Now();

Просмотреть файл

@ -21,18 +21,19 @@
#include "nsISupports.h"
// {90F55E53-40EB-11d3-B219-000064657374}
// {48B62AD1-48D3-11d3-B224-000064657374}
#define NS_TIMER_MOTIF_CID \
{ 0x90f55e53, 0x40eb, 0x11d3, \
{ 0xb2, 0x19, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
{ 0x48b62ad1, 0x48d3, 0x11d3, \
{ 0xb2, 0x24, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
// {90F55E54-40EB-11d3-B219-000064657374}
// {48B62AD2-48D3-11d3-B224-000064657374}
#define NS_TIMER_GTK_CID \
{ 0x90f55e54, 0x40eb, 0x11d3, \
{ 0xb2, 0x19, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
{ 0x48b62ad2, 0x48d3, 0x11d3, \
{ 0xb2, 0x24, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
// {90F55E57-40EB-11d3-B219-000064657374}
// {48B62AD3-48D3-11d3-B224-000064657374}
#define NS_TIMER_XLIB_CID \
{ 0x90f55e57, 0x40eb, 0x11d3, \
{ 0xb2, 0x19, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
{ 0x48b62ad3, 0x48d3, 0x11d3,
{ 0xb2, 0x24, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
#endif // nsUnixTimerCIID_h__

Просмотреть файл

@ -24,24 +24,33 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
LIBRARY_NAME = $(TIMER_LIB_NAME)
### XXX ### IS_COMPONENT=1
ifdef TOOLKIT_EXORCISM
LIBRARY_NAME = timer_xlib
IS_COMPONENT=1
REQUIRES=xpcom
DEFINES += -D_IMPL_NS_TIMER
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = \
nsTimerXlib.cpp \
### XXX ### nsTimerXlibFactory.cpp \
nsTimerXlibFactory.cpp \
$(NULL)
### XXX ### EXTRA_DSO_LDOPTS += $(TK_LIBS)
#EXTRA_DSO_LDOPTS += $(TK_LIBS)
EXTRA_DSO_LDOPTS += -L/usr/X11R6/lib -lX11
else
LIBRARY_NAME = $(TIMER_LIB_NAME)
REQUIRES = xpcom
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = nsTimerXlib.cpp
MKSHLIB =
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
endif # TOOLKIT_EXORCISM
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -18,6 +18,11 @@
#include "nsTimerXlib.h"
#ifdef TOOLKIT_EXORCISM
#include "nsIXlibWindowService.h"
#include "nsIServiceManager.h"
#endif /* TOOLKIT_EXORCISM */
#include <unistd.h>
#include <stdio.h>
@ -25,8 +30,13 @@
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
#ifdef TOOLKIT_EXORCISM
static int NS_TimeToNextTimeout(struct timeval *aTimer);
static void NS_ProcessTimeouts(void);
#else
extern "C" int NS_TimeToNextTimeout(struct timeval *aTimer);
extern "C" void NS_ProcessTimeouts(void);
#endif /* TOOLKIT_EXORCISM */
nsTimerXlib *nsTimerXlib::gTimerList = NULL;
struct timeval nsTimerXlib::gTimer = {0, 0};
@ -117,6 +127,9 @@ nsTimerXlib::Init(PRUint32 aDelay)
}
}
NS_ADDREF(this);
EnsureWindowService();
return NS_OK;
}
@ -200,7 +213,53 @@ nsTimerXlib::ProcessTimeouts(struct timeval *aNow)
}
}
int NS_TimeToNextTimeout(struct timeval *aTimer) {
#ifdef TOOLKIT_EXORCISM
static NS_DEFINE_IID(kWindowServiceCID,NS_XLIB_WINDOW_SERVICE_CID);
static NS_DEFINE_IID(kWindowServiceIID,NS_XLIB_WINDOW_SERVICE_IID);
#endif /* TOOLKIT_EXORCISM */
nsresult
nsTimerXlib::EnsureWindowService()
{
#ifdef TOOLKIT_EXORCISM
nsIXlibWindowService * xlibWindowService = nsnull;
nsresult rv = nsServiceManager::GetService(kWindowServiceCID,
kWindowServiceIID,
(nsISupports **)&xlibWindowService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Couldn't obtain window service.");
if (NS_OK == rv && nsnull != xlibWindowService)
{
xlibWindowService->SetTimeToNextTimeoutFunc(NS_TimeToNextTimeout);
xlibWindowService->SetProcessTimeoutsProc(NS_ProcessTimeouts);
NS_RELEASE(xlibWindowService);
}
#endif /* TOOLKIT_EXORCISM */
return NS_OK;
}
#ifdef TOOLKIT_EXORCISM
static
#else
extern "C"
#endif /* TOOLKIT_EXORCISM */
int NS_TimeToNextTimeout(struct timeval *aTimer)
{
#ifdef TOOLKIT_EXORCISM
static int once = 1;
if (once)
{
once = 0;
printf("NS_TimeToNextTimeout() lives!\n");
}
#endif /* TOOLKIT_EXORCISM */
nsTimerXlib *timer;
timer = nsTimerXlib::gTimerList;
if (timer) {
@ -231,24 +290,44 @@ int NS_TimeToNextTimeout(struct timeval *aTimer) {
}
}
void NS_ProcessTimeouts(void) {
#ifdef TOOLKIT_EXORCISM
static
#else
extern "C"
#endif /* TOOLKIT_EXORCISM */
void
NS_ProcessTimeouts(void)
{
#ifdef TOOLKIT_EXORCISM
static int once = 1;
if (once)
{
once = 0;
printf("NS_ProcessTimeouts() lives!\n");
}
#endif /* TOOLKIT_EXORCISM */
struct timeval now;
now.tv_sec = 0;
now.tv_usec = 0;
nsTimerXlib::ProcessTimeouts(&now);
}
#ifndef TOOLKIT_EXORCISM
nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
nsTimerXlib *timer = new nsTimerXlib();
if (nsnull == timer) {
return NS_ERROR_OUT_OF_MEMORY;
}
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
nsTimerXlib *timer = new nsTimerXlib();
if (nsnull == timer) {
return NS_ERROR_OUT_OF_MEMORY;
}
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
}
#endif /* TOOLKIT_EXORCISM */

Просмотреть файл

@ -57,6 +57,7 @@ public:
private:
nsresult Init(PRUint32 aDelay);
nsresult EnsureWindowService();
nsTimerCallbackFunc mFunc;
void * mClosure;

Просмотреть файл

@ -19,7 +19,7 @@
#include "nsTimerXlib.h"
#include "nsTimerCIID.h"
#include "nsUnixTimerCIID.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"

Просмотреть файл

@ -55,12 +55,21 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
BEOS_PROGRAM_RESOURCE = $(srcdir)/apprunner-beos.rsrc
endif
ifndef TOOLKIT_EXORCISM
UN_EXORCISED_WIDGET_FLAGS=$(MOZ_WIDGET_TOOLKIT_LDFLAGS)
UN_EXORCISED_GFX_FLAGS=$(MOZ_GFX_TOOLKIT_LDFLAGS)
endif
ifndef TOOLKIT_EXORCISM
UN_EXORCISED_TK_FLAGS=$(TK_LIBS)
endif
LIBS += \
-lnsappshell \
-lxpcom \
$(MOZ_WIDGET_TOOLKIT_LDFLAGS) \
$(UN_EXORCISED_WIDGET_FLAGS) \
-lraptorgfx \
$(MOZ_GFX_TOOLKIT_LDFLAGS) \
$(UN_EXORCISED_GFX_FLAGS) \
$(TIMER_LIBS) \
-lmozreg \
-lraptorwebwidget \
@ -80,7 +89,7 @@ LIBS += \
-lxpcom \
$(ZLIB_LIBS) \
$(NSPR_LIBS) \
$(TK_LIBS) \
$(UN_EXORCISED_TK_FLAGS) \
$(NULL)
include $(topsrcdir)/config/rules.mk