diff --git a/src/Platforms/Platform.h b/src/Platforms/Platform.h index 71b24ae..ba31633 100644 --- a/src/Platforms/Platform.h +++ b/src/Platforms/Platform.h @@ -1,70 +1,70 @@ /* This file is part of Spectacle, the KDE screenshot utility * Copyright (C) 2019 Boudhayan Gupta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * * SPDX-License-Identifier: LGPL-2.0-or-later */ #pragma once #include #include class Platform: public QObject { Q_OBJECT public: enum class GrabMode { InvalidChoice = 0x00, AllScreens = 0x01, CurrentScreen = 0x02, ActiveWindow = 0x04, WindowUnderCursor = 0x08, TransientWithParent = 0x10 }; using GrabModes = QFlags; Q_FLAG(GrabModes) enum class ShutterMode { Immediate = 0x01, OnClick = 0x02 }; using ShutterModes = QFlags; Q_FLAG(ShutterModes) explicit Platform(QObject *parent = nullptr); virtual ~Platform() = default; virtual QString platformName() const = 0; virtual GrabModes supportedGrabModes() const = 0; virtual ShutterModes supportedShutterModes() const = 0; public Q_SLOTS: - virtual void doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) = 0; + virtual void doGrab(Platform::ShutterMode theShutterMode, Platform::GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) = 0; Q_SIGNALS: void newScreenshotTaken(const QPixmap &thePixmap); void newScreenshotFailed(); void windowTitleChanged(const QString &theWindowTitle); }; Q_DECLARE_OPERATORS_FOR_FLAGS(Platform::GrabModes) Q_DECLARE_OPERATORS_FOR_FLAGS(Platform::ShutterModes) diff --git a/src/Platforms/PlatformKWinWayland.h b/src/Platforms/PlatformKWinWayland.h index d0d21b0..6ec1fb9 100644 --- a/src/Platforms/PlatformKWinWayland.h +++ b/src/Platforms/PlatformKWinWayland.h @@ -1,48 +1,48 @@ /* This file is part of Spectacle, the KDE screenshot utility * Copyright (C) 2016 Martin Graesslin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * * SPDX-License-Identifier: LGPL-2.0-or-later */ #pragma once #include "Platform.h" class PlatformKWinWayland final: public Platform { Q_OBJECT public: explicit PlatformKWinWayland(QObject *parent = nullptr); virtual ~PlatformKWinWayland() = default; QString platformName() const override final; GrabModes supportedGrabModes() const override final; ShutterModes supportedShutterModes() const override final; public Q_SLOTS: - void doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) override final; + void doGrab(Platform::ShutterMode theShutterMode, Platform::GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) override final; private: void startReadImage(int theReadPipe); template void doGrabHelper(const QString &theGrabMethod, ArgType theArgument); template void callDBus(const QString &theGrabMethod, ArgType theArgument, int theWriteFile); }; diff --git a/src/Platforms/PlatformNull.h b/src/Platforms/PlatformNull.h index 6b55ba4..518e1ba 100644 --- a/src/Platforms/PlatformNull.h +++ b/src/Platforms/PlatformNull.h @@ -1,42 +1,42 @@ /* This file is part of Spectacle, the KDE screenshot utility * Copyright (C) 2019 Boudhayan Gupta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * * SPDX-License-Identifier: LGPL-2.0-or-later */ #pragma once #include "Platform.h" class PlatformNull final: public Platform { Q_OBJECT public: explicit PlatformNull(QObject *parent = nullptr); virtual ~PlatformNull() = default; QString platformName() const override final; GrabModes supportedGrabModes() const override final; ShutterModes supportedShutterModes() const override final; public Q_SLOTS: - void doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) override final; + void doGrab(Platform::ShutterMode theShutterMode, Platform::GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) override final; }; diff --git a/src/Platforms/PlatformXcb.h b/src/Platforms/PlatformXcb.h index e3cb74d..11b5ba2 100644 --- a/src/Platforms/PlatformXcb.h +++ b/src/Platforms/PlatformXcb.h @@ -1,79 +1,79 @@ /* This file is part of Spectacle, the KDE screenshot utility * Copyright (C) 2019 Boudhayan Gupta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * * SPDX-License-Identifier: LGPL-2.0-or-later */ #pragma once #include "Platform.h" #include #include #include class PlatformXcb final: public Platform { Q_OBJECT public: explicit PlatformXcb(QObject *parent = nullptr); virtual ~PlatformXcb(); QString platformName() const override final; GrabModes supportedGrabModes() const override final; ShutterModes supportedShutterModes() const override final; public Q_SLOTS: - void doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) override final; + void doGrab(Platform::ShutterMode theShutterMode, Platform::GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) override final; private Q_SLOTS: void handleKWinScreenshotReply(quint64 theDrawable); - void doGrabNow(const GrabMode &theGrabMode, bool theIncludePointer, bool theIncludeDecorations); - void doGrabOnClick(const GrabMode &theGrabMode, bool theIncludePointer, bool theIncludeDecorations); + void doGrabNow(const Platform::GrabMode &theGrabMode, bool theIncludePointer, bool theIncludeDecorations); + void doGrabOnClick(const Platform::GrabMode &theGrabMode, bool theIncludePointer, bool theIncludeDecorations); private: inline void updateWindowTitle(xcb_window_t theWindow); bool isKWinAvailable(); QPoint getCursorPosition(); QRect getDrawableGeometry(xcb_drawable_t theDrawable); xcb_window_t getWindowUnderCursor(); xcb_window_t getTransientWindowParent(xcb_window_t theChildWindow, QRect &theWindowRectOut, bool theIncludeDectorations); QPixmap convertFromNative(xcb_image_t *theXcbImage); QPixmap blendCursorImage(QPixmap &thePixmap, const QRect theRect); QPixmap postProcessPixmap(QPixmap &thePixmap, QRect theRect, bool theBlendPointer); QPixmap getPixmapFromDrawable(xcb_drawable_t theXcbDrawable, const QRect &theRect); QPixmap getToplevelPixmap(QRect theRect, bool theBlendPointer); QPixmap getWindowPixmap(xcb_window_t theWindow, bool theBlendPointer); void grabAllScreens(bool theIncludePointer); void grabCurrentScreen(bool theIncludePointer); void grabApplicationWindow(xcb_window_t theWindow, bool theIncludePointer, bool theIncludeDecorations); void grabActiveWindow(bool theIncludePointer, bool theIncludeDecorations); void grabWindowUnderCursor(bool theIncludePointer, bool theIncludeDecorations); void grabTransientWithParent(bool theIncludePointer, bool theIncludeDecorations); // on-click screenshot shutter support needs a native event filter in xcb class OnClickEventFilter; OnClickEventFilter *mNativeEventFilter; };