diff options
author | Andrey Grozin <grozin@gentoo.org> | 2021-09-14 11:39:55 +0700 |
---|---|---|
committer | Andrey Grozin <grozin@gentoo.org> | 2021-09-14 11:40:40 +0700 |
commit | bf638078d2895af8b6faea89bbaa7abab5899d4a (patch) | |
tree | f9a14fe8151b1c86a9f616bc403de751f82df6f4 /app-text/coolreader | |
parent | dev-python/patch-ng: mark ALLARCHES (diff) | |
download | gentoo-bf638078d2895af8b6faea89bbaa7abab5899d4a.tar.gz gentoo-bf638078d2895af8b6faea89bbaa7abab5899d4a.tar.bz2 gentoo-bf638078d2895af8b6faea89bbaa7abab5899d4a.zip |
app-text/coolreader: forgotten patch added
Closes: https://bugs.gentoo.org/812953
Package-Manager: Portage-3.0.23, Repoman-3.0.3
Signed-off-by: Andrey Grozin <grozin@gentoo.org>
Diffstat (limited to 'app-text/coolreader')
-rw-r--r-- | app-text/coolreader/files/coolreader-wxwidgets.patch | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/app-text/coolreader/files/coolreader-wxwidgets.patch b/app-text/coolreader/files/coolreader-wxwidgets.patch new file mode 100644 index 000000000000..aac02864b0e4 --- /dev/null +++ b/app-text/coolreader/files/coolreader-wxwidgets.patch @@ -0,0 +1,109 @@ +From 2040a15d2a23ee4d16af8f2294e1593fa267e8d9 Mon Sep 17 00:00:00 2001 +From: Aleksey Chernov <valexlin@gmail.com> +Date: Thu, 9 Sep 2021 10:41:38 +0400 +Subject: [PATCH] Fixed wxWidgets build failure: compilation error due to API + change. Introduced in c47cab44799475a48230312b8e97cd7a71edddb0. + +--- + cr3wx/src/view.cpp | 82 ++++++++++++++++++++++++++++++++++------------ + 1 file changed, 61 insertions(+), 21 deletions(-) + +diff --git a/cr3wx/src/view.cpp b/cr3wx/src/view.cpp +index df2a264f7f..2ee30f9421 100644 +--- a/cr3wx/src/view.cpp ++++ b/cr3wx/src/view.cpp +@@ -307,33 +307,73 @@ void cr3view::OnTimer(wxTimerEvent& event) + } + } + +-void cr3view::Paint() ++static bool getBatteryState(int& state, int& chargingConn, int& level) + { +- //printf("cr3view::Paint() \n"); +- int battery_state = -1; + #ifdef _WIN32 ++ // update battery state + SYSTEM_POWER_STATUS bstatus; + BOOL pow = GetSystemPowerStatus(&bstatus); +- if (bstatus.BatteryFlag & 128) +- pow = FALSE; +- if (bstatus.ACLineStatus!=0 || bstatus.BatteryLifePercent==255) +- pow = FALSE; +- if ( pow ) +- battery_state = bstatus.BatteryLifePercent; ++ if (pow) { ++ state = CR_BATTERY_STATE_DISCHARGING; ++ if (bstatus.BatteryFlag & 128) ++ state = CR_BATTERY_STATE_NO_BATTERY; // no system battery ++ else if (bstatus.BatteryFlag & 8) ++ state = CR_BATTERY_STATE_CHARGING; // charging ++ chargingConn = CR_BATTERY_CHARGER_NO; ++ if (bstatus.ACLineStatus==1) ++ chargingConn = CR_BATTERY_CHARGER_AC; // AC power charging connected ++ if (bstatus.BatteryLifePercent>=0 && bstatus.BatteryLifePercent<=100) ++ level = bstatus.BatteryLifePercent; ++ return true; ++ } ++ return false; + #else +- if ( ::wxGetPowerType() == wxPOWER_BATTERY ) { +- int n = ::wxGetBatteryState(); +- if ( n == wxBATTERY_NORMAL_STATE ) +- battery_state = 100; +- else if ( n == wxBATTERY_LOW_STATE ) +- battery_state = 50; +- else if ( n == wxBATTERY_CRITICAL_STATE ) +- battery_state = 0; +- else if ( n == wxBATTERY_SHUTDOWN_STATE ) +- battery_state = 0; +- }; ++ wxPowerType wxpwrtype = wxGetPowerType(); ++ switch (wxpwrtype) { ++ case wxPOWER_SOCKET: ++ state = CR_BATTERY_STATE_CHARGING; ++ chargingConn = CR_BATTERY_CHARGER_AC; ++ break; ++ case wxPOWER_BATTERY: ++ state = CR_BATTERY_STATE_DISCHARGING; ++ chargingConn = CR_BATTERY_CHARGER_NO; ++ break; ++ default: ++ state = CR_BATTERY_STATE_NO_BATTERY; ++ chargingConn = CR_BATTERY_CHARGER_NO; ++ break; ++ } ++ wxBatteryState wxbatstate = wxGetBatteryState(); ++ switch (wxbatstate) { ++ case wxBATTERY_NORMAL_STATE: ++ level = 100; ++ break; ++ case wxBATTERY_LOW_STATE: ++ level = 50; ++ break; ++ case wxBATTERY_CRITICAL_STATE: ++ level = 5; ++ break; ++ case wxBATTERY_SHUTDOWN_STATE: ++ level = 0; ++ break; ++ default: ++ level = 0; ++ break; ++ } ++ return true; + #endif +- getDocView()->setBatteryState( battery_state ); ++} ++ ++void cr3view::Paint() ++{ ++ //printf("cr3view::Paint() \n"); ++ int battery_state; ++ int charging_conn; ++ int charge_level; ++ if (getBatteryState(battery_state, charging_conn, charge_level)) { ++ getDocView()->setBatteryState( battery_state, charging_conn, charge_level ); ++ } + //_docview->Draw(); + UpdateScrollBar(); + Refresh( FALSE ); |