summaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc180
1 files changed, 124 insertions, 56 deletions
diff --git a/src/Window.cc b/src/Window.cc
index fbec829..b03ee6f 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -3814,74 +3814,142 @@ void FluxboxWindow::setupWindow() {
3814 3814
3815 // clear old buttons from frame 3815 // clear old buttons from frame
3816 frame().removeAllButtons(); 3816 frame().removeAllButtons();
3817 //!! TODO: fix this ugly hack 3817
3818 // get titlebar configuration 3818 typedef FbTk::Resource<std::vector<WinButton::Type> > WinButtonsResource;
3819 const vector<Fluxbox::Titlebar> *dir = &Fluxbox::instance()->getTitlebarLeft(); 3819
3820 for (char c=0; c<2; c++) { 3820 std::string titlebar_name[2];
3821 for (size_t i=0; i< dir->size(); ++i) { 3821 std::string titlebar_alt_name[2];
3822 titlebar_name[0] = screen().name() + ".titlebar.left";
3823 titlebar_alt_name[0] = screen().altName() + ".Titlebar.Left";
3824 titlebar_name[1] = screen().name() + ".titlebar.right";
3825 titlebar_alt_name[1] = screen().altName() + ".Titlebar.Right";
3826
3827 WinButtonsResource *titlebar_side[2];
3828
3829
3830
3831 ResourceManager &rm = screen().resourceManager();
3832
3833 // create resource for titlebar
3834 for (int i=0; i < 2; ++i) {
3835 titlebar_side[i] = dynamic_cast<WinButtonsResource *>(
3836 rm.findResource( titlebar_name[i] ) );
3837
3838 if (titlebar_side[i] != 0)
3839 continue; // find next resource too
3840
3841 WinButton::Type titlebar_left[] = {
3842 WinButton::STICK
3843 };
3844
3845 WinButton::Type titlebar_right[] = {
3846 WinButton::MINIMIZE,
3847 WinButton::MAXIMIZE,
3848 WinButton::CLOSE
3849 };
3850
3851 WinButton::Type *begin = 0;
3852 WinButton::Type *end = 0;
3853
3854 if (i == 0) {
3855 begin = titlebar_left;
3856 end = titlebar_left + 1;
3857 } else {
3858 begin = titlebar_right;
3859 end = titlebar_right + 3;
3860 }
3861
3862 titlebar_side[i] =
3863 new WinButtonsResource(rm,
3864 WinButtonsResource::Type(begin, end),
3865 titlebar_name[i], titlebar_alt_name[i]);
3866
3867
3868 screen().addManagedResource(titlebar_side[i]);
3869 }
3870
3871
3872
3873
3874 for (char c = 0; c < 2 ; c++) {
3875 // get titlebar configuration for current side
3876 const std::vector<WinButton::Type> &dir = *(*titlebar_side[c]);
3877
3878 for (size_t i=0; i < dir.size(); ++i) {
3822 //create new buttons 3879 //create new buttons
3823 FbTk::Button *newbutton = 0; 3880 WinButton *winbtn = 0;
3824 if (isIconifiable() && (*dir)[i] == Fluxbox::MINIMIZE) { 3881
3825 newbutton = new WinButton(*this, winbutton_theme, 3882 switch (dir[i]) {
3826 WinButton::MINIMIZE, 3883 case WinButton::MINIMIZE:
3827 frame().titlebar(), 3884 if (isIconifiable()) {
3828 0, 0, 10, 10); 3885 winbtn = new WinButton(*this, winbutton_theme,
3829 newbutton->setOnClick(iconify_cmd); 3886 WinButton::MINIMIZE,
3830 3887 frame().titlebar(),
3831 } else if (isMaximizable() && (*dir)[i] == Fluxbox::MAXIMIZE) { 3888 0, 0, 10, 10);
3832 newbutton = new WinButton(*this, winbutton_theme, 3889 winbtn->setOnClick(iconify_cmd);
3833 WinButton::MAXIMIZE, 3890 }
3834 frame().titlebar(), 3891 break;
3835 0, 0, 10, 10); 3892 case WinButton::MAXIMIZE:
3836 3893 if (isMaximizable()) {
3837 newbutton->setOnClick(maximize_cmd, 1); 3894 winbtn = new WinButton(*this, winbutton_theme,
3838 newbutton->setOnClick(maximize_horiz_cmd, 3); 3895 dir[i],
3839 newbutton->setOnClick(maximize_vert_cmd, 2); 3896 frame().titlebar(),
3840 3897 0, 0, 10, 10);
3841 } else if (m_client->isClosable() && (*dir)[i] == Fluxbox::CLOSE) { 3898 winbtn->setOnClick(maximize_cmd, 1);
3842 newbutton = new WinButton(*this, winbutton_theme, 3899 winbtn->setOnClick(maximize_horiz_cmd, 3);
3843 WinButton::CLOSE, 3900 winbtn->setOnClick(maximize_vert_cmd, 2);
3844 frame().titlebar(), 3901
3845 0, 0, 10, 10); 3902 }
3846 3903 break;
3847 newbutton->setOnClick(close_cmd); 3904 case WinButton::CLOSE:
3848 3905 if (m_client->isClosable()) {
3849 } else if ((*dir)[i] == Fluxbox::STICK) { 3906 winbtn = new WinButton(*this, winbutton_theme,
3850 WinButton *winbtn = new WinButton(*this, winbutton_theme, 3907 dir[i],
3851 WinButton::STICK, 3908 frame().titlebar(),
3852 frame().titlebar(), 3909 0, 0, 10, 10);
3853 0, 0, 10, 10); 3910
3854 stateSig().attach(winbtn); 3911 winbtn->setOnClick(close_cmd);
3912 stateSig().attach(winbtn);
3913 }
3914 break;
3915 case WinButton::STICK:
3916 winbtn = new WinButton(*this, winbutton_theme,
3917 dir[i],
3918 frame().titlebar(),
3919 0, 0, 10, 10);
3920
3855 winbtn->setOnClick(stick_cmd); 3921 winbtn->setOnClick(stick_cmd);
3856 newbutton = winbtn; 3922 break;
3857 } else if ((*dir)[i] == Fluxbox::SHADE) { 3923 case WinButton::SHADE:
3858 WinButton *winbtn = new WinButton(*this, winbutton_theme, 3924 winbtn = new WinButton(*this, winbutton_theme,
3859 WinButton::SHADE, 3925 dir[i],
3860 frame().titlebar(), 3926 frame().titlebar(),
3861 0, 0, 10, 10); 3927 0, 0, 10, 10);
3862 stateSig().attach(winbtn); 3928 stateSig().attach(winbtn);
3863 winbtn->setOnClick(shade_cmd); 3929 winbtn->setOnClick(shade_cmd);
3864 newbutton = winbtn; 3930 break;
3865 } else if ((*dir)[i] == Fluxbox::MENUICON) { 3931 case WinButton::MENUICON:
3866 WinButton* winbtn = new WinButton(*this, winbutton_theme, 3932 winbtn = new WinButton(*this, winbutton_theme,
3867 WinButton::MENUICON, 3933 dir[i],
3868 frame().titlebar(), 3934 frame().titlebar(),
3869 0, 0, 10, 10); 3935 0, 0, 10, 10);
3870 hintSig().attach(winbtn); 3936 hintSig().attach(winbtn);
3871 titleSig().attach(winbtn); 3937 titleSig().attach(winbtn);
3872 winbtn->setOnClick(show_menu_cmd); 3938 winbtn->setOnClick(show_menu_cmd);
3873 newbutton = winbtn; 3939 break;
3874 } 3940 }
3875 3941
3876 if (newbutton != 0) { 3942
3877 newbutton->show(); 3943 if (winbtn != 0) {
3944 winbtn->show();
3878 if (c == 0) 3945 if (c == 0)
3879 frame().addLeftButton(newbutton); 3946 frame().addLeftButton(winbtn);
3880 else 3947 else
3881 frame().addRightButton(newbutton); 3948 frame().addRightButton(winbtn);
3882 } 3949 }
3883 } //end for i 3950 } //end for i
3884 dir = &Fluxbox::instance()->getTitlebarRight(); 3951
3952
3885 } // end for c 3953 } // end for c
3886 3954
3887 frame().reconfigure(); 3955 frame().reconfigure();