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; | ||
meven: Please notes this changes the default grab mode "One screen fullscreen" from `GrabMode… | |||||
90 | lSupportedModes |= Platform::GrabMode::AllScreensNativeSize; | ||||
90 | } | 91 | } | ||
91 | return lSupportedModes; | 92 | return lSupportedModes; | ||
92 | } | 93 | } | ||
93 | 94 | | |||
94 | Platform::ShutterModes PlatformKWinWayland::supportedShutterModes() const | 95 | Platform::ShutterModes PlatformKWinWayland::supportedShutterModes() const | ||
95 | { | 96 | { | ||
96 | return { ShutterMode::OnClick }; | 97 | return { ShutterMode::OnClick }; | ||
97 | } | 98 | } | ||
98 | 99 | | |||
99 | void PlatformKWinWayland::doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) | 100 | void PlatformKWinWayland::doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) | ||
100 | { | 101 | { | ||
101 | if (theShutterMode != ShutterMode::OnClick) { | 102 | if (theShutterMode != ShutterMode::OnClick) { | ||
102 | emit newScreenshotFailed(); | 103 | emit newScreenshotFailed(); | ||
103 | return; | 104 | return; | ||
104 | } | 105 | } | ||
105 | 106 | | |||
106 | switch(theGrabMode) { | 107 | switch(theGrabMode) { | ||
107 | case GrabMode::AllScreens: | 108 | case GrabMode::AllScreens: | ||
108 | return doGrabHelper(QStringLiteral("screenshotFullscreen"), theIncludePointer); | 109 | return doGrabHelper(QStringLiteral("screenshotFullscreen"), theIncludePointer, false); | ||
110 | case GrabMode::AllScreensNativeSize: | ||||
111 | return doGrabHelper(QStringLiteral("screenshotFullscreen"), theIncludePointer, true); | ||||
112 | break; | ||||
109 | case GrabMode::CurrentScreen: | 113 | case GrabMode::CurrentScreen: | ||
110 | return doGrabHelper(QStringLiteral("screenshotScreen"), theIncludePointer); | 114 | return doGrabHelper(QStringLiteral("screenshotScreen"), theIncludePointer); | ||
111 | case GrabMode::WindowUnderCursor: { | 115 | case GrabMode::WindowUnderCursor: { | ||
112 | int lOpMask = theIncludeDecorations ? 1 : 0; | 116 | int lOpMask = theIncludeDecorations ? 1 : 0; | ||
113 | if (theIncludePointer) { | 117 | if (theIncludePointer) { | ||
114 | lOpMask |= 1 << 1; | 118 | lOpMask |= 1 << 1; | ||
115 | } | 119 | } | ||
116 | return doGrabHelper(QStringLiteral("interactive"), lOpMask); | 120 | return doGrabHelper(QStringLiteral("interactive"), lOpMask); | ||
Show All 37 Lines | 156 | if (pipe2(lPipeFds, O_CLOEXEC|O_NONBLOCK) != 0) { | |||
154 | return; | 158 | return; | ||
155 | } | 159 | } | ||
156 | 160 | | |||
157 | callDBus(theGrabMethod, theArgument, lPipeFds[1]); | 161 | callDBus(theGrabMethod, theArgument, lPipeFds[1]); | ||
158 | startReadImage(lPipeFds[0]); | 162 | startReadImage(lPipeFds[0]); | ||
159 | 163 | | |||
160 | close(lPipeFds[1]); | 164 | close(lPipeFds[1]); | ||
161 | } | 165 | } | ||
166 | | ||||
167 | template <typename ArgType, typename ArgType2> | ||||
168 | void PlatformKWinWayland::callDBus(const QString &theGrabMethod, ArgType theArgument, ArgType2 theSecondArgument, int theWriteFile) | ||||
169 | { | ||||
170 | QDBusInterface lInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QStringLiteral("org.kde.kwin.Screenshot")); | ||||
171 | lInterface.asyncCall(theGrabMethod, QVariant::fromValue(QDBusUnixFileDescriptor(theWriteFile)), theArgument, theSecondArgument ); | ||||
172 | } | ||||
173 | | ||||
174 | template <typename ArgType, typename ArgType2> | ||||
175 | void PlatformKWinWayland::doGrabHelper(const QString &theGrabMethod, ArgType theArgument, ArgType2 theSecondArgument) | ||||
176 | { | ||||
177 | int lPipeFds[2]; | ||||
178 | if (pipe2(lPipeFds, O_CLOEXEC|O_NONBLOCK) != 0) { | ||||
179 | emit newScreenshotFailed(); | ||||
180 | return; | ||||
181 | } | ||||
182 | | ||||
183 | callDBus(theGrabMethod, theArgument, theSecondArgument, lPipeFds[1]); | ||||
184 | startReadImage(lPipeFds[0]); | ||||
185 | | ||||
186 | close(lPipeFds[1]); | ||||
187 | } |
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.