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