1 #ifndef WMAPP_H 2 #define WMAPP_H 3 4 #include "ysmapp.h" 5 #include "ymsgbox.h" 6 #include "guievent.h" 7 #include "yicon.h" 8 9 class YWindowManager; 10 class AboutDlg; 11 class CtrlAltDelete; 12 13 enum FocusModel { 14 FocusCustom, 15 FocusClick, 16 FocusSloppy, 17 FocusExplicit, 18 FocusStrict, 19 FocusQuiet, 20 FocusModelLast = FocusQuiet 21 }; 22 23 class YSMListener { 24 public: 25 virtual void handleSMAction(WMAction message) = 0; 26 virtual void restartClient(const char *path, char *const *args) = 0; 27 virtual int runProgram(const char *path, const char *const *args, int fd) = 0; 28 virtual void runCommand(const char *prog) = 0; 29 virtual void runOnce(const char *resource, long *pid, 30 const char *path, char *const *args) = 0; 31 virtual void runCommandOnce(const char *resource, const char *cmdline, long *pid) = 0; 32 protected: ~YSMListener()33 virtual ~YSMListener() {} 34 }; 35 36 class YWMApp: 37 public YSMApplication, 38 public YActionListener, 39 public YMsgBoxListener, 40 public YSMListener, 41 public YTimerListener 42 { 43 typedef YSMApplication super; 44 45 public: 46 YWMApp(int *argc, char ***argv, const char *displayName, 47 bool notifyParent, const char *splashFile, 48 const char *configFile, const char *overrideTheme); 49 ~YWMApp(); 50 void signalGuiEvent(GUIEvent ge); 51 int mainLoop(); 52 53 virtual void afterWindowEvent(XEvent &xev); 54 virtual void handleSignal(int sig); 55 virtual bool handleIdle(); 56 virtual bool filterEvent(const XEvent &xev); 57 virtual void actionPerformed(YAction action, unsigned int modifiers = 0); 58 59 virtual void handleMsgBox(YMsgBox *msgbox, int operation); 60 virtual void handleSMAction(WMAction message); 61 62 void doLogout(RebootShutdown reboot); 63 void logout(); 64 void cancelLogout(); 65 66 #ifdef CONFIG_SESSION 67 virtual void smSaveYourselfPhase2(); 68 virtual void smDie(); 69 #endif 70 71 void setFocusMode(FocusModel mode); 72 void initFocusMode(); 73 void initFocusCustom(); 74 FocusModel loadFocusMode(); 75 76 virtual void restartClient(const char *path, char *const *args); 77 virtual int runProgram(const char *path, const char *const *args, int fd = -1); 78 virtual void runOnce(const char *resource, long *pid, 79 const char *path, char *const *args); 80 virtual void runCommand(const char *prog); 81 virtual void runCommandOnce(const char *resource, const char *cmdline, long *pid); 82 bool mapClientByPid(const char* resource, long pid); 83 bool mapClientByResource(const char* resource, long *pid); 84 85 static YCursor leftPointer; 86 static YCursor rightPointer; 87 static YCursor movePointer; 88 static YCursor sizeRightPointer; 89 static YCursor sizeTopRightPointer; 90 static YCursor sizeTopPointer; 91 static YCursor sizeTopLeftPointer; 92 static YCursor sizeLeftPointer; 93 static YCursor sizeBottomLeftPointer; 94 static YCursor sizeBottomPointer; 95 static YCursor sizeBottomRightPointer; 96 static YCursor scrollLeftPointer; 97 static YCursor scrollRightPointer; 98 static YCursor scrollUpPointer; 99 static YCursor scrollDownPointer; 100 101 ref<YIcon> getDefaultAppIcon(); 102 hasCtrlAltDelete()103 bool hasCtrlAltDelete() const { return ctrlAltDelete != nullptr; } 104 CtrlAltDelete* getCtrlAltDelete(); getConfigFile()105 const char* getConfigFile() const { return configFile; } getFocusMode()106 FocusModel getFocusMode() const { return focusMode; } 107 YMenu* getWindowMenu(); 108 void subdirs(const char* subdir, bool themeOnly, MStringArray& paths); 109 void unregisterProtocols(); 110 void refreshDesktop(); 111 112 private: 113 char** mainArgv; 114 int mainArgc; 115 const char* configFile; 116 bool notifyParent; 117 pid_t notifiedParent; 118 119 // XXX: these pointers are PITA because they can become wild when objects 120 // are destroyed independently by manager. What we need is something like std::weak_ptr... 121 YMsgBox *fLogoutMsgBox; 122 YMsgBox* fRestartMsgBox; 123 AboutDlg* aboutDlg; 124 125 CtrlAltDelete* ctrlAltDelete; 126 YMenu* windowMenu; 127 int errorRequestCode; 128 YFrameWindow* errorFrame; 129 lazy<YTimer> errorTimer; 130 lazy<YTimer> pathsTimer; 131 lazy<YTimer> splashTimer; 132 lazy<YWindow> splashWindow; 133 lazy<GuiSignaler> guiSignaler; 134 135 void createTaskBar(); 136 YWindow* splash(const char* splashFile); getRightPointer()137 virtual Cursor getRightPointer() const { return rightPointer; } 138 virtual bool handleTimer(YTimer *timer); 139 virtual int handleError(XErrorEvent *xev); 140 void runRestart(const char *path, char *const *args); 141 142 FocusModel focusMode; 143 Window managerWindow; 144 ref<YIcon> defaultAppIcon; 145 146 MStringArray resourcePaths; 147 YArray<bool> themeOnlyPath; 148 149 void freePointers(); 150 void initPointers(); 151 void initIcons(); 152 void initIconSize(); 153 }; 154 155 extern YWMApp * wmapp; 156 157 #ifdef WMPROG_H 158 class RootMenu : public StartMenu { 159 public: RootMenu()160 RootMenu() : StartMenu(wmapp, wmapp, wmapp, "menu") { 161 setShared(true); 162 } 163 }; 164 extern lazily<RootMenu> rootMenu; 165 #endif 166 167 #ifdef WMWINMENU_H 168 class SharedWindowList : public WindowListMenu { 169 public: SharedWindowList()170 SharedWindowList() : WindowListMenu(wmapp) { 171 setShared(true); 172 } 173 }; 174 extern lazily<SharedWindowList> windowListMenu; 175 #endif 176 177 class SharedMenu : public YMenu { 178 public: SharedMenu()179 SharedMenu() { setShared(true); } 180 }; 181 182 class LogoutMenu : public SharedMenu { 183 public: 184 void updatePopup(); 185 }; 186 extern lazy<LogoutMenu> logoutMenu; 187 188 class LayerMenu : public SharedMenu { 189 public: 190 void updatePopup(); 191 }; 192 extern lazy<LayerMenu> layerMenu; 193 194 class MoveMenu : public SharedMenu { 195 public: 196 void updatePopup(); 197 }; 198 extern lazy<MoveMenu> moveMenu; 199 200 class TileMenu : public SharedMenu { 201 public: 202 void updatePopup(); 203 }; 204 extern lazy<TileMenu> tileMenu; 205 206 class KProgram; 207 typedef YObjectArray<KProgram> KProgramArrayType; 208 typedef KProgramArrayType::IterType KProgramIterType; 209 extern KProgramArrayType keyProgs; 210 211 extern RebootShutdown rebootOrShutdown; 212 213 #endif 214 215 // vim: set sw=4 ts=4 et: 216