aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/gwin_wm.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2015-08-16 21:53:47 +1000
committerinmarket <andrewh@inmarket.com.au>2015-08-16 21:53:47 +1000
commit15e7342fd7b21b76a565561a3caafee394e70c88 (patch)
treeaeb6898cfdbcb875f4b109d202f2b4560df42021 /src/gwin/gwin_wm.c
parent377fe644d1233e955dfd05e40fa9d335447de325 (diff)
downloaduGFX-15e7342fd7b21b76a565561a3caafee394e70c88.tar.gz
uGFX-15e7342fd7b21b76a565561a3caafee394e70c88.tar.bz2
uGFX-15e7342fd7b21b76a565561a3caafee394e70c88.zip
Updates to focus.
Diffstat (limited to 'src/gwin/gwin_wm.c')
-rw-r--r--src/gwin/gwin_wm.c57
1 files changed, 37 insertions, 20 deletions
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;