Added GrabGuard class

This commit is contained in:
fluxgen 2002-01-20 02:09:40 +00:00
parent 6c10acb3cb
commit fdb6b3f41b

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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_ #ifndef _BASEDISPLAY_HH_
#define _BASEDISPLAY_HH_ #define _BASEDISPLAY_HH_
@ -31,11 +31,11 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
// forward declaration // forward declaration
class BaseDisplay;
class ScreenInfo; class ScreenInfo;
#include "LinkedList.hh" #include "LinkedList.hh"
#include "Timer.hh" #include "Timer.hh"
#include "NotCopyable.hh"
#define PropBlackboxHintsElements (5) #define PropBlackboxHintsElements (5)
@ -45,6 +45,7 @@ class ScreenInfo;
void bexec(const char *, char *); void bexec(const char *, char *);
#endif // !__EMX__ #endif // !__EMX__
template <typename Z> inline Z min(Z a, Z b) { return ((a < b) ? a : b); } 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); } template <typename Z> inline Z max(Z a, Z b) { return ((a > b) ? a : b); }
@ -257,6 +258,17 @@ public:
// doesn't understand itself // doesn't understand itself
virtual Bool handleSignal(int) = 0; 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: private:
struct cursor { struct cursor {
Cursor session, move, ll_angle, lr_angle; Cursor session, move, ll_angle, lr_angle;