Skip to content

Commit

Permalink
[lipstick] Handle display wakeup to dimmed state. MER#1831
Browse files Browse the repository at this point in the history
Waking display directly to dimmed state is handled incorrectly
in the sense that application logic listening to displayOn and
displayOff signals is left believeing that the display is still
off.

Treat the "dimmed" and "on" display states as equals for the
purposes of emitting of displayOn and displayOff signals,

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Feb 20, 2018
1 parent b6fe13b commit acf8ec0
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/compositor/lipstickcompositor.cpp
Expand Up @@ -103,6 +103,16 @@ LipstickCompositor::LipstickCompositor()
setClientFullScreenHint(true);
}

static inline bool displayStateIsDimmed(TouchScreen::DisplayState state)
{
return state == TouchScreen::DisplayDimmed;
}

static bool displayStateIsOn(TouchScreen::DisplayState state)
{
return state == TouchScreen::DisplayOn || state == TouchScreen::DisplayDimmed;
}

LipstickCompositor::~LipstickCompositor()
{
// ~QWindow can a call into onVisibleChanged and QWaylandCompositor after we
Expand Down Expand Up @@ -610,7 +620,7 @@ void LipstickCompositor::setScreenOrientation(Qt::ScreenOrientation screenOrient
bool LipstickCompositor::displayDimmed() const
{
TouchScreen *touchScreen = HomeApplication::instance()->touchScreen();
return touchScreen->currentDisplayState() == TouchScreen::DisplayDimmed;
return displayStateIsDimmed(touchScreen->currentDisplayState());
}

LipstickKeymap *LipstickCompositor::keymap() const
Expand Down Expand Up @@ -657,15 +667,22 @@ void LipstickCompositor::updateKeymap()

void LipstickCompositor::reactOnDisplayStateChanges(TouchScreen::DisplayState oldState, TouchScreen::DisplayState newState)
{
if (newState == TouchScreen::DisplayOn) {
emit displayOn();
} else if (newState == TouchScreen::DisplayOff) {
QCoreApplication::postEvent(this, new QTouchEvent(QEvent::TouchCancel));
emit displayOff();
bool oldOn = displayStateIsOn(oldState);
bool newOn = displayStateIsOn(newState);

if (oldOn != newOn) {
if (newOn) {
emit displayOn();
} else {
QCoreApplication::postEvent(this, new QTouchEvent(QEvent::TouchCancel));
emit displayOff();
}
}

bool changeInDimming = (newState == TouchScreen::DisplayDimmed) != (oldState == TouchScreen::DisplayDimmed);
if (changeInDimming) {
bool oldDimmed = displayStateIsDimmed(oldState);
bool newDimmed = displayStateIsDimmed(newState);

if (oldDimmed != newDimmed) {
emit displayDimmedChanged();
}
}
Expand Down

0 comments on commit acf8ec0

Please sign in to comment.