summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-09-10 11:06:26 (GMT)
committerfluxgen <fluxgen>2002-09-10 11:06:26 (GMT)
commit93da0bc4924eb73ba467a5198c7e16c931713afc (patch)
treec5ce9d3286475ee21063478b1fcdbd4bd8f475f5 /src
parent50c686fa22861dcfd0182747dd422fb40ec2afd2 (diff)
downloadfluxbox_lack-93da0bc4924eb73ba467a5198c7e16c931713afc.zip
fluxbox_lack-93da0bc4924eb73ba467a5198c7e16c931713afc.tar.bz2
from pointer to referens
Diffstat (limited to 'src')
-rw-r--r--src/Windowmenu.cc132
1 files changed, 64 insertions, 68 deletions
diff --git a/src/Windowmenu.cc b/src/Windowmenu.cc
index b8f34c0..b4219f1 100644
--- a/src/Windowmenu.cc
+++ b/src/Windowmenu.cc
@@ -21,7 +21,7 @@
21// 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
22// DEALINGS IN THE SOFTWARE. 22// DEALINGS IN THE SOFTWARE.
23 23
24// $Id: Windowmenu.cc,v 1.18 2002/09/06 16:59:29 fluxgen Exp $ 24// $Id: Windowmenu.cc,v 1.19 2002/09/10 11:06:26 fluxgen Exp $
25 25
26//use GNU extensions 26//use GNU extensions
27#ifndef _GNU_SOURCE 27#ifndef _GNU_SOURCE
@@ -44,9 +44,11 @@
44#endif // STDC_HEADERS 44#endif // STDC_HEADERS
45 45
46 46
47Windowmenu::Windowmenu(FluxboxWindow *win) : Basemenu(win->getScreen()), 47Windowmenu::Windowmenu(FluxboxWindow &win) : Basemenu(win.getScreen()),
48window(win), 48window(win),
49screen(window->getScreen()){ 49screen(win.getScreen()),
50sendToMenu(this),
51sendGroupToMenu(this) {
50 52
51 setTitleVisibility(False); 53 setTitleVisibility(False);
52 setMovable(False); 54 setMovable(False);
@@ -54,18 +56,16 @@ screen(window->getScreen()){
54 56
55 I18n *i18n = I18n::instance(); 57 I18n *i18n = I18n::instance();
56 58
57 sendToMenu = new SendtoWorkspacemenu(this);
58 sendGroupToMenu = new SendGroupToWorkspacemenu(this);
59 using namespace FBNLS; 59 using namespace FBNLS;
60 insert(i18n->getMessage( 60 insert(i18n->getMessage(
61 WindowmenuSet, WindowmenuSendTo, 61 WindowmenuSet, WindowmenuSendTo,
62 "Send To ..."), 62 "Send To ..."),
63 sendToMenu); 63 &sendToMenu);
64 64
65 insert(i18n->getMessage( 65 insert(i18n->getMessage(
66 WindowmenuSet, WindowmenuSendGroupTo, 66 WindowmenuSet, WindowmenuSendGroupTo,
67 "Send Group To ..."), 67 "Send Group To ..."),
68 sendGroupToMenu); 68 &sendGroupToMenu);
69 69
70 insert(i18n->getMessage( 70 insert(i18n->getMessage(
71 WindowmenuSet, WindowmenuShade, 71 WindowmenuSet, WindowmenuShade,
@@ -106,25 +106,27 @@ screen(window->getScreen()){
106 106
107 update(); 107 update();
108 108
109 setItemEnabled(2, window->hasTitlebar()); 109 setItemEnabled(2, window.hasTitlebar());
110 setItemEnabled(3, window->isIconifiable()); 110 setItemEnabled(3, window.isIconifiable());
111 setItemEnabled(4, window->isMaximizable()); 111 setItemEnabled(4, window.isMaximizable());
112 setItemEnabled(9, window->isClosable()); 112 setItemEnabled(9, window.isClosable());
113 setItemEnabled(10, true); //we should always be able to enable the tab 113 setItemEnabled(10, true); //we should always be able to enable the tab
114 114
115} 115}
116 116
117 117
118Windowmenu::~Windowmenu(void) { 118Windowmenu::~Windowmenu() {
119 delete sendToMenu; 119
120 delete sendGroupToMenu;
121} 120}
122 121
123 122
124void Windowmenu::show(void) { 123void Windowmenu::show() {
125 if (isItemEnabled(2)) setItemSelected(2, window->isShaded()); 124 if (isItemEnabled(2))
126 if (isItemEnabled(4)) setItemSelected(4, window->isMaximized()); 125 setItemSelected(2, window.isShaded());
127 if (isItemEnabled(7)) setItemSelected(7, window->isStuck()); 126 if (isItemEnabled(4))
127 setItemSelected(4, window.isMaximized());
128 if (isItemEnabled(7))
129 setItemSelected(7, window.isStuck());
128 130
129 Basemenu::show(); 131 Basemenu::show();
130} 132}
@@ -135,71 +137,71 @@ void Windowmenu::itemSelected(int button, unsigned int index) {
135 hide(); 137 hide();
136 switch (item->function()) { 138 switch (item->function()) {
137 case BScreen::WINDOWSHADE: 139 case BScreen::WINDOWSHADE:
138 if (window->isIconic()) 140 if (window.isIconic())
139 break; 141 break;
140 142
141 window->shade(); 143 window.shade();
142 if (window->hasTab()) 144 if (window.hasTab())
143 window->getTab()->shade(); 145 window.getTab()->shade();
144 break; 146 break;
145 147
146 case BScreen::WINDOWICONIFY: 148 case BScreen::WINDOWICONIFY:
147 if (!window->isIconic()) 149 if (!window.isIconic())
148 window->iconify(); 150 window.iconify();
149 else 151 else
150 window->deiconify(); // restore window 152 window.deiconify(); // restore window
151 153
152 break; 154 break;
153 155
154 case BScreen::WINDOWMAXIMIZE: 156 case BScreen::WINDOWMAXIMIZE:
155 window->maximize((unsigned int) button); 157 window.maximize((unsigned int) button);
156 break; 158 break;
157 159
158 case BScreen::WINDOWCLOSE: 160 case BScreen::WINDOWCLOSE:
159 window->close(); 161 window.close();
160 break; 162 break;
161 163
162 case BScreen::WINDOWRAISE: 164 case BScreen::WINDOWRAISE:
163 if (window->isIconic()) 165 if (window.isIconic())
164 break; 166 break;
165 167
166 if (window->hasTab()) 168 if (window.hasTab())
167 window->getTab()->raise(); //raise tabs 169 window.getTab()->raise(); //raise tabs
168 screen->getWorkspace(window->getWorkspaceNumber())->raiseWindow(window); 170 screen->getWorkspace(window.getWorkspaceNumber())->raiseWindow(&window);
169 break; 171 break;
170 172
171 case BScreen::WINDOWLOWER: 173 case BScreen::WINDOWLOWER:
172 if (window->isIconic()) 174 if (window.isIconic())
173 break; 175 break;
174 176
175 screen->getWorkspace(window->getWorkspaceNumber())->lowerWindow(window); 177 screen->getWorkspace(window.getWorkspaceNumber())->lowerWindow(&window);
176 if (window->hasTab()) 178 if (window.hasTab())
177 window->getTab()->lower(); //lower tabs AND all it's windows 179 window.getTab()->lower(); //lower tabs AND all it's windows
178 break; 180 break;
179 181
180 case BScreen::WINDOWSTICK: 182 case BScreen::WINDOWSTICK:
181 window->stick(); 183 window.stick();
182 break; 184 break;
183 185
184 case BScreen::WINDOWKILL: 186 case BScreen::WINDOWKILL:
185 XKillClient(screen->getBaseDisplay()->getXDisplay(), 187 XKillClient(BaseDisplay::getXDisplay(),
186 window->getClientWindow()); 188 window.getClientWindow());
187 break; 189 break;
188 case BScreen::WINDOWTAB: 190 case BScreen::WINDOWTAB:
189 window->setTab(!window->hasTab()); 191 window.setTab(!window.hasTab());
190 break; 192 break;
191 } 193 }
192} 194}
193 195
194 196
195void Windowmenu::reconfigure(void) { 197void Windowmenu::reconfigure() {
196 setItemEnabled(1, window->hasTitlebar()); 198 setItemEnabled(1, window.hasTitlebar());
197 setItemEnabled(2, window->isIconifiable()); 199 setItemEnabled(2, window.isIconifiable());
198 setItemEnabled(3, window->isMaximizable()); 200 setItemEnabled(3, window.isMaximizable());
199 setItemEnabled(8, window->isClosable()); 201 setItemEnabled(8, window.isClosable());
200 202
201 sendToMenu->reconfigure(); 203 sendToMenu.reconfigure();
202 sendGroupToMenu->reconfigure(); 204 sendGroupToMenu.reconfigure();
203 205
204 Basemenu::reconfigure(); 206 Basemenu::reconfigure();
205} 207}
@@ -218,7 +220,8 @@ Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu *w)
218 220
219 221
220void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, unsigned int index) { 222void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, unsigned int index) {
221 if (button > 2) return; 223 if (button > 2)
224 return;
222 225
223 if (index <= windowmenu->screen->getCount()) { 226 if (index <= windowmenu->screen->getCount()) {
224 227
@@ -226,20 +229,12 @@ void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, unsigned int inde
226 if (index == windowmenu->screen->getCurrentWorkspaceID()) 229 if (index == windowmenu->screen->getCurrentWorkspaceID())
227 return; 230 return;
228 231
229 // if the window is stuck then unstick it
230 if (windowmenu->window->isStuck())
231 windowmenu->window->stick();
232
233 // if the window is iconic, deiconify it
234 if (windowmenu->window->isIconic())
235 windowmenu->window->deiconify();
236
237 if (button == 1) { // send to workspace without changing workspace 232 if (button == 1) { // send to workspace without changing workspace
238 windowmenu->screen->sendToWorkspace(index, 233 windowmenu->screen->sendToWorkspace(index,
239 windowmenu->window, false); 234 &windowmenu->window, false);
240 } else if (button == 2) { // send to workspace and change workspace 235 } else if (button == 2) { // send to workspace and change workspace
241 windowmenu->screen->sendToWorkspace(index, 236 windowmenu->screen->sendToWorkspace(index,
242 windowmenu->window, true); 237 &windowmenu->window, true);
243 } 238 }
244 } 239 }
245 240
@@ -247,7 +242,7 @@ void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, unsigned int inde
247} 242}
248 243
249 244
250void Windowmenu::SendtoWorkspacemenu::update(void) { 245void Windowmenu::SendtoWorkspacemenu::update() {
251 unsigned int i, r = numberOfItems(); 246 unsigned int i, r = numberOfItems();
252 247
253 if (numberOfItems() != 0) { 248 if (numberOfItems() != 0) {
@@ -261,7 +256,7 @@ void Windowmenu::SendtoWorkspacemenu::update(void) {
261} 256}
262 257
263 258
264void Windowmenu::SendtoWorkspacemenu::show(void) { 259void Windowmenu::SendtoWorkspacemenu::show() {
265 update(); 260 update();
266 261
267 Basemenu::show(); 262 Basemenu::show();
@@ -274,17 +269,17 @@ void Windowmenu::SendGroupToWorkspacemenu::itemSelected(int button, unsigned int
274 if (index <= getWindowMenu()->screen->getCount()) { 269 if (index <= getWindowMenu()->screen->getCount()) {
275 if (index == getWindowMenu()->screen->getCurrentWorkspaceID()) 270 if (index == getWindowMenu()->screen->getCurrentWorkspaceID())
276 return; 271 return;
277 if (getWindowMenu()->window->isStuck()) 272 if (getWindowMenu()->window.isStuck())
278 getWindowMenu()->window->stick(); 273 getWindowMenu()->window.stick();
279 274
280 // if the window is iconic, deiconify it 275 // if the window is iconic, deiconify it
281 if (getWindowMenu()->window->isIconic()) 276 if (getWindowMenu()->window.isIconic())
282 getWindowMenu()->window->deiconify(); 277 getWindowMenu()->window.deiconify();
283 278
284 if (button == 1) { 279 if (button == 1) {
285 // TODO: use reassociateGroup from BScreen instead 280 // TODO: use reassociateGroup from BScreen instead
286 if (getWindowMenu()->window->hasTab()) { 281 if (getWindowMenu()->window.hasTab()) {
287 for (Tab *first = Tab::getFirst(getWindowMenu()->window->getTab()); 282 for (Tab *first = Tab::getFirst(getWindowMenu()->window.getTab());
288 first!=0; first=first->next()) { 283 first!=0; first=first->next()) {
289 first->withdraw(); 284 first->withdraw();
290 first->getWindow()->withdraw(); 285 first->getWindow()->withdraw();
@@ -292,8 +287,8 @@ void Windowmenu::SendGroupToWorkspacemenu::itemSelected(int button, unsigned int
292 287
293 } 288 }
294 } else { 289 } else {
295 getWindowMenu()->window->withdraw(); 290 getWindowMenu()->window.withdraw();
296 getWindowMenu()->screen->reassociateWindow(getWindowMenu()->window, index, True); 291 getWindowMenu()->screen->reassociateWindow(&getWindowMenu()->window, index, True);
297 } 292 }
298 293
299 } 294 }
@@ -304,7 +299,8 @@ void Windowmenu::SendGroupToWorkspacemenu::itemSelected(int button, unsigned int
304 hide(); 299 hide();
305} 300}
306 301
307Windowmenu::SendGroupToWorkspacemenu::SendGroupToWorkspacemenu(Windowmenu *w):SendtoWorkspacemenu(w) 302Windowmenu::SendGroupToWorkspacemenu::
303 SendGroupToWorkspacemenu(Windowmenu *w):SendtoWorkspacemenu(w)
308{ 304{
309 305
310} 306}