From fdb6b3f41b0fc45ffc2b31454807b32dd5b5bbf6 Mon Sep 17 00:00:00 2001
From: fluxgen <fluxgen>
Date: Sun, 20 Jan 2002 02:09:40 +0000
Subject: Added GrabGuard class

---
 src/BaseDisplay.hh | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/BaseDisplay.hh b/src/BaseDisplay.hh
index 8513699..3165aae 100644
--- a/src/BaseDisplay.hh
+++ b/src/BaseDisplay.hh
@@ -22,7 +22,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: BaseDisplay.hh,v 1.6 2002/01/10 12:52:51 fluxgen Exp $
+// $Id: BaseDisplay.hh,v 1.7 2002/01/20 02:09:40 fluxgen Exp $
 
 #ifndef   _BASEDISPLAY_HH_
 #define   _BASEDISPLAY_HH_
@@ -31,11 +31,11 @@
 #include <X11/Xatom.h>
 
 // forward declaration
-class BaseDisplay;
 class ScreenInfo;
 
 #include "LinkedList.hh"
 #include "Timer.hh"
+#include "NotCopyable.hh"
 
 
 #define PropBlackboxHintsElements      (5)
@@ -45,6 +45,7 @@ class ScreenInfo;
 void bexec(const char *, char *);
 #endif // !__EMX__
 
+
 template <typename Z> inline Z min(Z a, Z b) { return ((a < b) ? a : b); }
 template <typename Z> inline Z max(Z a, Z b) { return ((a > b) ? a : b); }
 
@@ -256,7 +257,18 @@ public:
   // another pure virtual... this is used to handle signals that BaseDisplay
   // doesn't understand itself
   virtual Bool handleSignal(int) = 0;
-	
+
+	class GrabGuard:private NotCopyable
+	{
+		public:
+		GrabGuard(BaseDisplay &bd):m_bd(bd) { }
+		~GrabGuard() { m_bd.ungrab(); }
+		inline void grab() { m_bd.grab(); }		
+		inline void ungrab() { m_bd.ungrab(); }		
+		private:
+		BaseDisplay &m_bd;
+	};
+
 private:
   struct cursor {
     Cursor session, move, ll_angle, lr_angle;
-- 
cgit v0.11.2