aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2005-06-23 03:07:25 (GMT)
committerfluxgen <fluxgen>2005-06-23 03:07:25 (GMT)
commit5373f6d840abaa49685c15fee2f411e77472a7da (patch)
tree46da25845eac32769bad85c264e4edf335cc1783 /src/Window.cc
parent18cf5862495aa6f37110c90286bb6c315a145526 (diff)
downloadfluxbox-5373f6d840abaa49685c15fee2f411e77472a7da.zip
fluxbox-5373f6d840abaa49685c15fee2f411e77472a7da.tar.bz2
moved window menu from FluxboxWindow to BScreen
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc80
1 files changed, 15 insertions, 65 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 6d33a5c..5f45ce8 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -36,6 +36,7 @@
36#include "FbWinFrame.hh" 36#include "FbWinFrame.hh"
37#include "WinButton.hh" 37#include "WinButton.hh"
38#include "WinButtonTheme.hh" 38#include "WinButtonTheme.hh"
39#include "WindowCmd.hh"
39#include "Remember.hh" 40#include "Remember.hh"
40#include "MenuCreator.hh" 41#include "MenuCreator.hh"
41 42
@@ -294,7 +295,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm,
294 m_attaching_tab(0), 295 m_attaching_tab(0),
295 m_screen(client.screen()), 296 m_screen(client.screen()),
296 display(FbTk::App::instance()->display()), 297 display(FbTk::App::instance()->display()),
297 m_windowmenu(MenuCreator::createMenu("", client.screenNumber())),
298 m_button_grab_x(0), m_button_grab_y(0), 298 m_button_grab_x(0), m_button_grab_y(0),
299 m_last_move_x(0), m_last_move_y(0), 299 m_last_move_x(0), m_last_move_y(0),
300 m_last_resize_h(1), m_last_resize_w(1), 300 m_last_resize_h(1), m_last_resize_w(1),
@@ -323,6 +323,9 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm,
323 323
324 324
325FluxboxWindow::~FluxboxWindow() { 325FluxboxWindow::~FluxboxWindow() {
326 if (WindowCmd<void>::window() == this)
327 WindowCmd<void>::setWindow(0);
328
326#ifdef DEBUG 329#ifdef DEBUG
327 cerr<<__FILE__<<"("<<__LINE__<<"): starting ~FluxboxWindow("<<this<<", "<<title()<<")"<<endl; 330 cerr<<__FILE__<<"("<<__LINE__<<"): starting ~FluxboxWindow("<<this<<", "<<title()<<")"<<endl;
328 cerr<<__FILE__<<"("<<__LINE__<<"): num clients = "<<numClients()<<endl; 331 cerr<<__FILE__<<"("<<__LINE__<<"): num clients = "<<numClients()<<endl;
@@ -364,24 +367,6 @@ FluxboxWindow::~FluxboxWindow() {
364 } 367 }
365 368
366 // deal with extra menus 369 // deal with extra menus
367 ExtraMenus::iterator mit = m_extramenus.begin();
368 ExtraMenus::iterator mit_end = m_extramenus.end();
369 for (; mit != mit_end; ++mit) {
370 // we set them to NOT internal so that they will be deleted when the
371 // menu is cleaned up. We can't delete them here because they are
372 // still in the menu
373 // (They need to be internal for most of the time so that if we
374 // rebuild the menu, then they won't be removed.
375 if (mit->second->parent() == 0) {
376 // not attached to our windowmenu
377 // so we clean it up
378 delete mit->second;
379 } else {
380 // let the parent clean it up
381 mit->second->setInternalMenu(false);
382 }
383 }
384
385#ifdef DEBUG 370#ifdef DEBUG
386 cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; 371 cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl;
387#endif // DEBUG 372#endif // DEBUG
@@ -2263,7 +2248,7 @@ void FluxboxWindow::showMenu(int menu_x, int menu_y) {
2263 else if (menu_x + static_cast<signed>(menu().width()) >= static_cast<signed>(screen().maxRight(head))) 2248 else if (menu_x + static_cast<signed>(menu().width()) >= static_cast<signed>(screen().maxRight(head)))
2264 menu_x = screen().maxRight(head) - menu().width() - 1; 2249 menu_x = screen().maxRight(head) - menu().width() - 1;
2265 2250
2266 2251 WindowCmd<void>::setWindow(this);
2267 menu().move(menu_x, menu_y); 2252 menu().move(menu_x, menu_y);
2268 menu().show(); 2253 menu().show();
2269 menu().raise(); 2254 menu().raise();
@@ -2275,6 +2260,8 @@ void FluxboxWindow::showMenu(int menu_x, int menu_y) {
2275 if it's already visible it'll be hidden 2260 if it's already visible it'll be hidden
2276 */ 2261 */
2277void FluxboxWindow::popupMenu() { 2262void FluxboxWindow::popupMenu() {
2263 WindowCmd<void>::setWindow(this);
2264
2278 if (menu().isVisible()) { 2265 if (menu().isVisible()) {
2279 menu().hide(); 2266 menu().hide();
2280 return; 2267 return;
@@ -3553,6 +3540,14 @@ const FbTk::FbWindow &FluxboxWindow::fbWindow() const {
3553 return frame().window(); 3540 return frame().window();
3554} 3541}
3555 3542
3543FbTk::Menu &FluxboxWindow::menu() {
3544 return screen().windowMenu();
3545}
3546
3547const FbTk::Menu &FluxboxWindow::menu() const {
3548 return screen().windowMenu();
3549}
3550
3556unsigned int FluxboxWindow::titlebarHeight() const { 3551unsigned int FluxboxWindow::titlebarHeight() const {
3557 return frame().titlebarHeight(); 3552 return frame().titlebarHeight();
3558} 3553}
@@ -3736,24 +3731,6 @@ void FluxboxWindow::sendConfigureNotify(bool send_to_netizens) {
3736 } // end for 3731 } // end for
3737} 3732}
3738 3733
3739void FluxboxWindow::addExtraMenu(const char *label, FbTk::Menu *menu) {
3740 menu->setInternalMenu();
3741 menu->disableTitle();
3742 m_extramenus.push_back(std::make_pair(label, menu));
3743
3744 setupMenu();
3745}
3746
3747void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) {
3748 ExtraMenus::iterator it = find_if(m_extramenus.begin(),
3749 m_extramenus.end(),
3750 Compose(bind2nd(equal_to<Menu *>(), menu),
3751 Select2nd<ExtraMenus::value_type>()));
3752 if (it != m_extramenus.end())
3753 m_extramenus.erase(it);
3754
3755 setupMenu();
3756}
3757 3734
3758void FluxboxWindow::close() { 3735void FluxboxWindow::close() {
3759 if (m_client) 3736 if (m_client)
@@ -3870,33 +3847,6 @@ void FluxboxWindow::setupWindow() {
3870 3847
3871 // end setup frame 3848 // end setup frame
3872 3849
3873 setupMenu();
3874}
3875
3876void FluxboxWindow::setupMenu() {
3877 // setup menu
3878
3879 menu().removeAll(); // clear old items
3880 menu().disableTitle(); // not titlebar
3881
3882 if (screen().windowMenuFilename().empty() ||
3883 ! MenuCreator::createFromFile(screen().windowMenuFilename(), menu(), *this, true))
3884
3885 {
3886 MenuCreator::createWindowMenuItem("shade", "", menu(), *this);
3887 MenuCreator::createWindowMenuItem("stick", "", menu(), *this);
3888 MenuCreator::createWindowMenuItem("maximize", "", menu(), *this);
3889 MenuCreator::createWindowMenuItem("iconify", "", menu(), *this);
3890 MenuCreator::createWindowMenuItem("raise", "", menu(), *this);
3891 MenuCreator::createWindowMenuItem("lower", "", menu(), *this);
3892 MenuCreator::createWindowMenuItem("sendto", "", menu(), *this);
3893 MenuCreator::createWindowMenuItem("layer", "", menu(), *this);
3894 MenuCreator::createWindowMenuItem("extramenus", "", menu(), *this);
3895 MenuCreator::createWindowMenuItem("separator", "", menu(), *this);
3896 MenuCreator::createWindowMenuItem("close", "", menu(), *this);
3897 }
3898
3899 menu().reconfigure(); // update graphics
3900} 3850}
3901 3851
3902 3852