Moving Event loop interfaces to it's new home from xpcom/apps. Implementation will start here. Also renamed msg to be event to be less windows-ish.

This commit is contained in:
tbogard%aol.net 1999-08-24 05:47:30 +00:00
Родитель 2ebbecd6c7
Коммит 43ed877918
14 изменённых файлов: 554 добавлений и 0 удалений

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

@ -0,0 +1,30 @@
#!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@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = eventloop nativeApp
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,23 @@
#!nmake
#
# 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=..\..\..
DIRS=xp windows
include <$(DEPTH)\config\rules.mak>
include <$(DEPTH)\config\config.mak>

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

@ -0,0 +1,27 @@
#!nmake
#
# 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=..\..\..\..
MODULE=xpcom_eventloop_windows
XPIDLSRCS= \
.\nsIWinEvent.idl \
.\nsIWinEventFilter.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>
include <$(DEPTH)\config\config.mak>

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

@ -0,0 +1,12 @@
#include "nsISupports.idl"
#include "nsIEvent.idl"
/**
* The nsIWinEvent defines what a message looks like on the Windows Platform.
*/
[scriptable, uuid(2EFB5005-4508-11d3-AEDA-00A024FFC08C)]
interface nsIWinEvent : nsIEvent
{
//XXX Place the contents of a Windows MSG struct here.
};

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

@ -0,0 +1,14 @@
#include "nsISupports.idl"
#include "nsIEventFilter.idl"
/**
* The nsIWinEventFilter defines what a message filter looks like on the Windows
* Platform.
*/
[scriptable, uuid(2EFB5006-4508-11d3-AEDA-00A024FFC08C)]
interface nsIWinEventFilter : nsIEventFilter
{
//XXX Place the contents of a Windows MSG struct here.
//As well as other needed filtering criteria.
};

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

@ -0,0 +1,30 @@
#!nmake
#
# 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=..\..\..\..
MODULE=xpcom_eventloop_xp
XPIDLSRCS= \
.\nsIDispatchListener.idl \
.\nsIEventLoop.idl \
.\nsIEventFilter.idl \
.\nsIEvent.idl \
.\nsITranslateListener.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>
include <$(DEPTH)\config\config.mak>

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

@ -0,0 +1,44 @@
#include "nsISupports.idl"
#include "nsIEvent.idl"
/**
* The nsIDispatchListener defines the callback listener interface that
* can be passed to the Run routine on and event loop. This allows
* application override or additions to the default dispatching event mechanism.
*/
[scriptable, uuid(2EFB5007-4508-11d3-AEDA-00A024FFC08C)]
interface nsIDispatchListener : nsISupports
{
/* Called just before the nsIEventLoop::DispatchMessage() is called.
This allows a listener first crack at dispatching Messages. The
listener can then control if DispatchMessage() is called via the
return.
@param msg This is the native message that has been retrieved from the Queue
and awaiting dispatching.
@return NS_OK - Indicates nsIEventLoop::DispatchMessage() should be called
following the return from this function.
NS_FALSE - Processing went successfully, but
nsIEventLoop::DispatchMessage() should not be called.
NS_ERROR_FAILURE - Catastrophic processing failure. Event loop should
die immediately.
*/
void PreDispatch(in nsIEvent msg);
/*
Called just after the nsIEventLoop::DispatchMessage() has been called.
@param msg This is the native message that has been retrieved from the Queue
and awaiting dispatching.
@param fDispatchHandled Indicates if nsIEventLoop::DispatchMessage() handled
the message being passed in.
@return NS_OK - Processing completed fine.
NS_ERROR_FAILURE - Catastrophic processing failure. Event loop
should die immediately.
*/
void PostDispatch(in nsIEvent msg, in boolean fDispatchHandled);
};

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

@ -0,0 +1,11 @@
#include "nsISupports.idl"
/**
* The nsIEvent serves as a base interface for the platform specific
* interfaces that define what an event looks like.
*/
[scriptable, uuid(2EFB5004-4508-11d3-AEDA-00A024FFC08C)]
interface nsIEvent : nsISupports
{
};

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

@ -0,0 +1,11 @@
#include "nsISupports.idl"
/**
* The nsIEventFilter serves as a base interface for the platform specific
* interfaces that define what a filter message looks like.
*/
[scriptable, uuid(2EFB5003-4508-11d3-AEDA-00A024FFC08C)]
interface nsIEventFilter : nsISupports
{
};

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

@ -0,0 +1,200 @@
#include "nsISupports.idl"
#include "nsIEventFilter.idl"
#include "nsIEvent.idl"
#include "nsIDispatchListener.idl"
#include "nsITranslateListener.idl"
typedef long nsEventLoopType;
/*
There are three basic types of Event Loops that can exist in a system.
1.) There is the Main Event loop that services the application. This
is typically what would be found at the bottom of a main(). Event loops
of this type are specified with the 'MainAppLoop' type. There can only
be one of these per Application. It is also important to note that
Run() called on a Loop of this type blocks until the loop exits.
2.) User-interface threads are distinct from worker threads in that they
provide an event loop that services native system events. This is the loop
that that is found at the bottom of the ThreadMain often looking very
similar to the one found in main(). Event loops of this type are specified
with the 'ThreadLoop' type. There can only be one of these per thread.It is
also important to note that Run() called on a Loop of this type blocks
until the loop exits.
3.) The third type of loop that exists is one that is done to allow the
application and sytem to "breathe". This loop is often invoked from various
places on the stack virtually always with the main thread loop living down
the stack in some fashion. Great care should be taken in using loops of
this kind. Event loops of this type are specified with the 'AppBreathLoop'
type. There can be as many of these per application as the application
wishes to create. This loop is different than others with respect to the
way Run() works on events of this type. Run() will return once the app
has had suffiecient breathe time. This may be once the event queue is
empty or may be after a specified yield time. As loops of this type aren't
tied to the life of a thread or app, the return from Run() does not
indicate the desire to end a thread or app either.
******* Talk about life of a loop of these types ******
*/
[scriptable, uuid(2EFB5002-4508-11d3-AEDA-00A024FFC08C)]
interface nsEventLoopTypes
{
const long MainAppLoop = 1;
const long ThreadLoop = 2;
const long AppBreathLoop = 3;
};
/**
* The nsIEventLoop provides the facilities to interfact with a native
* application event queue.
*/
[scriptable, uuid(2EFB5001-4508-11d3-AEDA-00A024FFC08C)]
interface nsIEventLoop : nsISupports
{
/******** High Level App Usage *******/
/* Runs the Event Loop. This is a blocking call, it will return when the
application or OS has indicated the loop should quit. This is a convience
function that can be recreated by a client of this interface using the
low-level methods. Unless the application truly needs to handle events
on it's own, it is suggested that this method be used rather than manually
creating the event loop. To end an event loop one can call the Exit()
method on the nsIEventLoop interface.
In the case of a AppBreathLoop this blocks the app has had suffiecient
"breathe" time. This may be once the event queue is empty or may be after
a specified yield time. As loops of this type aren't tied to the life of
a thread or app, the return from Run() does not indicate the desire to end
a thread or app either.
@param filter Message Filter for handling of events in this loop. If the
application wishes to select ranges for message
it can pass in a filter. This may be null.
@param translateListener Callback called for application specific tranlation
of events. This should be null unless the calling
application really needs to override the default translation.
@param dispatchListener Callback called for application specific dispatching
of events. This should be null unless the calling application
really needs to override the default processing.
*/
// Bool for nested PL_Events.
void Run(in nsIEventFilter filter, in nsITranslateListener translateListener,
in nsIDispatchListener dispatchListener);
/* Exits the Event loop referred to by the instantiation of this interface
*/
void Exit();
/******* Low Level Loop Management *****/
/* This retrieves the next message in the queue for this event loop.
If there are no messages in the queue, GetNextMessage will wait for
messages to be placed in the queue offering control up to other applications
while waiting. When an event to exit the queue is retrieved, GetNextMessage
will return NS_FALSE to indicate the loop should finish.
@param filter Message Filter for handling of events in this loop. If the
application wishes to select ranges for message
it can pass in a filter. This may be null.
@param msg This is the message returned from the queue. Each platform can
QI on this returned interface to get the platform specific
message contents. This interface is addrefd and must be
released when processing is complete.
@return NS_OK - msg has been retrieved and ready to be processed.
NS_FALSE - An exit event has been signalled. msg will be null.
NS_ERROR_FAILURE - Internal failure, ignore all results and
cease use of loop.
*/
void GetNextMessage(in nsIEventFilter filter, out nsIEvent msg);
/* This retrieves the next message in the queue for this event loop.
If there are no messages in the queue, unlike GetNextMessage,
PeekNextMessage will return immediately with NS_FALSE.
messages to be placed in the queue offering control up to other applications
while waiting. When an event to exit the queue is retrieved, GetNextMessage
will return NS_FALSE to indicate the loop should finish.
@param filter Message Filter for handling of events in this loop. If the
application wishes to select ranges for message
it can pass in a filter. This may be null.
@param msg This is the message returned from the queue. Each platform can
QI on this returned interface to get the platform specific
message contents. This interface is addrefd and must be
released when processing is complete.
@return NS_OK - msg has been retrieved and ready to be processed.
NS_FALSE - There are no more messages to retrieve. msg will be null.
NS_ERROR_FAILURE - Internal failure, ignore all results and
cease use of loop.
*/
void PeekNextMessage(in nsIEventFilter filter, out nsIEvent msg);
/* This does any pre-processing of the message that may be needed.
@param msg This is the message returned from the queue. Each platform can
QI on this returned interface to get the platform specific
message contents. This interface is addrefd and must be
released when processing is complete.
@return NS_OK - Translated Message.
NS_FALSE - Was unable to Translate Message, but this is normal.
NS_ERROR_FAILURE - Catastrophic processing failure. Event loop
should die immediately.
*/
void TranslateMessage(in nsIEvent msg);
/* This does any pre-processing of the message that may be needed.
@param msg This is the message returned from the queue. Each platform can
QI on this returned interface to get the platform specific
message contents. This interface is addrefd and must be
released when processing is complete.
@return NS_OK - Processed and Dispatched Message.
NS_FALSE - Was unable to Dispatch Message, but this is normal.
NS_ERROR_FAILURE - Catastrophic processing failure. Event loop
should die immediately.
*/
void DispatchMessage(in nsIEvent msg);
/******* Loop Manipulation ******/
/* Puts a Message on the event loop referred to by the interface pointer
and waits for the message to be processed.
@param msg This is the message returned from the queue. Each platform can
QI on this returned interface to get the platform specific
message contents. This interface is addrefd and must be
released when processing is complete.
@return NS_OK - Message Sent and Processed.
NS_FALSE - Message was Sent but was unable to wait for event
processing.
NS_ERROR_INVALID_ARG - Message passed in was mal-formed.
NS_ERROR_FAILURE - Catastrophic processing failure.
*/
void SendLoopMessage(in nsIEvent msg);
/* Puts a Message on the event loop referred to by the interface pointer
and then returns immediately not waiting for the message to be processed.
@param msg This is the message returned from the queue. Each platform can
QI on this returned interface to get the platform specific
message contents. This interface is addrefd and must be
released when processing is complete.
@return NS_OK - Message was placed on the event queue.
NS_ERROR_INVALID_ARG - Message passed in was mal-formed.
NS_ERROR_FAILURE - Catastrophic processing failure.
*/
void PostLoopMessage(in nsIEvent msg);
/******* Event Loop Information ******/
/* Specifies the type of the event loop. This was set upon creation. */
readonly attribute nsEventLoopType EventLoopType;
/* Specifies the name of the event loop. This was set upon creation. */
readonly attribute wstring EventLoopName;
};

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

