mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-08 05:57:19 +00:00
apps/graphics/twm4nx: Correct design of input event logic. Still getting a hardfault.
This commit is contained in:
parent
358f32bfdc
commit
2fff83d60d
15 changed files with 131 additions and 146 deletions
|
|
@ -85,7 +85,7 @@ namespace NXWidgets
|
|||
{
|
||||
protected:
|
||||
NXHANDLE m_hNxServer; /**< Handle to the NX server. */
|
||||
NXTKWINDOW m_hNxTkWindow; /**< Handle to the NX raw window */
|
||||
NXTKWINDOW m_hNxTkWindow; /**< Handle to the NxTk window */
|
||||
CWidgetControl *m_widgetControl; /**< Controlling widget for the window */
|
||||
CNxToolbar *m_toolbar; /**< Child toolbar */
|
||||
nxgl_coord_t m_toolbarHeight; /**< The height of the toolbar */
|
||||
|
|
|
|||
|
|
@ -298,11 +298,11 @@ namespace NXWidgets
|
|||
|
||||
bool pollCursorControlEvents(void);
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
/**
|
||||
* Wake up and external logic that is waiting for a window event.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
void postWindowEvent(void);
|
||||
#endif
|
||||
|
||||
|
|
@ -382,6 +382,7 @@ namespace NXWidgets
|
|||
|
||||
virtual ~CWidgetControl(void);
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
/**
|
||||
* Wait for an interesting window event to occur (like a mouse or keyboard event)
|
||||
* Caller's should exercise care to assure that the test for waiting and this
|
||||
|
|
@ -396,17 +397,16 @@ namespace NXWidgets
|
|||
* sched_unlock();
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
void waitForWindowEvent(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
/**
|
||||
* Is external logic awaiting for a window event?
|
||||
*
|
||||
* @return True if the widget if external logic is waiting.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
inline const bool isWaiting(void) const
|
||||
{
|
||||
return m_waiting;
|
||||
|
|
@ -619,6 +619,7 @@ namespace NXWidgets
|
|||
|
||||
void newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t buttons);
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
/**
|
||||
* This event means that keyboard/keypad data is available for the window.
|
||||
*
|
||||
|
|
@ -626,7 +627,6 @@ namespace NXWidgets
|
|||
* @param pStr The array of characters.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void newKeyboardEvent(uint8_t nCh, FAR const uint8_t *pStr);
|
||||
#endif
|
||||
|
||||
|
|
@ -824,3 +824,4 @@ namespace NXWidgets
|
|||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETCONTROLT_HXX
|
||||
|
||||
|
|
|
|||
|
|
@ -148,19 +148,19 @@ namespace NXWidgets
|
|||
|
||||
void raiseGeometryEvent(void);
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
/**
|
||||
* Raise an NX mouse window input event.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
void raiseMouseEvent(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
/**
|
||||
* Raise an NX keybord input event
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void raiseKeyboardEvent(void);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ namespace Twm4Nx
|
|||
private:
|
||||
FAR CTwm4Nx *m_twm4nx; /**< Cached instance of CTwm4Nx */
|
||||
mqd_t m_eventq; /**< NxWidget event message queue */
|
||||
FAR void *m_object; /**< Window object (context specific) */
|
||||
bool m_isBackground; /**< True if this serves the background window */
|
||||
|
||||
/**
|
||||
|
|
@ -86,14 +87,14 @@ namespace Twm4Nx
|
|||
|
||||
// Override CWidgetEventHandler virtual methods ///////////////////////
|
||||
|
||||
/**
|
||||
* Handle a NX window redraw request event
|
||||
*
|
||||
* @param nxRect The region in the window to be redrawn
|
||||
* @param more More redraw requests will follow
|
||||
*/
|
||||
/**
|
||||
* Handle a NX window redraw request event
|
||||
*
|
||||
* @param nxRect The region in the window to be redrawn
|
||||
* @param more More redraw requests will follow
|
||||
*/
|
||||
|
||||
void handleRedrawEvent(FAR const nxgl_rect_s *nxRect, bool more);
|
||||
void handleRedrawEvent(FAR const nxgl_rect_s *nxRect, bool more);
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
/**
|
||||
|
|
@ -115,7 +116,7 @@ namespace Twm4Nx
|
|||
* Handle a NX window blocked event
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
*/
|
||||
|
||||
void handleBlockedEvent(FAR void *arg);
|
||||
|
||||
|
|
@ -124,14 +125,16 @@ namespace Twm4Nx
|
|||
/**
|
||||
* CWindowEvent Constructor
|
||||
*
|
||||
* @param twm4nx. The Twm4Nx session instance.
|
||||
* @param isBackground. True is this for the background window.
|
||||
* @param twm4nx The Twm4Nx session instance.
|
||||
* @param obj Contextual object (Usually 'this' of instantiator)
|
||||
* @param isBackground True is this for the background window.
|
||||
* @param style The default style that all widgets on this display
|
||||
* should use. If this is not specified, the widget will use the
|
||||
* values stored in the defaultCWidgetStyle object.
|
||||
*/
|
||||
|
||||
CWindowEvent(FAR CTwm4Nx *twm4nx, bool isBackground = false,
|
||||
CWindowEvent(FAR CTwm4Nx *twm4nx, FAR void *obj,
|
||||
bool isBackground = false,
|
||||
FAR const NXWidgets::CWidgetStyle *style =
|
||||
(const NXWidgets::CWidgetStyle *)NULL);
|
||||
|
||||
|
|
@ -140,16 +143,6 @@ namespace Twm4Nx
|
|||
*/
|
||||
|
||||
~CWindowEvent(void);
|
||||
|
||||
/**
|
||||
* Handle MSG events.
|
||||
*
|
||||
* @param msg. The received system MSG event message.
|
||||
* @return True if the message was properly handled. false is
|
||||
* return on any failure.
|
||||
*/
|
||||
|
||||
static bool event(FAR struct SEventMsg *msg);
|
||||
};
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace Twm4Nx
|
|||
{
|
||||
class CWindow; // Forward reference
|
||||
class CWindowEvent; // Forward reference
|
||||
class CTwm4NxEvent; // Forward reference
|
||||
class CTwm4NxEvent; // Forward reference
|
||||
class CTwm4Nx; // Forward reference
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -82,17 +82,16 @@ namespace Twm4Nx
|
|||
|
||||
enum EEventRecipient
|
||||
{
|
||||
EVENT_RECIPIENT_MSG = 0x0000, /**< Twm4Nx messenging event */
|
||||
EVENT_RECIPIENT_SYSTEM = 0x1000, /**< Twm4Nx system event */
|
||||
EVENT_RECIPIENT_BACKGROUND = 0x2000, /**< Background window event */
|
||||
EVENT_RECIPIENT_ICONWIDGET = 0x3000, /**< Icon Widget event */
|
||||
EVENT_RECIPIENT_ICONMGR = 0x4000, /**< Icon Manager event */
|
||||
EVENT_RECIPIENT_MENU = 0x5000, /**< Menu related event */
|
||||
EVENT_RECIPIENT_WINDOW = 0x6000, /**< Window related event */
|
||||
EVENT_RECIPIENT_TOOLBAR = 0x7000, /**< Toolbar related event */
|
||||
EVENT_RECIPIENT_BORDER = 0x8000, /**< Window border related event */
|
||||
EVENT_RECIPIENT_RESIZE = 0x9000, /**< Window resize event */
|
||||
EVENT_RECIPIENT_APP = 0xa000, /**< App received event via CTwn4NxEvent */
|
||||
EVENT_RECIPIENT_SYSTEM = 0x0000, /**< Twm4Nx system event */
|
||||
EVENT_RECIPIENT_BACKGROUND = 0x1000, /**< Background window event */
|
||||
EVENT_RECIPIENT_ICONWIDGET = 0x2000, /**< Icon Widget event */
|
||||
EVENT_RECIPIENT_ICONMGR = 0x3000, /**< Icon Manager event */
|
||||
EVENT_RECIPIENT_MENU = 0x4000, /**< Menu related event */
|
||||
EVENT_RECIPIENT_WINDOW = 0x5000, /**< Window related event */
|
||||
EVENT_RECIPIENT_TOOLBAR = 0x6000, /**< Toolbar related event */
|
||||
EVENT_RECIPIENT_BORDER = 0x7000, /**< Window border related event */
|
||||
EVENT_RECIPIENT_RESIZE = 0x8000, /**< Window resize event */
|
||||
EVENT_RECIPIENT_APP = 0x9000, /**< App received event via CTwn4NxEvent */
|
||||
EVENT_RECIPIENT_MASK = 0xf000, /**< Used to isolate recipient */
|
||||
};
|
||||
|
||||
|
|
@ -102,69 +101,67 @@ namespace Twm4Nx
|
|||
|
||||
enum EEventID
|
||||
{
|
||||
// Recipient == MSG
|
||||
|
||||
EVENT_MSG_POLL = 0x0000, /**< Poll widgets for events */
|
||||
|
||||
// Recipient == SYSTEM
|
||||
|
||||
EVENT_SYSTEM_NOP = 0x1000, /**< Null event */
|
||||
EVENT_SYSTEM_ERROR = 0x1001, /**< Report system error */
|
||||
EVENT_SYSTEM_EXIT = 0x1002, /**< Terminate the Twm4Nx session */
|
||||
EVENT_SYSTEM_NOP = 0x0000, /**< Null event */
|
||||
EVENT_SYSTEM_ERROR = 0x0001, /**< Report system error */
|
||||
EVENT_SYSTEM_EXIT = 0x0002, /**< Terminate the Twm4Nx session */
|
||||
|
||||
// Recipient == BACKGOUND
|
||||
|
||||
EVENT_BACKGROUND_REDRAW = 0x2000, /**< Redraw the background */
|
||||
EVENT_BACKGROUND_POLL = 0x1000, /**< Poll background icons for events */
|
||||
EVENT_BACKGROUND_REDRAW = 0x1001, /**< Redraw the background */
|
||||
|
||||
// Recipient == ICONWIDGET
|
||||
|
||||
EVENT_ICONWIDGET_GRAB = 0x3000, /**< Click on toolbar title */
|
||||
EVENT_ICONWIDGET_DRAG = 0x3001, /**< Drag window */
|
||||
EVENT_ICONWIDGET_UNGRAB = 0x3002, /**< Release click on toolbar */
|
||||
EVENT_ICONWIDGET_GRAB = 0x2000, /**< Click on toolbar title */
|
||||
EVENT_ICONWIDGET_DRAG = 0x2001, /**< Drag window */
|
||||
EVENT_ICONWIDGET_UNGRAB = 0x2002, /**< Release click on toolbar */
|
||||
|
||||
// Recipient == ICONMGR
|
||||
|
||||
// Recipient == MENU
|
||||
|
||||
EVENT_MENU_IDENTIFY = 0x5001, /**< Describe the window */
|
||||
EVENT_MENU_VERSION = 0x5002, /**< Show the Twm4Nx version */
|
||||
EVENT_MENU_ICONIFY = 0x5003, /**< Tool bar minimize button pressed */
|
||||
EVENT_MENU_DEICONIFY = 0x5004, /**< Window icon pressed */
|
||||
EVENT_MENU_FUNCTION = 0x5005, /**< Perform function on unknown menu */
|
||||
EVENT_MENU_TITLE = 0x5006, /**< REVISIT: Really an action not an event */
|
||||
EVENT_MENU_ROOT = 0x5007, /**< REVISIT: Popup root menu */
|
||||
EVENT_MENU_IDENTIFY = 0x4000, /**< Describe the window */
|
||||
EVENT_MENU_VERSION = 0x4001, /**< Show the Twm4Nx version */
|
||||
EVENT_MENU_ICONIFY = 0x4002, /**< Tool bar minimize button pressed */
|
||||
EVENT_MENU_DEICONIFY = 0x4003, /**< Window icon pressed */
|
||||
EVENT_MENU_FUNCTION = 0x4004, /**< Perform function on unknown menu */
|
||||
EVENT_MENU_TITLE = 0x4005, /**< REVISIT: Really an action not an event */
|
||||
EVENT_MENU_ROOT = 0x4006, /**< REVISIT: Popup root menu */
|
||||
|
||||
// Recipient == WINDOW
|
||||
|
||||
EVENT_WINDOW_FOCUS = 0x6000, /**< Enter modal state */
|
||||
EVENT_WINDOW_UNFOCUS = 0x6001, /**< Exit modal state */
|
||||
EVENT_WINDOW_RAISE = 0x6002, /**< Raise window to the top of the heirarchy */
|
||||
EVENT_WINDOW_LOWER = 0x6003, /**< Lower window to the bottom of the heirarchy */
|
||||
EVENT_WINDOW_DEICONIFY = 0x6004, /**< De-iconify and raise window */
|
||||
EVENT_WINDOW_DRAG = 0x6005, /**< Drag window */
|
||||
EVENT_WINDOW_DELETE = 0x6006, /**< Delete window */
|
||||
EVENT_WINDOW_POLL = 0x5000, /**< Poll window for widget events */
|
||||
EVENT_WINDOW_FOCUS = 0x5001, /**< Enter modal state */
|
||||
EVENT_WINDOW_UNFOCUS = 0x5002, /**< Exit modal state */
|
||||
EVENT_WINDOW_RAISE = 0x5003, /**< Raise window to the top of the heirarchy */
|
||||
EVENT_WINDOW_LOWER = 0x5004, /**< Lower window to the bottom of the heirarchy */
|
||||
EVENT_WINDOW_DEICONIFY = 0x5005, /**< De-iconify and raise window */
|
||||
EVENT_WINDOW_DRAG = 0x5006, /**< Drag window */
|
||||
EVENT_WINDOW_DELETE = 0x5007, /**< Delete window */
|
||||
|
||||
// Recipient == TOOLBAR
|
||||
|
||||
EVENT_TOOLBAR_GRAB = 0x7000, /**< Click on title widget */
|
||||
EVENT_TOOLBAR_UNGRAB = 0x7001, /**< Release click on title widget */
|
||||
EVENT_TOOLBAR_MENU = 0x7002, /**< Toolbar menu button released */
|
||||
EVENT_TOOLBAR_MINIMIZE = 0x7003, /**< Toolbar minimize button released */
|
||||
EVENT_TOOLBAR_RESIZE = 0x7004, /**< Toolbar resize button released */
|
||||
EVENT_TOOLBAR_TERMINATE = 0x7005, /**< Toolbar delete button released */
|
||||
EVENT_TOOLBAR_GRAB = 0x6000, /**< Click on title widget */
|
||||
EVENT_TOOLBAR_UNGRAB = 0x6001, /**< Release click on title widget */
|
||||
EVENT_TOOLBAR_MENU = 0x6002, /**< Toolbar menu button released */
|
||||
EVENT_TOOLBAR_MINIMIZE = 0x6003, /**< Toolbar minimize button released */
|
||||
EVENT_TOOLBAR_RESIZE = 0x6004, /**< Toolbar resize button released */
|
||||
EVENT_TOOLBAR_TERMINATE = 0x6005, /**< Toolbar delete button released */
|
||||
|
||||
// Recipient == BORDER
|
||||
|
||||
// Recipient == RESIZE
|
||||
|
||||
EVENT_RESIZE_START = 0x9000, /**< Start window resize */
|
||||
EVENT_RESIZE_VERTZOOM = 0x9001, /**< Zoom vertically only */
|
||||
EVENT_RESIZE_HORIZOOM = 0x9002, /**< Zoom horizontally only */
|
||||
EVENT_RESIZE_FULLZOOM = 0x9003, /**< Zoom both vertically and horizontally */
|
||||
EVENT_RESIZE_LEFTZOOM = 0x9004, /**< Zoom left only */
|
||||
EVENT_RESIZE_RIGHTZOOM = 0x9005, /**< Zoom right only */
|
||||
EVENT_RESIZE_TOPZOOM = 0x9006, /**< Zoom top only */
|
||||
EVENT_RESIZE_BOTTOMZOOM = 0x9007, /**< Zoom bottom only */
|
||||
EVENT_RESIZE_START = 0x8000, /**< Start window resize */
|
||||
EVENT_RESIZE_VERTZOOM = 0x8001, /**< Zoom vertically only */
|
||||
EVENT_RESIZE_HORIZOOM = 0x8002, /**< Zoom horizontally only */
|
||||
EVENT_RESIZE_FULLZOOM = 0x8003, /**< Zoom both vertically and horizontally */
|
||||
EVENT_RESIZE_LEFTZOOM = 0x8004, /**< Zoom left only */
|
||||
EVENT_RESIZE_RIGHTZOOM = 0x8005, /**< Zoom right only */
|
||||
EVENT_RESIZE_TOPZOOM = 0x8006, /**< Zoom top only */
|
||||
EVENT_RESIZE_BOTTOMZOOM = 0x8007, /**< Zoom bottom only */
|
||||
|
||||
// Recipient == APP
|
||||
// All application defined events must (1) use recepient == EVENT_RECIPIENT_APP,
|
||||
|
|
@ -221,7 +218,7 @@ namespace Twm4Nx
|
|||
{
|
||||
uint16_t eventID; /**< Encoded event ID */
|
||||
FAR CWindowEvent *instance; /**< X/Y position */
|
||||
FAR struct SWindow *win; /**< Twm4NX window reference */
|
||||
FAR void *obj; /**< Context specific reference */
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue