File indexing completed on 2022-11-23 12:13:07

0001 /********************************************************************
0002  KSld - the KDE Screenlocker Daemon
0003  This file is part of the KDE project.
0004 
0005 Copyright (C) 1999 Martin R. Jones <mjones@kde.org>
0006 Copyright (C) 2002 Luboš Luňák <l.lunak@kde.org>
0007 Copyright (C) 2003 Oswald Buddenhagen <ossi@kde.org>
0008 Copyright (C) 2008 Chani Armitage <chanika@gmail.com>
0009 Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.org>
0010 
0011 This program is free software; you can redistribute it and/or modify
0012 it under the terms of the GNU General Public License as published by
0013 the Free Software Foundation; either version 2 of the License, or
0014 (at your option) any later version.
0015 
0016 This program is distributed in the hope that it will be useful,
0017 but WITHOUT ANY WARRANTY; without even the implied warranty of
0018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0019 GNU General Public License for more details.
0020 
0021 You should have received a copy of the GNU General Public License
0022 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0023 *********************************************************************/
0024 #ifndef SCREENLOCKER_LOCKWINDOW_H
0025 #define SCREENLOCKER_LOCKWINDOW_H
0026 
0027 #include "abstractlocker.h"
0028 
0029 #include <QAbstractNativeEventFilter>
0030 #include <X11/Xlib.h>
0031 #include <fixx11h.h>
0032 
0033 namespace ScreenLocker
0034 {
0035 class AbstractLocker;
0036 
0037 class X11Locker : public AbstractLocker, public QAbstractNativeEventFilter
0038 {
0039     Q_OBJECT
0040 public:
0041     explicit X11Locker(QObject *parent = nullptr);
0042     ~X11Locker() override;
0043 
0044     void showLockWindow() override;
0045     void hideLockWindow() override;
0046 
0047     void addAllowedWindow(quint32 window) override;
0048 
0049 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0050     bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
0051 #else
0052     bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
0053 #endif
0054 
0055 private Q_SLOTS:
0056     void updateGeo();
0057 
0058 private:
0059     void initialize();
0060     void saveVRoot();
0061     void setVRoot(Window win, Window vr);
0062     void removeVRoot(Window win);
0063     int findWindowInfo(Window w);
0064     void fakeFocusIn(WId window);
0065     void stayOnTop() override;
0066     struct WindowInfo {
0067         Window window;
0068         bool viewable;
0069     };
0070     QList<WindowInfo> m_windowInfo;
0071     QList<WId> m_lockWindows;
0072     QList<quint32> m_allowedWindows;
0073     WId m_focusedLockWindow;
0074 };
0075 }
0076 
0077 #endif // SCREENLOCKER_LOCKWINDOW_H