@ -0,0 +1,45 @@
#include "nsISupports.idl"
#include "nsIEvent.idl"
/**
* The nsITranslateListener defines the callback listener interface that
* can be passed to the Run routine on and event loop. This allows
* application overriding or additions to the default event translation
* mechanism.
*/
[scriptable, uuid(2EFB5008-4508-11d3-AEDA-00A024FFC08C)]
interface nsITranslateListener : nsISupports
{
/* Called just before the nsIEventLoop::TranslateMessage() is called.
This allows a listener first crack at translating Messages. The
listener can then control if TranslateMessage() is called via the
return.
@param msg This is the native message that has been retrieved from the Queue
and awaiting dispatching.
@return NS_OK - Indicates nsIEventLoop::TranslateMessage() should be called
following the return from this function.
NS_FALSE - Translating went successfully, but
nsIEventLoop::TranlateMessage() should not be called.
NS_ERROR_FAILURE - Catastrophic processing failure. Event loop should
die immediately.
*/
void PreTranslate(in nsIEvent msg);
/*
Called just after the nsIEventLoop::TranslateMessage() has been called.
@param msg This is the native message that has been retrieved from the Queue
and awaiting dispatching.
@param fTranslateHandled Indicates if nsIEventLoop::TranslateMessage() handled
the message being passed in.
@return NS_OK - Processing completed fine.
NS_ERROR_FAILURE - Catastrophic processing failure. Event loop
should die immediately.
*/
void PostTranslate(in nsIEvent msg, in boolean fTranslateHandled);
};

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

