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
47985faa
Unverified
Commit
47985faa
authored
Feb 18, 2022
by
Aleksandr Veselov
Committed by
GitHub
Feb 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make focus tracking work for windows (#503)
parent
cb53dfe0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
HardwareLayer.kt
...o/src/awtMain/kotlin/org/jetbrains/skiko/HardwareLayer.kt
+21
-4
No files found.
skiko/src/awtMain/kotlin/org/jetbrains/skiko/HardwareLayer.kt
View file @
47985faa
...
@@ -4,6 +4,7 @@ import kotlinx.coroutines.*
...
@@ -4,6 +4,7 @@ import kotlinx.coroutines.*
import
kotlinx.coroutines.channels.Channel
import
kotlinx.coroutines.channels.Channel
import
kotlinx.coroutines.swing.Swing
import
kotlinx.coroutines.swing.Swing
import
java.awt.*
import
java.awt.*
import
java.awt.event.FocusEvent
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
...
@@ -92,10 +93,14 @@ internal open class HardwareLayer(
...
@@ -92,10 +93,14 @@ internal open class HardwareLayer(
fun
requestNativeFocusOnAccessible
(
accessible
:
Accessible
?)
{
fun
requestNativeFocusOnAccessible
(
accessible
:
Accessible
?)
{
_focusedAccessible
=
accessible
_focusedAccessible
=
accessible
val
focusManager
=
KeyboardFocusManager
.
getCurrentKeyboardFocusManager
()
when
(
hostOs
)
{
val
listeners
=
focusManager
.
getPropertyChangeListeners
(
"focusOwner"
)
OS
.
Windows
->
requestAccessBridgeFocusOnAccessible
()
val
event
=
PropertyChangeEvent
(
focusManager
,
"focusOwner"
,
null
,
accessible
)
OS
.
MacOS
->
requestMacOSFocusOnAccessible
(
accessible
)
listeners
.
forEach
{
it
.
propertyChange
(
event
)
}
else
->
{
_focusedAccessible
=
null
return
}
}
// 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 timeout is used to deal with concurrency
// and its accessibility context. This timeout is used to deal with concurrency
...
@@ -106,6 +111,18 @@ internal open class HardwareLayer(
...
@@ -106,6 +111,18 @@ internal open class HardwareLayer(
_focusedAccessible
=
null
_focusedAccessible
=
null
}
}
}
}
private
fun
requestAccessBridgeFocusOnAccessible
()
{
val
focusEvent
=
FocusEvent
(
this
,
FocusEvent
.
FOCUS_GAINED
)
focusListeners
.
forEach
{
it
.
focusGained
(
focusEvent
)
}
}
private
fun
requestMacOSFocusOnAccessible
(
accessible
:
Accessible
?)
{
val
focusManager
=
KeyboardFocusManager
.
getCurrentKeyboardFocusManager
()
val
listeners
=
focusManager
.
getPropertyChangeListeners
(
"focusOwner"
)
val
event
=
PropertyChangeEvent
(
focusManager
,
"focusOwner"
,
null
,
accessible
)
listeners
.
forEach
{
it
.
propertyChange
(
event
)
}
}
}
}
/**
/**
...
...
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