exmamples/, graphics/NxWidgets: Update NX window clients so that they use the new 'event' callback (vs. the obsoluted 'blocked' callback).

This commit is contained in:
Gregory Nutt 2019-03-25 13:01:52 -06:00
parent fab0ac6e82
commit 11b6bc9447
16 changed files with 101 additions and 46 deletions

View File

@ -97,14 +97,15 @@ static void nxeg_tbmousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
const struct nx_callback_s g_nxcb = const struct nx_callback_s g_nxcb =
{ {
nxeg_redraw, /* redraw */ nxeg_redraw, /* redraw */
nxeg_position /* position */ nxeg_position /* position */
#ifdef CONFIG_NX_XYINPUT #ifdef CONFIG_NX_XYINPUT
, nxeg_mousein /* mousein */ , nxeg_mousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, nxeg_kbdin /* my kbdin */ , nxeg_kbdin /* kbdin */
#endif #endif
, NULL /* event */
}; };
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
@ -118,6 +119,7 @@ const struct nx_callback_s g_tbcb =
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, nxeg_tbkbdin /* my kbdin */ , nxeg_tbkbdin /* my kbdin */
#endif #endif
, NULL /* event */
}; };
#endif #endif

View File

@ -122,16 +122,15 @@ static void nxdemo_demo_3(NXWINDOW hwnd);
const struct nx_callback_s g_nxdemocb = const struct nx_callback_s g_nxdemocb =
{ {
nxdemo_redraw, /* redraw */ nxdemo_redraw, /* redraw */
nxdemo_position /* position */ nxdemo_position /* position */
#ifdef CONFIG_NX_XYINPUT #ifdef CONFIG_NX_XYINPUT
, , nxdemo_mousein /* mousein */
nxdemo_mousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, , nxdemo_kbdin /* kbdin */
nxdemo_kbdin /* my kbdin */
#endif #endif
, NULL /* event */
}; };
/**************************************************************************** /****************************************************************************

View File

@ -124,8 +124,9 @@ const struct nx_callback_s g_nxhellocb =
, nxhello_mousein /* mousein */ , nxhello_mousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, nxhello_kbdin /* my kbdin */ , nxhello_kbdin /* kbdin */
#endif #endif
, NULL /* event */
}; };
/**************************************************************************** /****************************************************************************

View File

@ -159,8 +159,9 @@ const struct nx_callback_s g_nximagecb =
, nximage_mousein /* mousein */ , nximage_mousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, nximage_kbdin /* my kbdin */ , nximage_kbdin /* kbdin */
#endif #endif
, NULL /* event */
}; };
/**************************************************************************** /****************************************************************************

View File

@ -112,8 +112,9 @@ const struct nx_callback_s g_nxlinescb =
, nxlines_mousein /* mousein */ , nxlines_mousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, nxlines_kbdin /* my kbdin */ , nxlines_kbdin /* kbdin */
#endif #endif
, NULL /* event */
}; };
/**************************************************************************** /****************************************************************************

View File

@ -99,8 +99,9 @@ const struct nx_callback_s g_nxtoolcb =
, nxtool_mousein /* mousein */ , nxtool_mousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, nxtool_kbdin /* my kbdin */ , nxtool_kbdin /* kbdin */
#endif #endif
, NULL /* event */
}; };
/**************************************************************************** /****************************************************************************

View File

@ -90,8 +90,9 @@ const struct nx_callback_s g_nxtermcb =
, nxwndo_mousein /* mousein */ , nxwndo_mousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, nxwndo_kbdin /* my kbdin */ , nxwndo_kbdin /* kbdin */
#endif #endif
, NULL /* event */
}; };
/**************************************************************************** /****************************************************************************

View File

@ -103,8 +103,9 @@ const struct nx_callback_s g_nxtextcb =
, nxbg_mousein /* mousein */ , nxbg_mousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, nxbg_kbdin /* my kbdin */ , nxbg_kbdin /* kbdin */
#endif #endif
, NULL /* event */
}; };
/* Background window handle */ /* Background window handle */

View File

@ -97,8 +97,9 @@ static const struct nx_callback_s g_pucb =
, nxpu_mousein /* mousein */ , nxpu_mousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, nxpu_kbdin /* my kbdin */ , nxpu_kbdin /* kbdin */
#endif #endif
, NULL /* event */
}; };
/* Pop-up state information */ /* Pop-up state information */

