aboutsummaryrefslogtreecommitdiff
path: root/src/Windowmenu.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Windowmenu.cc')
-rw-r--r--src/Windowmenu.cc362
1 files changed, 165 insertions, 197 deletions
diff --git a/src/Windowmenu.cc b/src/Windowmenu.cc
index 159f090..dd55b0e 100644
--- a/src/Windowmenu.cc
+++ b/src/Windowmenu.cc
@@ -1,3 +1,5 @@
1// Windowmenu.cc for Fluxbox
2// Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org)
1// Windowmenu.cc for Blackbox - an X11 Window manager 3// Windowmenu.cc for Blackbox - an X11 Window manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 4// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3// 5//
@@ -19,14 +21,15 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 22// DEALINGS IN THE SOFTWARE.
21 23
22// stupid macros needed to access some functions in version 2 of the GNU C 24// $Id: Windowmenu.cc,v 1.14 2002/05/15 09:37:27 fluxgen Exp $
23// library 25
24#ifndef _GNU_SOURCE 26//use GNU extensions
25#define _GNU_SOURCE 27#ifndef _GNU_SOURCE
28#define _GNU_SOURCE
26#endif // _GNU_SOURCE 29#endif // _GNU_SOURCE
27 30
28#ifdef HAVE_CONFIG_H 31#ifdef HAVE_CONFIG_H
29# include "../config.h" 32#include "../config.h"
30#endif // HAVE_CONFIG_H 33#endif // HAVE_CONFIG_H
31 34
32#include "i18n.hh" 35#include "i18n.hh"
@@ -36,254 +39,219 @@
36#include "Windowmenu.hh" 39#include "Windowmenu.hh"
37#include "Workspace.hh" 40#include "Workspace.hh"
38 41
39#ifdef STDC_HEADERS 42#ifdef STDC_HEADERS
40# include <string.h> 43#include <string.h>
41#endif // STDC_HEADERS 44#endif // STDC_HEADERS
42 45
43 46
44Windowmenu::Windowmenu(FluxboxWindow *win) : Basemenu(win->getScreen()) { 47Windowmenu::Windowmenu(FluxboxWindow *win) : Basemenu(win->getScreen()),
45 window = win; 48window(win),
46 screen = window->getScreen(); 49screen(window->getScreen()){
47 50
48 setTitleVisibility(False); 51 setTitleVisibility(False);
49 setMovable(False); 52 setMovable(False);
50 setInternalMenu(); 53 setInternalMenu();
51 54
52 I18n *i18n = I18n::instance(); 55 I18n *i18n = I18n::instance();
53 56
54 sendToMenu = new SendtoWorkspacemenu(this); 57 sendToMenu = new SendtoWorkspacemenu(this);
55 sendGroupToMenu = new SendGroupToWorkspacemenu(this); 58 sendGroupToMenu = new SendGroupToWorkspacemenu(this);
56 59 using namespace FBNLS;
57 insert(i18n->getMessage( 60 insert(i18n->getMessage(
58#ifdef NLS 61 WindowmenuSet, WindowmenuSendTo,
59 WindowmenuSet, WindowmenuSendTo, 62 "Send To ..."),
60#else // !NLS
61 0, 0,
62#endif // NLS
63 "Send To ..."),
64 sendToMenu); 63 sendToMenu);
65 64
66 insert(i18n->getMessage( 65 insert(i18n->getMessage(
67#ifdef NLS 66 WindowmenuSet, WindowmenuSendGroupTo,
68 WindowmenuSet, WindowmenuSendGroupTo, 67 "Send Group To ..."),
69#else // !NLS 68 sendGroupToMenu);
70 0, 0,
71#endif // NLS
72 "Send Group To ..."),
73 sendGroupToMenu);
74
75 insert(i18n->getMessage(
76#ifdef NLS
77 WindowmenuSet, WindowmenuShade,
78#else // !NLS
79 0, 0,
80#endif // NLS
81 "Shade"),
82 BScreen::WindowShade);
83 insert(i18n->getMessage(
84#ifdef NLS
85 WindowmenuSet, WindowmenuIconify,
86#else // !NLS
87 0, 0,
88#endif // NLS
89 "Iconify"),
90 BScreen::WindowIconify);
91 insert(i18n->getMessage(
92#ifdef NLS
93 WindowmenuSet, WindowmenuMaximize,
94#else // !NLS
95 0, 0,
96#endif // NLS
97 "Maximize"),
98 BScreen::WindowMaximize);
99 insert(i18n->getMessage(
100#ifdef NLS
101 WindowmenuSet, WindowmenuRaise,
102#else // !NLS
103 0, 0,
104#endif // NLS
105 "Raise"),
106 BScreen::WindowRaise);
107 insert(i18n->getMessage(
108#ifdef NLS
109 WindowmenuSet, WindowmenuLower,
110#else // !NLS
111 0, 0,
112#endif // NLS
113 "Lower"),
114 BScreen::WindowLower);
115 insert(i18n->getMessage(
116#ifdef NLS
117 WindowmenuSet, WindowmenuStick,
118#else // !NLS
119 0, 0,
120#endif // NLS
121 "Stick"),
122 BScreen::WindowStick);
123 insert(i18n->getMessage(
124#ifdef NLS
125 WindowmenuSet, WindowmenuKillClient,
126#else // !NLS
127 0, 0,
128#endif // NLS
129 "Kill Client"),
130 BScreen::WindowKill);
131 insert(i18n->getMessage(
132#ifdef NLS
133 WindowmenuSet, WindowmenuClose,
134#else // !NLS
135 0, 0,
136#endif // NLS
137 "Close"),
138 BScreen::WindowClose);
139
140 //TODO: nls
141 insert("Tab", BScreen::WindowTab);
142 69
143 update(); 70 insert(i18n->getMessage(
71 WindowmenuSet, WindowmenuShade,
72 "Shade"),
73 BScreen::WINDOWSHADE);
74 insert(i18n->getMessage(
75 WindowmenuSet, WindowmenuIconify,
76 "Iconify"),
77 BScreen::WINDOWICONIFY);
78 insert(i18n->getMessage(
79 WindowmenuSet, WindowmenuMaximize,
80 "Maximize"),
81 BScreen::WINDOWMAXIMIZE);
82 insert(i18n->getMessage(
83 WindowmenuSet, WindowmenuRaise,
84 "Raise"),
85 BScreen::WINDOWRAISE);
86 insert(i18n->getMessage(
87 WindowmenuSet, WindowmenuLower,
88 "Lower"),
89 BScreen::WINDOWLOWER);
90 insert(i18n->getMessage(
91 WindowmenuSet, WindowmenuStick,
92 "Stick"),
93 BScreen::WINDOWSTICK);
94 insert(i18n->getMessage(
95 WindowmenuSet, WindowmenuKillClient,
96 "Kill Client"),
97 BScreen::WINDOWKILL);
98 insert(i18n->getMessage(
99 WindowmenuSet, WindowmenuClose,
100 "Close"),
101 BScreen::WINDOWCLOSE);
102 insert(i18n->getMessage(
103 WindowmenuSet, WindowmenuTab,
104 "Tab"),
105 BScreen::WINDOWTAB);
106
107 update();
108
109 setItemEnabled(2, window->hasTitlebar());
110 setItemEnabled(3, window->isIconifiable());
111 setItemEnabled(4, window->isMaximizable());
112 setItemEnabled(9, window->isClosable());
113 setItemEnabled(10, true); //we should always be able to enable the tab
144 114
145 setItemEnabled(1, window->hasTitlebar());
146 setItemEnabled(2, window->isIconifiable());
147 setItemEnabled(3, window->isMaximizable());
148 setItemEnabled(8, window->isClosable());
149 setItemEnabled(9, window->hasTab());
150} 115}
151 116
152 117
153Windowmenu::~Windowmenu(void) { 118Windowmenu::~Windowmenu(void) {
154 delete sendToMenu; 119 delete sendToMenu;
155 delete sendGroupToMenu; 120 delete sendGroupToMenu;
156} 121}
157 122
158 123
159void Windowmenu::show(void) { 124void Windowmenu::show(void) {
160 if (isItemEnabled(1)) setItemSelected(1, window->isShaded()); 125 if (isItemEnabled(2)) setItemSelected(2, window->isShaded());
161 if (isItemEnabled(3)) setItemSelected(3, window->isMaximized()); 126 if (isItemEnabled(4)) setItemSelected(4, window->isMaximized());
162 if (isItemEnabled(6)) setItemSelected(6, window->isStuck()); 127 if (isItemEnabled(7)) setItemSelected(7, window->isStuck());
163 128
164 Basemenu::show(); 129 Basemenu::show();
165} 130}
166 131
167 132
168void Windowmenu::itemSelected(int button, int index) { 133void Windowmenu::itemSelected(int button, unsigned int index) {
169 BasemenuItem *item = find(index); 134 BasemenuItem *item = find(index);
135
136 switch (item->function()) {
137 case BScreen::WINDOWSHADE:
138 hide();
170 139
171 switch (item->function()) { 140 window->shade();
172 case BScreen::WindowShade: 141 if (window->hasTab())
173 hide();
174 if (window->getTab())
175 window->getTab()->shade(); 142 window->getTab()->shade();
176 window->shade(); 143 break;
177 break; 144
178 145 case BScreen::WINDOWICONIFY:
179 case BScreen::WindowIconify: 146 hide();
180 hide(); 147 window->iconify();
181 window->iconify(); 148 break;
182 break; 149
183 150 case BScreen::WINDOWMAXIMIZE:
184 case BScreen::WindowMaximize: 151 hide();
185 hide(); 152 window->maximize((unsigned int) button);
186 window->maximize((unsigned int) button); 153 break;
187 break; 154
188 155 case BScreen::WINDOWCLOSE:
189 case BScreen::WindowClose: 156 hide();
190 hide(); 157 window->close();
191 window->close(); 158 break;
192 break; 159
193 160 case BScreen::WINDOWRAISE:
194 case BScreen::WindowRaise: 161 hide();
195 hide(); 162 if (window->hasTab())
196 screen->getWorkspace(window->getWorkspaceNumber())->raiseWindow(window); 163 window->getTab()->raise(); //raise tabs
197 break; 164 screen->getWorkspace(window->getWorkspaceNumber())->raiseWindow(window);
198 165 break;
199 case BScreen::WindowLower: 166
200 hide(); 167 case BScreen::WINDOWLOWER:
201 screen->getWorkspace(window->getWorkspaceNumber())->lowerWindow(window); 168 hide();
202 break; 169 screen->getWorkspace(window->getWorkspaceNumber())->lowerWindow(window);
203 170 if (window->hasTab())
204 case BScreen::WindowStick: 171 window->getTab()->lower(); //lower tabs AND all it's windows
205 hide(); 172 break;
206 window->stick(); 173
207 break; 174 case BScreen::WINDOWSTICK:
208 175 hide();
209 case BScreen::WindowKill: 176 window->stick();
210 hide(); 177 break;
211 XKillClient(screen->getBaseDisplay()->getXDisplay(), 178
212 window->getClientWindow()); 179 case BScreen::WINDOWKILL:
213 break; 180 hide();
214 case BScreen::WindowTab: 181 XKillClient(screen->getBaseDisplay()->getXDisplay(),
182 window->getClientWindow());
183 break;
184 case BScreen::WINDOWTAB:
215 hide(); 185 hide();
216 window->setTab(!window->hasTab()); 186 window->setTab(!window->hasTab());
217 break; 187 break;
218 } 188 }
219} 189}
220 190
221 191
222void Windowmenu::reconfigure(void) { 192void Windowmenu::reconfigure(void) {
223 setItemEnabled(1, window->hasTitlebar()); 193 setItemEnabled(1, window->hasTitlebar());
224 setItemEnabled(2, window->isIconifiable()); 194 setItemEnabled(2, window->isIconifiable());
225 setItemEnabled(3, window->isMaximizable()); 195 setItemEnabled(3, window->isMaximizable());
226 setItemEnabled(8, window->isClosable()); 196 setItemEnabled(8, window->isClosable());
227 197
228 sendToMenu->reconfigure(); 198 sendToMenu->reconfigure();
229 sendGroupToMenu->reconfigure(); 199 sendGroupToMenu->reconfigure();
230 200
231 Basemenu::reconfigure(); 201 Basemenu::reconfigure();
232} 202}
233 203
234 204
235Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu *w) 205Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu *w)
236 : Basemenu(w->screen) 206 : Basemenu(w->screen)
237{ 207{
238 windowmenu = w; 208 windowmenu = w;
239 209
240 setTitleVisibility(False); 210 setTitleVisibility(False);
241 setMovable(False); 211 setMovable(False);
242 setInternalMenu(); 212 setInternalMenu();
243 update(); 213 update();
244} 214}
245 215
246 216
247void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, int index) { 217void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, unsigned int index) {
248 if (button > 2) return; 218 if (button > 2) return;
249 219
250 if (index <= windowmenu->screen->getCount()) { 220 if (index <= windowmenu->screen->getCount()) {
251 if (index == windowmenu->screen->getCurrentWorkspaceID()) return; 221 if (index == windowmenu->screen->getCurrentWorkspaceID()) return;
252 if (windowmenu->window->isStuck()) windowmenu->window->stick(); 222 if (windowmenu->window->isStuck()) windowmenu->window->stick();
253 223
254 if (button == 1) windowmenu->window->withdraw(); 224 if (button == 1)
255 windowmenu->screen->reassociateWindow(windowmenu->window, index, True); 225 windowmenu->screen->sendToWorkspace(index, False);
256 if (windowmenu->window->getTab()) { 226 else if (button == 2)
257 windowmenu->window->getTab()->disconnect(); 227 windowmenu->screen->sendToWorkspace(index);
258 windowmenu->window->getTab()->setPosition(); 228 }
259 } 229
260 if (button == 2) windowmenu->screen->changeWorkspaceID(index); 230 hide();
261 }
262 hide();
263} 231}
264 232
265 233
266void Windowmenu::SendtoWorkspacemenu::update(void) { 234void Windowmenu::SendtoWorkspacemenu::update(void) {
267 int i, r = getCount(); 235 unsigned int i, r = numberOfItems();
268 236
269 if (getCount() != 0) 237 if (numberOfItems() != 0) {
270 for (i = 0; i < r; ++i) 238 for (i = 0; i < r; ++i)
271 remove(0); 239 remove(0);
272 240 }
273 for (i = 0; i < windowmenu->screen->getCount(); ++i) 241 for (i = 0; i < windowmenu->screen->getCount(); ++i)
274 insert(windowmenu->screen->getWorkspace(i)->getName()); 242 insert(windowmenu->screen->getWorkspace(i)->name().c_str());
275 243
276 Basemenu::update(); 244 Basemenu::update();
277} 245}
278 246
279 247
280void Windowmenu::SendtoWorkspacemenu::show(void) { 248void Windowmenu::SendtoWorkspacemenu::show(void) {
281 update(); 249 update();
282 250
283 Basemenu::show(); 251 Basemenu::show();
284} 252}
285 253
286void Windowmenu::SendGroupToWorkspacemenu::itemSelected(int button, int index) { 254void Windowmenu::SendGroupToWorkspacemenu::itemSelected(int button, unsigned int index) {
287 if (button > 2) 255 if (button > 2)
288 return; 256 return;
289 257
@@ -296,13 +264,13 @@ void Windowmenu::SendGroupToWorkspacemenu::itemSelected(int button, int index) {
296 if (button == 1) { 264 if (button == 1) {
297 if (getWindowMenu()->window->hasTab()) { 265 if (getWindowMenu()->window->hasTab()) {
298 for (Tab *first = Tab::getFirst(getWindowMenu()->window->getTab()); 266 for (Tab *first = Tab::getFirst(getWindowMenu()->window->getTab());
299 first!=0; first=first->next()) { 267 first!=0; first=first->next()) {
300 first->withdraw(); 268 first->withdraw();
301 first->getWindow()->withdraw(); 269 first->getWindow()->withdraw();
302 getWindowMenu()->screen->reassociateWindow(first->getWindow(), index, True); 270 getWindowMenu()->screen->reassociateWindow(first->getWindow(), index, True);
303 271
304 } 272 }
305 } else { 273 } else {
306 getWindowMenu()->window->withdraw(); 274 getWindowMenu()->window->withdraw();
307 getWindowMenu()->screen->reassociateWindow(getWindowMenu()->window, index, True); 275 getWindowMenu()->screen->reassociateWindow(getWindowMenu()->window, index, True);
308 } 276 }