Disabling Swipe from a Fullscreen Game
The swipe is really annoying feature in fullscreen gaming (antsnes for example). Instead of controlling the game you might end up swiping the game into the background, which is not cool. Luckily the swipe can be disabled quite easily from QWidget based classes.
Here’s how you can disable the swipe:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void disableSwipe()
{
QWidget * activeWindow = QApplication::activeWindow();
Display *dpy = QX11Info::display();
Atom atom;
unsigned int customRegion[4];
customRegion[0] = 0;
customRegion[1] = 0;
customRegion[2] = 854;
customRegion[3] = 480;
atom = XInternAtom(dpy, "_MEEGOTOUCH_CUSTOM_REGION", False);
XChangeProperty(dpy, activeWindow->effectiveWinId(),
atom, XA_CARDINAL, 32, PropModeReplace,
reinterpret_cast<unsigned char *>(&customRegion[0]), 4);
}
And here’s an example of enabling it:
1
2
3
4
5
6
7
8
9
10
void enableSwipe()
{
QWidget * activeWindow = QApplication::activeWindow();
Display *dpy = QX11Info::display();
Atom atom;
atom = XInternAtom(dpy, "_MEEGOTOUCH_CUSTOM_REGION", False);
if(XDeleteProperty(dpy, activeWindow->effectiveWinId(), atom) < 0){
qWarning("XDeleteProperty for _MEEGOTOUCH_CUSTOM_REGION returns <0");
}
}
This post is licensed under CC BY 4.0 by the author.