|
Mac OS 9
|
CoreGraphics remote operation. More...
Go to the source code of this file.
Typedefs | |
| typedef CGError | CGEventErr |
| typedef u_int32_t | CGRectCount |
| typedef const CGRect * | rectArray |
| typedef const CGRect void * | userParameter |
| typedef u_int32_t | CGButtonCount |
| typedef u_int32_t | CGWheelCount |
| typedef u_int16_t | CGCharCode |
| typedef u_int16_t | CGKeyCode |
| typedef enum CGEventFilterMask | CGEventFilterMask |
| typedef enum CGEventSupressionState | CGEventSupressionState |
Enumerations | |
| enum | { CGEventNoErr = kCGErrorSuccess } |
| enum | CGEventFilterMask { kCGEventFilterMaskPermitLocalMouseEvents , kCGEventFilterMaskPermitLocalKeyboardEvents , kCGEventFilterMaskPermitSystemDefinedEvents , kCGEventFilterMaskPermitAllEvents } |
| enum | CGEventSupressionState { kCGEventSupressionStateSupressionInterval = 0 , kCGEventSupressionStateRemoteMouseDrag = 1 , kCGNumberOfEventSupressionStates = 2 } |
Functions | |
| typedef | CALLBACK_API_C (void, CGScreenRefreshCallback)(CGRectCount count |
| void | CGRegisterScreenRefreshCallback (CGScreenRefreshCallback callback, void *userParameter) |
| void | CGUnregisterScreenRefreshCallback (CGScreenRefreshCallback callback, void *userParameter) |
| CGEventErr | CGWaitForScreenRefreshRects (CGRect **pRectArray, CGRectCount *pCount) |
| void | CGReleaseScreenRefreshRects (CGRect *rectArray) |
| CGEventErr | CGPostMouseEvent (CGPoint mouseCursorPosition, boolean_t updateMouseCursorPosition, CGButtonCount buttonCount, boolean_t mouseButtonDown,...) |
| CGEventErr | CGPostScrollWheelEvent (CGWheelCount wheelCount, int32_t wheel1,...) |
| CGEventErr | CGPostKeyboardEvent (CGCharCode keyChar, CGKeyCode virtualKey, boolean_t keyDown) |
| CGEventErr | CGWarpMouseCursorPosition (CGPoint newCursorPosition) |
| CGEventErr | CGInhibitLocalEvents (boolean_t doInhibit) |
| CGEventErr | CGSetLocalEventsSuppressionInterval (CFTimeInterval seconds) |
| CGEventErr | CGEnableEventStateCombining (boolean_t doCombineState) |
| CGEventErr | CGSetLocalEventsFilterDuringSupressionState (CGEventFilterMask filter, CGEventSupressionState state) |
| CGEventErr | CGAssociateMouseAndMouseCursorPosition (boolean_t connected) |
CoreGraphics remote operation.
For bug reports, consult the following page on the World Wide Web:
http://developer.apple.com/bugreporter/
| typedef u_int32_t CGButtonCount |
Posting events: These functions post events into the system. Use for remote operation and virtualization.
Note that remote operation requires a valid connection to the server, which must be owned by either the root/Administrator user or the logged in console user. This means that your application must be running as root/Administrator user or the logged in console user. Synthesize mouse events. mouseCursorPosition should be the global coordinates the mouse is at for the event. updateMouseCursor should be TRUE if the on-screen cursor should be moved to mouseCursorPosition.
Based on the values entered, the appropriate mouse-down, mouse-up, mouse-move, or mouse-drag events are generated, by comparing the new state with the current state.
The current implemementation of the event system supports a maximum of thirty-two buttons. The buttonCount parameter should be followed by 'buttonCount' boolean_t values indicating button state. The first value should reflect the state of the primary button on the mouse. The second value, if any, should reflect the state of the secondary mouse button (right), if any. A third value woule be the center button, and the remaining buttons would be in USB device order.
| typedef u_int16_t CGCharCode |
Synthesize keyboard events. Based on the values entered, the appropriate key down, key up, and flags changed events are generated. If keyChar is NUL (0), an apropriate value will be guessed at, based on the default keymapping.
All keystrokes needed to generate a character must be entered, including SHIFT, CONTROL, OPTION, and COMMAND keys. For example, to produce a 'Z', the SHIFT key must be down, the 'z' key must go down, and then the SHIFT and 'z' key must be released: CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)56, true ); // shift down CGPostKeyboardEvent( (CGCharCode)'Z', (CGKeyCode)6, true ); // 'z' down CGPostKeyboardEvent( (CGCharCode)'Z', (CGKeyCode)6, false ); // 'z' up CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)56, false ); // 'shift up
| typedef u_int32_t CGRectCount |
Callback function pointer; Declare your callback function in this form. When an area of the display is modified or refreshed, your callback function will be invoked with a count of the number of rectangles in the refreshed areas, and a list of the refreshed rectangles. The rectangles are in global coordinates.
Your function should not modify, deallocate or free memory pointed to by rectArray.
The system continues to accumulate refreshed areas constantly. Whenever new information is available, your callback function is invoked.The list of rects passed to the callback function are cleared from the accumulated refreshed area when the callback is made.
This callback may be triggered by drawing operations, window movement, and display reconfiguration.
Bear in mind that a single rectangle may occupy multiple displays, either by overlapping the displays, or by residing on coincident displays when mirroring is active. Use the CGGetDisplaysWithRect() to determine the displays a rectangle occupies.
| typedef u_int32_t CGWheelCount |
Synthesize scroll wheel events.
The current implemementation of the event system supports a maximum of three wheels.
The wheelCount parameter should be followed by 'wheelCount' 32 bit integer values indicating wheel movements. The first value should reflect the state of the primary wheel on the mouse. The second value, if any, should reflect the state of a secondary mouse wheel, if any.
Wheel movement is represented by small signed integer values, typically in a range from -10 to +10. Large values may have unexpected results, depending on the application that processes the event.
| enum CGEventFilterMask |
By default the system supresses local hardware events from the keyboard and mouse during a short interval after a synthetic event is posted (see CGSetLocalEventsSuppressionInterval()) and while a synthetic mouse drag (mouse movement with the left/only mouse button down). Some classes of applications may want to enable events from some of the local hardware. For example, an app may want to post only mouse events, and so may wish to permit local keyboard hardware events to pass through.
This interface lets an app specify a state (event supression interval, or mouse drag), and a mask of event categories to be passed through.
| CGEventErr CGAssociateMouseAndMouseCursorPosition | ( | boolean_t | connected | ) |
Helper function to connect or disconnect the mouse and mouse cursor. CGAssociateMouseAndMouseCursorPosition(false) has the same effect as the following, without actually modifying the supression interval:
CGSetLocalEventsSuppressionInterval(MAX_DOUBLE); CGWarpMouseCursorPosition(currentPosition);
While disconnected, mouse move and drag events will reflect the current position of the mouse cursor position, which will not change with mouse movement. Use the <CoreGraphics/CGDirectDisplay.h> function:
void CGGetLastMouseDelta( CGMouseDelta * deltaX, CGMouseDelta * deltaY );
This will report mouse movement associated with the last mouse move or drag event.
To update the display cursor position, use the function defined in this module:
CGEventErr CGWarpMouseCursorPosition( CGPoint newCursorPosition ); CGAssociateMouseAndMouseCursorPosition()
Availability:
| CGEventErr CGEnableEventStateCombining | ( | boolean_t | doCombineState | ) |
By default, the flags that indicate modifier key state (Command, Alt, Shift, etc.) from the system's keyboard and from other event sources are ORed together as an event is posted into the system, and current key and mouse button state is considered in generating new events. This function allows your application to enable or disable the merging of event state. When combining is turned off, the event state propagated in the events posted by your app reflect state built up only by your app. The state within your app's generated event will not be combined with the system's current state, so the system-wide state reflecting key and mouse button state will remain unchanged
When called with doCombineState equal to FALSE, this function initializes local (per application) state tracking information to a state of all keys, modifiers, and mouse buttons up.
When called with doCombineState equal to TRUE, the current global state of keys, modifiers, and mouse buttons are used in generating events. CGEnableEventStateCombining()
Availability:
| CGEventErr CGInhibitLocalEvents | ( | boolean_t | doInhibit | ) |
Remote operation may want to inhibit local events (events from the machine's keyboard and mouse). This may be done either as a explicit request (tracked per app) or as a short term side effect of posting an event.
CGInhibitLocalEvents() is typically used for long term remote operation of a system, as in automated system testing or telecommuting applications. Local device state changes are discarded.
Local event inhibition is turned off if the app that requested it terminates. CGInhibitLocalEvents()
Availability:
| CGEventErr CGPostKeyboardEvent | ( | CGCharCode | keyChar, |
| CGKeyCode | virtualKey, | ||
| boolean_t | keyDown | ||
| ) |
Availability:
| CGEventErr CGPostMouseEvent | ( | CGPoint | mouseCursorPosition, |
| boolean_t | updateMouseCursorPosition, | ||
| CGButtonCount | buttonCount, | ||
| boolean_t | mouseButtonDown, | ||
| ... | |||
| ) |
Availability:
| CGEventErr CGPostScrollWheelEvent | ( | CGWheelCount | wheelCount, |
| int32_t | wheel1, | ||
| ... | |||
| ) |
Availability:
| void CGRegisterScreenRefreshCallback | ( | CGScreenRefreshCallback | callback, |
| void * | userParameter | ||
| ) |
Register a callback function to be invoked when an area of the display is refreshed, or modified. The function is invoked on the same thread of execution that is processing events within your application. userParameter is passed back with each invocation of the callback function. CGRegisterScreenRefreshCallback()
Availability:
| void CGReleaseScreenRefreshRects | ( | CGRect * | rectArray | ) |
Deallocate the list of rects recieved from CGWaitForScreenRefreshRects() CGReleaseScreenRefreshRects()
Availability:
| CGEventErr CGSetLocalEventsFilterDuringSupressionState | ( | CGEventFilterMask | filter, |
| CGEventSupressionState | state | ||
| ) |
CGSetLocalEventsFilterDuringSupressionState()
Availability:
| CGEventErr CGSetLocalEventsSuppressionInterval | ( | CFTimeInterval | seconds | ) |
Set the period of time in seconds that local hardware events (keyboard and mouse) are supressed after posting an event. Defaults to 0.25 second. CGSetLocalEventsSuppressionInterval()
Availability:
| void CGUnregisterScreenRefreshCallback | ( | CGScreenRefreshCallback | callback, |
| void * | userParameter | ||
| ) |
Remove a previously registered calback function. Both the function and the userParameter must match the registered entry to be removed. CGUnregisterScreenRefreshCallback()
Availability:
| CGEventErr CGWaitForScreenRefreshRects | ( | CGRect ** | pRectArray, |
| CGRectCount * | pCount | ||
| ) |
In some applications it may be preferable to have a seperate thread wait for screen refresh data. This function should be called on a thread seperate from the event processing thread. If screen refresh callback functions are registered, this function should not be used. The mechanisms are mutually exclusive.
Deallocate screen refresh rects using CGReleaseScreenRefreshRects().
Returns an error code if parameters are invalid or an error occurs in retrieving dirty screen rects from the server. CGWaitForScreenRefreshRects()
Availability:
| CGEventErr CGWarpMouseCursorPosition | ( | CGPoint | newCursorPosition | ) |
Warp the mouse cursor to the desired position in global coordinates without generating events CGWarpMouseCursorPosition()
Availability: