Debian Codegraph @

src/backend/imageGrabber/X11Wrapper.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2017 Damir Porobic <https://github.com/damirporobic>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef X11WRAPPER_H
21 #define X11WRAPPER_H
22
23 #include <xcb/xfixes.h>
24
25 // Can't include <QtGlobal> for QT_VERSION_CHECK because it includes too much,
26 // and symbols conflict with X11. Can't include <QtVersionChecks> because it
27 // doesn't exist in Qt 5.
28 #include "BuildConfig.h"
29 #if KSNIP_QT6
30 #include <QtGui/private/qtx11extras_p.h>
31 #else
32 #include <QX11Info>
33 #endif
34
35 #include "src/common/dtos/CursorDto.h"
36
37 class X11Wrapper
38 {
39 public:
40 X11Wrapper() = default;
41 ~X11Wrapper() = default;
42 virtual bool isCompositorActive() const;
43 virtual QRect getFullScreenRect() const;
44 virtual QRect getActiveWindowRect() const;
45 virtual CursorDto getCursorWithPosition() const;
46
47 protected:
48 QPoint getNativeCursorPosition() const;
49 QRect getWindowRect(xcb_window_t window) const;
50 xcb_window_t getActiveWindowId() const;
51 };
52
53 /*
54 * QScopedPointer class overwritten to free pointers that need to be freed by
55 * free() instead of delete.
56 */
57 template <typename T>
58 class ScopedCPointer : public QScopedPointer<T, QScopedPointerPodDeleter>
59 {
60 public:
61 explicit ScopedCPointer(T *p = 0) : QScopedPointer<T, QScopedPointerPodDeleter>(p) {}
62 };
63
64 #endif // X11WRAPPER_H