summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/action.cpp7
-rw-r--r--gui/blanktimer.cpp34
-rw-r--r--gui/blanktimer.hpp4
-rw-r--r--gui/gui.cpp4
-rw-r--r--gui/objects.hpp1
-rw-r--r--gui/theme/common/landscape.xml5
-rw-r--r--gui/theme/common/portrait.xml5
-rw-r--r--gui/theme/common/watch.xml5
-rw-r--r--gui/theme/landscape_hdpi/ui.xml2
-rw-r--r--gui/theme/landscape_mdpi/ui.xml2
-rw-r--r--gui/theme/portrait_hdpi/ui.xml2
-rw-r--r--gui/theme/portrait_mdpi/ui.xml2
-rw-r--r--gui/theme/watch_mdpi/ui.xml2
13 files changed, 69 insertions, 6 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index 7d34da8a0..ef110bcfd 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -198,6 +198,7 @@ GUIAction::GUIAction(xml_node<>* node)
ADD_ACTION(mountsystemtoggle);
ADD_ACTION(setlanguage);
ADD_ACTION(checkforapp);
+ ADD_ACTION(togglebacklight);
// remember actions that run in the caller thread
for (mapFunc::const_iterator it = mf.begin(); it != mf.end(); ++it)
@@ -1865,6 +1866,12 @@ int GUIAction::setlanguage(std::string arg __unused)
return 0;
}
+int GUIAction::togglebacklight(std::string arg __unused)
+{
+ blankTimer.toggleBlank();
+ return 0;
+}
+
int GUIAction::setbootslot(std::string arg)
{
operation_start("Set Boot Slot");
diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp
index 4662b1fab..220525387 100644
--- a/gui/blanktimer.cpp
+++ b/gui/blanktimer.cpp
@@ -116,3 +116,37 @@ void blanktimer::resetTimerAndUnblank(void) {
pthread_mutex_unlock(&mutex);
#endif
}
+
+void blanktimer::blank(void) {
+/* 1) No need for timer handling since checkForTimeout() verifies
+ * state of screen before performing screen-off
+ * 2) Assume screen-off causes issues for devices that set
+ * TW_NO_SCREEN_TIMEOUT and do not blank screen here either
+ */
+
+#ifndef TW_NO_SCREEN_TIMEOUT
+ pthread_mutex_lock(&mutex);
+ if (state == kOn) {
+ orig_brightness = getBrightness();
+ state = kOff;
+ TWFunc::Set_Brightness("0");
+ TWFunc::check_and_run_script("/sbin/postscreenblank.sh", "blank");
+ }
+#ifndef TW_NO_SCREEN_BLANK
+ if (state == kOff) {
+ gr_fb_blank(true);
+ state = kBlanked;
+ }
+#endif
+ pthread_mutex_unlock(&mutex);
+#endif
+}
+
+void blanktimer::toggleBlank(void) {
+ if (state == kOn) {
+ blank();
+ PageManager::ChangeOverlay("lock");
+ } else {
+ resetTimerAndUnblank();
+ }
+}
diff --git a/gui/blanktimer.hpp b/gui/blanktimer.hpp
index 5e617901f..fe7b77c17 100644
--- a/gui/blanktimer.hpp
+++ b/gui/blanktimer.hpp
@@ -37,11 +37,15 @@ public:
// call this when an input event is received or when an operation is finished
void resetTimerAndUnblank();
+ // call this when power button is pressed
+ void toggleBlank(void);
+
bool isScreenOff();
private:
void setTimer(void);
string getBrightness(void);
+ void blank(void);
pthread_mutex_t mutex;
enum State { kOn = 0, kDim = 1, kOff = 2, kBlanked = 3 };
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 17ed108fc..3f1312f46 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -205,7 +205,9 @@ bool InputHandler::processInput(int timeout_ms)
break;
}
- blankTimer.resetTimerAndUnblank();
+ if (ev.code != KEY_POWER && ev.code > KEY_RESERVED)
+ blankTimer.resetTimerAndUnblank();
+
return true; // we got an event, so there might be more in the queue
}
diff --git a/gui/objects.hpp b/gui/objects.hpp
index f1c9c49dd..28ed29cdb 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -363,6 +363,7 @@ protected:
int checkpartitionlifetimewrites(std::string arg);
int mountsystemtoggle(std::string arg);
int setlanguage(std::string arg);
+ int togglebacklight(std::string arg);
int twcmd(std::string arg);
int setbootslot(std::string arg);
int installapp(std::string arg);
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index 3aed1981e..b0e4238b8 100644
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -3517,6 +3517,11 @@
<text>{@swipe_to_unlock=Swipe to Unlock}</text>
<action function="overlay"/>
</slider>
+
+ <action>
+ <touch key="power"/>
+ <action function="togglebacklight"/>
+ </action>
</page>
<page name="filemanagerlist">
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index 80e358b77..7e30be41e 100644
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -3779,6 +3779,11 @@
<text>{@swipe_to_unlock=Swipe to Unlock}</text>
<action function="overlay"/>
</slider>
+
+ <action>
+ <touch key="power"/>
+ <action function="togglebacklight"/>
+ </action>
</page>
<page name="filemanagerlist">
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index 921e72c60..a62b2b393 100644
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -4424,6 +4424,11 @@
<text>{@swipe_unlock= Unlock}</text>
<action function="overlay"/>
</slider>
+
+ <action>
+ <touch key="power"/>
+ <action function="togglebacklight"/>
+ </action>
</page>
<page name="filemanagerlist">
diff --git a/gui/theme/landscape_hdpi/ui.xml b/gui/theme/landscape_hdpi/ui.xml
index 2e263520a..16efc8812 100644
--- a/gui/theme/landscape_hdpi/ui.xml
+++ b/gui/theme/landscape_hdpi/ui.xml
@@ -432,7 +432,7 @@
<action>
<touch key="power"/>
- <action function="overlay">lock</action>
+ <action function="togglebacklight"/>
</action>
<action>
diff --git a/gui/theme/landscape_mdpi/ui.xml b/gui/theme/landscape_mdpi/ui.xml
index 8b63dcbfd..bb8f1726a 100644
--- a/gui/theme/landscape_mdpi/ui.xml
+++ b/gui/theme/landscape_mdpi/ui.xml
@@ -432,7 +432,7 @@
<action>
<touch key="power"/>
- <action function="overlay">lock</action>
+ <action function="togglebacklight"/>
</action>
<action>
diff --git a/gui/theme/portrait_hdpi/ui.xml b/gui/theme/portrait_hdpi/ui.xml
index a5ee22cd4..67eaa5aaf 100644
--- a/gui/theme/portrait_hdpi/ui.xml
+++ b/gui/theme/portrait_hdpi/ui.xml
@@ -336,7 +336,7 @@
<action>
<touch key="power"/>
- <action function="overlay">lock</action>
+ <action function="togglebacklight"/>
</action>
<action>
diff --git a/gui/theme/portrait_mdpi/ui.xml b/gui/theme/portrait_mdpi/ui.xml
index 9a0adf334..8d424dbd5 100644
--- a/gui/theme/portrait_mdpi/ui.xml
+++ b/gui/theme/portrait_mdpi/ui.xml
@@ -336,7 +336,7 @@
<action>
<touch key="power"/>
- <action function="overlay">lock</action>
+ <action function="togglebacklight"/>
</action>
<action>
diff --git a/gui/theme/watch_mdpi/ui.xml b/gui/theme/watch_mdpi/ui.xml
index c56610bf2..b2f069d09 100644
--- a/gui/theme/watch_mdpi/ui.xml
+++ b/gui/theme/watch_mdpi/ui.xml
@@ -258,7 +258,7 @@
<action>
<touch key="power"/>
- <action function="overlay">lock</action>
+ <action function="togglebacklight"/>
</action>
<action>