Make smart hide more perfect

This commit is contained in:
reionwong 2021-09-06 02:15:53 +08:00
parent f0c473507a
commit 0dbc91c371

View file

@ -47,6 +47,8 @@ MainWindow::MainWindow(QQuickView *parent)
{
new DockAdaptor(this);
installEventFilter(this);
setDefaultAlphaBuffer(false);
setColor(Qt::transparent);
@ -256,8 +258,6 @@ void MainWindow::clearViewStruts()
void MainWindow::createFakeWindow()
{
if (!m_fakeWindow) {
installEventFilter(this);
m_fakeWindow = new FakeWindow;
m_fakeWindow->setScreen(screen());
m_fakeWindow->updateGeometry();
@ -292,7 +292,7 @@ void MainWindow::createFakeWindow()
void MainWindow::deleteFakeWindow()
{
if (m_fakeWindow) {
removeEventFilter(this);
// removeEventFilter(this);
disconnect(m_fakeWindow);
m_fakeWindow->deleteLater();
m_fakeWindow = nullptr;
@ -373,9 +373,6 @@ void MainWindow::onVisibilityChanged()
clearViewStruts();
setGeometry(windowRect());
if (!m_fakeWindow && !m_activity->existsWindowMaximized())
m_hideBlocked = false;
if (m_activity->existsWindowMaximized() && !m_hideBlocked) {
setVisible(false);
} else {
@ -412,19 +409,23 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *e)
{
switch (e->type()) {
case QEvent::Enter:
if (m_fakeWindow)
m_hideTimer->stop();
m_hideBlocked = true;
break;
case QEvent::Leave:
if (m_fakeWindow)
m_hideTimer->start();
m_hideBlocked = false;
break;
case QEvent::DragEnter:
case QEvent::DragMove:
if (m_fakeWindow)
m_hideTimer->stop();
break;
case QEvent::DragLeave:
case QEvent::Drop:
if (m_fakeWindow)
m_hideTimer->stop();
break;
default: