00001
00002
00003
00004
00005
00006 #ifndef __KERNEL_H
00007 #define __KERNEL_H
00008
00009 #include "singleton.h"
00010
00011 extern "C" {
00012 #include <X11/Xlib.h>
00013 }
00014
00015
00016 #include <list>
00017 #include <string>
00018 #include <map>
00019
00020 #include "ncwm.h"
00021
00022
00023 class Action;
00024 class Bar;
00025 class Box;
00026 class Client;
00027 template <class P, class LT, class LTI, class T> class Container;
00028 class Frame;
00029 class Kernel;
00030 class Menu;
00031 class Monitor;
00032 class Prompt;
00033 class Rectangle;
00034 class Shortcut;
00035 #ifdef SLOT_SUPPORT
00036 class Slot;
00037 #endif // SLOT_SUPPORT
00038 class Thing;
00039 class Workspace;
00040
00041 typedef list<Action *> LAction;
00042 typedef list<Monitor *> LMonitor;
00043 typedef map<string, string, less<string> > MSettings;
00044 typedef map<string, Action *, less<string> > MBindings;
00045 typedef Container<Kernel, LMonitor, LMonitor::iterator, Monitor> CMonitor;
00046
00051 class Kernel : public Singleton<Kernel>
00052 {
00053
00054 public:
00055
00057 Kernel();
00058
00059 ~Kernel();
00060
00062 MSettings *themeSettings();
00063
00064 MSettings *commonSettings();
00065
00066 MSettings *actionSettings();
00067
00068 MSettings *sessionSettings();
00069
00071 Display *display() const;
00072
00074 Monitor *focusedMonitor() const;
00075
00077 bool isInputMode();
00078
00080 Client *focusedClient();
00081
00082 void killClient(Client *client);
00083
00085 Window rootWindow();
00086
00088 Window defaultRootWindow();
00089
00091 enum Runlevel {START, RUN, STOP, RESTART};
00092
00093 Runlevel runlevel() const;
00094
00096 int start(char *argv[],
00097 Display *display,
00098 MSettings *themeSettings,
00099 MSettings *commonSettings,
00100 MSettings *actionSettings,
00101 MSettings *sessionSettings,
00102 bool isFirstRun = false);
00103
00104 void stop();
00105 void restart();
00106
00108 void updateBars();
00109
00111 void saveSettings();
00112
00113 MBindings *actionBindings() const;
00114
00116 bool isRootWindow(Window window);
00117
00119 Bar *barWindow(Window window);
00120
00122 Box *boxWindow(Window window);
00123
00125 Menu *menuWindow(Window window);
00126
00127 #ifdef SLOT_SUPPORT
00128
00129 Slot *slotWindow(Window window);
00130 #endif // SLOT_SUPPORT
00131
00133 Thing *thingWindow(Window window);
00134
00136 bool isNCWMWindow(Window window);
00137
00139 Client *clientForWindow(Window window);
00140
00142 void bindShortcut(string argument);
00143
00144 void installCursor(Cursor cursor, Window window);
00145
00147 void addClient(Client *client);
00148
00150 int run();
00151
00153 void runResizeMode(Thing *thing, XButtonEvent *buttonEvent,
00154 Direction dir, bool resize = false);
00155
00156 bool isRecording() const;
00157
00158 LAction *recordedActions();
00159
00160 void beginRecording();
00161 void endChainRecording(string name);
00162 void endScriptRecording(string name);
00163 void cancelRecording();
00164
00165
00166 unsigned int borderWidth() const;
00167
00168 void cleanup();
00169
00170 Prompt *Kernel::defaultPrompt() const;
00171
00172 void setMenuMode(bool isMenuMode);
00173
00174 void toggleSloppyMode();
00175
00176 bool isStackedTabbing() const;
00177
00178 void toggleShortcuts();
00179
00180 CMonitor *monitors() const;
00181 void selectMonitor(string displayString);
00182
00185 void grabMove();
00186
00187 private:
00188
00190 void handleButtonPress(XButtonEvent *event);
00191 void handleButtonRelease(XButtonEvent *event);
00192 void handleConfigureRequest(XConfigureRequestEvent *event);
00193 void handleClientMessage(XClientMessageEvent *event);
00194 void handleCreateNotify(XCreateWindowEvent *event);
00195 void handleDestroyNotify(XDestroyWindowEvent *event);
00196 void handleExpose(XExposeEvent *event);
00197 void handleKeyPress(XKeyEvent *event);
00198 void handleMapRequest(XMapRequestEvent *event);
00199 void handleMotionNotify(XMotionEvent *event);
00200 void handlePropertyNotify(XPropertyEvent *event);
00201 void handleUnmapNotify(XUnmapEvent *event);
00202
00204 void initAtoms();
00205
00207 void initMonitors();
00208
00210 void initWindows();
00211
00213 void initActionBindings();
00214
00216 void initKeys();
00217
00219 void grabShortcutOnAllMonitors(Shortcut *shortcut);
00220
00222 void ungrabShortcutOnAllMonitors(Shortcut *shortcut);
00223
00227 void serialize();
00228
00229 bool isSloppyMode_;
00230 bool isRecording_;
00231 LAction recordedActions_;
00232 Display *display_;
00233 CMonitor *monitors_;
00234
00235 unsigned int borderWidth_;
00236 bool isMenuMode_;
00237 bool isStackedTabbing_;
00238
00239
00240 MSettings *themeSettings_;
00241 MSettings *commonSettings_;
00242 MSettings *actionSettings_;
00243 MSettings *sessionSettings_;
00244
00245
00246 MBindings *actionBindings_;
00247
00248 Runlevel runlevel_;
00249 Prompt *defaultPrompt_;
00250
00251 };
00252
00253 #endif // __KERNEL_H