all repos — fluxbox @ 67929002b1285897c212e1b88592d8f47ac468c1

custom fork of the fluxbox windowmanager

current label button focused
fluxgen fluxgen
commit

67929002b1285897c212e1b88592d8f47ac468c1

parent

274e0a928efd7dad917e148e69e59fe84b6cefca

3 files changed, 118 insertions(+), 49 deletions(-)

jump to
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrame.cc,v 1.20 2003/04/16 10:56:37 fluxgen Exp $ +// $Id: FbWinFrame.cc,v 1.21 2003/04/16 12:26:21 fluxgen Exp $ #include "FbWinFrame.hh" #include "ImageControl.hh"

@@ -259,6 +259,17 @@ if (erase_it == m_labelbuttons.end())

return; m_labelbuttons.erase(erase_it); +} + +void FbWinFrame::setLabelButtonFocus(FbTk::Button &btn) { + ButtonList::iterator it = find(m_labelbuttons.begin(), + m_labelbuttons.end(), + &btn); + if (it == m_labelbuttons.end()) + return; + + m_current_label = *it; // current focused button + renderLabelButtons(); } void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {

@@ -649,51 +660,25 @@ m_label_unfocused_pm,

m_label.width(), m_label.height()); // finaly set up pixmaps for titlebar windows - Pixmap labelpm = None; - FbTk::Color labelcolor; - - if (m_focused) { - if (m_label_focused_pm != 0){ - labelpm = m_label_focused_pm; - m_label.setBackgroundPixmap(m_label_focused_pm); - } else { - labelcolor = m_label_focused_color; - m_label.setBackgroundColor(m_label_focused_color); - } - - if (m_title_focused_pm != 0) - m_titlebar.setBackgroundPixmap(m_title_focused_pm); - else - m_titlebar.setBackgroundColor(m_title_focused_color); - - } else { - if (m_label_unfocused_pm != 0) { - labelpm = m_label_unfocused_pm; - m_label.setBackgroundPixmap(m_label_unfocused_pm); - } else { - labelcolor = m_label_unfocused_color; - m_label.setBackgroundColor(m_label_unfocused_color); - } - - - if (m_title_unfocused_pm != 0) - m_titlebar.setBackgroundPixmap(m_title_unfocused_pm); - else - m_titlebar.setBackgroundColor(m_title_unfocused_color); + Pixmap label_pm = None; + Pixmap title_pm = None; + FbTk::Color label_color; + FbTk::Color title_color; + getCurrentFocusPixmap(label_pm, title_pm, + label_color, title_color); - } - ButtonList::iterator btn_it = m_labelbuttons.begin(); - ButtonList::iterator btn_it_end = m_labelbuttons.end(); - for (; btn_it != btn_it_end; ++btn_it) { - (*btn_it)->setGC(theme().labelTextFocusGC()); - (*btn_it)->window().setBorderWidth(1); - if (labelpm) - (*btn_it)->setBackgroundPixmap(labelpm); - else - (*btn_it)->setBackgroundColor(labelcolor); - } + if (label_pm != 0) + m_label.setBackgroundPixmap(label_pm); + else + m_label.setBackgroundColor(label_color); + if (title_pm != 0) + m_titlebar.setBackgroundPixmap(title_pm); + else + m_titlebar.setBackgroundColor(title_color); + + renderLabelButtons(); redrawTitle(); }

@@ -779,6 +764,7 @@ }

void FbWinFrame::init() { // clear pixmaps + m_current_label = 0; // no focused button at first m_title_focused_pm = m_title_unfocused_pm = 0; m_label_focused_pm = m_label_unfocused_pm = 0; m_button_unfocused_pm = m_button_pressed_pm = 0;

@@ -843,3 +829,68 @@ if (tmp)

m_imagectrl.removeImage(tmp); } + +void FbWinFrame::getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm, + FbTk::Color &label_color, FbTk::Color &title_color) { + if (m_focused) { + if (m_label_focused_pm != 0) + label_pm = m_label_focused_pm; + else + label_color = m_label_focused_color; + + if (m_title_focused_pm != 0) + title_pm = m_title_focused_pm; + else + title_color = m_title_focused_color; + + } else { + getUnFocusPixmap(label_pm, title_pm, + label_color, title_color); + } + +} + +void FbWinFrame::getUnFocusPixmap(Pixmap &label_pm, Pixmap &title_pm, + FbTk::Color &label_color, FbTk::Color &title_color) { + if (m_label_unfocused_pm != 0) + label_pm = m_label_unfocused_pm; + else + label_color = m_label_unfocused_color; + + if (m_title_unfocused_pm != 0) + title_pm = m_title_unfocused_pm; + else + title_color = m_title_unfocused_color; +} + +void FbWinFrame::renderLabelButtons() { + Pixmap label_pm = None; + Pixmap not_used_pm = None; + FbTk::Color label_color; + FbTk::Color not_used_color; + getCurrentFocusPixmap(label_pm, not_used_pm, + label_color, not_used_color); + + ButtonList::iterator btn_it = m_labelbuttons.begin(); + ButtonList::iterator btn_it_end = m_labelbuttons.end(); + for (; btn_it != btn_it_end; ++btn_it) { + (*btn_it)->setGC(theme().labelTextFocusGC()); + (*btn_it)->window().setBorderWidth(1); + if ((*btn_it) != m_current_label) { + if (m_label_unfocused_pm != 0) + (*btn_it)->setBackgroundPixmap(m_label_unfocused_pm); + else + (*btn_it)->setBackgroundColor(m_label_unfocused_color); + + } else { + + if (label_pm) + (*btn_it)->setBackgroundPixmap(label_pm); + else + (*btn_it)->setBackgroundColor(label_color); + } + + (*btn_it)->clear(); + } + +}
M src/FbWinFrame.hhsrc/FbWinFrame.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrame.hh,v 1.5 2003/04/14 14:38:21 fluxgen Exp $ +// $Id: FbWinFrame.hh,v 1.6 2003/04/16 12:24:28 fluxgen Exp $ #ifndef FBWINFRAME_HH #define FBWINFRAME_HH

