diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index d3f67828..7fd15cb8 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -19,7 +19,7 @@
// 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"
@@ -261,6 +261,17 @@ void FbWinFrame::removeLabelButton(FbTk::Button &btn) {
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) {
setClientWindow(win.window());
}
@@ -649,51 +660,25 @@ void FbWinFrame::renderTitlebar() {
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::renderButtons() {
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 @@ void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,
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();
+ }
+
+}
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh
index e6bd5858..590c30ae 100644
--- a/src/FbWinFrame.hh
+++ b/src/FbWinFrame.hh
@@ -19,7 +19,7 @@
// 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: image)
+/// holds a window frame with a client window
+/// (see: image)
class FbWinFrame:public FbTk::EventHandler {
public:
@@ -89,7 +90,8 @@ public:
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 @@ private:
/// 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 @@ private:
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
diff --git a/src/Window.cc b/src/Window.cc
index 5839c529..a2a9d021 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
// 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 @@ void FluxboxWindow::init() {
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 @@ bool FluxboxWindow::detachClient(WinClient &client) {
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 @@ void FluxboxWindow::nextClient() {
else
m_client = *it;
m_client->raise();
+ m_frame.setLabelButtonFocus(*m_labelbuttons[m_client]);
setInputFocus();
}
@@ -680,6 +689,7 @@ void FluxboxWindow::prevClient() {
m_client = *(--it);
m_client->raise();
+ m_frame.setLabelButtonFocus(*m_labelbuttons[m_client]);
setInputFocus();
}
@@ -691,6 +701,7 @@ void FluxboxWindow::setCurrentClient(WinClient &client) {
m_client = &client;
m_client->raise();
Fluxbox::instance()->setFocusedWindow(this);
+ m_frame.setLabelButtonFocus(*m_labelbuttons[m_client]);
setInputFocus();
}
@@ -2365,7 +2376,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
// drag'n'drop code for tabs
//
if (m_attaching_tab == 0) {
- cerr<<"starting m_attching_tab for this="<