UICocoaApplication.mm revision a729d7d3b19e5c02a395915b050741a31b826e7c
/* $Id$ */
/** @file
* UICocoaApplication - C++ interface to NSApplication for handling -sendEvent.
*/
/*
* Copyright (C) 2009-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/* GUI includes: */
#include "UICocoaApplication.h"
#include "VBoxUtils-darwin.h"
/* Global includes */
#import <AppKit/NSEvent.h>
#import <AppKit/NSApplication.h>
#import <Foundation/NSArray.h>
#import <AppKit/NSWindow.h>
/** Class for tracking a callback. */
@interface CallbackData: NSObject
{
@public
/** Mask of events to send to this callback. */
/** The callback. */
/** The user argument. */
void *pvUser;
}
@end /* @interface CallbackData */
{
if (self)
{
}
return self;
}
@end /* @implementation CallbackData */
/** Class for event handling */
@interface UICocoaApplicationPrivate: NSApplication
{
/** The event mask for which there currently are callbacks. */
/** Array of callbacks. */
}
@end /* @interface UICocoaApplicationPrivate */
{
if (self)
return self;
}
{
/*
* Check if the type matches any of the registered callbacks.
*/
#if 0 /* for debugging */
if (fMask != 0)
{
{
/*
* Do the callouts in LIFO order.
*/
{
{
return;
}
}
}
}
/*
* Get on with it.
*/
}
/**
* Register an event callback.
*
* @param fMask The event mask for which the callback is to be invoked.
* @param pfnCallback The callback function.
* @param pvUser The user argument.
*/
{
/* Add the callback data to the array */
CallbackData *pData = [[[CallbackData alloc] initWithMask: fMask callback: pfnCallback user: pvUser] autorelease];
/* Update the global mask */
}
/**
* Deregister an event callback.
*
* @param fMask Same as setCallback.
* @param pfnCallback Same as setCallback.
* @param pvUser Same as setCallback.
*/
{
/*
* Loop the event array LIFO fashion searching for a matching callback.
*/
{
{
break;
}
}
}
/** Register @a pWindow to cocoa notification @a pstrNotificationName. */
{
/* Register notification observer: */
}
/** Unregister @a pWindow from cocoa notification @a pstrNotificationName. */
{
/* Uninstall notification observer: */
}
/** Redirects cocoa @a notification to UICocoaApplication instance. */
{
/* Get current notification name: */
/* Define known notification names: */
NSString *spstrDidFailToEnterFullScreenNotification = @"NSWindowDidFailToEnterFullScreenNotification";
/* Redirect known notifications to UICocoaApplication instance: */
}
@end /* @implementation UICocoaApplicationPrivate */
/* C++ singleton for our private NSApplication object */
/* static */
{
if (!m_pInstance)
m_pInstance = new UICocoaApplication();
return m_pInstance;
}
void UICocoaApplication::hide()
{
}
{
/* Make sure our private NSApplication object is created */
/* Create one auto release pool which is in place for all the
initialization and deinitialization stuff. That is when the
NSApplication is not running the run loop (there is a separate auto
release pool defined). */
}
{
}
void UICocoaApplication::registerForNativeEvents(uint32_t fMask, PFNVBOXCACALLBACK pfnCallback, void *pvUser)
{
}
void UICocoaApplication::unregisterForNativeEvents(uint32_t fMask, PFNVBOXCACALLBACK pfnCallback, void *pvUser)
{
}
void UICocoaApplication::registerToNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget, PfnNativeNotificationCallbackForQWidget pCallback)
{
/* Make sure it is not registered yet: */
AssertReturnVoid(!m_callbacks.contains(pWidget) || !m_callbacks[pWidget].contains(strNativeNotificationName));
/* Remember callback: */
/* Register observer: */
NativeNSStringRef pstrNativeNotificationName = darwinToNativeString(strNativeNotificationName.toLatin1().constData());
}
void UICocoaApplication::unregisterFromNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget)
{
/* Make sure it is registered yet: */
AssertReturnVoid(m_callbacks.contains(pWidget) && m_callbacks[pWidget].contains(strNativeNotificationName));
/* Forget callback: */
/* Unregister observer: */
NativeNSStringRef pstrNativeNotificationName = darwinToNativeString(strNativeNotificationName.toLatin1().constData());
}
void UICocoaApplication::nativeNotificationProxy(NativeNSStringRef pstrNotificationName, NativeNSWindowRef pWindow)
{
/* Get notification name: */
/* Check if existing widget(s) have corresponding notification handler: */
{
{
}
}
}