We now create titlebar resource session.screen<num>.titlbar.left/right on the fly here instead of fluxbox.cc
This commit is contained in:
parent
75c7965446
commit
bdc74e7995
1 changed files with 120 additions and 52 deletions
154
src/Window.cc
154
src/Window.cc
|
@ -3814,74 +3814,142 @@ void FluxboxWindow::setupWindow() {
|
||||||
|
|
||||||
// clear old buttons from frame
|
// clear old buttons from frame
|
||||||
frame().removeAllButtons();
|
frame().removeAllButtons();
|
||||||
//!! TODO: fix this ugly hack
|
|
||||||
// get titlebar configuration
|
typedef FbTk::Resource<std::vector<WinButton::Type> > WinButtonsResource;
|
||||||
const vector<Fluxbox::Titlebar> *dir = &Fluxbox::instance()->getTitlebarLeft();
|
|
||||||
for (char c=0; c<2; c++) {
|
std::string titlebar_name[2];
|
||||||
for (size_t i=0; i< dir->size(); ++i) {
|
std::string titlebar_alt_name[2];
|
||||||
|
titlebar_name[0] = screen().name() + ".titlebar.left";
|
||||||
|
titlebar_alt_name[0] = screen().altName() + ".Titlebar.Left";
|
||||||
|
titlebar_name[1] = screen().name() + ".titlebar.right";
|
||||||
|
titlebar_alt_name[1] = screen().altName() + ".Titlebar.Right";
|
||||||
|
|
||||||
|
WinButtonsResource *titlebar_side[2];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ResourceManager &rm = screen().resourceManager();
|
||||||
|
|
||||||
|
// create resource for titlebar
|
||||||
|
for (int i=0; i < 2; ++i) {
|
||||||
|
titlebar_side[i] = dynamic_cast<WinButtonsResource *>(
|
||||||
|
rm.findResource( titlebar_name[i] ) );
|
||||||
|
|
||||||
|
if (titlebar_side[i] != 0)
|
||||||
|
continue; // find next resource too
|
||||||
|
|
||||||
|
WinButton::Type titlebar_left[] = {
|
||||||
|
WinButton::STICK
|
||||||
|
};
|
||||||
|
|
||||||
|
WinButton::Type titlebar_right[] = {
|
||||||
|
WinButton::MINIMIZE,
|
||||||
|
WinButton::MAXIMIZE,
|
||||||
|
WinButton::CLOSE
|
||||||
|
};
|
||||||
|
|
||||||
|
WinButton::Type *begin = 0;
|
||||||
|
WinButton::Type *end = 0;
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
begin = titlebar_left;
|
||||||
|
end = titlebar_left + 1;
|
||||||
|
} else {
|
||||||
|
begin = titlebar_right;
|
||||||
|
end = titlebar_right + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
titlebar_side[i] =
|
||||||
|
new WinButtonsResource(rm,
|
||||||
|
WinButtonsResource::Type(begin, end),
|
||||||
|
titlebar_name[i], titlebar_alt_name[i]);
|
||||||
|
|
||||||
|
|
||||||
|
screen().addManagedResource(titlebar_side[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (char c = 0; c < 2 ; c++) {
|
||||||
|
// get titlebar configuration for current side
|
||||||
|
const std::vector<WinButton::Type> &dir = *(*titlebar_side[c]);
|
||||||
|
|
||||||
|
for (size_t i=0; i < dir.size(); ++i) {
|
||||||
//create new buttons
|
//create new buttons
|
||||||
FbTk::Button *newbutton = 0;
|
WinButton *winbtn = 0;
|
||||||
if (isIconifiable() && (*dir)[i] == Fluxbox::MINIMIZE) {
|
|
||||||
newbutton = new WinButton(*this, winbutton_theme,
|
switch (dir[i]) {
|
||||||
|
case WinButton::MINIMIZE:
|
||||||
|
if (isIconifiable()) {
|
||||||
|
winbtn = new WinButton(*this, winbutton_theme,
|
||||||
WinButton::MINIMIZE,
|
WinButton::MINIMIZE,
|
||||||
frame().titlebar(),
|
frame().titlebar(),
|
||||||
0, 0, 10, 10);
|
0, 0, 10, 10);
|
||||||
newbutton->setOnClick(iconify_cmd);
|
winbtn->setOnClick(iconify_cmd);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WinButton::MAXIMIZE:
|
||||||
|
if (isMaximizable()) {
|
||||||
|
winbtn = new WinButton(*this, winbutton_theme,
|
||||||
|
dir[i],
|
||||||
|
frame().titlebar(),
|
||||||
|
0, 0, 10, 10);
|
||||||
|
winbtn->setOnClick(maximize_cmd, 1);
|
||||||
|
winbtn->setOnClick(maximize_horiz_cmd, 3);
|
||||||
|
winbtn->setOnClick(maximize_vert_cmd, 2);
|
||||||
|
|
||||||
} else if (isMaximizable() && (*dir)[i] == Fluxbox::MAXIMIZE) {
|
}
|
||||||
newbutton = new WinButton(*this, winbutton_theme,
|
break;
|
||||||
WinButton::MAXIMIZE,
|
case WinButton::CLOSE:
|
||||||
|
if (m_client->isClosable()) {
|
||||||
|
winbtn = new WinButton(*this, winbutton_theme,
|
||||||
|
dir[i],
|
||||||
frame().titlebar(),
|
frame().titlebar(),
|
||||||
0, 0, 10, 10);
|
0, 0, 10, 10);
|
||||||
|
|
||||||
newbutton->setOnClick(maximize_cmd, 1);
|
winbtn->setOnClick(close_cmd);
|
||||||
newbutton->setOnClick(maximize_horiz_cmd, 3);
|
|
||||||
newbutton->setOnClick(maximize_vert_cmd, 2);
|
|
||||||
|
|
||||||
} else if (m_client->isClosable() && (*dir)[i] == Fluxbox::CLOSE) {
|
|
||||||
newbutton = new WinButton(*this, winbutton_theme,
|
|
||||||
WinButton::CLOSE,
|
|
||||||
frame().titlebar(),
|
|
||||||
0, 0, 10, 10);
|
|
||||||
|
|
||||||
newbutton->setOnClick(close_cmd);
|
|
||||||
|
|
||||||
} else if ((*dir)[i] == Fluxbox::STICK) {
|
|
||||||
WinButton *winbtn = new WinButton(*this, winbutton_theme,
|
|
||||||
WinButton::STICK,
|
|
||||||
frame().titlebar(),
|
|
||||||
0, 0, 10, 10);
|
|
||||||
stateSig().attach(winbtn);
|
stateSig().attach(winbtn);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WinButton::STICK:
|
||||||
|
winbtn = new WinButton(*this, winbutton_theme,
|
||||||
|
dir[i],
|
||||||
|
frame().titlebar(),
|
||||||
|
0, 0, 10, 10);
|
||||||
|
|
||||||
winbtn->setOnClick(stick_cmd);
|
winbtn->setOnClick(stick_cmd);
|
||||||
newbutton = winbtn;
|
break;
|
||||||
} else if ((*dir)[i] == Fluxbox::SHADE) {
|
case WinButton::SHADE:
|
||||||
WinButton *winbtn = new WinButton(*this, winbutton_theme,
|
winbtn = new WinButton(*this, winbutton_theme,
|
||||||
WinButton::SHADE,
|
dir[i],
|
||||||
frame().titlebar(),
|
frame().titlebar(),
|
||||||
0, 0, 10, 10);
|
0, 0, 10, 10);
|
||||||
stateSig().attach(winbtn);
|
stateSig().attach(winbtn);
|
||||||
winbtn->setOnClick(shade_cmd);
|
winbtn->setOnClick(shade_cmd);
|
||||||
newbutton = winbtn;
|
break;
|
||||||
} else if ((*dir)[i] == Fluxbox::MENUICON) {
|
case WinButton::MENUICON:
|
||||||
WinButton* winbtn = new WinButton(*this, winbutton_theme,
|
winbtn = new WinButton(*this, winbutton_theme,
|
||||||
WinButton::MENUICON,
|
dir[i],
|
||||||
frame().titlebar(),
|
frame().titlebar(),
|
||||||
0, 0, 10, 10);
|
0, 0, 10, 10);
|
||||||
hintSig().attach(winbtn);
|
hintSig().attach(winbtn);
|
||||||
titleSig().attach(winbtn);
|
titleSig().attach(winbtn);
|
||||||
winbtn->setOnClick(show_menu_cmd);
|
winbtn->setOnClick(show_menu_cmd);
|
||||||
newbutton = winbtn;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newbutton != 0) {
|
|
||||||
newbutton->show();
|
if (winbtn != 0) {
|
||||||
|
winbtn->show();
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
frame().addLeftButton(newbutton);
|
frame().addLeftButton(winbtn);
|
||||||
else
|
else
|
||||||
frame().addRightButton(newbutton);
|
frame().addRightButton(winbtn);
|
||||||
}
|
}
|
||||||
} //end for i
|
} //end for i
|
||||||
dir = &Fluxbox::instance()->getTitlebarRight();
|
|
||||||
|
|
||||||
} // end for c
|
} // end for c
|
||||||
|
|
||||||
frame().reconfigure();
|
frame().reconfigure();
|
||||||
|
|
Loading…
Reference in a new issue