Skip to content

Commit

Permalink
Merge branch 'mer1831_tkunlock_in_display_off' into 'master'
Browse files Browse the repository at this point in the history
Handle display wakeup to dimmed state

See merge request !73
  • Loading branch information
spiiroin committed Feb 20, 2018
2 parents b6fe13b + acf8ec0 commit 18c1315
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 18c1315

Please sign in to comment.