fix(ESC key failure issue): The ESC button fails in the Wayland environment
Description: The ESC button fails in the Wayland environment Log: wayland环境下esc按键失效问题 Bug: 无
This commit is contained in:
parent
3da041e518
commit
36d65049a0
|
@ -40,6 +40,7 @@
|
|||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
#include <KWindowSystem>
|
||||
#include <QKeyEvent>
|
||||
#include "commonfunc.h"
|
||||
#include "screensavermode.h"
|
||||
#include "screensaverwidget.h"
|
||||
|
@ -135,7 +136,7 @@ bool FullBackgroundWidget::eventFilter(QObject *obj, QEvent *event)
|
|||
static bool isFirstActive = true;
|
||||
|
||||
if (!QX11Info::isPlatformX11()) {
|
||||
if(event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseMove || event->type() == 7){
|
||||
if(event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseMove/* || event->type() == 7*/){
|
||||
if(screenStatus & SCREEN_SAVER && !isBlank){
|
||||
onClearScreensaver();
|
||||
}
|
||||
|
@ -551,6 +552,21 @@ void FullBackgroundWidget::showEvent(QShowEvent *event)
|
|||
KWindowSystem::setType(this->winId(), NET::ScreenLock);
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::keyReleaseEvent(QKeyEvent *e)
|
||||
{
|
||||
if (!QX11Info::isPlatformX11()) {
|
||||
if(e->key() == Qt::Key_Escape && screenStatus == SCREEN_LOCK) { // "escape"
|
||||
bool canShow = true;
|
||||
if (m_lockWidget && !m_lockWidget->exitSubWidget())
|
||||
canShow = false;
|
||||
if (canShow)
|
||||
onShowScreensaver();
|
||||
} else if(screenStatus & SCREEN_SAVER/* && !isBlank*/) {
|
||||
onClearScreensaver();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::tryGrabKeyboard()
|
||||
{
|
||||
if (window()->windowHandle() && window()->windowHandle()->setKeyboardGrabEnabled(true)) {
|
||||
|
|
|
@ -97,6 +97,7 @@ protected:
|
|||
void mousePressEvent(QMouseEvent *e);
|
||||
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *e);
|
||||
private:
|
||||
void initUI();
|
||||
void initConnections();
|
||||
|
|
Loading…
Reference in New Issue