storing layouts in window properties and restoring when Jrugr restarted
[jrugr.git] / src / jrugr.h
blob47bff039b95b49a8f69946d59e957c658fb9a23a
1 ////////////////////////////////////////
2 // Copyright : GPL //
3 ////////////////////////////////////////
4 #ifndef JRUGR_H
5 #define JRUGR_H
7 #define K8_MPLAYER_HACK
8 #define MPLAYER_HACK_TIMEOUT (300)
11 #include "jrugrdefs.h"
12 #include "xkeyboard.h"
13 #include "x11tools.h"
14 #include "jcfg.h"
15 #include "jrugrconfui.h"
17 #include <QAbstractEventDispatcher>
18 #ifdef K8_MPLAYER_HACK
19 # include <QTimer>
20 #endif
23 typedef struct {
24 Window w;
25 Window appWindow;
26 int layout; // language for this window
27 } WinInfo;
30 typedef QHash<Window, WinInfo *> QWIHash;
31 typedef QHashIterator<Window, WinInfo *> QWIHashIterator;
32 typedef QMutableHashIterator<Window, WinInfo *> QWIHashMutableIterator;
35 class Jrugr : public QApplication {
36 Q_OBJECT
38 public:
39 Jrugr (int &argc, char **argv);
40 ~Jrugr ();
42 bool firstStart ();
43 void startup ();
44 void initialize ();
46 signals:
47 void changeLayout (int index);
48 void activeWindowChanged ();
49 void activeDesktopChanged ();
50 void clientListChanged ();
52 public slots:
53 void onLayoutChanged ();
54 void onGroupChanged (int index);
55 void setNextGroup ();
56 void setPrevGroup ();
57 void trayClicked (QSystemTrayIcon::ActivationReason reason);
59 protected slots:
60 void reconfigure ();
62 private slots:
63 void actionsActivate (QAction *action);
64 void onChangeLayout (int index);
66 void doActiveWindowChanged ();
67 void doActiveDesktopChanged ();
68 void onClientListChanged ();
70 #ifdef K8_MPLAYER_HACK
71 void onMPFix ();
72 #endif
74 protected:
75 virtual bool x11EventFilter (XEvent *);
77 void mousePressEvent (QMouseEvent *);
78 int setKeyLayout (QString keyConf);
79 void configure ();
80 void configureXkb ();
82 private:
83 void buildIcon ();
84 void createMenu ();
85 bool loadRules ();
87 QIcon langIcon (const QString &lsym, int wdt=32, int hgt=22, bool noFlag=false); // get icon for language defined by it's sym ("us", etc)
89 void onActiveWindowChanged (Window w);
90 void onActiveDesktopChanged (int desk);
92 void installFacehuggers ();
94 bool isKnownWindow (Window w) const;
95 bool isKnownApp (Window w) const;
97 WinInfo *findWindowInfo (Window w);
98 WinInfo *findAppInfo (Window w); // find application info for the given window
100 int desktopLayout (int desk) const;
101 void setDesktopLayout (int desk, int group);
103 Window deskActiveWindow (int desk);
104 void setDeskActiveWindow (int desk, Window w);
106 void windowDies (Window w);
108 #ifdef K8_MPLAYER_HACK
109 bool deactivateMPlayer ();
110 #endif
112 int layIndex (Window w, const QString &propname, bool unknownIsZero=false) const;
114 private:
115 QAbstractEventDispatcher *mEDisp;
117 QString mLangThemePath;
118 QXkbLayoutList mGroupInfo; // list of all active groups (those that can be activated)
119 int mActiveGroup; // currently active group
121 XKeyboard *mXkb;
122 QSystemTrayIcon *mTrayIcon;
123 QMenu *mTrayMenu;
125 JrugrCfg *jCfg;
127 QWIHash mKnownWindows;
128 QWIHash mKnownApps;
129 QList<int> mDeskLangs;
130 QList<Window> mDeskActiveWindows;
132 int mCurDesk;
133 Window mActiveWindow;
135 bool mDeskJustChanged;
137 QString mCfgFileName;
139 #ifdef K8_MPLAYER_HACK
140 bool mMplayerHack;
141 QTimer *mMPFix;
142 #endif
146 #endif