diff options
author | fluxgen <fluxgen> | 2002-08-13 21:19:00 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-08-13 21:19:00 (GMT) |
commit | e7f5d341bc713762caceb3e3a570306df94629e5 (patch) | |
tree | 309170931fde46448d133ef21a7b640488401028 /src | |
parent | 7b02be7b19fbd696c2ca804d77bd28532956eac4 (diff) | |
download | fluxbox_paul-e7f5d341bc713762caceb3e3a570306df94629e5.zip fluxbox_paul-e7f5d341bc713762caceb3e3a570306df94629e5.tar.bz2 |
removed friend main
Diffstat (limited to 'src')
-rw-r--r-- | src/fluxbox.cc | 65 | ||||
-rw-r--r-- | src/fluxbox.hh | 23 |
2 files changed, 40 insertions, 48 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 8d2d57c..c45c340 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -22,28 +22,15 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: fluxbox.cc,v 1.65 2002/08/11 20:38:23 fluxgen Exp $ | 25 | // $Id: fluxbox.cc,v 1.66 2002/08/13 21:19:00 fluxgen Exp $ |
26 | 26 | ||
27 | //Use GNU extensions | 27 | #include "fluxbox.hh" |
28 | #ifndef _GNU_SOURCE | ||
29 | #define _GNU_SOURCE | ||
30 | #endif // _GNU_SOURCE | ||
31 | |||
32 | #ifdef HAVE_CONFIG_H | ||
33 | # include "../config.h" | ||
34 | #endif // HAVE_CONFIG_H | ||
35 | 28 | ||
36 | #include "i18n.hh" | 29 | #include "i18n.hh" |
37 | #include "fluxbox.hh" | ||
38 | #include "Basemenu.hh" | 30 | #include "Basemenu.hh" |
39 | #include "Clientmenu.hh" | 31 | #include "Clientmenu.hh" |
40 | #include "Rootmenu.hh" | 32 | #include "Rootmenu.hh" |
41 | #include "Screen.hh" | 33 | #include "Screen.hh" |
42 | |||
43 | #ifdef SLIT | ||
44 | #include "Slit.hh" | ||
45 | #endif // SLIT | ||
46 | |||
47 | #include "Toolbar.hh" | 34 | #include "Toolbar.hh" |
48 | #include "Window.hh" | 35 | #include "Window.hh" |
49 | #include "Workspace.hh" | 36 | #include "Workspace.hh" |
@@ -52,6 +39,19 @@ | |||
52 | #include "Resource.hh" | 39 | #include "Resource.hh" |
53 | #include "XrmDatabaseHelper.hh" | 40 | #include "XrmDatabaseHelper.hh" |
54 | 41 | ||
42 | #ifdef SLIT | ||
43 | #include "Slit.hh" | ||
44 | #endif // SLIT | ||
45 | |||
46 | //Use GNU extensions | ||
47 | #ifndef _GNU_SOURCE | ||
48 | #define _GNU_SOURCE | ||
49 | #endif // _GNU_SOURCE | ||
50 | |||
51 | #ifdef HAVE_CONFIG_H | ||
52 | #include "../config.h" | ||
53 | #endif // HAVE_CONFIG_H | ||
54 | |||
55 | #include <X11/Xlib.h> | 55 | #include <X11/Xlib.h> |
56 | #include <X11/Xutil.h> | 56 | #include <X11/Xutil.h> |
57 | #include <X11/Xresource.h> | 57 | #include <X11/Xresource.h> |
@@ -63,11 +63,8 @@ | |||
63 | #endif // SHAPE | 63 | #endif // SHAPE |
64 | 64 | ||
65 | #include <cstdio> | 65 | #include <cstdio> |
66 | 66 | #include <cstdlib> | |
67 | #ifdef STDC_HEADERS | 67 | #include <cstring> |
68 | #include <stdlib.h> | ||
69 | #include <string.h> | ||
70 | #endif // STDC_HEADERS | ||
71 | 68 | ||
72 | #ifdef HAVE_UNISTD_H | 69 | #ifdef HAVE_UNISTD_H |
73 | #include <sys/types.h> | 70 | #include <sys/types.h> |
@@ -284,19 +281,12 @@ getString() { | |||
284 | //static singleton var | 281 | //static singleton var |
285 | Fluxbox *Fluxbox::singleton=0; | 282 | Fluxbox *Fluxbox::singleton=0; |
286 | 283 | ||
287 | //------------ instance --------------------- | ||
288 | //returns singleton object of Fluxbox class | ||
289 | //since we only need to create one instance of Fluxbox | ||
290 | //------------------------------------------- | ||
291 | Fluxbox *Fluxbox::instance(int m_argc, char **m_argv, char *dpy_name, char *rc) { | ||
292 | return singleton; | ||
293 | } | ||
294 | //default values for titlebar left and right | 284 | //default values for titlebar left and right |
295 | //don't forget to change last value in m_rc_titlebar_* if you add more to these | 285 | //don't forget to change last value in m_rc_titlebar_* if you add more to these |
296 | Fluxbox::Titlebar Fluxbox::m_titlebar_left[] = {STICK}; | 286 | Fluxbox::Titlebar Fluxbox::m_titlebar_left[] = {STICK}; |
297 | Fluxbox::Titlebar Fluxbox::m_titlebar_right[] = {MINIMIZE, MAXIMIZE, CLOSE}; | 287 | Fluxbox::Titlebar Fluxbox::m_titlebar_right[] = {MINIMIZE, MAXIMIZE, CLOSE}; |
298 | 288 | ||
299 | Fluxbox::Fluxbox(int m_argc, char **m_argv, char *dpy_name, char *rc) | 289 | Fluxbox::Fluxbox(int m_argc, char **m_argv, const char *dpy_name, const char *rc) |
300 | : BaseDisplay(m_argv[0], dpy_name), | 290 | : BaseDisplay(m_argv[0], dpy_name), |
301 | m_resourcemanager(), m_screen_rm(), | 291 | m_resourcemanager(), m_screen_rm(), |
302 | m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"), | 292 | m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"), |
@@ -314,11 +304,16 @@ m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), | |||
314 | focused_window(0), masked_window(0), | 304 | focused_window(0), masked_window(0), |
315 | timer(this), | 305 | timer(this), |
316 | no_focus(false), | 306 | no_focus(false), |
317 | rc_file(rc), | 307 | rc_file(rc ? rc : ""), |
318 | argv(m_argv), argc(m_argc), | 308 | argv(m_argv), argc(m_argc), |
319 | key(0) | 309 | key(0) |
320 | { | 310 | { |
321 | 311 | ||
312 | if (singleton != 0) { | ||
313 | cerr<<"Fatal! There can only one instance of fluxbox class."<<endl; | ||
314 | abort(); | ||
315 | } | ||
316 | |||
322 | //singleton pointer | 317 | //singleton pointer |
323 | singleton = this; | 318 | singleton = this; |
324 | BaseDisplay::GrabGuard gg(*this); | 319 | BaseDisplay::GrabGuard gg(*this); |
@@ -1911,9 +1906,9 @@ void Fluxbox::save_rc(void) { | |||
1911 | XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); //merge database together | 1906 | XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); //merge database together |
1912 | XrmPutFileDatabase(old_blackboxrc, dbfile.get()); | 1907 | XrmPutFileDatabase(old_blackboxrc, dbfile.get()); |
1913 | XrmDestroyDatabase(old_blackboxrc); | 1908 | XrmDestroyDatabase(old_blackboxrc); |
1914 | #ifdef DEBUG | 1909 | #ifdef DEBUG |
1915 | cerr<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl; | 1910 | cerr<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl; |
1916 | #endif | 1911 | #endif // DEBUG |
1917 | } | 1912 | } |
1918 | 1913 | ||
1919 | //-------- getRcFilename ------------- | 1914 | //-------- getRcFilename ------------- |
@@ -1922,12 +1917,12 @@ void Fluxbox::save_rc(void) { | |||
1922 | char *Fluxbox::getRcFilename() { | 1917 | char *Fluxbox::getRcFilename() { |
1923 | char *dbfile=0; | 1918 | char *dbfile=0; |
1924 | 1919 | ||
1925 | if (!rc_file) { | 1920 | if (rc_file.size() == 0) { |
1926 | string str(getenv("HOME")+string("/.")+RC_PATH+string("/")+RC_INIT_FILE); | 1921 | string str(getenv("HOME")+string("/.")+RC_PATH+string("/")+RC_INIT_FILE); |
1927 | return StringUtil::strdup(str.c_str()); | 1922 | return StringUtil::strdup(str.c_str()); |
1928 | 1923 | ||
1929 | } else | 1924 | } else |
1930 | dbfile = StringUtil::strdup(rc_file); | 1925 | dbfile = StringUtil::strdup(rc_file.c_str()); |
1931 | 1926 | ||
1932 | return dbfile; | 1927 | return dbfile; |
1933 | } | 1928 | } |
@@ -2473,7 +2468,7 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) { | |||
2473 | old_wkspc->menu()->setItemSelected(old_win->getWindowNumber(), false); | 2468 | old_wkspc->menu()->setItemSelected(old_win->getWindowNumber(), false); |
2474 | 2469 | ||
2475 | } | 2470 | } |
2476 | 2471 | ||
2477 | if (win && ! win->isIconic()) { | 2472 | if (win && ! win->isIconic()) { |
2478 | // make sure we have a valid win pointer with a valid screen | 2473 | // make sure we have a valid win pointer with a valid screen |
2479 | ScreenList::iterator winscreen = | 2474 | ScreenList::iterator winscreen = |
@@ -2491,7 +2486,7 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) { | |||
2491 | wkspc->menu()->setItemSelected(win->getWindowNumber(), true); | 2486 | wkspc->menu()->setItemSelected(win->getWindowNumber(), true); |
2492 | } | 2487 | } |
2493 | } else | 2488 | } else |
2494 | focused_window = (FluxboxWindow *) 0; | 2489 | focused_window = 0; |
2495 | 2490 | ||
2496 | if (tbar != 0) | 2491 | if (tbar != 0) |
2497 | tbar->redrawWindowLabel(True); | 2492 | tbar->redrawWindowLabel(True); |
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index ecc9e0f..a8de98c 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: fluxbox.hh,v 1.23 2002/08/11 20:36:43 fluxgen Exp $ | 25 | // $Id: fluxbox.hh,v 1.24 2002/08/13 21:18:17 fluxgen Exp $ |
26 | 26 | ||
27 | #ifndef FLUXBOX_HH | 27 | #ifndef FLUXBOX_HH |
28 | #define FLUXBOX_HH | 28 | #define FLUXBOX_HH |
@@ -69,20 +69,21 @@ | |||
69 | */ | 69 | */ |
70 | class Fluxbox : public BaseDisplay, public TimeoutHandler { | 70 | class Fluxbox : public BaseDisplay, public TimeoutHandler { |
71 | public: | 71 | public: |
72 | Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0); | ||
73 | virtual ~Fluxbox(); | ||
72 | 74 | ||
73 | 75 | static Fluxbox *instance() { return singleton; } | |
74 | static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0); | ||
75 | 76 | ||
76 | inline bool useTabs() { return *m_rc_tabs; } | 77 | inline bool useTabs() { return *m_rc_tabs; } |
77 | inline bool useIconBar() { return *m_rc_iconbar; } | 78 | inline bool useIconBar() { return *m_rc_iconbar; } |
78 | inline void saveTabs(bool value) { *m_rc_tabs = value; } | 79 | inline void saveTabs(bool value) { *m_rc_tabs = value; } |
79 | inline void saveIconBar(bool value) { m_rc_iconbar = value; } | 80 | inline void saveIconBar(bool value) { m_rc_iconbar = value; } |
80 | #ifdef HAVE_GETPID | 81 | #ifdef HAVE_GETPID |
81 | inline const Atom &getFluxboxPidAtom() const { return fluxbox_pid; } | 82 | inline Atom getFluxboxPidAtom() const { return fluxbox_pid; } |
82 | #ifdef KDE | 83 | #ifdef KDE |
83 | //For KDE dock applets | 84 | //For KDE dock applets |
84 | inline const Atom &getKWM1DockwindowAtom() const { return kwm1_dockwindow; } //KDE v1.x | 85 | inline Atom getKWM1DockwindowAtom() const { return kwm1_dockwindow; } //KDE v1.x |
85 | inline const Atom &getKWM2DockwindowAtom() const { return kwm2_dockwindow; } //KDE v2.x | 86 | inline Atom getKWM2DockwindowAtom() const { return kwm2_dockwindow; } //KDE v2.x |
86 | #endif | 87 | #endif |
87 | #endif // HAVE_GETPID | 88 | #endif // HAVE_GETPID |
88 | 89 | ||
@@ -232,7 +233,8 @@ private: | |||
232 | bool no_focus, reconfigure_wait, reread_menu_wait; | 233 | bool no_focus, reconfigure_wait, reread_menu_wait; |
233 | Time last_time; | 234 | Time last_time; |
234 | Window masked; | 235 | Window masked; |
235 | char *rc_file, **argv; | 236 | std::string rc_file; ///< resource filename |
237 | char **argv; | ||
236 | int argc; | 238 | int argc; |
237 | Keys *key; | 239 | Keys *key; |
238 | std::string slitlist_path; | 240 | std::string slitlist_path; |
@@ -240,7 +242,6 @@ private: | |||
240 | static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[]; | 242 | static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[]; |
241 | 243 | ||
242 | protected: | 244 | protected: |
243 | Fluxbox(int, char **, char * = 0, char * = 0); | ||
244 | char *getRcFilename(); | 245 | char *getRcFilename(); |
245 | void getDefaultDataFilename(char *, std::string &); | 246 | void getDefaultDataFilename(char *, std::string &); |
246 | void load_rc(); | 247 | void load_rc(); |
@@ -250,11 +251,7 @@ protected: | |||
250 | void real_reconfigure(); | 251 | void real_reconfigure(); |
251 | 252 | ||
252 | virtual void process_event(XEvent *); | 253 | virtual void process_event(XEvent *); |
253 | //only main should be able to creat new blackbox object | 254 | static Fluxbox *singleton; |
254 | //TODO this must be removed! | ||
255 | friend int main(int,char **); | ||
256 | static Fluxbox *singleton; //singleton object ( can only be destroyed by main ) | ||
257 | virtual ~Fluxbox(); | ||
258 | 255 | ||
259 | }; | 256 | }; |
260 | 257 | ||