View File

@ -84,6 +84,7 @@ const struct nx_callback_s g_pwfb_wncb =
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, NULL /* kbdin */ , NULL /* kbdin */
#endif #endif
, NULL /* event */
}; };
const struct nx_callback_s g_pwfb_tbcb = const struct nx_callback_s g_pwfb_tbcb =
@ -96,6 +97,7 @@ const struct nx_callback_s g_pwfb_tbcb =
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, NULL /* kbdin */ , NULL /* kbdin */
#endif #endif
, NULL /* event */
}; };
/**************************************************************************** /****************************************************************************

View File

@ -412,6 +412,7 @@ static bool pwfb_configure_window(FAR struct pwfb_state_s *st, int wndx,
* a command is sent to server which responds with an event. So we need * a command is sent to server which responds with an event. So we need
* to be synchronized at this point or the following fill will fail because * to be synchronized at this point or the following fill will fail because
* it depends on current knowlede of the size and position. * it depends on current knowlede of the size and position.
* REVISIT: Use nx_synch()!
*/ */
/* Create a bounding box. This is actually too large because it does not /* Create a bounding box. This is actually too large because it does not

View File

@ -72,11 +72,12 @@ const struct nx_callback_s g_pwlines_wncb =
pwlines_wndo_redraw, /* redraw */ pwlines_wndo_redraw, /* redraw */
pwlines_wndo_position /* position */ pwlines_wndo_position /* position */
#ifdef CONFIG_NX_XYINPUT #ifdef CONFIG_NX_XYINPUT
, NULL /* mousein */ , NULL /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, NULL /* kbdin */ , NULL /* kbdin */
#endif #endif
, NULL /* event */
}; };
/**************************************************************************** /****************************************************************************

View File

@ -254,6 +254,7 @@ static bool pwlines_configure_window(FAR struct pwlines_state_s *st, int wndx,
* a command is sent to server which responds with an event. So we need * a command is sent to server which responds with an event. So we need
* to be synchronized at this point or the following fill will fail because * to be synchronized at this point or the following fill will fail because
* it depends on current knowlede of the size and position. * it depends on current knowlede of the size and position.
* REVISIT: Use nx_synch()!
*/ */
rect.pt1.x = 0; rect.pt1.x = 0;

View File

@ -83,7 +83,7 @@ CCallback::CCallback(CWidgetControl *widgetControl)
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
m_callbacks.kbdin = newKeyboardEvent; m_callbacks.kbdin = newKeyboardEvent;
#endif #endif
m_callbacks.blocked = windowBlocked; m_callbacks.event = windowEvent;
// Keyboard input is initially direct to the widgets within the window // Keyboard input is initially direct to the widgets within the window
@ -234,34 +234,57 @@ void CCallback::newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
#endif // CONFIG_NX_KBD #endif // CONFIG_NX_KBD
/** /**
* This callback is the response from nx_block (or nxtk_block). Those * This callback is used to communicate server events to the window
* blocking interfaces are used to assure that no further messages are * listener.
* directed to the window. Receipt of the blocked callback signifies
* that (1) there are no further pending callbacks and (2) that the
* window is now 'defunct' and will receive no further callbacks.
* *
* This callback supports coordinated destruction of a window in multi- * NXEVENT_BLOCKED - Window messages are blocked.
* user mode. In multi-use more, the client window logic must stay *
* intact until all of the queued callbacks are processed. Then the * This callback is the response from nx_block (or nxtk_block). Those
* window may be safely closed. Closing the window prior with pending * blocking interfaces are used to assure that no further messages are
* callbacks can lead to bad behavior when the callback is executed. * directed to the window. Receipt of the blocked callback signifies
* that (1) there are no further pending callbacks and (2) that the
* window is now 'defunct' and will receive no further callbacks.
*
* This callback supports coordinated destruction of a window. In
* the multi-user mode, the client window logic must stay intact until
* all of the queued callbacks are processed. Then the window may be
* safely closed. Closing the window prior with pending callbacks can
* lead to bad behavior when the callback is executed.
*
* NXEVENT_SYCNCHED - Synchronization handshake
*
* This completes the handshake started by nx_synch(). nx_synch()
* sends a syncrhonization messages to the NX server which responds
* with this event. The sleeping client is awakened and continues
* graphics processing, completing the handshake.
*
* Due to the highly asynchronous nature of client-server
* communications, nx_synch() is sometimes necessary to assure that
* the client and server are fully synchronized.
* *
* @param hwnd. Window handle of the blocked window * @param hwnd. Window handle of the blocked window
* @param event. The server event
* @param arg1. User provided argument (see nx_openwindow, nx_requestbkgd, * @param arg1. User provided argument (see nx_openwindow, nx_requestbkgd,
* nxtk_openwindow, or nxtk_opentoolbar) * nxtk_openwindow, or nxtk_opentoolbar)
* @param arg2 - User provided argument (see nx_block or nxtk_block) * @param arg2 - User provided argument (see nx_block or nxtk_block)
*/ */
void CCallback::windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2) void CCallback::windowEvent(NXWINDOW hwnd, enum nx_event_e event,
FAR void *arg1, FAR void *arg2)
{ {
ginfo("hwnd=%p arg1=%p arg2=%p\n", hwnd, arg1, arg2); ginfo("hwnd=%p devent=%d arg1=%p arg2=%p\n", hwnd, event, arg1, arg2);
// The first argument must be the CCallback instance // The first argument must be the CCallback instance
CCallback *This = (CCallback *)arg1; CCallback *This = (CCallback *)arg1;
// Just forward the callback to the CWidgetControl::windowBlocked method // Check for the window blocked event
This->m_widgetControl->windowBlocked(arg2); if (event == NXEVENT_BLOCKED)
{
// Let the CWidgetControl::windowBlocked method handle the event.
This->m_widgetControl->windowBlocked(arg2);
}
} }

