Changeset View
Changeset View
Standalone View
Standalone View
src/Platforms/PlatformKWinWayland.cpp
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | |||||
79 | 79 | | |||
80 | QString PlatformKWinWayland::platformName() const | 80 | QString PlatformKWinWayland::platformName() const | ||
81 | { | 81 | { | ||
82 | return QStringLiteral("KWinWayland"); | 82 | return QStringLiteral("KWinWayland"); | ||
83 | } | 83 | } | ||
84 | 84 | | |||
85 | Platform::GrabModes PlatformKWinWayland::supportedGrabModes() const | 85 | Platform::GrabModes PlatformKWinWayland::supportedGrabModes() const | ||
86 | { | 86 | { | ||
87 | Platform::GrabModes lSupportedModes({ GrabMode::AllScreens, GrabMode::WindowUnderCursor }); | 87 | Platform::GrabModes lSupportedModes({ Platform::GrabMode::CurrentScreen, GrabMode::WindowUnderCursor }); | ||
88 | if (QApplication::screens().count() > 1) { | 88 | if (QApplication::screens().count() > 1) { | ||
89 | lSupportedModes |= Platform::GrabMode::CurrentScreen; | 89 | lSupportedModes |= Platform::GrabMode::AllScreens; | ||
90 | lSupportedModes |= Platform::GrabMode::AllScreensNativeSize; | ||||
meven: Please notes this changes the default grab mode "One screen fullscreen" from `GrabMode… | |||||
90 | } | 91 | } | ||
91 | return lSupportedModes; | 92 | return lSupportedModes; | ||
92 | } | 93 | } | ||
93 | 94 | | |||
94 | static QPair<int,int> s_plasmaVersion = {-1, -1}; | 95 | static QPair<int,int> s_plasmaVersion = {-1, -1}; | ||
95 | QPair<int, int> findPlasmaMinorVersion () { | 96 | QPair<int, int> findPlasmaMinorVersion () { | ||
96 | if (s_plasmaVersion == QPair<int, int>(-1, -1)) { | 97 | if (s_plasmaVersion == QPair<int, int>(-1, -1)) { | ||
97 | auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), | 98 | auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 135 | { | |||
139 | } else { | 140 | } else { | ||
140 | return { ShutterMode::OnClick }; | 141 | return { ShutterMode::OnClick }; | ||
141 | } | 142 | } | ||
142 | } | 143 | } | ||
143 | 144 | | |||
144 | void PlatformKWinWayland::doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) | 145 | void PlatformKWinWayland::doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) | ||
145 | { | 146 | { | ||
146 | switch(theGrabMode) { | 147 | switch(theGrabMode) { | ||
147 | case GrabMode::AllScreens: { | 148 | case GrabMode::AllScreens: | ||
148 | doGrabHelper(QStringLiteral("screenshotFullscreen"), theIncludePointer); | 149 | return doGrabHelper(QStringLiteral("screenshotFullscreen"), theIncludePointer, false); | ||
149 | return; | 150 | case GrabMode::AllScreensNativeSize: | ||
150 | } | 151 | return doGrabHelper(QStringLiteral("screenshotFullscreen"), theIncludePointer, true); | ||
151 | case GrabMode::CurrentScreen: { | 152 | break; | ||
152 | doGrabHelper(QStringLiteral("screenshotScreen"), theIncludePointer); | 153 | case GrabMode::CurrentScreen: | ||
153 | return; | 154 | return doGrabHelper(QStringLiteral("screenshotScreen"), theIncludePointer); | ||
154 | } | | |||
155 | case GrabMode::WindowUnderCursor: { | 155 | case GrabMode::WindowUnderCursor: { | ||
156 | int lOpMask = theIncludeDecorations ? 1 : 0; | 156 | int lOpMask = theIncludeDecorations ? 1 : 0; | ||
157 | if (theIncludePointer) { | 157 | if (theIncludePointer) { | ||
158 | lOpMask |= 1 << 1; | 158 | lOpMask |= 1 << 1; | ||
159 | } | 159 | } | ||
160 | doGrabHelper(QStringLiteral("interactive"), lOpMask); | 160 | doGrabHelper(QStringLiteral("interactive"), lOpMask); | ||
161 | return; | 161 | return; | ||
162 | } | 162 | } | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 208 | if (pipe2(lPipeFds, O_CLOEXEC|O_NONBLOCK) != 0) { | |||
210 | return; | 210 | return; | ||
211 | } | 211 | } | ||
212 | 212 | | |||
213 | callDBus(theGrabMethod, theArgument, lPipeFds[1]); | 213 | callDBus(theGrabMethod, theArgument, lPipeFds[1]); | ||
214 | startReadImage(lPipeFds[0]); | 214 | startReadImage(lPipeFds[0]); | ||
215 | 215 | | |||
216 | close(lPipeFds[1]); | 216 | close(lPipeFds[1]); | ||
217 | } | 217 | } | ||
218 | | ||||
219 | template <typename ArgType, typename ArgType2> | ||||
220 | void PlatformKWinWayland::callDBus(const QString &theGrabMethod, ArgType theArgument, ArgType2 theSecondArgument, int theWriteFile) | ||||
221 | { | ||||
222 | QDBusInterface lInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QStringLiteral("org.kde.kwin.Screenshot")); | ||||
223 | lInterface.asyncCall(theGrabMethod, QVariant::fromValue(QDBusUnixFileDescriptor(theWriteFile)), theArgument, theSecondArgument ); | ||||
224 | } | ||||
225 | | ||||
226 | template <typename ArgType, typename ArgType2> | ||||
227 | void PlatformKWinWayland::doGrabHelper(const QString &theGrabMethod, ArgType theArgument, ArgType2 theSecondArgument) | ||||
228 | { | ||||
229 | int lPipeFds[2]; | ||||
230 | if (pipe2(lPipeFds, O_CLOEXEC|O_NONBLOCK) != 0) { | ||||
231 | emit newScreenshotFailed(); | ||||
232 | return; | ||||
233 | } | ||||
234 | | ||||
235 | callDBus(theGrabMethod, theArgument, theSecondArgument, lPipeFds[1]); | ||||
236 | startReadImage(lPipeFds[0]); | ||||
237 | | ||||
238 | close(lPipeFds[1]); | ||||
239 | } |
Please notes this changes the default grab mode "One screen fullscreen" from GrabMode::AllScreens to Platform::GrabMode::CurrentScreen.
This is because GrabMode::AllScreens is now rendered with scaling applied by default, whereas Platform::GrabMode::CurrentScreen is not.
It will change the wording to the user other than nothing really.