Mapped rocker switch to favorite keysets
[pierogi] / pirapplication.cpp
1 #include "pirapplication.h"
2
3 #include <QWidget>
4 #include <X11/Xlib.h>
5 #include <X11/Xatom.h>
6 #include <QX11Info>
7
8 PIRApplication::PIRApplication(
9   int &argc,
10   char **argv)
11   : QApplication(argc, argv)
12 {
13 }
14
15
16 void PIRApplication::setupRockerSwitch(QWidget *window)
17 {
18   // free the rocker switch from the volume controls:
19   unsigned long val = 1;
20
21   Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", 0);
22
23   XChangeProperty( 
24     QX11Info::display(),
25     window->winId(),
26     atom,
27     XA_INTEGER,
28     32,
29     PropModeReplace,
30     (unsigned char *) &val,
31     1);
32 }
33
34
35 bool PIRApplication::x11EventFilter(
36   XEvent *event)
37 {
38   // Return true means we will consume the event here; return false means
39   // letting the event continue to be passed up the chain.
40
41   if (event->type == KeyPress)
42   {
43     // Check for function key 7 (keycode 73) or for "Zoom Out" button:
44     if (
45       event->xkey.keycode == 73 ||
46       event->xkey.keycode == QKeySequence::ZoomOut)
47     {
48       emit decreaseRockerPressed();
49       return true;
50     }
51     else if (
52       event->xkey.keycode == 74 ||
53       event->xkey.keycode == QKeySequence::ZoomIn)
54     {
55       emit increaseRockerPressed();
56       return true;
57     }
58   }
59
60   return false;
61 }