forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make MouseEvent.nativeEvent and KeyEvent.nativeKeyEvent as Any?, move…
… desktop code to skikoMain Also introduce extensions, which should be used by the users, if they need interop with AWT: val PointerEvent.awtEventOrNull: java.awt.event.MouseEvent? val KeyEvent.awtEventOrNull: java.awt.event.KeyEvent? We gradually get rid of AWT from Compose core codebase, AWT will be just one of the implementations. Backward compatibility isn't violated, this change was before Compose MPP 1.0 PointerEvent.awtEvent, KeyEvent.awtEvent are deprecated, because we shipped them in 1.0 without Experimental annotation Also, this CL contains small fix for JetBrains/compose-multiplatform#1457 in KeyEvent.desktop.kt file If Caps is on, or it is not English layout, Linux sends LOCATION_UNKNOWN instead of LOCATION_STANDARD Change-Id: I929d5d854e15f59d1dcddd6dc85221253c57a684 Test: ./gradlew jvmTest desktopTest -Pandroidx.compose.multiplatformEnabled=true
- Loading branch information
Showing
13 changed files
with
147 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/AwtEvents.desktop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package androidx.compose.ui.awt | ||
|
||
import androidx.compose.ui.input.key.KeyEvent | ||
import androidx.compose.ui.input.pointer.PointerEvent | ||
|
||
/** | ||
* The original raw native event from AWT | ||
*/ | ||
@Deprecated( | ||
"Use awtEventOrNull. `awtEvent` will be removed in Compose 1.3", | ||
replaceWith = ReplaceWith("awtEventOrNull") | ||
) | ||
val PointerEvent.awtEvent: java.awt.event.MouseEvent get() { | ||
require(nativeEvent is java.awt.event.MouseEvent) { | ||
"nativeEvent wasn't sent by AWT. Make sure, that you use AWT backed API" + | ||
" (from androidx.compose.ui.awt.* or from androidx.compose.ui.window.*)" | ||
} | ||
return nativeEvent | ||
} | ||
|
||
/** | ||
* The original raw native event from AWT | ||
*/ | ||
@Deprecated( | ||
"Use awtEventOrNull. `awtEvent` will be removed in Compose 1.3", | ||
replaceWith = ReplaceWith("awtEventOrNull") | ||
) | ||
val KeyEvent.awtEvent: java.awt.event.KeyEvent get() { | ||
require(nativeKeyEvent is java.awt.event.KeyEvent) { | ||
"nativeKeyEvent wasn't sent by AWT. Make sure, that you use AWT backed API" + | ||
" (from androidx.compose.ui.awt.* or from androidx.compose.ui.window.*)" | ||
} | ||
return nativeKeyEvent | ||
} | ||
|
||
/** | ||
* The original raw native event from AWT. | ||
* | ||
* Null if: | ||
* - the native event is sent by another framework (when Compose UI is embed into it) | ||
* - there no native event (in tests, for example) | ||
* - there was a synthetic move event sent by compose on relayout | ||
* - there was a synthetic move event sent by compose when move is missing between two non-move events | ||
*/ | ||
@Suppress("DEPRECATION") | ||
val PointerEvent.awtEventOrNull: java.awt.event.MouseEvent? get() { | ||
return nativeEvent as? java.awt.event.MouseEvent | ||
} | ||
|
||
/** | ||
* The original raw native event from AWT. | ||
* | ||
* Null if: | ||
* - the native event is sent by another framework (when Compose UI is embed into it) | ||
* - there no native event (in tests, for example) | ||
*/ | ||
val KeyEvent.awtEventOrNull: java.awt.event.KeyEvent? get() { | ||
return nativeKeyEvent as? java.awt.event.KeyEvent | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.