diff options
Diffstat (limited to 'src/Rootmenu.cc')
-rw-r--r-- | src/Rootmenu.cc | 72 |
1 files changed, 49 insertions, 23 deletions
diff --git a/src/Rootmenu.cc b/src/Rootmenu.cc index c86879f..513a971 100644 --- a/src/Rootmenu.cc +++ b/src/Rootmenu.cc | |||
@@ -19,8 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // stupid macros needed to access some functions in version 2 of the GNU C | 22 | //Use GNU extensions |
23 | // library | ||
24 | #ifndef _GNU_SOURCE | 23 | #ifndef _GNU_SOURCE |
25 | #define _GNU_SOURCE | 24 | #define _GNU_SOURCE |
26 | #endif // _GNU_SOURCE | 25 | #endif // _GNU_SOURCE |
@@ -51,12 +50,15 @@ | |||
51 | #endif // MAXPATHLEN | 50 | #endif // MAXPATHLEN |
52 | 51 | ||
53 | 52 | ||
54 | Rootmenu::Rootmenu(BScreen *scrn) : Basemenu(scrn) { | 53 | Rootmenu::Rootmenu(BScreen *scrn) |
54 | : Basemenu(scrn), | ||
55 | auto_group_window(0) | ||
56 | { | ||
55 | screen = scrn; | 57 | screen = scrn; |
56 | } | 58 | } |
57 | 59 | ||
58 | 60 | ||
59 | void Rootmenu::itemSelected(int button, int index) { | 61 | void Rootmenu::itemSelected(int button, unsigned int index) { |
60 | 62 | ||
61 | Fluxbox *fluxbox = Fluxbox::instance(); | 63 | Fluxbox *fluxbox = Fluxbox::instance(); |
62 | 64 | ||
@@ -65,8 +67,8 @@ void Rootmenu::itemSelected(int button, int index) { | |||
65 | 67 | ||
66 | if (item->function()) { | 68 | if (item->function()) { |
67 | switch (item->function()) { | 69 | switch (item->function()) { |
68 | case BScreen::Execute: | 70 | case BScreen::EXECUTE: |
69 | if (item->exec()) { | 71 | if (item->exec().size()) { |
70 | #ifndef __EMX__ | 72 | #ifndef __EMX__ |
71 | char displaystring[MAXPATHLEN]; | 73 | char displaystring[MAXPATHLEN]; |
72 | sprintf(displaystring, "DISPLAY=%s", | 74 | sprintf(displaystring, "DISPLAY=%s", |
@@ -74,42 +76,66 @@ void Rootmenu::itemSelected(int button, int index) { | |||
74 | sprintf(displaystring + strlen(displaystring) - 1, "%d", | 76 | sprintf(displaystring + strlen(displaystring) - 1, "%d", |
75 | screen->getScreenNumber()); | 77 | screen->getScreenNumber()); |
76 | 78 | ||
77 | bexec(item->exec(), displaystring); | 79 | screen->setAutoGroupWindow(useAutoGroupWindow()); |
80 | |||
81 | bexec(item->exec().c_str(), displaystring); | ||
82 | |||
78 | #else // __EMX__ | 83 | #else // __EMX__ |
79 | spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec(), NULL); | 84 | spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL); |
80 | #endif // !__EMX__ | 85 | #endif // !__EMX__ |
81 | } | 86 | } |
82 | break; | 87 | break; |
83 | 88 | ||
84 | case BScreen::Restart: | 89 | case BScreen::RESTART: |
85 | fluxbox->restart(); | 90 | fluxbox->restart(); |
86 | break; | 91 | break; |
87 | 92 | ||
88 | case BScreen::RestartOther: | 93 | case BScreen::RESTARTOTHER: |
89 | if (item->exec()) | 94 | if (item->exec().size()) |
90 | fluxbox->restart(item->exec()); | 95 | fluxbox->restart(item->exec().c_str()); |
91 | break; | 96 | break; |
92 | 97 | ||
93 | case BScreen::Exit: | 98 | case BScreen::EXIT: |
94 | fluxbox->shutdown(); | 99 | fluxbox->shutdown(); |
95 | break; | 100 | break; |
96 | 101 | ||
97 | case BScreen::SetStyle: | 102 | case BScreen::SETSTYLE: |
98 | if (item->exec()) { | 103 | if (item->exec().size()) { |
99 | fluxbox->saveStyleFilename(item->exec()); | 104 | fluxbox->saveStyleFilename(item->exec().c_str()); |
100 | fluxbox->reconfigureTabs(); //TODO | 105 | fluxbox->reconfigureTabs(); |
101 | } | 106 | } |
102 | 107 | fluxbox->reconfigure(); | |
103 | case BScreen::Reconfigure: | 108 | fluxbox->save_rc(); |
109 | break; | ||
110 | case BScreen::RECONFIGURE: | ||
104 | fluxbox->reconfigure(); | 111 | fluxbox->reconfigure(); |
105 | return; | 112 | return; |
106 | } | 113 | } |
107 | |||
108 | if (! (screen->getRootmenu()->isTorn() || isTorn()) && | 114 | if (! (screen->getRootmenu()->isTorn() || isTorn()) && |
109 | item->function() != BScreen::Reconfigure && | 115 | item->function() != BScreen::RECONFIGURE && |
110 | item->function() != BScreen::SetStyle) | 116 | item->function() != BScreen::SETSTYLE) |
111 | hide(); | 117 | hide(); |
112 | } | 118 | } |
113 | } | 119 | } |
114 | } | 120 | } |
115 | 121 | ||
122 | void Rootmenu::setAutoGroupWindow(Window window) | ||
123 | { | ||
124 | auto_group_window = window; | ||
125 | } | ||
126 | |||
127 | Window Rootmenu::useAutoGroupWindow() | ||
128 | { | ||
129 | // Return and clear the auto-grouping state. | ||
130 | Window w = auto_group_window; | ||
131 | if (w) | ||
132 | auto_group_window = 0; // clear it immediately | ||
133 | // If not set check the parent and the parent's parent, ... | ||
134 | else { | ||
135 | // TODO: dynamic_cast throws std::bad_cast! | ||
136 | Rootmenu *p = dynamic_cast<Rootmenu*>(parent()); | ||
137 | if (p) | ||
138 | w = p->useAutoGroupWindow(); | ||
139 | } | ||
140 | return w; | ||
141 | } | ||