aboutsummaryrefslogtreecommitdiff
path: root/src/Rootmenu.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rootmenu.cc')
-rw-r--r--src/Rootmenu.cc115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/Rootmenu.cc b/src/Rootmenu.cc
new file mode 100644
index 0000000..c86879f
--- /dev/null
+++ b/src/Rootmenu.cc
@@ -0,0 +1,115 @@
1// Rootmenu.cc for Blackbox - an X11 Window manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// stupid macros needed to access some functions in version 2 of the GNU C
23// library
24#ifndef _GNU_SOURCE
25#define _GNU_SOURCE
26#endif // _GNU_SOURCE
27
28#ifdef HAVE_CONFIG_H
29# include "../config.h"
30#endif // HAVE_CONFIG_H
31
32#include "fluxbox.hh"
33#include "Rootmenu.hh"
34#include "Screen.hh"
35
36#ifdef HAVE_STDIO_H
37# include <stdio.h>
38#endif // HAVE_STDIO_H
39
40#ifdef STDC_HEADERS
41# include <stdlib.h>
42# include <string.h>
43#endif // STDC_HEADERS
44
45#ifdef HAVE_SYS_PARAM_H
46# include <sys/param.h>
47#endif // HAVE_SYS_PARAM_H
48
49#ifndef MAXPATHLEN
50#define MAXPATHLEN 255
51#endif // MAXPATHLEN
52
53
54Rootmenu::Rootmenu(BScreen *scrn) : Basemenu(scrn) {
55 screen = scrn;
56}
57
58
59void Rootmenu::itemSelected(int button, int index) {
60
61 Fluxbox *fluxbox = Fluxbox::instance();
62
63 if (button == 1) {
64 BasemenuItem *item = find(index);
65
66 if (item->function()) {
67 switch (item->function()) {
68 case BScreen::Execute:
69 if (item->exec()) {
70 #ifndef __EMX__
71 char displaystring[MAXPATHLEN];
72 sprintf(displaystring, "DISPLAY=%s",
73 DisplayString(screen->getBaseDisplay()->getXDisplay()));
74 sprintf(displaystring + strlen(displaystring) - 1, "%d",
75 screen->getScreenNumber());
76
77 bexec(item->exec(), displaystring);
78 #else // __EMX__
79 spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec(), NULL);
80 #endif // !__EMX__
81 }
82 break;
83
84 case BScreen::Restart:
85 fluxbox->restart();
86 break;
87
88 case BScreen::RestartOther:
89 if (item->exec())
90 fluxbox->restart(item->exec());
91 break;
92
93 case BScreen::Exit:
94 fluxbox->shutdown();
95 break;
96
97 case BScreen::SetStyle:
98 if (item->exec()) {
99 fluxbox->saveStyleFilename(item->exec());
100 fluxbox->reconfigureTabs(); //TODO
101 }
102
103 case BScreen::Reconfigure:
104 fluxbox->reconfigure();
105 return;
106 }
107
108 if (! (screen->getRootmenu()->isTorn() || isTorn()) &&
109 item->function() != BScreen::Reconfigure &&
110 item->function() != BScreen::SetStyle)
111 hide();
112 }
113 }
114}
115