NxWM: Add a missing part of the message blocking logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4748 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
ad63005d6a
commit
c6c67e8987
@ -195,12 +195,13 @@ namespace NXWidgets
|
||||
* callbacks can lead to bad behavior when the callback is executed.
|
||||
*
|
||||
* @param hwnd. Window handle of the blocked window
|
||||
* @param arg. User provided argument (see nx_openwindow, nx_requestbkgd,
|
||||
* @param arg1. User provided argument (see nx_openwindow, nx_requestbkgd,
|
||||
* nxtk_openwindow, or nxtk_opentoolbar)
|
||||
* @param arg2 - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
static void windowBlocked(NXWINDOW hwnd, FAR void *arg);
|
||||
static void windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
@ -609,15 +609,13 @@ namespace NXWidgets
|
||||
* window may be safely closed. Closing the window prior with pending
|
||||
* callbacks can lead to bad behavior when the callback is executed.
|
||||
*
|
||||
* @param hwnd. Window handle of the blocked window
|
||||
* @param arg. User provided argument (see nx_openwindow, nx_requestbkgd,
|
||||
* nxtk_openwindow, or nxtk_opentoolbar)
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
inline void windowBlocked(void)
|
||||
inline void windowBlocked(FAR void *arg)
|
||||
{
|
||||
m_eventHandlers.raiseBlockedEvent();
|
||||
m_eventHandlers.raiseBlockedEvent(arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -108,9 +108,11 @@ namespace NXWidgets
|
||||
|
||||
/**
|
||||
* Handle a NX window blocked event
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
virtual void handleBlockedEvent(void) { }
|
||||
virtual void handleBlockedEvent(FAR void *arg) { }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -163,9 +163,11 @@ namespace NXWidgets
|
||||
|
||||
/**
|
||||
* Raise an NX window blocked event.
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
void raiseBlockedEvent(void);
|
||||
void raiseBlockedEvent(FAR void *arg);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -211,22 +211,23 @@ void CCallback::newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
|
||||
* callbacks can lead to bad behavior when the callback is executed.
|
||||
*
|
||||
* @param hwnd. Window handle of the blocked window
|
||||
* @param arg. User provided argument (see nx_openwindow, nx_requestbkgd,
|
||||
* @param arg1. User provided argument (see nx_openwindow, nx_requestbkgd,
|
||||
* nxtk_openwindow, or nxtk_opentoolbar)
|
||||
* @param arg2 - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
void CCallback::windowBlocked(NXWINDOW hwnd, FAR void *arg)
|
||||
void CCallback::windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2)
|
||||
{
|
||||
gvdbg("hwnd=%p arg=%p\n", hwnd, arg);
|
||||
gvdbg("hwnd=%p arg1=%p arg2=%p\n", hwnd, arg1, arg2);
|
||||
|
||||
// The argument must be the CWidgetControl instance
|
||||
// The first argument must be the CWidgetControl instance
|
||||
|
||||
CWidgetControl *This = (CWidgetControl *)arg;
|
||||
CWidgetControl *This = (CWidgetControl *)arg1;
|
||||
|
||||
// Just forward the callback to the CWidgetControl::windowBlocked method
|
||||
|
||||
This->windowBlocked();
|
||||
This->windowBlocked(arg2);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -162,12 +162,14 @@ void CWindowEventHandlerList::raiseKeyboardEvent(void)
|
||||
|
||||
/**
|
||||
* Raise an NX window blocked event.
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
void CWindowEventHandlerList::raiseBlockedEvent(void)
|
||||
void CWindowEventHandlerList::raiseBlockedEvent(FAR void *arg)
|
||||
{
|
||||
for (int i = 0; i < m_eventHandlers.size(); ++i)
|
||||
{
|
||||
m_eventHandlers.at(i)->handleBlockedEvent();
|
||||
m_eventHandlers.at(i)->handleBlockedEvent(arg);
|
||||
}
|
||||
}
|
||||
|
@ -162,9 +162,11 @@ namespace NxWM
|
||||
/**
|
||||
* Block further activity on this window in preparation for window
|
||||
* shutdown.
|
||||
*
|
||||
* @param app. The application to be blocked
|
||||
*/
|
||||
|
||||
void block(void);
|
||||
void block(IApplication *app);
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
|
@ -126,9 +126,11 @@ namespace NxWM
|
||||
/**
|
||||
* Block further activity on this window in preparation for window
|
||||
* shutdown.
|
||||
*
|
||||
* @param app. The application to be blocked
|
||||
*/
|
||||
|
||||
void block(void);
|
||||
void block(IApplication *app);
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
|
@ -98,6 +98,14 @@ namespace NxWM
|
||||
void handleKeyboardEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a NX window blocked event
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
void handleBlockedEvent(FAR void *arg);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -111,16 +119,6 @@ namespace NxWM
|
||||
*/
|
||||
|
||||
~CWindowMessenger(void);
|
||||
|
||||
/**
|
||||
* Destroy the application window and everything in it. This is
|
||||
* handled by CWindowMessenger (vs just calling the destructors) because
|
||||
* in the case where an application destroys itself (because of pressing
|
||||
* the stop button), then we need to unwind and get out of the application
|
||||
* logic before destroying all of its objects.
|
||||
*/
|
||||
|
||||
void destroy(IApplication *app);
|
||||
};
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
@ -45,8 +45,6 @@
|
||||
#include "cnxstring.hxx"
|
||||
#include "ibitmap.hxx"
|
||||
|
||||
#include "iapplicationwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
@ -59,6 +57,12 @@
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* Foward references
|
||||
*/
|
||||
|
||||
class IApplicationWindow;
|
||||
|
||||
/**
|
||||
* IApplication provides the abstract base class for each NxWM application.
|
||||
*/
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "cnxstring.hxx"
|
||||
#include "cwidgetcontrol.hxx"
|
||||
|
||||
#include "iapplication.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
@ -58,6 +60,12 @@
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* Foward references
|
||||
*/
|
||||
|
||||
class IApplication;
|
||||
|
||||
/**
|
||||
* This callback class is used by the application to get notification of toolbar
|
||||
* related events.
|
||||
@ -137,9 +145,11 @@ namespace NxWM
|
||||
/**
|
||||
* Block further activity on this window in preparation for window
|
||||
* shutdown.
|
||||
*
|
||||
* @param app. The application to be blocked
|
||||
*/
|
||||
|
||||
virtual void block(void) = 0;
|
||||
virtual void block(IApplication *app) = 0;
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
|
@ -426,9 +426,11 @@ NXWidgets::CWidgetControl *CApplicationWindow::getWidgetControl(void) const
|
||||
/**
|
||||
* Block further activity on this window in preparation for window
|
||||
* shutdown.
|
||||
*
|
||||
* @param app. The application to be blocked
|
||||
*/
|
||||
|
||||
void CApplicationWindow::block(void)
|
||||
void CApplicationWindow::block(IApplication *app)
|
||||
{
|
||||
// Get the widget control from the NXWidgets::CNxWindow instance
|
||||
|
||||
@ -437,7 +439,7 @@ void CApplicationWindow::block(void)
|
||||
// And then block further reporting activity on the underlying
|
||||
// NX framed window
|
||||
|
||||
nxtk_block(control->getWindowHandle());
|
||||
nxtk_block(control->getWindowHandle(), (FAR void *)app);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,13 +220,13 @@ void CCalibration::stop(void)
|
||||
|
||||
void CCalibration::destroy(void)
|
||||
{
|
||||
// Block any further window messages
|
||||
|
||||
m_window->block();
|
||||
|
||||
// Make sure that the application is stopped
|
||||
// Make sure that the application is stopped (should already be stopped)
|
||||
|
||||
stop();
|
||||
|
||||
// Block any further window messages
|
||||
|
||||
m_window->block(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,9 +141,11 @@ NXWidgets::CWidgetControl *CFullScreenWindow::getWidgetControl(void) const
|
||||
/**
|
||||
* Block further activity on this window in preparation for window
|
||||
* shutdown.
|
||||
*
|
||||
* @param app. The application to be blocked
|
||||
*/
|
||||
|
||||
void CFullScreenWindow::block(void)
|
||||
void CFullScreenWindow::block(IApplication *app)
|
||||
{
|
||||
// Get the widget control from the NXWidgets::CNxWindow instance
|
||||
|
||||
@ -152,7 +154,7 @@ void CFullScreenWindow::block(void)
|
||||
// And then block further reporting activity on the underlying
|
||||
// NX raw window
|
||||
|
||||
nx_block(control->getWindowHandle());
|
||||
nx_block(control->getWindowHandle(), (FAR void *)app);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -341,7 +341,7 @@ void CNxConsole::destroy(void)
|
||||
{
|
||||
// Block any further window messages
|
||||
|
||||
m_window->block();
|
||||
m_window->block(this);
|
||||
|
||||
// Make sure that the application is stopped
|
||||
|
||||
|
@ -234,7 +234,7 @@ void CStartWindow::destroy(void)
|
||||
|
||||
// Block any further window messages
|
||||
|
||||
m_window->block();
|
||||
m_window->block(this);
|
||||
|
||||
// Make sure that the application is stopped
|
||||
|
||||
|
@ -90,31 +90,6 @@ CWindowMessenger::~CWindowMessenger(void)
|
||||
(void)mq_close(m_mqd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the application window and everything in it. This is
|
||||
* handled by CWindowMessenger (vs just calling the destructors) because
|
||||
* in the case where an application destroys itself (because of pressing
|
||||
* the stop button), then we need to unwind and get out of the application
|
||||
* logic before destroying all of its objects.
|
||||
*/
|
||||
|
||||
void CWindowMessenger::destroy(IApplication *app)
|
||||
{
|
||||
// Send a message to destroy the window isntance at a later time
|
||||
|
||||
struct SStartWindowMessage outmsg;
|
||||
outmsg.msgId = MSGID_DESTROY_APP;
|
||||
outmsg.instance = (FAR void *)app;
|
||||
|
||||
gdbg("Sending MSGID_DESTROY_APP with instance=%p\n", app);
|
||||
int ret = mq_send(m_mqd, &outmsg, sizeof(struct SStartWindowMessage),
|
||||
CONFIG_NXWM_STARTWINDOW_MXMPRIO);
|
||||
if (ret < 0)
|
||||
{
|
||||
gdbg("ERROR: mq_send failed: %d\n", errno);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an NX window mouse input event.
|
||||
*
|
||||
@ -208,3 +183,35 @@ void CWindowMessenger::handleKeyboardEvent(void)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a NX window blocked event. This handler is called when we
|
||||
* receive the BLOCKED message meaning that there are no further pending
|
||||
* actions on the window. It is now safe to delete the window.
|
||||
*
|
||||
* This is handled by sending a message to the start window thread (vs just
|
||||
* calling the destructors) because in the case where an application
|
||||
* destroys itself (because of pressing the stop button), then we need to
|
||||
* unwind and get out of the application logic before destroying all of its
|
||||
* objects.
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
void CWindowMessenger::handleBlockedEvent(FAR void *arg)
|
||||
{
|
||||
// Send a message to destroy the window isntance at a later time
|
||||
|
||||
struct SStartWindowMessage outmsg;
|
||||
outmsg.msgId = MSGID_DESTROY_APP;
|
||||
outmsg.instance = arg;
|
||||
|
||||
gdbg("Sending MSGID_DESTROY_APP with instance=%p\n", arg);
|
||||
int ret = mq_send(m_mqd, &outmsg, sizeof(struct SStartWindowMessage),
|
||||
CONFIG_NXWM_STARTWINDOW_MXMPRIO);
|
||||
if (ret < 0)
|
||||
{
|
||||
gdbg("ERROR: mq_send failed: %d\n", errno);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user