From e96ff7a31a39eef2f41e570969017e153f1f8829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 11 Dec 2012 21:09:58 +0100 Subject: [PATCH] Introduce an XServerGrabber helper class Performs grabXServer in ctor and ungrabXServer in dtor. Useful to ensure that each grab is matched by an ungrab. --- utils.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utils.h b/utils.h index d880e08b8e..5b68d57a41 100644 --- a/utils.h +++ b/utils.h @@ -286,6 +286,22 @@ bool grabbedXServer(); bool grabXKeyboard(Window w = rootWindow()); void ungrabXKeyboard(); +/** + * Small helper class which performs @link grabXServer in the ctor and + * @link ungrabXServer in the dtor. Use this class to ensure that grab and + * ungrab are matched. + **/ +class XServerGrabber +{ +public: + XServerGrabber() { + grabXServer(); + } + ~XServerGrabber() { + ungrabXServer(); + } +}; + // the docs say it's UrgencyHint, but it's often #defined as XUrgencyHint #ifndef UrgencyHint #define UrgencyHint XUrgencyHint