aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc191
1 files changed, 178 insertions, 13 deletions
diff --git a/src/Window.cc b/src/Window.cc
index ca6ab99..bfb7dae 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.205 2003/07/19 11:55:49 rathnor Exp $ 25// $Id: Window.cc,v 1.206 2003/07/20 08:12:36 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -41,6 +41,8 @@
41#include "Workspace.hh" 41#include "Workspace.hh"
42#include "LayerMenu.hh" 42#include "LayerMenu.hh"
43#include "FbWinFrame.hh" 43#include "FbWinFrame.hh"
44#include "WinButton.hh"
45#include "WinButtonTheme.hh"
44 46
45#ifdef HAVE_CONFIG_H 47#ifdef HAVE_CONFIG_H
46#include "config.h" 48#include "config.h"
@@ -234,12 +236,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t
234 m_screen(scr), 236 m_screen(scr),
235 m_timer(this), 237 m_timer(this),
236 display(0), 238 display(0),
237 m_layermenu(new LayerMenu<FluxboxWindow>(*scr.menuTheme(),
238 scr.screenNumber(),
239 scr.imageControl(),
240 *scr.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
241 this,
242 false)),
243 m_windowmenu(*scr.menuTheme(), scr.screenNumber(), scr.imageControl()), 239 m_windowmenu(*scr.menuTheme(), scr.screenNumber(), scr.imageControl()),
244 m_old_decoration(DECOR_NORMAL), 240 m_old_decoration(DECOR_NORMAL),
245 m_client(&client), 241 m_client(&client),
@@ -295,6 +291,18 @@ FluxboxWindow::~FluxboxWindow() {
295 } 291 }
296 } 292 }
297 293
294 // deal with extra menus
295 ExtraMenus::iterator mit = m_extramenus.begin();
296 ExtraMenus::iterator mit_end = m_extramenus.end();
297 for (; mit != mit_end; ++mit) {
298 // we set them to NOT internal so that they will be deleted when the
299 // menu is cleaned up. We can't delete them here because they are
300 // still in the menu
301 // (They need to be internal for most of the time so that if we
302 // rebuild the menu, then they won't be removed.
303 mit->second->setInternalMenu(false);
304 }
305
298#ifdef DEBUG 306#ifdef DEBUG
299 cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; 307 cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl;
300#endif // DEBUG 308#endif // DEBUG
@@ -302,10 +310,6 @@ FluxboxWindow::~FluxboxWindow() {
302 310
303 311
304void FluxboxWindow::init() { 312void FluxboxWindow::init() {
305 // so parent menu don't kill us
306 m_layermenu->setInternalMenu();
307 m_layermenu->disableTitle();
308
309 m_attaching_tab = 0; 313 m_attaching_tab = 0;
310 314
311 assert(m_client); 315 assert(m_client);
@@ -518,7 +522,17 @@ void FluxboxWindow::init() {
518 } 522 }
519 523
520 setState(m_current_state); 524 setState(m_current_state);
521 frame().reconfigure(); 525
526 addExtraMenu("Layer...",
527 new LayerMenu<FluxboxWindow>(*screen().menuTheme(),
528 screen().screenNumber(),
529 screen().imageControl(),
530 *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
531 this,
532 false));
533 // the layermenu will get deleted as an extra menu
534 // don't call setupWindow here as the addExtraMenu call should
535
522 sendConfigureNotify(); 536 sendConfigureNotify();
523 // no focus default 537 // no focus default
524 setFocusFlag(false); 538 setFocusFlag(false);
@@ -2169,7 +2183,7 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) {
2169 getWMProtocols(); 2183 getWMProtocols();
2170 //!!TODO check this area 2184 //!!TODO check this area
2171 // reset window actions 2185 // reset window actions
2172 screen().setupWindowActions(*this); 2186 setupWindow();
2173 2187
2174 } 2188 }
2175 break; 2189 break;
@@ -3304,3 +3318,154 @@ void FluxboxWindow::sendConfigureNotify(bool send_to_netizens) {
3304 } // end for 3318 } // end for
3305} 3319}
3306 3320
3321void FluxboxWindow::addExtraMenu(const char *label, FbTk::Menu *menu) {
3322 menu->setInternalMenu();
3323 menu->disableTitle();
3324 m_extramenus.push_back(std::make_pair(label, menu));
3325
3326 setupWindow();
3327}
3328
3329void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) {
3330 ExtraMenus::iterator it = m_extramenus.begin();
3331 ExtraMenus::iterator it_end = m_extramenus.end();
3332 for (; it != it_end; ++it) {
3333 if (it->second == menu) {
3334 m_extramenus.erase(it);
3335 break;
3336 }
3337 }
3338 setupWindow();
3339}
3340
3341
3342void FluxboxWindow::setupWindow() {
3343 // sets up our window
3344 // we allow both to be done at once to share the commands
3345
3346 FbWinFrame &frame = *m_frame.get();
3347 WinButtonTheme &winbutton_theme = screen().winButtonTheme();
3348
3349 typedef FbTk::RefCount<FbTk::Command> CommandRef;
3350
3351 using namespace FbTk;
3352 typedef RefCount<Command> CommandRef;
3353 typedef SimpleCommand<FluxboxWindow> WindowCmd;
3354
3355 CommandRef iconify_cmd(new WindowCmd(*this, &FluxboxWindow::iconify));
3356 CommandRef maximize_cmd(new WindowCmd(*this, &FluxboxWindow::maximize));
3357 CommandRef maximize_vert_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeVertical));
3358 CommandRef maximize_horiz_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeHorizontal));
3359 CommandRef close_cmd(new WindowCmd(*this, &FluxboxWindow::close));
3360 CommandRef shade_cmd(new WindowCmd(*this, &FluxboxWindow::shade));
3361 CommandRef raise_cmd(new WindowCmd(*this, &FluxboxWindow::raise));
3362 CommandRef lower_cmd(new WindowCmd(*this, &FluxboxWindow::lower));
3363 CommandRef raise_and_focus_cmd(new WindowCmd(*this, &FluxboxWindow::raiseAndFocus));
3364 CommandRef stick_cmd(new WindowCmd(*this, &FluxboxWindow::stick));
3365 CommandRef show_menu_cmd(new WindowCmd(*this, &FluxboxWindow::popupMenu));
3366
3367 // clear old buttons from frame
3368 frame.removeAllButtons();
3369 //!! TODO: fix this ugly hack
3370 // get titlebar configuration
3371 const vector<Fluxbox::Titlebar> *dir = &Fluxbox::instance()->getTitlebarLeft();
3372 for (char c=0; c<2; c++) {
3373 for (size_t i=0; i< dir->size(); ++i) {
3374 //create new buttons
3375 FbTk::Button *newbutton = 0;
3376 if (isIconifiable() && (*dir)[i] == Fluxbox::MINIMIZE) {
3377 newbutton = new WinButton(*this, winbutton_theme,
3378 WinButton::MINIMIZE,
3379 frame.titlebar(),
3380 0, 0, 10, 10);
3381 newbutton->setOnClick(iconify_cmd);
3382
3383 } else if (isMaximizable() && (*dir)[i] == Fluxbox::MAXIMIZE) {
3384 newbutton = new WinButton(*this, winbutton_theme,
3385 WinButton::MAXIMIZE,
3386 frame.titlebar(),
3387 0, 0, 10, 10);
3388
3389 newbutton->setOnClick(maximize_cmd, 1);
3390 newbutton->setOnClick(maximize_horiz_cmd, 3);
3391 newbutton->setOnClick(maximize_vert_cmd, 2);
3392
3393 } else if (isClosable() && (*dir)[i] == Fluxbox::CLOSE) {
3394 newbutton = new WinButton(*this, winbutton_theme,
3395 WinButton::CLOSE,
3396 frame.titlebar(),
3397 0, 0, 10, 10);
3398
3399 newbutton->setOnClick(close_cmd);
3400#ifdef DEBUG
3401 cerr<<__FILE__<<": Creating close button"<<endl;
3402#endif // DEBUG
3403 } else if ((*dir)[i] == Fluxbox::STICK) {
3404 WinButton *winbtn = new WinButton(*this, winbutton_theme,
3405 WinButton::STICK,
3406 frame.titlebar(),
3407 0, 0, 10, 10);
3408 stateSig().attach(winbtn);
3409 winbtn->setOnClick(stick_cmd);
3410 newbutton = winbtn;
3411 } else if ((*dir)[i] == Fluxbox::SHADE) {
3412 WinButton *winbtn = new WinButton(*this, winbutton_theme,
3413 WinButton::SHADE,
3414 frame.titlebar(),
3415 0, 0, 10, 10);
3416 winbtn->setOnClick(shade_cmd);
3417 }
3418
3419 if (newbutton != 0) {
3420 newbutton->show();
3421 if (c == 0)
3422 frame.addLeftButton(newbutton);
3423 else
3424 frame.addRightButton(newbutton);
3425 }
3426 } //end for i
3427 dir = &Fluxbox::instance()->getTitlebarRight();
3428 } // end for c
3429
3430 frame.reconfigure();
3431
3432 // setup titlebar
3433 frame.setOnClickTitlebar(raise_and_focus_cmd, 1, false, true); // on press with button 1
3434 frame.setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1
3435 frame.setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3
3436 frame.setOnClickTitlebar(lower_cmd, 2); // on release with button 2
3437 frame.setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
3438
3439 // end setup frame
3440
3441 // setup menu
3442 FbTk::Menu &menu = m_windowmenu;
3443 menu.removeAll(); // clear old items
3444 menu.disableTitle(); // not titlebar
3445
3446 // set new menu items
3447 menu.insert("Shade", shade_cmd);
3448 menu.insert("Stick", stick_cmd);
3449 menu.insert("Maximize", maximize_cmd);
3450 menu.insert("Maximize Vertical", maximize_vert_cmd);
3451 menu.insert("Maximize Horizontal", maximize_horiz_cmd);
3452 menu.insert("Iconify", iconify_cmd);
3453 menu.insert("Raise", raise_cmd);
3454 menu.insert("Lower", lower_cmd);
3455 CommandRef next_client_cmd(new WindowCmd(*this, &FluxboxWindow::nextClient));
3456 CommandRef prev_client_cmd(new WindowCmd(*this, &FluxboxWindow::prevClient));
3457 menu.insert("Next Client", next_client_cmd);
3458 menu.insert("Prev Client", prev_client_cmd);
3459
3460 ExtraMenus::iterator it = m_extramenus.begin();
3461 ExtraMenus::iterator it_end = m_extramenus.end();
3462 for (; it != it_end; ++it) {
3463 it->second->disableTitle(); // be sure there is no title
3464 menu.insert(it->first, it->second);
3465 }
3466
3467 menu.insert("ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ");
3468 menu.insert("Close", close_cmd);
3469
3470 menu.reconfigure(); // update graphics
3471}