View File

@ -96,8 +96,9 @@ const struct nx_callback_s g_trv_nxcallback =
, trv_nxmousein /* mousein */ , trv_nxmousein /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, trv_nxkbdin /* my kbdin */ , trv_nxkbdin /* kbdin */
#endif #endif
, NULL /* event */
}; };
/**************************************************************************** /****************************************************************************

View File

@ -189,25 +189,43 @@ namespace NXWidgets
#endif // CONFIG_NX_KBD #endif // CONFIG_NX_KBD
/** /**
* This callback is the response from nx_block (or nxtk_block). Those * This callback is used to communicate server events to the window
* blocking interfaces are used to assure that no further messages are * listener.
* directed to the window. Receipt of the blocked callback signifies
* that (1) there are no further pending callbacks and (2) that the
* window is now 'defunct' and will receive no further callbacks.
* *
* This callback supports coordinated destruction of a window in multi- * NXEVENT_BLOCKED - Window messages are blocked.
* user mode. In multi-use mode, the client window logic must stay *
* intact until all of the queued callbacks are processed. Then the * This callback is the response from nx_block (or nxtk_block). Those
* window may be safely closed. Closing the window prior with pending * blocking interfaces are used to assure that no further messages are
* callbacks can lead to bad behavior when the callback is executed. * directed to the window. Receipt of the blocked callback signifies
* that (1) there are no further pending callbacks and (2) that the
* window is now 'defunct' and will receive no further callbacks.
*
* This callback supports coordinated destruction of a window. In
* the multi-user mode, the client window logic must stay intact until
* all of the queued callbacks are processed. Then the window may be
* safely closed. Closing the window prior with pending callbacks can
* lead to bad behavior when the callback is executed.
*
* NXEVENT_SYCNCHED - Synchronization handshake
*
* This completes the handshake started by nx_synch(). nx_synch()
* sends a syncrhonization messages to the NX server which responds
* with this event. The sleeping client is awakened and continues
* graphics processing, completing the handshake.
*
* Due to the highly asynchronous nature of client-server
* communications, nx_synch() is sometimes necessary to assure that
* the client and server are fully synchronized.
* *
* @param hwnd. Window handle of the blocked window * @param hwnd. Window handle of the blocked window
* @param event. The server event
* @param arg1. User provided argument (see nx_openwindow, nx_requestbkgd, * @param arg1. User provided argument (see nx_openwindow, nx_requestbkgd,
* nxtk_openwindow, or nxtk_opentoolbar) * nxtk_openwindow, or nxtk_opentoolbar)
* @param arg2 - User provided argument (see nx_block or nxtk_block) * @param arg2 - User provided argument (see nx_block or nxtk_block)
*/ */
static void windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2); static void windowEvent(NXWINDOW hwnd, enum nx_event_e event,
FAR void *arg1, FAR void *arg2);
public: public: