diff --git a/examples/nx/nx_events.c b/examples/nx/nx_events.c index 4d2a3ee45..d23750782 100644 --- a/examples/nx/nx_events.c +++ b/examples/nx/nx_events.c @@ -97,14 +97,15 @@ static void nxeg_tbmousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos, const struct nx_callback_s g_nxcb = { - nxeg_redraw, /* redraw */ - nxeg_position /* position */ + nxeg_redraw, /* redraw */ + nxeg_position /* position */ #ifdef CONFIG_NX_XYINPUT - , nxeg_mousein /* mousein */ + , nxeg_mousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , nxeg_kbdin /* my kbdin */ + , nxeg_kbdin /* kbdin */ #endif + , NULL /* event */ }; #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS @@ -118,6 +119,7 @@ const struct nx_callback_s g_tbcb = #ifdef CONFIG_NX_KBD , nxeg_tbkbdin /* my kbdin */ #endif + , NULL /* event */ }; #endif diff --git a/examples/nxdemo/nxdemo_bkgd.c b/examples/nxdemo/nxdemo_bkgd.c index f0c0982be..6d357d9f0 100644 --- a/examples/nxdemo/nxdemo_bkgd.c +++ b/examples/nxdemo/nxdemo_bkgd.c @@ -122,16 +122,15 @@ static void nxdemo_demo_3(NXWINDOW hwnd); const struct nx_callback_s g_nxdemocb = { - nxdemo_redraw, /* redraw */ - nxdemo_position /* position */ + nxdemo_redraw, /* redraw */ + nxdemo_position /* position */ #ifdef CONFIG_NX_XYINPUT - , - nxdemo_mousein /* mousein */ + , nxdemo_mousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , - nxdemo_kbdin /* my kbdin */ + , nxdemo_kbdin /* kbdin */ #endif + , NULL /* event */ }; /**************************************************************************** diff --git a/examples/nxhello/nxhello_bkgd.c b/examples/nxhello/nxhello_bkgd.c index c77d237b9..dfd74887f 100644 --- a/examples/nxhello/nxhello_bkgd.c +++ b/examples/nxhello/nxhello_bkgd.c @@ -124,8 +124,9 @@ const struct nx_callback_s g_nxhellocb = , nxhello_mousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , nxhello_kbdin /* my kbdin */ + , nxhello_kbdin /* kbdin */ #endif + , NULL /* event */ }; /**************************************************************************** diff --git a/examples/nximage/nximage_bkgd.c b/examples/nximage/nximage_bkgd.c index be119d052..4b1ca7525 100644 --- a/examples/nximage/nximage_bkgd.c +++ b/examples/nximage/nximage_bkgd.c @@ -159,8 +159,9 @@ const struct nx_callback_s g_nximagecb = , nximage_mousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , nximage_kbdin /* my kbdin */ + , nximage_kbdin /* kbdin */ #endif + , NULL /* event */ }; /**************************************************************************** diff --git a/examples/nxlines/nxlines_bkgd.c b/examples/nxlines/nxlines_bkgd.c index dafbb49ea..c535bc1c5 100644 --- a/examples/nxlines/nxlines_bkgd.c +++ b/examples/nxlines/nxlines_bkgd.c @@ -112,8 +112,9 @@ const struct nx_callback_s g_nxlinescb = , nxlines_mousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , nxlines_kbdin /* my kbdin */ + , nxlines_kbdin /* kbdin */ #endif + , NULL /* event */ }; /**************************************************************************** diff --git a/examples/nxterm/nxterm_toolbar.c b/examples/nxterm/nxterm_toolbar.c index 0428ac1e4..fc592b41b 100644 --- a/examples/nxterm/nxterm_toolbar.c +++ b/examples/nxterm/nxterm_toolbar.c @@ -99,8 +99,9 @@ const struct nx_callback_s g_nxtoolcb = , nxtool_mousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , nxtool_kbdin /* my kbdin */ + , nxtool_kbdin /* kbdin */ #endif + , NULL /* event */ }; /**************************************************************************** diff --git a/examples/nxterm/nxterm_wndo.c b/examples/nxterm/nxterm_wndo.c index 9d0acfcd9..a8a006b8e 100644 --- a/examples/nxterm/nxterm_wndo.c +++ b/examples/nxterm/nxterm_wndo.c @@ -90,8 +90,9 @@ const struct nx_callback_s g_nxtermcb = , nxwndo_mousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , nxwndo_kbdin /* my kbdin */ + , nxwndo_kbdin /* kbdin */ #endif + , NULL /* event */ }; /**************************************************************************** diff --git a/examples/nxtext/nxtext_bkgd.c b/examples/nxtext/nxtext_bkgd.c index 78baded2f..040fdd0a5 100644 --- a/examples/nxtext/nxtext_bkgd.c +++ b/examples/nxtext/nxtext_bkgd.c @@ -103,8 +103,9 @@ const struct nx_callback_s g_nxtextcb = , nxbg_mousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , nxbg_kbdin /* my kbdin */ + , nxbg_kbdin /* kbdin */ #endif + , NULL /* event */ }; /* Background window handle */ diff --git a/examples/nxtext/nxtext_popup.c b/examples/nxtext/nxtext_popup.c index 0daccf42e..971cde0aa 100644 --- a/examples/nxtext/nxtext_popup.c +++ b/examples/nxtext/nxtext_popup.c @@ -97,8 +97,9 @@ static const struct nx_callback_s g_pucb = , nxpu_mousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , nxpu_kbdin /* my kbdin */ + , nxpu_kbdin /* kbdin */ #endif + , NULL /* event */ }; /* Pop-up state information */ diff --git a/examples/pwfb/pwfb_events.c b/examples/pwfb/pwfb_events.c index 602b08ea2..d7a02b7b6 100644 --- a/examples/pwfb/pwfb_events.c +++ b/examples/pwfb/pwfb_events.c @@ -84,6 +84,7 @@ const struct nx_callback_s g_pwfb_wncb = #ifdef CONFIG_NX_KBD , NULL /* kbdin */ #endif + , NULL /* event */ }; const struct nx_callback_s g_pwfb_tbcb = @@ -96,6 +97,7 @@ const struct nx_callback_s g_pwfb_tbcb = #ifdef CONFIG_NX_KBD , NULL /* kbdin */ #endif + , NULL /* event */ }; /**************************************************************************** diff --git a/examples/pwfb/pwfb_main.c b/examples/pwfb/pwfb_main.c index 2d13ee2b4..9859d9383 100644 --- a/examples/pwfb/pwfb_main.c +++ b/examples/pwfb/pwfb_main.c @@ -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 * to be synchronized at this point or the following fill will fail because * 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 diff --git a/examples/pwlines/pwlines_events.c b/examples/pwlines/pwlines_events.c index 932eae3ef..355799525 100644 --- a/examples/pwlines/pwlines_events.c +++ b/examples/pwlines/pwlines_events.c @@ -72,11 +72,12 @@ const struct nx_callback_s g_pwlines_wncb = pwlines_wndo_redraw, /* redraw */ pwlines_wndo_position /* position */ #ifdef CONFIG_NX_XYINPUT - , NULL /* mousein */ + , NULL /* mousein */ #endif #ifdef CONFIG_NX_KBD - , NULL /* kbdin */ + , NULL /* kbdin */ #endif + , NULL /* event */ }; /**************************************************************************** diff --git a/examples/pwlines/pwlines_main.c b/examples/pwlines/pwlines_main.c index fa498d5bb..a13c3e7cb 100644 --- a/examples/pwlines/pwlines_main.c +++ b/examples/pwlines/pwlines_main.c @@ -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 * to be synchronized at this point or the following fill will fail because * it depends on current knowlede of the size and position. + * REVISIT: Use nx_synch()! */ rect.pt1.x = 0; diff --git a/graphics/NxWidgets/nxwidgets/src/ccallback.cxx b/graphics/NxWidgets/nxwidgets/src/ccallback.cxx index f45b9ab0f..e7b69c344 100644 --- a/graphics/NxWidgets/nxwidgets/src/ccallback.cxx +++ b/graphics/NxWidgets/nxwidgets/src/ccallback.cxx @@ -83,7 +83,7 @@ CCallback::CCallback(CWidgetControl *widgetControl) #ifdef CONFIG_NX_KBD m_callbacks.kbdin = newKeyboardEvent; #endif - m_callbacks.blocked = windowBlocked; + m_callbacks.event = windowEvent; // 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 /** - * This callback is the response from nx_block (or nxtk_block). Those - * blocking interfaces are used to assure that no further messages are - * 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 is used to communicate server events to the window + * listener. * - * This callback supports coordinated destruction of a window in multi- - * user mode. In multi-use more, 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_BLOCKED - Window messages are blocked. + * + * This callback is the response from nx_block (or nxtk_block). Those + * blocking interfaces are used to assure that no further messages are + * 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 event. The server event * @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) */ -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 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); + } } diff --git a/graphics/traveler/src/trv_nxbkgd.c b/graphics/traveler/src/trv_nxbkgd.c index e0f34a512..22f248b3d 100644 --- a/graphics/traveler/src/trv_nxbkgd.c +++ b/graphics/traveler/src/trv_nxbkgd.c @@ -96,8 +96,9 @@ const struct nx_callback_s g_trv_nxcallback = , trv_nxmousein /* mousein */ #endif #ifdef CONFIG_NX_KBD - , trv_nxkbdin /* my kbdin */ + , trv_nxkbdin /* kbdin */ #endif + , NULL /* event */ }; /**************************************************************************** diff --git a/include/graphics/nxwidgets/ccallback.hxx b/include/graphics/nxwidgets/ccallback.hxx index 3b91dd262..fa44f5ce2 100644 --- a/include/graphics/nxwidgets/ccallback.hxx +++ b/include/graphics/nxwidgets/ccallback.hxx @@ -189,25 +189,43 @@ namespace NXWidgets #endif // CONFIG_NX_KBD /** - * This callback is the response from nx_block (or nxtk_block). Those - * blocking interfaces are used to assure that no further messages are - * 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 is used to communicate server events to the window + * listener. * - * This callback supports coordinated destruction of a window in multi- - * user mode. In multi-use 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_BLOCKED - Window messages are blocked. + * + * This callback is the response from nx_block (or nxtk_block). Those + * blocking interfaces are used to assure that no further messages are + * 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 event. The server event * @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) */ - 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: