Changeset View
Changeset View
Standalone View
Standalone View
src/Platforms/PlatformXcb.h
- This file was added.
1 | /* This file is part of Spectacle, the KDE screenshot utility | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 Boudhayan Gupta <bgupta@kde.org> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Lesser 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 Lesser 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 | * SPDX-License-Identifier: LGPL-2.0-or-later | ||||
20 | */ | ||||
21 | | ||||
22 | #pragma once | ||||
23 | | ||||
24 | #include "Platform.h" | ||||
25 | | ||||
26 | #include <xcb/xcb.h> | ||||
27 | #include <xcb/xcb_image.h> | ||||
28 | | ||||
29 | #include <QPixmap> | ||||
30 | | ||||
31 | class PlatformXcb final: public Platform | ||||
32 | { | ||||
33 | Q_OBJECT | ||||
34 | | ||||
35 | public: | ||||
36 | | ||||
37 | explicit PlatformXcb(QObject *parent = nullptr); | ||||
38 | virtual ~PlatformXcb(); | ||||
39 | | ||||
40 | QString platformName() const override final; | ||||
41 | GrabModes supportedGrabModes() const override final; | ||||
42 | ShutterModes supportedShutterModes() const override final; | ||||
43 | | ||||
44 | public Q_SLOTS: | ||||
45 | | ||||
46 | void doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) override final; | ||||
47 | | ||||
48 | private Q_SLOTS: | ||||
49 | | ||||
50 | void handleKWinScreenshotReply(quint64 theDrawable); | ||||
51 | void doGrabNow(const GrabMode &theGrabMode, bool theIncludePointer, bool theIncludeDecorations); | ||||
52 | void doGrabOnClick(const GrabMode &theGrabMode, bool theIncludePointer, bool theIncludeDecorations); | ||||
53 | | ||||
54 | private: | ||||
55 | | ||||
56 | inline void updateWindowTitle(xcb_window_t theWindow); | ||||
57 | bool isKWinAvailable(); | ||||
58 | QPoint getCursorPosition(); | ||||
59 | QRect getDrawableGeometry(xcb_drawable_t theDrawable); | ||||
60 | xcb_window_t getWindowUnderCursor(); | ||||
61 | xcb_window_t getTransientWindowParent(xcb_window_t theChildWindow, QRect &theWindowRectOut, bool theIncludeDectorations); | ||||
62 | QPixmap convertFromNative(xcb_image_t *theXcbImage); | ||||
63 | QPixmap blendCursorImage(QPixmap &thePixmap, const QRect theRect); | ||||
64 | QPixmap postProcessPixmap(QPixmap &thePixmap, QRect theRect, bool theBlendPointer); | ||||
65 | QPixmap getPixmapFromDrawable(xcb_drawable_t theXcbDrawable, const QRect &theRect); | ||||
66 | QPixmap getToplevelPixmap(QRect theRect, bool theBlendPointer); | ||||
67 | QPixmap getWindowPixmap(xcb_window_t theWindow, bool theBlendPointer); | ||||
68 | | ||||
69 | void grabAllScreens(bool theIncludePointer); | ||||
70 | void grabCurrentScreen(bool theIncludePointer); | ||||
71 | void grabApplicationWindow(xcb_window_t theWindow, bool theIncludePointer, bool theIncludeDecorations); | ||||
72 | void grabActiveWindow(bool theIncludePointer, bool theIncludeDecorations); | ||||
73 | void grabWindowUnderCursor(bool theIncludePointer, bool theIncludeDecorations); | ||||
74 | void grabTransientWithParent(bool theIncludePointer, bool theIncludeDecorations); | ||||
75 | | ||||
76 | // on-click screenshot shutter support needs a native event filter in xcb | ||||
77 | class OnClickEventFilter; | ||||
78 | OnClickEventFilter *mNativeEventFilter; | ||||
79 | }; |