Git commit f5848bef6999a93c93f033e8e7cd425260db8e0c by Boudhayan Gupta. Committed on 07/07/2015 at 16:04. Pushed by bgupta into branch 'master'.
Abort On-Click on non-left clicks M +1 -1 doc/index.docbook M +11 -3 src/PlatformBackends/X11ImageGrabber.cpp http://commits.kde.org/kscreengenie/f5848bef6999a93c93f033e8e7cd425260db8e0c diff --git a/doc/index.docbook b/doc/index.docbook index 6185420..9120978 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -149,7 +149,7 @@ <para>The <guilabel>Delay</guilabel> spin-box allows you to set the delay between pressing the <guibutton>Take New Screenshot</guibutton> (<keycombo action="simul">&Ctrl;<keycap>N</keycap></keycombo>) button and taking the screenshot. This delay can be set in increments of 0.1 seconds, or 100 milliseconds.</para> - <para>Enabling the <guilabel>On Click</guilabel> checkbox overrides the delay. When this checkbox is enabled, pressing the <guibutton>Take New Screenshot</guibutton> (<keycombo action="simul">&Ctrl;<keycap>N</keycap></keycombo>) button hides the &kscreengenie; window and changes the mouse cursor to a crosshair. The screenshot is captured when the mouse is clicked. Note that you cannot interact with the desktop using the mouse while the cursor is a crosshair, but you can use the keyboard.</para> + <para>Enabling the <guilabel>On Click</guilabel> checkbox overrides the delay. When this checkbox is enabled, pressing the <guibutton>Take New Screenshot</guibutton> (<keycombo action="simul">&Ctrl;<keycap>N</keycap></keycombo>) button hides the &kscreengenie; window and changes the mouse cursor to a crosshair. The screenshot is captured when the mouse is left-clicked, or aborted if the mouse is right-clicked. Note that you cannot interact with the desktop using the mouse while the cursor is a crosshair, but you can use the keyboard.</para> </sect2> <sect2> diff --git a/src/PlatformBackends/X11ImageGrabber.cpp b/src/PlatformBackends/X11ImageGrabber.cpp index 22fa177..354b984 100644 --- a/src/PlatformBackends/X11ImageGrabber.cpp +++ b/src/PlatformBackends/X11ImageGrabber.cpp @@ -55,15 +55,23 @@ bool OnClickEventFilter::nativeEventFilter(const QByteArray &eventType, void *me case XCB_BUTTON_RELEASE: // uninstall the event filter first + qApp->removeNativeEventFilter(this); // ungrab the mouse + xcb_ungrab_pointer(QX11Info::connection(), XCB_TIME_CURRENT_TIME); - // grab the image - QMetaObject::invokeMethod(mImageGrabber, "doImageGrab", Qt::QueuedConnection); + // decide whether to grab or abort - // done + { + xcb_button_release_event_t *ev2 = static_cast<xcb_button_release_event_t *>(message); + if (ev2->state == XCB_BUTTON_MASK_1) { + QMetaObject::invokeMethod(mImageGrabber, "doImageGrab", Qt::QueuedConnection); + } else { + emit mImageGrabber->imageGrabFailed(); + } + } return true; default: return false;
