  
  bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
    // wake screen on tap
    if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::TouchBegin) {
      device.setAwake(true, true);
    }
  
  #ifdef QCOM
    // filter out touches while in android activity
    const static QSet<QEvent::Type> filter_events({QEvent::MouseButtonPress, QEvent::MouseMove, QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd});
 
</s> remove   // wake screen on tap
 </s> add  </s> remove   device.setAwake(true, true);
 </s> add  </s> remove   awake_timeout = std::max(awake_timeout - 1, 0);

  bool should_wake = s.scene.started || s.scene.ignition;
  if (!should_wake) {
    // tap detection while display is off
    bool accel_trigger = abs(s.scene.accel_sensor - accel_prev) > 0.2;
    bool gyro_trigger = abs(s.scene.gyro_sensor - gyro_prev) > 0.15;
    should_wake = accel_trigger && gyro_trigger;
    gyro_prev = s.scene.gyro_sensor;
    accel_prev = (accel_prev * (accel_samples - 1) + s.scene.accel_sensor) / accel_samples;
 </s> add   bool ignition_just_turned_off = !s.scene.ignition && ignition_on;
  ignition_on = s.scene.ignition;

  if (ignition_just_turned_off || motionTriggered(s)) {
    resetInteractiveTimout();
  } else if (interactive_timeout > 0 && --interactive_timeout == 0) {
    emit interactiveTimout(); </s> remove   QObject::connect(&device, &Device::displayPowerChanged, [=]() {
     if(main_layout->currentWidget() != onboardingWindow) {
       closeSettings();
     }
 </s> add   QObject::connect(&device, &Device::interactiveTimout, [=]() {
    if (main_layout->currentWidget() == settingsWindow) {
      closeSettings();
    }
    device.resetInteractiveTimout();
  
  bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
    // wake screen on tap
    if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::TouchBegin) {
    device.resetInteractiveTimout();
    }
  
  #ifdef QCOM
    // filter out touches while in android activity
    const static QSet<QEvent::Type> filter_events({QEvent::MouseButtonPress, QEvent::MouseMove, QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd});
keep keep keep keep replace keep keep keep keep keep
  UI: add timeout to close settings window while onroad (#22980)

* refactor updateWakefulness

* don't hide sidebar

* rename reset->reset_timeout

* move related variables and functions into class Device

* reset timeout in ctor

* set timeout to 10s if ignition is on

* cleanup

* remove unused QTimer *timer

* check getTimestamp

* keep socket reading in update_state

* keep filtering

Co-authored-by: Willem Melching <willem.melching@gmail.com> 
selfdrive/ui/qt/window.cc