File indexing completed on 2024-12-22 04:31:07

0001 /*
0002  * Copyright (C) 2021 CutefishOS Team.
0003  *
0004  * Author:     cutefish <cutefishos@foxmail.com>
0005  *
0006  * This program is free software: you can redistribute it and/or modify
0007  * it under the terms of the GNU General Public License as published by
0008  * the Free Software Foundation, either version 3 of the License, or
0009  * any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #ifndef WINDOWHELPER_H
0021 #define WINDOWHELPER_H
0022 
0023 #include <QObject>
0024 #include <QWindow>
0025 #include <xcb/xcb.h>
0026 
0027 class WindowHelper : public QObject
0028 {
0029     Q_OBJECT
0030     Q_PROPERTY(bool compositing READ compositing NOTIFY compositingChanged)
0031 
0032 public:
0033     explicit WindowHelper(QObject *parent = nullptr);
0034 
0035     bool compositing() const;
0036 
0037     Q_INVOKABLE void startSystemMove(QWindow *w);
0038     Q_INVOKABLE void startSystemResize(QWindow *w, Qt::Edges edges);
0039 
0040     Q_INVOKABLE void minimizeWindow(QWindow *w);
0041 
0042 signals:
0043     void compositingChanged();
0044 
0045 private:
0046     void doStartSystemMoveResize(QWindow *w, int edges);
0047     void onCompositingChanged(bool enabled);
0048 
0049 private:
0050     xcb_atom_t m_moveResizeAtom;
0051     bool m_compositing;
0052 };
0053 
0054 #endif // WINDOWHELPER_H