diff --git a/backends/hwcomposer/hwcomposer_backend.cpp b/backends/hwcomposer/hwcomposer_backend.cpp
index 45a20cc746..538b31440e 100644
--- a/backends/hwcomposer/hwcomposer_backend.cpp
+++ b/backends/hwcomposer/hwcomposer_backend.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see .
#include "hwcomposer_backend.h"
#include "logging.h"
#include "screens_hwcomposer.h"
+#include "composite.h"
#include "wayland_server.h"
// KWayland
#include
@@ -298,6 +299,12 @@ void HwcomposerBackend::inputEvent(Event *event, void *context)
if (key == KEY_RESERVED) {
break;
}
+ if (key == KEY_POWER) {
+ // this key is handled internally
+ // TODO: trigger timer to decide what should be done: short press/release (un)blank screen
+ // long press should emit the normal key pressed
+ break;
+ }
backend->keyboardKeyPressed(key, event->details.key.event_time);
break;
}
@@ -306,6 +313,11 @@ void HwcomposerBackend::inputEvent(Event *event, void *context)
if (key == KEY_RESERVED) {
break;
}
+ if (key == KEY_POWER) {
+ // this key is handled internally
+ QMetaObject::invokeMethod(backend, "toggleBlankOutput", Qt::QueuedConnection);
+ break;
+ }
backend->keyboardKeyReleased(key, event->details.key.event_time);
break;
}
@@ -405,7 +417,8 @@ void HwcomposerBackend::init()
}
// unblank, setPowerMode?
- hwcDevice->blank(hwcDevice, 0, 0);
+ m_device = hwcDevice;
+ toggleBlankOutput();
// get display configuration
auto output = createOutput(hwcDevice);
@@ -415,7 +428,6 @@ void HwcomposerBackend::init()
}
m_displaySize = output->pixelSize();
qCDebug(KWIN_HWCOMPOSER) << "Display size:" << m_displaySize;
- m_device = hwcDevice;
initInput();
@@ -447,6 +459,24 @@ void HwcomposerBackend::initInput()
waylandServer()->seat()->setHasTouch(true);
}
+void HwcomposerBackend::toggleBlankOutput()
+{
+ if (!m_device) {
+ return;
+ }
+ m_outputBlank = !m_outputBlank;
+ m_device->blank(m_device, 0, m_outputBlank ? 1 : 0);
+ // enable/disable compositor repainting when blanked
+ if (Compositor *compositor = Compositor::self()) {
+ if (m_outputBlank) {
+ compositor->aboutToSwapBuffers();
+ } else {
+ compositor->bufferSwapComplete();
+ compositor->addRepaintFull();
+ }
+ }
+}
+
HwcomposerWindow *HwcomposerBackend::createSurface()
{
return new HwcomposerWindow(this);
diff --git a/backends/hwcomposer/hwcomposer_backend.h b/backends/hwcomposer/hwcomposer_backend.h
index de240090b4..96a0a214b1 100644
--- a/backends/hwcomposer/hwcomposer_backend.h
+++ b/backends/hwcomposer/hwcomposer_backend.h
@@ -60,12 +60,16 @@ public:
return m_device;
}
+private Q_SLOTS:
+ void toggleBlankOutput();
+
private:
static void inputEvent(Event *event, void *context);
void initInput();
QSize m_displaySize;
hwc_composer_device_1_t *m_device = nullptr;
AndroidEventListener *m_inputListener = nullptr;
+ bool m_outputBlank = true;
};
class HwcomposerWindow : public HWComposerNativeWindow