@@ -42,7 +42,8 @@ namespace FbTk {

class ImageControl; }; -/// holds a window frame with a client window (see: <a href="fluxbox_fbwinframe.png">image</a>) +/// holds a window frame with a client window +/// (see: <a href="fluxbox_fbwinframe.png">image</a>) class FbWinFrame:public FbTk::EventHandler { public:

@@ -89,7 +90,8 @@ /// adds a button to label window

void addLabelButton(FbTk::Button &btn); /// removes a specific button from label window void removeLabelButton(FbTk::Button &btn); - + /// which button is to be rendered focused + void setLabelButtonFocus(FbTk::Button &btn); /// attach a client window for client area void setClientWindow(Window win); /// same as above but with FbWindow

@@ -172,6 +174,11 @@ void renderLabel();

/// renders to pixmap or sets color void render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm, unsigned int width, unsigned int height); + void getUnFocusPixmap(Pixmap &label_pm, Pixmap &title_pm, + FbTk::Color &label_color, FbTk::Color &title_color); + void getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm, + FbTk::Color &label_color, FbTk::Color &title_color); + void renderLabelButtons(); //@} /// initiate some commont variables

@@ -197,6 +204,7 @@ typedef std::vector<FbTk::Button *> ButtonList;

ButtonList m_buttons_left, ///< buttons to the left m_buttons_right; ///< buttons to the right ButtonList m_labelbuttons; ///< holds buttons inside label window + FbTk::Button *m_current_label; ///< which button is focused at the moment std::string m_titletext; ///< text to be displayed int m_label int m_bevel; ///< bevel between titlebar items and titlebar bool m_use_titlebar; ///< if we should use titlebar
M src/Window.ccsrc/Window.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.139 2003/04/16 00:38:06 fluxgen Exp $ +// $Id: Window.cc,v 1.140 2003/04/16 12:27:49 fluxgen Exp $ #include "Window.hh"

@@ -307,7 +307,8 @@ m_client->title());

btn->setJustify(m_frame.theme().justify()); m_labelbuttons[m_client] = btn; m_frame.addLabelButton(*btn); - btn->show(); + m_frame.setLabelButtonFocus(*btn); + btn->show(); FbTk::EventManager &evm = *FbTk::EventManager::instance(); // we need motion notify so we mask it btn->window().setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask |

@@ -594,6 +595,13 @@ setInputFocus();

return true; } +void FluxboxWindow::detachCurrentClient() { + // should only operate if we had more than one client + if (numClients() <= 1) + return; + detachClient(*m_client); +} + /// removes client from client list, does not create new fluxboxwindow for it bool FluxboxWindow::removeClient(WinClient &client) { if (client.m_win != this || numClients() == 0)

@@ -662,6 +670,7 @@ m_client = m_clientlist.front();

else m_client = *it; m_client->raise(); + m_frame.setLabelButtonFocus(*m_labelbuttons[m_client]); setInputFocus(); }

@@ -680,6 +689,7 @@ else

m_client = *(--it); m_client->raise(); + m_frame.setLabelButtonFocus(*m_labelbuttons[m_client]); setInputFocus(); }

@@ -691,6 +701,7 @@

m_client = &client; m_client->raise(); Fluxbox::instance()->setFocusedWindow(this); + m_frame.setLabelButtonFocus(*m_labelbuttons[m_client]); setInputFocus(); }

@@ -2365,7 +2376,6 @@ //

// drag'n'drop code for tabs // if (m_attaching_tab == 0) { - cerr<<"starting m_attching_tab for this="<<this<<endl; // start drag'n'drop for tab m_attaching_tab = client;