mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
More precise handling of ACLineStatus values (IDEA-CR-32704)
This commit is contained in:
@@ -30,7 +30,11 @@ private fun getWindowsPowerStatus(): PowerStatus {
|
||||
if (!JnaLoader.isLoaded()) return PowerStatus.UNKNOWN
|
||||
val systemPowerStatus = SYSTEM_POWER_STATUS()
|
||||
if (!kernel32.GetSystemPowerStatus(systemPowerStatus)) return PowerStatus.UNKNOWN
|
||||
return if (systemPowerStatus.ACLineStatus.toInt() == 1) PowerStatus.AC_POWER else PowerStatus.BATTERY
|
||||
return when(systemPowerStatus.ACLineStatus.toInt()) {
|
||||
1 -> PowerStatus.AC_POWER
|
||||
0 -> PowerStatus.BATTERY
|
||||
else -> PowerStatus.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
class SYSTEM_POWER_STATUS : Structure() {
|
||||
|
||||
Reference in New Issue
Block a user