Introduce an XServerGrabber helper class

Performs grabXServer in ctor and ungrabXServer in dtor. Useful to ensure
that each grab is matched by an ungrab.
icc-effect-5.14.5
Martin Gräßlin 2012-12-11 21:09:58 +01:00
parent 41f6a2c7d2
commit e96ff7a31a
1 changed files with 16 additions and 0 deletions

16
utils.h
View File

@ -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