Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
cb53dfe0
Unverified
Commit
cb53dfe0
authored
Feb 18, 2022
by
Aleksandr Veselov
Committed by
GitHub
Feb 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace timer with a Job (#502)
parent
ed8ee560
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
HardwareLayer.kt
...o/src/awtMain/kotlin/org/jetbrains/skiko/HardwareLayer.kt
+10
-7
No files found.
skiko/src/awtMain/kotlin/org/jetbrains/skiko/HardwareLayer.kt
View file @
cb53dfe0
package
org.jetbrains.skiko
package
org.jetbrains.skiko
import
kotlinx.coroutines.
CoroutineScope
import
kotlinx.coroutines.
*
import
kotlinx.coroutines.channels.Channel
import
kotlinx.coroutines.channels.Channel
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.swing.Swing
import
kotlinx.coroutines.launch
import
java.awt.*
import
java.awt.*
import
java.awt.event.InputMethodEvent
import
java.awt.event.InputMethodEvent
import
java.beans.PropertyChangeEvent
import
java.beans.PropertyChangeEvent
import
javax.accessibility.Accessible
import
javax.accessibility.Accessible
import
javax.accessibility.AccessibleContext
import
javax.accessibility.AccessibleContext
import
javax.swing.Timer
import
kotlin.time.ExperimentalTime
import
kotlin.time.ExperimentalTime
internal
open
class
HardwareLayer
(
internal
open
class
HardwareLayer
(
...
@@ -35,6 +33,7 @@ internal open class HardwareLayer(
...
@@ -35,6 +33,7 @@ internal open class HardwareLayer(
}
}
open
fun
dispose
()
{
open
fun
dispose
()
{
resetFocusAccessibleJob
?.
cancel
()
nativeDispose
()
nativeDispose
()
}
}
...
@@ -88,7 +87,7 @@ internal open class HardwareLayer(
...
@@ -88,7 +87,7 @@ internal open class HardwareLayer(
return
res
?:
super
.
getAccessibleContext
()
return
res
?:
super
.
getAccessibleContext
()
}
}
val
resetFocusAccessibleTimer
:
Timer
=
Timer
(
100
)
{
_focusedAccessible
=
null
}
private
var
resetFocusAccessibleJob
:
Job
?
=
null
fun
requestNativeFocusOnAccessible
(
accessible
:
Accessible
?)
{
fun
requestNativeFocusOnAccessible
(
accessible
:
Accessible
?)
{
_focusedAccessible
=
accessible
_focusedAccessible
=
accessible
...
@@ -99,9 +98,13 @@ internal open class HardwareLayer(
...
@@ -99,9 +98,13 @@ internal open class HardwareLayer(
listeners
.
forEach
{
it
.
propertyChange
(
event
)
}
listeners
.
forEach
{
it
.
propertyChange
(
event
)
}
// Listener spawns asynchronous notification post procedure, reading current focus owner
// Listener spawns asynchronous notification post procedure, reading current focus owner
// and its accessibility context. This time
r
is used to deal with concurrency
// and its accessibility context. This time
out
is used to deal with concurrency
// TODO Find more reliable procedure
// TODO Find more reliable procedure
resetFocusAccessibleTimer
.
restart
()
resetFocusAccessibleJob
?.
cancel
()
resetFocusAccessibleJob
=
GlobalScope
.
launch
(
Dispatchers
.
Swing
)
{
delay
(
100
)
_focusedAccessible
=
null
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment