Pārlūkot izejas kodu

Refresh the battery state before we query it on Linux

Sam Lantinga 3 gadi atpakaļ
vecāks
revīzija
ec8e3104c8
1 mainītis faili ar 2 papildinājumiem un 0 dzēšanām
  1. 2 0
      src/power/linux/SDL_syspower.c

+ 2 - 0
src/power/linux/SDL_syspower.c

@@ -565,6 +565,8 @@ check_upower_device(DBusConnection *conn, const char *path, SDL_PowerState *stat
         return;
     } else if (!ui32) {
         st = SDL_POWERSTATE_NO_BATTERY;
+    } else if (!SDL_DBus_CallMethodOnConnection(conn, UPOWER_DBUS_NODE, path, UPOWER_DEVICE_DBUS_INTERFACE, "Refresh", DBUS_TYPE_INVALID)) {
+	return;
     } else if (!SDL_DBus_QueryPropertyOnConnection(conn, UPOWER_DBUS_NODE, path, UPOWER_DEVICE_DBUS_INTERFACE, "State", DBUS_TYPE_UINT32, &ui32)) {
         st = SDL_POWERSTATE_UNKNOWN;  /* uh oh */
     } else if (ui32 == 1) {  /* 1 == charging */