mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-12-16 12:08:49 +00:00
poll all displays
This commit is contained in:
parent
e0b8e8440a
commit
147f8e660c
@ -47,9 +47,18 @@ class SecondaryDisplay(val context: Context) : DisplayManager.DisplayListener {
|
|||||||
|
|
||||||
private fun getExternalDisplay(context: Context): Display? {
|
private fun getExternalDisplay(context: Context): Display? {
|
||||||
val dm = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
val dm = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
||||||
val internalId = context.display.displayId ?: Display.DEFAULT_DISPLAY
|
val currentDisplayId = context.display.displayId
|
||||||
val displays = dm.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION)
|
val displays = dm.displays
|
||||||
return displays.firstOrNull { it.displayId != internalId && it.name != "HiddenDisplay" }
|
val presDisplays = dm.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
|
||||||
|
return displays.firstOrNull {
|
||||||
|
val isPresentable = presDisplays.any { pd -> pd.displayId == it.displayId }
|
||||||
|
val isNotDefaultOrPresentable = it.displayId != Display.DEFAULT_DISPLAY || isPresentable
|
||||||
|
isNotDefaultOrPresentable &&
|
||||||
|
it.displayId != currentDisplayId &&
|
||||||
|
it.name != "HiddenDisplay" &&
|
||||||
|
it.state != Display.STATE_OFF &&
|
||||||
|
it.isValid
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateDisplay() {
|
fun updateDisplay() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user