@ -0,0 +1,22 @@
#!nmake
#
# 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=..\..
DIRS=eventloop nativeApp
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,26 @@
#!nmake
#
# 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=..\..\..
MODULE=xpcom_nativeapp
XPIDLSRCS= \
.\nsINativeApp.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>
include <$(DEPTH)\config\config.mak>

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

@ -0,0 +1,59 @@
#include "nsISupports.idl"
#include "nsIEventLoop.idl"
/**
* The nsINativeAppService provides necessary services to build a native
* application.
*/
/*
{2EFB5000-4508-11d3-AEDA-00A024FFC08C} -
{2EFB5100-4508-11d3-AEDA-00A024FFC08C} have been reserved for Native App
Service Interfaces.
Currently Used:
{2EFB5000-4508-11d3-AEDA-00A024FFC08C} - nsINativeApp
{2EFB5001-4508-11d3-AEDA-00A024FFC08C} - nsIEventLoop
{2EFB5002-4508-11d3-AEDA-00A024FFC08C} - nsEventLoopTypes
{2EFB5003-4508-11d3-AEDA-00A024FFC08C} - nsIEventFilter
{2EFB5004-4508-11d3-AEDA-00A024FFC08C} - nsIEvent
{2EFB5005-4508-11d3-AEDA-00A024FFC08C} - nsIWinEvent
{2EFB5006-4508-11d3-AEDA-00A024FFC08C} - nsIWinEventFilter
{2EFB5007-4508-11d3-AEDA-00A024FFC08C} - nsIDispatchListener
{2EFB5008-4508-11d3-AEDA-00A024FFC08C} - nsITranslateListener
*/
[scriptable, uuid(2EFB5000-4508-11d3-AEDA-00A024FFC08C)]
interface nsINativeApp : nsISupports
{
/* Used to Create an Event Loop of a specified Event Loop type.
There can only be one event loop per App of the MainAppLoop type.
There can only be one event loop per thread of the ThreadLoop type.
There can be any number of AppBreathLoop type threads.
@param EventLoopName This is the name to associate with an event loop.
This allows you to later find the event loop using the FineEventLoop
mechanism. This may be null, but is usually helpful to associate a
name with the loop.
@param type This is the event Loop type. Look at the various types
described in nsEventLoopType const definitions.
@param eventLoop This is the return created event loop.
@return NS_OK - Event Loop was created successfully.
NS_ERROR_INVALID_ARG - There is already an event loop for the
requested type and there can not be more than one.
NS_ERROR_INVALID_POINTER - eventLoop was null.
NS_ERROR_FAILURE - Internal error and event loop couldn't be
created.
*/
void CreateEventLoop(in wstring EventLoopName, in nsEventLoopType type,
out nsIEventLoop eventLoop);
/* Used to find a previously created event loop.
*/
void FindEventLoop(in wstring EventLoopName, out nsIEventLoop eventLoop);
};