cleaning, create and delete tabs with FbWinFrame createTab/removeTab
This commit is contained in:
parent
55f62bc5cc
commit
d3362370f5
3 changed files with 60 additions and 74 deletions
|
@ -331,33 +331,41 @@ void FbWinFrame::removeAllButtons() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FbWinFrame::addLabelButton(FbTk::TextButton &btn) {
|
FbWinFrame::ButtonId FbWinFrame::createTab(const std::string &title, FbTk::Command *command) {
|
||||||
LabelList::iterator found_it = find(m_labelbuttons.begin(),
|
FbTk::TextButton *button = new FbTk::TextButton(label(),
|
||||||
m_labelbuttons.end(),
|
theme().font(),
|
||||||
&btn);
|
title);
|
||||||
|
button->show();
|
||||||
|
button->setEventMask(ExposureMask | ButtonPressMask |
|
||||||
|
ButtonReleaseMask | ButtonMotionMask |
|
||||||
|
EnterWindowMask);
|
||||||
|
|
||||||
if (found_it != m_labelbuttons.end())
|
FbTk::RefCount<FbTk::Command> refcmd(command);
|
||||||
return;
|
button->setOnClick(refcmd);
|
||||||
|
|
||||||
btn.setTextPadding(Fluxbox::instance()->getTabsPadding());
|
button->setTextPadding(Fluxbox::instance()->getTabsPadding());
|
||||||
m_labelbuttons.push_back(&btn);
|
button->setJustify(theme().justify());
|
||||||
|
|
||||||
|
m_labelbuttons.push_back(button);
|
||||||
|
|
||||||
if (currentLabel() == 0)
|
if (currentLabel() == 0)
|
||||||
setLabelButtonFocus(btn);
|
setLabelButtonFocus(*button);
|
||||||
|
|
||||||
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FbWinFrame::removeLabelButton(FbTk::TextButton &btn) {
|
void FbWinFrame::removeTab(ButtonId btn) {
|
||||||
LabelList::iterator erase_it = remove(m_labelbuttons.begin(),
|
LabelList::iterator erase_it = remove(m_labelbuttons.begin(),
|
||||||
m_labelbuttons.end(),
|
m_labelbuttons.end(),
|
||||||
&btn);
|
btn);
|
||||||
if (erase_it == m_labelbuttons.end())
|
if (erase_it == m_labelbuttons.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (&btn == m_current_label)
|
if (btn == m_current_label)
|
||||||
m_current_label = 0;
|
m_current_label = 0;
|
||||||
|
|
||||||
m_labelbuttons.erase(erase_it);
|
m_labelbuttons.erase(erase_it);
|
||||||
|
delete btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -550,6 +558,7 @@ void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {
|
||||||
m_clientarea.raise();
|
m_clientarea.raise();
|
||||||
win.raise();
|
win.raise();
|
||||||
m_window.showSubwindows();
|
m_window.showSubwindows();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FbWinFrame::hideTitlebar() {
|
bool FbWinFrame::hideTitlebar() {
|
||||||
|
|
|
@ -51,6 +51,7 @@ class Texture;
|
||||||
/// (see: <a href="fluxbox_fbwinframe.png">image</a>)
|
/// (see: <a href="fluxbox_fbwinframe.png">image</a>)
|
||||||
class FbWinFrame:public FbTk::EventHandler {
|
class FbWinFrame:public FbTk::EventHandler {
|
||||||
public:
|
public:
|
||||||
|
typedef FbTk::TextButton *ButtonId; ///< defines a button id
|
||||||
|
|
||||||
/// create a top level window
|
/// create a top level window
|
||||||
FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
|
FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
|
||||||
|
@ -81,10 +82,14 @@ public:
|
||||||
void resizeForClient(unsigned int width, unsigned int height, int win_gravity=ForgetGravity);
|
void resizeForClient(unsigned int width, unsigned int height, int win_gravity=ForgetGravity);
|
||||||
|
|
||||||
// for when there needs to be an atomic move+resize operation
|
// for when there needs to be an atomic move+resize operation
|
||||||
void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity);
|
void moveResizeForClient(int x, int y,
|
||||||
|
unsigned int width, unsigned int height,
|
||||||
|
bool move = true, bool resize = true, int win_gravity=ForgetGravity);
|
||||||
|
|
||||||
// can elect to ignore move or resize (mainly for use of move/resize individual functions
|
// can elect to ignore move or resize (mainly for use of move/resize individual functions
|
||||||
void moveResize(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity);
|
void moveResize(int x, int y,
|
||||||
|
unsigned int width, unsigned int height,
|
||||||
|
bool move = true, bool resize = true, int win_gravity=ForgetGravity);
|
||||||
|
|
||||||
/// some outside move/resize happened, and we need to notify all of our windows
|
/// some outside move/resize happened, and we need to notify all of our windows
|
||||||
/// in case of transparency
|
/// in case of transparency
|
||||||
|
@ -101,10 +106,11 @@ public:
|
||||||
void addRightButton(FbTk::Button *btn);
|
void addRightButton(FbTk::Button *btn);
|
||||||
/// remove all buttons from titlebar
|
/// remove all buttons from titlebar
|
||||||
void removeAllButtons();
|
void removeAllButtons();
|
||||||
/// adds a button to label window
|
/// adds a button to label window with specified title and command
|
||||||
void addLabelButton(FbTk::TextButton &btn);
|
ButtonId createTab(const std::string &title, FbTk::Command *cmd);
|
||||||
|
// void addLabelButton(FbTk::TextButton &btn);
|
||||||
/// removes a specific button from label window
|
/// removes a specific button from label window
|
||||||
void removeLabelButton(FbTk::TextButton &btn);
|
void removeTab(ButtonId id);
|
||||||
/// move label button to the left
|
/// move label button to the left
|
||||||
void moveLabelButtonLeft(const FbTk::TextButton &btn);
|
void moveLabelButtonLeft(const FbTk::TextButton &btn);
|
||||||
/// move label button to the right
|
/// move label button to the right
|
||||||
|
|
|
@ -338,10 +338,9 @@ FluxboxWindow::~FluxboxWindow() {
|
||||||
|
|
||||||
Client2ButtonMap::iterator it = m_labelbuttons.begin();
|
Client2ButtonMap::iterator it = m_labelbuttons.begin();
|
||||||
Client2ButtonMap::iterator it_end = m_labelbuttons.end();
|
Client2ButtonMap::iterator it_end = m_labelbuttons.end();
|
||||||
for (; it != it_end; ++it) {
|
for (; it != it_end; ++it)
|
||||||
frame().removeLabelButton(*(*it).second);
|
frame().removeTab((*it).second);
|
||||||
delete (*it).second;
|
|
||||||
}
|
|
||||||
m_labelbuttons.clear();
|
m_labelbuttons.clear();
|
||||||
|
|
||||||
m_timer.stop();
|
m_timer.stop();
|
||||||
|
@ -420,21 +419,14 @@ void FluxboxWindow::init() {
|
||||||
frame().gripRight().setCursor(frame().theme().lowerRightAngleCursor());
|
frame().gripRight().setCursor(frame().theme().lowerRightAngleCursor());
|
||||||
|
|
||||||
|
|
||||||
FbTk::TextButton *btn = new FbTk::TextButton(frame().label(),
|
FbWinFrame::ButtonId btn = frame().createTab(m_client->title(),
|
||||||
frame().theme().font(),
|
new SetClientCmd(*m_client));
|
||||||
m_client->title());
|
|
||||||
btn->setJustify(frame().theme().justify());
|
m_labelbuttons[m_client] = btn;
|
||||||
m_labelbuttons[m_client] = btn;
|
frame().setLabelButtonFocus(*btn);
|
||||||
frame().addLabelButton(*btn);
|
|
||||||
frame().setLabelButtonFocus(*btn);
|
FbTk::EventManager &evm = *FbTk::EventManager::instance();
|
||||||
btn->show();
|
|
||||||
FbTk::EventManager &evm = *FbTk::EventManager::instance();
|
|
||||||
// we need motion notify so we mask it
|
|
||||||
btn->setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask |
|
|
||||||
ButtonMotionMask | EnterWindowMask);
|
|
||||||
|
|
||||||
FbTk::RefCount<FbTk::Command> set_client_cmd(new SetClientCmd(*m_client));
|
|
||||||
btn->setOnClick(set_client_cmd);
|
|
||||||
evm.add(*this, btn->window()); // we take care of button events for this
|
evm.add(*this, btn->window()); // we take care of button events for this
|
||||||
evm.add(*this, m_client->window());
|
evm.add(*this, m_client->window());
|
||||||
|
|
||||||
|
@ -668,11 +660,10 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
|
||||||
if (client.fbwindow() != 0) {
|
if (client.fbwindow() != 0) {
|
||||||
FluxboxWindow *old_win = client.fbwindow(); // store old window
|
FluxboxWindow *old_win = client.fbwindow(); // store old window
|
||||||
|
|
||||||
ClientList::iterator client_insert_pos=getClientInsertPosition(x,y);
|
ClientList::iterator client_insert_pos = getClientInsertPosition(x, y);
|
||||||
FbTk::TextButton *button_insert_pos=NULL;
|
FbTk::TextButton *button_insert_pos = NULL;
|
||||||
if(client_insert_pos!=m_clientlist.end())
|
if(client_insert_pos != m_clientlist.end())
|
||||||
button_insert_pos=m_labelbuttons[*client_insert_pos];
|
button_insert_pos = m_labelbuttons[*client_insert_pos];
|
||||||
|
|
||||||
|
|
||||||
// make sure we set new window search for each client
|
// make sure we set new window search for each client
|
||||||
ClientList::iterator client_it = old_win->clientList().begin();
|
ClientList::iterator client_it = old_win->clientList().begin();
|
||||||
|
@ -693,29 +684,18 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
|
||||||
frame().clientArea().height());
|
frame().clientArea().height());
|
||||||
|
|
||||||
(*client_it)->setFluxboxWindow(this);
|
(*client_it)->setFluxboxWindow(this);
|
||||||
|
|
||||||
// create a labelbutton for this client and
|
// create a labelbutton for this client and
|
||||||
// associate it with the pointer
|
// associate it with the pointer
|
||||||
FbTk::TextButton *btn = new FbTk::TextButton(frame().label(),
|
FbWinFrame::ButtonId btn = frame().createTab((*client_it)->title(),
|
||||||
frame().theme().font(),
|
new SetClientCmd(*(*client_it)));
|
||||||
(*client_it)->title());
|
|
||||||
btn->setJustify(frame().theme().justify());
|
|
||||||
m_labelbuttons[(*client_it)] = btn;
|
m_labelbuttons[(*client_it)] = btn;
|
||||||
frame().addLabelButton(*btn);
|
|
||||||
if(x >= 0) {
|
//null if we want the new button at the end of the list
|
||||||
if(button_insert_pos){ //null if we want the new button at the end of the list
|
if(x >= 0 && button_insert_pos)
|
||||||
frame().moveLabelButtonLeftOf(*btn, *button_insert_pos);
|
frame().moveLabelButtonLeftOf(*btn, *button_insert_pos);
|
||||||
}
|
|
||||||
}
|
|
||||||
btn->show();
|
|
||||||
// we need motion notify so we mask it
|
|
||||||
btn->setEventMask(ExposureMask | ButtonPressMask |
|
|
||||||
ButtonReleaseMask | ButtonMotionMask |
|
|
||||||
EnterWindowMask);
|
|
||||||
|
|
||||||
|
|
||||||
FbTk::RefCount<FbTk::Command>
|
|
||||||
set_client_cmd(new SetClientCmd(*(*client_it)));
|
|
||||||
btn->setOnClick(set_client_cmd);
|
|
||||||
evm.add(*this, btn->window()); // we take care of button events for this
|
evm.add(*this, btn->window()); // we take care of button events for this
|
||||||
|
|
||||||
(*client_it)->saveBlackboxAttribs(m_blackbox_attrib);
|
(*client_it)->saveBlackboxAttribs(m_blackbox_attrib);
|
||||||
|
@ -731,25 +711,17 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
|
||||||
|
|
||||||
} else { // client.fbwindow() == 0
|
} else { // client.fbwindow() == 0
|
||||||
// create a labelbutton for this client and associate it with the pointer
|
// create a labelbutton for this client and associate it with the pointer
|
||||||
FbTk::TextButton *btn = new FbTk::TextButton(frame().label(),
|
FbWinFrame::ButtonId btn = frame().createTab(client.title(),
|
||||||
frame().theme().font(),
|
new SetClientCmd(client));
|
||||||
client.title());
|
|
||||||
m_labelbuttons[&client] = btn;
|
m_labelbuttons[&client] = btn;
|
||||||
frame().addLabelButton(*btn);
|
|
||||||
btn->show();
|
|
||||||
FbTk::EventManager &evm = *FbTk::EventManager::instance();
|
FbTk::EventManager &evm = *FbTk::EventManager::instance();
|
||||||
// we need motion notify so we mask it
|
|
||||||
btn->setEventMask(ExposureMask | ButtonPressMask |
|
|
||||||
ButtonReleaseMask | ButtonMotionMask |
|
|
||||||
EnterWindowMask);
|
|
||||||
|
|
||||||
|
|
||||||
FbTk::RefCount<FbTk::Command> set_client_cmd(new SetClientCmd(client));
|
|
||||||
btn->setOnClick(set_client_cmd);
|
|
||||||
evm.add(*this, btn->window()); // we take care of button events for this
|
evm.add(*this, btn->window()); // we take care of button events for this
|
||||||
|
|
||||||
if (&client == focused_win)
|
if (&client == focused_win)
|
||||||
was_focused = focused_win;
|
was_focused = focused_win;
|
||||||
|
|
||||||
client.setFluxboxWindow(this);
|
client.setFluxboxWindow(this);
|
||||||
|
|
||||||
client.saveBlackboxAttribs(m_blackbox_attrib);
|
client.saveBlackboxAttribs(m_blackbox_attrib);
|
||||||
|
@ -871,9 +843,8 @@ bool FluxboxWindow::removeClient(WinClient &client) {
|
||||||
|
|
||||||
FbTk::TextButton *label_btn = m_labelbuttons[&client];
|
FbTk::TextButton *label_btn = m_labelbuttons[&client];
|
||||||
if (label_btn != 0) {
|
if (label_btn != 0) {
|
||||||
frame().removeLabelButton(*label_btn);
|
frame().removeTab(label_btn);
|
||||||
evm.remove(label_btn->window());
|
evm.remove(label_btn->window());
|
||||||
delete label_btn;
|
|
||||||
label_btn = 0;
|
label_btn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue