From 3ba3be201cddf3c6a4606f49028fc6640da0b28e Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Thu, 13 Aug 2015 01:13:36 +0200 Subject: Adding gwinSetFocus() and gwinGetFocus() --- src/gwin/gwin_wm.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/gwin/gwin_wm.c') diff --git a/src/gwin/gwin_wm.c b/src/gwin/gwin_wm.c index 00365c36..52f7a1aa 100644 --- a/src/gwin/gwin_wm.c +++ b/src/gwin/gwin_wm.c @@ -162,7 +162,7 @@ extern const GWindowManager GNullWindowManager; GWindowManager * _GWINwm; bool_t _gwinFlashState; - +static GHandle _widgetInFocus; static gfxSem gwinsem; static gfxQueueASync _GWINList; #if GWIN_NEED_FLASHING @@ -184,6 +184,8 @@ static volatile uint8_t RedrawPending; void _gwmInit(void) { + _widgetInFocus = 0; + gfxSemInit(&gwinsem, 1, 1); gfxQueueASyncInit(&_GWINList); #if GWIN_NEED_FLASHING @@ -571,6 +573,25 @@ GHandle gwinGetNextWindow(GHandle gh) { return gh ? (GHandle)gfxQueueASyncNext(&gh->wmq) : (GHandle)gfxQueueASyncPeek(&_GWINList); } +void gwinSetFocus(GHandle gh) { + // Passing NULL removes the focus from any widget + if (gh == 0) { + _widgetInFocus = 0; + return; + } + + // Only accept widgets + if (!gwinIsWidget(gh)) { + return; + } + + _widgetInFocus = gh; +} + +GHandle gwinGetFocus(void) { + return _widgetInFocus; +} + #if GWIN_NEED_FLASHING static void FlashTimerFn(void *param) { GHandle gh; -- cgit v1.2.3 From 15e7342fd7b21b76a565561a3caafee394e70c88 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sun, 16 Aug 2015 21:53:47 +1000 Subject: Updates to focus. --- src/gwin/gwin_wm.c | 57 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 20 deletions(-) (limited to 'src/gwin/gwin_wm.c') diff --git a/src/gwin/gwin_wm.c b/src/gwin/gwin_wm.c index 52f7a1aa..41fc385d 100644 --- a/src/gwin/gwin_wm.c +++ b/src/gwin/gwin_wm.c @@ -162,7 +162,6 @@ extern const GWindowManager GNullWindowManager; GWindowManager * _GWINwm; bool_t _gwinFlashState; -static GHandle _widgetInFocus; static gfxSem gwinsem; static gfxQueueASync _GWINList; #if GWIN_NEED_FLASHING @@ -333,14 +332,23 @@ void _gwinUpdate(GHandle gh) { if (!gh->parent || (gh->parent->flags & GWIN_FLG_SYSVISIBLE)) { // We have been made visible gh->flags |= (GWIN_FLG_SYSVISIBLE|GWIN_FLG_NEEDREDRAW|GWIN_FLG_BGREDRAW); + + // Do we want to grab the focus + _gwinFixFocus(gh); + RedrawPending |= DOREDRAW_VISIBLES; } break; case (GWIN_FLG_VISIBLE|GWIN_FLG_SYSVISIBLE): if (!gh->parent || (gh->parent->flags & GWIN_FLG_SYSVISIBLE)) break; + // Parent has been made invisible gh->flags &= ~GWIN_FLG_SYSVISIBLE; + + // No focus for us anymore + _gwinFixFocus(gh); + break; case GWIN_FLG_SYSVISIBLE: // We have been made invisible @@ -348,6 +356,10 @@ void _gwinUpdate(GHandle gh) { if (!gh->parent || (gh->parent->flags & GWIN_FLG_SYSVISIBLE)) { // The parent is visible so we must clear the area we took gh->flags |= (GWIN_FLG_NEEDREDRAW|GWIN_FLG_BGREDRAW); + + // No focus for us anymore + _gwinFixFocus(gh); + RedrawPending |= DOREDRAW_INVISIBLES; } break; @@ -457,6 +469,10 @@ void gwinRedraw(GHandle gh) { if (visible) { if (!(gh->flags & GWIN_FLG_VISIBLE)) { gh->flags |= (GWIN_FLG_VISIBLE|GWIN_FLG_SYSVISIBLE|GWIN_FLG_NEEDREDRAW|GWIN_FLG_BGREDRAW); + + // Do we want to grab the focus + _gwinFixFocus(gh); + RedrawPending |= DOREDRAW_VISIBLES; TriggerRedraw(); } @@ -464,6 +480,10 @@ void gwinRedraw(GHandle gh) { if ((gh->flags & GWIN_FLG_VISIBLE)) { gh->flags &= ~(GWIN_FLG_VISIBLE|GWIN_FLG_SYSVISIBLE); gh->flags |= (GWIN_FLG_NEEDREDRAW|GWIN_FLG_BGREDRAW); + + // No focus for us anymore + _gwinFixFocus(gh); + RedrawPending |= DOREDRAW_INVISIBLES; TriggerRedraw(); } @@ -484,6 +504,10 @@ void gwinRedraw(GHandle gh) { for(gh = gwinGetNextWindow(0); gh; gh = gwinGetNextWindow(gh)) { if ((gh->flags & (GWIN_FLG_SYSENABLED|GWIN_FLG_ENABLED)) == GWIN_FLG_ENABLED && (!gh->parent || (gh->parent->flags & GWIN_FLG_SYSENABLED))) { gh->flags |= GWIN_FLG_SYSENABLED; // Fix it + + // Do we want to grab the focus + _gwinFixFocus(gh); + _gwinUpdate(gh); } } @@ -497,6 +521,10 @@ void gwinRedraw(GHandle gh) { for(gh = gwinGetNextWindow(0); gh; gh = gwinGetNextWindow(gh)) { if ((gh->flags & GWIN_FLG_SYSENABLED) && (!(gh->flags & GWIN_FLG_ENABLED) || (gh->parent && !(gh->parent->flags & GWIN_FLG_SYSENABLED)))) { gh->flags &= ~GWIN_FLG_SYSENABLED; // Fix it + + // No focus for us anymore + _gwinFixFocus(gh); + _gwinUpdate(gh); } } @@ -508,11 +536,19 @@ void gwinRedraw(GHandle gh) { if (enabled) { if (!(gh->flags & GWIN_FLG_ENABLED)) { gh->flags |= (GWIN_FLG_ENABLED|GWIN_FLG_SYSENABLED); + + // Do we want to grab the focus + _gwinFixFocus(gh); + _gwinUpdate(gh); } } else { if ((gh->flags & GWIN_FLG_ENABLED)) { gh->flags &= ~(GWIN_FLG_ENABLED|GWIN_FLG_SYSENABLED); + + // No focus for us anymore + _gwinFixFocus(gh); + _gwinUpdate(gh); } } @@ -573,25 +609,6 @@ GHandle gwinGetNextWindow(GHandle gh) { return gh ? (GHandle)gfxQueueASyncNext(&gh->wmq) : (GHandle)gfxQueueASyncPeek(&_GWINList); } -void gwinSetFocus(GHandle gh) { - // Passing NULL removes the focus from any widget - if (gh == 0) { - _widgetInFocus = 0; - return; - } - - // Only accept widgets - if (!gwinIsWidget(gh)) { - return; - } - - _widgetInFocus = gh; -} - -GHandle gwinGetFocus(void) { - return _widgetInFocus; -} - #if GWIN_NEED_FLASHING static void FlashTimerFn(void *param) { GHandle gh; -- cgit v1.2.3 From 8c3c536111325eecdab186b54365930e50057530 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sun, 16 Aug 2015 22:11:19 +1000 Subject: Another compile fix --- src/gwin/gwin_wm.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gwin/gwin_wm.c') diff --git a/src/gwin/gwin_wm.c b/src/gwin/gwin_wm.c index 41fc385d..ef7333fa 100644 --- a/src/gwin/gwin_wm.c +++ b/src/gwin/gwin_wm.c @@ -183,8 +183,6 @@ static volatile uint8_t RedrawPending; void _gwmInit(void) { - _widgetInFocus = 0; - gfxSemInit(&gwinsem, 1, 1); gfxQueueASyncInit(&_GWINList); #if GWIN_NEED_FLASHING -- cgit v1.2.3