aboutsummaryrefslogtreecommitdiff
path: root/src/Rootmenu.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rootmenu.cc')
-rw-r--r--src/Rootmenu.cc158
1 files changed, 0 insertions, 158 deletions
diff --git a/src/Rootmenu.cc b/src/Rootmenu.cc
deleted file mode 100644
index bb290cd..0000000
--- a/src/Rootmenu.cc
+++ /dev/null
@@ -1,158 +0,0 @@
1// Rootmenu.cc for fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org)
3// Rootmenu.cc for Blackbox - an X11 Window manager
4// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5//
6// Permission is hereby granted, free of charge, to any person obtaining a
7// copy of this software and associated documentation files (the "Software"),
8// to deal in the Software without restriction, including without limitation
9// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10// and/or sell copies of the Software, and to permit persons to whom the
11// Software is furnished to do so, subject to the following conditions:
12//
13// The above copyright notice and this permission notice shall be included in
14// all copies or substantial portions of the Software.
15//
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22// DEALINGS IN THE SOFTWARE.
23
24//Use GNU extensions
25#ifndef _GNU_SOURCE
26#define _GNU_SOURCE
27#endif // _GNU_SOURCE
28
29#ifdef HAVE_CONFIG_H
30# include "../config.h"
31#endif // HAVE_CONFIG_H
32
33#include "fluxbox.hh"
34#include "Rootmenu.hh"
35#include "Screen.hh"
36
37#ifdef HAVE_STDIO_H
38# include <stdio.h>
39#endif // HAVE_STDIO_H
40
41#ifdef STDC_HEADERS
42# include <stdlib.h>
43# include <string.h>
44#endif // STDC_HEADERS
45
46#ifdef HAVE_SYS_PARAM_H
47# include <sys/param.h>
48#endif // HAVE_SYS_PARAM_H
49
50#ifndef MAXPATHLEN
51#define MAXPATHLEN 255
52#endif // MAXPATHLEN
53
54
55Rootmenu::Rootmenu(BScreen *scrn)
56 : Basemenu(scrn),
57 auto_group_window(0)
58{
59
60}
61
62
63void Rootmenu::itemSelected(int button, unsigned int index) {
64
65 Fluxbox *fluxbox = Fluxbox::instance();
66
67 if (button == 1) {
68 BasemenuItem *item = find(index);
69
70 if (item->function()) {
71 switch (item->function()) {
72 case BScreen::EXECUTE:
73 if (item->exec().size()) {
74#ifndef __EMX__
75 char displaystring[MAXPATHLEN];
76 sprintf(displaystring, "DISPLAY=%s",
77 DisplayString(screen()->getBaseDisplay()->getXDisplay()));
78 sprintf(displaystring + strlen(displaystring) - 1, "%d",
79 screen()->getScreenNumber());
80
81 screen()->setAutoGroupWindow(useAutoGroupWindow());
82
83 bexec(item->exec().c_str(), displaystring);
84#else // __EMX__
85 spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL);
86#endif // !__EMX__
87 }
88 break;
89
90 case BScreen::RESTART:
91 fluxbox->restart();
92 break;
93
94 case BScreen::RESTARTOTHER:
95 if (item->exec().size())
96 fluxbox->restart(item->exec().c_str());
97 break;
98
99 case BScreen::EXIT:
100 fluxbox->shutdown();
101 break;
102
103 case BScreen::SETSTYLE:
104 if (item->exec().size()) {
105 fluxbox->saveStyleFilename(item->exec().c_str());
106 fluxbox->reconfigureTabs();
107 }
108 fluxbox->reconfigure();
109 fluxbox->save_rc();
110 break;
111 case BScreen::RECONFIGURE:
112 fluxbox->reconfigure();
113 return;
114 }
115 if (! (screen()->getRootmenu()->isTorn() || isTorn()) &&
116 item->function() != BScreen::RECONFIGURE &&
117 item->function() != BScreen::SETSTYLE)
118 hide();
119 }
120 }
121}
122
123void Rootmenu::setAutoGroupWindow(Window window) {
124 auto_group_window = window;
125}
126
127void Rootmenu::show() {
128 Basemenu::show();
129 // make sure it's full visible
130
131 int newx = x(), newy = y();
132 if (x() < 0)
133 newx = 0;
134 else if (x() + width() > screen()->getWidth())
135 newx = screen()->getWidth() - width();
136 if (y() < 0)
137 newy = 0;
138 else if (y() + height() > screen()->getHeight())
139 newy = screen()->getHeight() - height();
140
141 move(newx, newy);
142}
143
144Window Rootmenu::useAutoGroupWindow() {
145 // Return and clear the auto-grouping state.
146 Window w = auto_group_window;
147 if (w)
148 auto_group_window = 0; // clear it immediately
149 // If not set check the parent and the parent's parent, ...
150 else if (parent()) {
151 // TODO: dynamic_cast throws std::bad_cast!
152 Rootmenu *p = dynamic_cast<Rootmenu*>(parent());
153 w = p->useAutoGroupWindow();
154 }
155 return w;
156}
157
158