#endregion
#region kEventClassApplication constants
- // TODO: We dont use these yet; fill if needed
+ internal const uint kEventAppActivated = 1;
+ internal const uint kEventAppDeactivated = 2;
+ internal const uint kEventAppQuit = 3;
+ internal const uint kEventAppLaunchNotification = 4;
+ internal const uint kEventAppLaunched = 5;
+ internal const uint kEventAppTerminated = 6;
+ internal const uint kEventAppFrontSwitched = 7;
+ internal const uint kEventAppFocusMenuBar = 8;
+ internal const uint kEventAppFocusNextDocumentWindow = 9;
+ internal const uint kEventAppFocusNextFloatingWindow = 10;
+ internal const uint kEventAppFocusToolbar = 11;
+ internal const uint kEventAppFocusDrawer = 12;
+ internal const uint kEventAppGetDockTileMenu = 20;
+ internal const uint kEventAppIsEventInInstantMouser = 104;
+ internal const uint kEventAppHidden = 107;
+ internal const uint kEventAppShown = 108;
+ internal const uint kEventAppSystemUIModeChanged = 109;
+ internal const uint kEventAppAvailableWindowBoundsChanged = 110;
+ internal const uint kEventAppActiveWindowChanged = 111;
#endregion
#region kEventClassAppleEvent constants
new EventTypeSpec (OSXConstants.kEventClassKeyboard, OSXConstants.kEventRawKeyRepeat),
new EventTypeSpec (OSXConstants.kEventClassKeyboard, OSXConstants.kEventRawKeyUp)
};
+ private static EventTypeSpec [] application_events = new EventTypeSpec[] {
+ new EventTypeSpec (OSXConstants.kEventClassApplication, OSXConstants.kEventAppActivated),
+ new EventTypeSpec (OSXConstants.kEventClassApplication, OSXConstants.kEventAppDeactivated)
+ };
// Message loop
SetRect (ref rect, (short)0, (short)0, (short)0, (short)0);
ProcessSerialNumber psn = new ProcessSerialNumber();
- CheckError (GetCurrentProcess( ref psn ), "GetCurrentProcess ()");
- CheckError (TransformProcessType (ref psn, 1), "TransformProcessType ()");
- CheckError (SetFrontProcess (ref psn), "SetFrontProcess ()");
- CheckError (CreateNewWindow (WindowClass.kDocumentWindowClass, WindowAttributes.kWindowStandardHandlerAttribute | WindowAttributes.kWindowCloseBoxAttribute | WindowAttributes.kWindowFullZoomAttribute | WindowAttributes.kWindowCollapseBoxAttribute | WindowAttributes.kWindowResizableAttribute | WindowAttributes.kWindowCompositingAttribute, ref rect, ref FosterParent), "CreateFosterParent ()");
+ InstallEventHandler (GetApplicationEventTarget (), CarbonEventHandler, (uint)application_events.Length, application_events, IntPtr.Zero, IntPtr.Zero);
+ GetCurrentProcess( ref psn );
+ TransformProcessType (ref psn, 1);
+ SetFrontProcess (ref psn);
+
+ CreateNewWindow (WindowClass.kDocumentWindowClass, WindowAttributes.kWindowStandardHandlerAttribute | WindowAttributes.kWindowCloseBoxAttribute | WindowAttributes.kWindowFullZoomAttribute | WindowAttributes.kWindowCollapseBoxAttribute | WindowAttributes.kWindowResizableAttribute | WindowAttributes.kWindowCompositingAttribute, ref rect, ref FosterParent);
CreateNewWindow (WindowClass.kOverlayWindowClass, WindowAttributes.kWindowNoUpdatesAttribute | WindowAttributes.kWindowNoActivatesAttribute, ref rect, ref ReverseWindow);
InstallEventHandler (GetWindowEventTarget (ReverseWindow), CarbonEventHandler, (uint)window_events.Length, window_events, ReverseWindow, IntPtr.Zero);
+
// Get some values about bar heights
Rect structRect = new Rect ();
retVal = ProcessControlEvent (inEvent, eventKind, handle);
break;
}
+ // application
+ case OSXConstants.kEventClassApplication: {
+ retVal = ProcessApplicationEvent (inEvent, eventKind, handle);
+ break;
+ }
default: {
break;
}
return -9874;
}
+ private int ProcessApplicationEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
+ switch (eventKind) {
+ case OSXConstants.kEventAppDeactivated: {
+ if (FocusWindow != IntPtr.Zero) {
+ SendMessage(FocusWindow, Msg.WM_KILLFOCUS, IntPtr.Zero, IntPtr.Zero);
+ }
+ /* If we deactivate we need to send a MOUSEDOWN/MOUSEUP to kill overlay windows */
+ if (GrabWindowHwnd != null) {
+ SendMessage(GrabWindowHwnd.Handle, Msg.WM_LBUTTONDOWN, (IntPtr)MsgButtons.MK_LBUTTON, (IntPtr) (mouse_position.X << 16 | mouse_position.Y));
+ }
+ break;
+ }
+ }
+
+ return -9874;
+ }
+
private int ProcessMouseEvent (IntPtr inEvent, uint eventKind, IntPtr handle) {
MSG msg = new MSG ();
}
break;
}
- case Msg.WM_SETFOCUS: {
- break;
- }
-
}
return Keyboard.TranslateMessage (ref msg);
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int SetKeyboardFocus (IntPtr windowHdn, IntPtr cntrlHnd, short partcode);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern IntPtr GetApplicationEventTarget ();
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
internal static extern IntPtr GetWindowEventTarget (IntPtr window);
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]