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
bed10c51
Unverified
Commit
bed10c51
authored
Apr 15, 2021
by
Igor Demin
Committed by
GitHub
Apr 15, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #93 from JetBrains/fix_focus_on_window_start
Compose. Hot keys didn't work until we clicked on the window.
parents
55c1cad7
f829e238
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
SkiaLayer.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
+25
-2
No files found.
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
View file @
bed10c51
...
...
@@ -9,12 +9,14 @@ import org.jetbrains.skiko.context.ContextHandler
import
org.jetbrains.skiko.context.createContextHandler
import
org.jetbrains.skiko.redrawer.Redrawer
import
java.awt.Graphics
import
java.awt.event.FocusEvent
import
java.awt.event.HierarchyEvent
import
java.awt.event.InputMethodListener
import
java.awt.event.KeyListener
import
java.awt.event.MouseListener
import
java.awt.event.MouseMotionListener
import
java.awt.event.MouseWheelListener
import
java.awt.im.InputMethodRequests
import
javax.swing.JPanel
import
javax.swing.SwingUtilities.isEventDispatchThread
...
...
@@ -44,6 +46,10 @@ open class SkiaLayer(
// 3. to avoid double paint in one single frame, use needRedraw instead of redrawImmediately
redrawer
?.
needRedraw
()
}
override
fun
getInputMethodRequests
():
InputMethodRequests
?
{
return
this
@SkiaLayer
.
inputMethodRequests
}
}
add
(
backedLayer
)
@Suppress
(
"LeakingThis"
)
...
...
@@ -146,6 +152,25 @@ open class SkiaLayer(
}
}
// We need to delegate all event listeners to the Canvas (so and focus/input)
// Canvas is heavyweight AWT component, JPanel is lightweight Swing component
// Event handling doesn't properly work when we mix heavyweight and lightweight components.
// For example, Canvas will eat all mouse events
// (see "mouse events on a heavyweight component do not fall through to its parent",
// https://www.comp.nus.edu.sg/~cs3283/ftp/Java/swingConnect/archive/tech_topics_arch/mixing/mixing.html)
override
fun
enableInputMethods
(
enable
:
Boolean
)
{
backedLayer
.
enableInputMethods
(
enable
)
}
override
fun
requestFocus
()
{
backedLayer
.
requestFocus
()
}
override
fun
requestFocus
(
cause
:
FocusEvent
.
Cause
?)
{
backedLayer
.
requestFocus
(
cause
)
}
override
fun
addInputMethodListener
(
l
:
InputMethodListener
)
{
backedLayer
.
addInputMethodListener
(
l
)
}
...
...
@@ -186,8 +211,6 @@ open class SkiaLayer(
backedLayer
.
removeKeyListener
(
l
)
}
private
var
redrawScheduled
=
false
/**
* Redraw on the next animation Frame (on vsync signal if vsync is enabled).
*/
...
...
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