AlObserver
 
 
 

An OpenAlias class that allows a plug-in to detect selected Alias events.

Synopsis

#include <AlObserver.h>
class AlObserver
enum ObserverMessage
{
kMaximizeWindow,
kMinimizeWindow,
kLowerWindow,
kRaiseWindow,
};
static statusCode	create();
static statusCode	deleteObject();
static statusCode	installHandler( ObserverMessage, void (*)(void) );
static statusCode	removeHandler( ObserverMessage, void (*)(void) );

Description

AlObserver is a static OpenAlias class. Currently, it allows a user to detect when the Alias window is minimized, maximized, lowered or raised. This class cannot trap events that are handled by the Window Manager.

An example of an event that cannot be trapped is the raising of a window by clicking on its window bar. However, this situation can be detected by an X-event handler installed by the AlXevents class, so to test if a window is below the Alias window on ConfigureNotify events use the method AlXevents::belowAliasWindow().

statusCode AlObserver::create()

Description

Initializes the API observer class. Note that this method should always be called by a plug-in that wants to observe events. If the observer class is already initialized, this routine will return successfully.

Return Codes

sSuccess - the method succeeded

sFailure - the method failed

statusCode AlObserver::deleteObject()

Description

Terminates the observation of events if there are no handlers installed. This allows several plug-ins loaded into Alias to call deleteObject(). The observer is not removed until the last plug-in has removed its handlers and called this routine.

Return Codes

sSuccess - the method succeeded

sFailure - the method failed. There may be handlers still installed.

sInvalidObject - the observer has not been initialized; call AlObserver::create()

statusCode AlObserver::installHandler( ObserverMessage observerType, void (*function)(void) )

Description

Installs a callback handler for a specific observerType.

Arguments

< observerType - one of kMaximizeWindow, kMinimizeWindow, kLowerWindow, kRaiseWindow

< function - pointer to a void function

Return Codes

sSuccess - the method succeeded

sFailure - the method failed or the observer type was invalid

sInvalidObject - the observer has not been initialized; call AlObserver::create()

sInvalidArgument - function parameter was NULL

statusCode AlObserver::removeHandler( ObserverMessage observerType, void (*function)(void) )

Description

Removes a callback handler for a specific observer type. Plug-ins must properly remove observer handlers to avoid Alias calling a routine that no longer exists in memory.

Arguments

< observerType - one of kMaximizeWindow, kMinimizeWindow, kLowerWindow, kRaiseWindow

< function - pointer to a void function

Return Codes

sSuccess - the method succeeded

sFailure - the method failed or the observer type was invalid

sInvalidObject - the observer has not been initialized; call AlObserver::create()