From 12a8b3c038c9ccb577c699d41a1d19602132a7a8 Mon Sep 17 00:00:00 2001 From: markt Date: Sat, 7 Apr 2007 17:39:27 +0000 Subject: more of the same --- src/AttentionNoticeHandler.cc | 14 +++++----- src/AttentionNoticeHandler.hh | 3 +-- src/Container.cc | 18 ------------- src/Container.hh | 4 --- src/FbWinFrame.cc | 41 +---------------------------- src/FbWinFrame.hh | 2 -- src/Focusable.hh | 19 +++++++++++--- src/IconButton.cc | 18 +++++++++---- src/IconbarTool.cc | 61 ++----------------------------------------- src/IconbarTool.hh | 3 --- src/WinClient.cc | 6 +++++ src/WinClient.hh | 1 + src/Window.cc | 21 ++------------- src/Window.hh | 22 +--------------- 14 files changed, 50 insertions(+), 183 deletions(-) diff --git a/src/AttentionNoticeHandler.cc b/src/AttentionNoticeHandler.cc index 02fa95c..c2599c9 100644 --- a/src/AttentionNoticeHandler.cc +++ b/src/AttentionNoticeHandler.cc @@ -23,7 +23,7 @@ #include "AttentionNoticeHandler.hh" -#include "WinClient.hh" +#include "Focusable.hh" #include "Screen.hh" #include "STLUtil.hh" @@ -34,16 +34,15 @@ namespace { class ToggleFrameFocusCmd: public FbTk::Command { public: - ToggleFrameFocusCmd(WinClient &client): + ToggleFrameFocusCmd(Focusable &client): m_client(client), m_state(false) {} void execute() { m_state ^= true; - m_client.fbwindow()->setLabelButtonFocus(m_client, m_state); - m_client.fbwindow()->setAttentionState(m_state); + m_client.setAttentionState(m_state); } private: - WinClient& m_client; + Focusable &m_client; bool m_state; }; @@ -54,9 +53,9 @@ AttentionNoticeHandler::~AttentionNoticeHandler() { STLUtil::destroyAndClearSecond(m_attentions); } -void AttentionNoticeHandler::addAttention(WinClient &client) { +void AttentionNoticeHandler::addAttention(Focusable &client) { // no need to add already active client - if (client.fbwindow()->isFocused() && &client.fbwindow()->winClient() == &client) + if (client.isFocused()) return; // Already have a notice for it? @@ -105,5 +104,6 @@ void AttentionNoticeHandler::update(FbTk::Subject *subj) { static_cast(subj); delete m_attentions[&winsubj->win()]; m_attentions.erase(&winsubj->win()); + winsubj->win().setAttentionState(false); } diff --git a/src/AttentionNoticeHandler.hh b/src/AttentionNoticeHandler.hh index 368c568..ddef42d 100644 --- a/src/AttentionNoticeHandler.hh +++ b/src/AttentionNoticeHandler.hh @@ -28,7 +28,6 @@ #include class Focusable; -class WinClient; namespace FbTk { class Timer; @@ -45,7 +44,7 @@ public: typedef std::map NoticeMap; /// Adds a client that requires attention, /// will fail if the client is already active - void addAttention(WinClient &client); + void addAttention(Focusable &client); /// removes the client from the attention map void update(FbTk::Subject *subj); diff --git a/src/Container.cc b/src/Container.cc index d6ffcf3..e2d01c7 100644 --- a/src/Container.cc +++ b/src/Container.cc @@ -36,7 +36,6 @@ Container::Container(const FbTk::FbWindow &parent): m_align(RELATIVE), m_max_size_per_client(60), m_max_total_size(0), - m_selected(0), m_update_lock(false) { FbTk::EventManager::instance()->add(*this, *this); } @@ -215,9 +214,6 @@ bool Container::removeItem(int index) { for (; index != 0; ++it, --index) continue; - if (*it == selected()) - m_selected = 0; - m_item_list.erase(it); repositionItems(); @@ -225,7 +221,6 @@ bool Container::removeItem(int index) { } void Container::removeAll() { - m_selected = 0; m_item_list.clear(); if (!m_update_lock) { clear(); @@ -248,19 +243,6 @@ int Container::find(ConstItem item) { return index; } -void Container::setSelected(int pos) { - if (pos < 0 || pos >= size()) - m_selected = 0; - else { - ItemList::iterator it = m_item_list.begin(); - for (; pos != 0; --pos, ++it) - continue; - m_selected = *it; - // caller does any graphics stuff if appropriate - } - -} - void Container::setMaxSizePerClient(unsigned int size) { if (size != m_max_size_per_client) { m_max_size_per_client = size; diff --git a/src/Container.hh b/src/Container.hh index cfaf1ea..69da43d 100644 --- a/src/Container.hh +++ b/src/Container.hh @@ -65,7 +65,6 @@ public: void moveItem(Item item, int movement); // wraps around bool moveItemTo(Item item, int x, int y); int find(ConstItem item); - void setSelected(int index); void setMaxSizePerClient(unsigned int size); void setMaxTotalSize(unsigned int size); void setAlignment(Alignment a); @@ -93,8 +92,6 @@ public: inline FbTk::Orientation orientation() const { return m_orientation; } inline int size() const { return m_item_list.size(); } inline bool empty() const { return m_item_list.empty(); } - inline const Item& selected() const { return m_selected; } - inline Item selected() { return m_selected; } unsigned int maxWidthPerClient() const; inline bool updateLock() const { return m_update_lock; } @@ -115,7 +112,6 @@ private: unsigned int m_max_size_per_client; unsigned int m_max_total_size; ItemList m_item_list; - Item m_selected; bool m_update_lock; }; diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index bf1ab42..7a8a14e 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -522,9 +522,6 @@ void FbWinFrame::setFocus(bool newvalue) { } } - if (currentLabel()) - m_current_label->reconfigTheme(); - applyAll(); clearAll(); } @@ -626,25 +623,14 @@ IconButton *FbWinFrame::createTab(Focusable &client) { EnterWindowMask); FbTk::EventManager::instance()->add(*button, button->window()); - button->setJustify(theme().iconbarTheme().unfocusedText().justify()); - button->setBorderColor(theme().border().color()); - button->setBorderWidth(m_window.borderWidth()); - m_tab_container.insertItem(button); - if (currentLabel() == 0) - setLabelButtonFocus(*button); - return button; } void FbWinFrame::removeTab(IconButton *btn) { - if (btn == m_current_label) - m_current_label = 0; - if (m_tab_container.removeItem(btn)) delete btn; - } @@ -689,24 +675,9 @@ void FbWinFrame::moveLabelButtonRightOf(FbTk::TextButton &btn, const FbTk::TextB } void FbWinFrame::setLabelButtonFocus(IconButton &btn) { - if (&btn == currentLabel() || btn.parent() != &m_tab_container) - return; - - // render label buttons - if (currentLabel() != 0) - m_current_label->reconfigTheme(); - - m_current_label = &btn; // current focused button - m_label.setText(btn.text()); - btn.reconfigTheme(); -} - -void FbWinFrame::setLabelButtonFocus(IconButton &btn, bool value) { if (btn.parent() != &m_tab_container) return; - - btn.reconfigTheme(); - btn.clear(); + m_label.setText(btn.text()); } void FbWinFrame::setClientWindow(FbTk::FbWindow &win) { @@ -891,10 +862,6 @@ void FbWinFrame::removeEventHandler() { } void FbWinFrame::buttonPressEvent(XButtonEvent &event) { - // we can ignore which window the event was generated for - if (event.window == m_label.window() && m_current_label) - event.window = m_current_label->window(); - m_tab_container.tryButtonPressEvent(event); if (event.window == m_grip_right.window() || event.window == m_grip_left.window() || @@ -910,10 +877,6 @@ void FbWinFrame::buttonPressEvent(XButtonEvent &event) { } void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { - // we can ignore which window the event was generated for - if (event.window == m_label.window() && m_current_label) - event.window = m_current_label->window(); - // we continue even if a button got the event m_tab_container.tryButtonReleaseEvent(event); @@ -1440,8 +1403,6 @@ void FbWinFrame::init() { m_disable_shape = false; - m_current_label = 0; // no focused button at first - m_handle.showSubwindows(); // clear pixmaps diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 35e4bd8..54d91df 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -156,8 +156,6 @@ public: void moveLabelButtonRightOf(FbTk::TextButton &btn, const FbTk::TextButton &dest); /// which button is to be rendered focused void setLabelButtonFocus(IconButton &btn); - /// specify focus state of button - void setLabelButtonFocus(IconButton &btn, bool value); /// attach a client window for client area void setClientWindow(FbTk::FbWindow &win); /// remove attached client window diff --git a/src/Focusable.hh b/src/Focusable.hh index 8982f29..e02e0d7 100644 --- a/src/Focusable.hh +++ b/src/Focusable.hh @@ -41,8 +41,10 @@ class Focusable: public FbTk::ITypeAheadable { public: Focusable(BScreen &scr, FluxboxWindow *fbwin = 0): m_screen(scr), m_fbwin(fbwin), - m_instance_name("fluxbox"), m_class_name("fluxbox"), m_focused(false), - m_titlesig(*this), m_focussig(*this), m_diesig(*this) { } + m_instance_name("fluxbox"), m_class_name("fluxbox"), + m_focused(false), m_attention_state(false), + m_titlesig(*this), m_focussig(*this), m_diesig(*this), + m_attentionsig(*this) { } virtual ~Focusable() { } /** * Take focus. @@ -54,6 +56,14 @@ public: virtual bool isFocused() const { return m_focused; } /// @return return true if it can be focused virtual bool acceptsFocus() const { return true; } + + /// @return true if icon button should appear focused + inline bool getAttentionState() const { return m_attention_state; } + /// @set the attention state + virtual void setAttentionState(bool value) { + m_attention_state = value; attentionSig().notify(); + } + /// @return the screen in which this object resides inline BScreen &screen() { return m_screen; } /// @return the screen in which this object resides @@ -110,6 +120,8 @@ public: const FbTk::Subject &focusSig() const { return m_focussig; } FbTk::Subject &dieSig() { return m_diesig; } const FbTk::Subject &dieSig() const { return m_diesig; } + FbTk::Subject &attentionSig() { return m_attentionsig; } + const FbTk::Subject &attentionSig() const { return m_attentionsig; } /** @} */ // end group signals protected: @@ -118,10 +130,11 @@ protected: std::string m_title, m_instance_name, m_class_name; bool m_focused; //< whether or not it has focus + bool m_attention_state; //< state of icon button while demanding attention FbTk::PixmapWithMask m_icon; //< icon pixmap with mask // state and hint signals - FocusSubject m_titlesig, m_focussig, m_diesig; + FocusSubject m_titlesig, m_focussig, m_diesig, m_attentionsig; }; #endif // FOCUSABLE_HH diff --git a/src/IconButton.cc b/src/IconButton.cc index 5cb47d1..04fc391 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -60,6 +60,8 @@ IconButton::IconButton(const FbTk::FbWindow &parent, IconbarTheme &theme, m_unfocused_pm(win.screen().imageControl()) { m_win.titleSig().attach(this); + m_win.focusSig().attach(this); + m_win.attentionSig().attach(this); FbTk::EventManager::instance()->add(*this, m_icon_window); @@ -129,12 +131,11 @@ void IconButton::reconfigTheme() { width(), height(), m_theme.unfocusedTexture(), orientation())); else - m_unfocused_pm.reset( 0 ); + m_unfocused_pm.reset(0); setAlpha(parent()->alpha()); - // TODO: this ignores attention state, which isn't in Focusable.hh yet - if (m_win.isFocused()) { + if (m_win.isFocused() || m_win.getAttentionState()) { if (m_focused_pm != 0) setBackgroundPixmap(m_focused_pm); else @@ -163,12 +164,18 @@ void IconButton::reconfigTheme() { } void IconButton::update(FbTk::Subject *subj) { + // if the window's focus state changed, we need to update the background + if (subj == &m_win.focusSig() || subj == &m_win.attentionSig()) { + reconfigTheme(); + clear(); + return; + } + // we got signal that either title or // icon pixmap was updated, // so we refresh everything Display *display = FbTk::App::instance()->display(); - int screen = m_win.screen().screenNumber(); if (m_use_pixmap && m_win.icon().pixmap().drawable() != None) { @@ -190,7 +197,8 @@ void IconButton::update(FbTk::Subject *subj) { m_icon_window.moveResize(iconx, icony, neww, newh); - m_icon_pixmap.copy(m_win.icon().pixmap().drawable(), DefaultDepth(display, screen), screen); + m_icon_pixmap.copy(m_win.icon().pixmap().drawable(), + DefaultDepth(display, screen), screen); m_icon_pixmap.scale(m_icon_window.width(), m_icon_window.height()); // rotate the icon or not?? lets go not for now, and see what they say... diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 4ba3a44..2c73dc5 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -444,15 +444,6 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr screen.clientListSig().attach(this); screen.iconListSig().attach(this); screen.currentWorkspaceSig().attach(this); - // setup focus timer - - FbTk::RefCount timer_cmd(new FbTk::SimpleCommand(*this, &IconbarTool::timedRender)); - timeval to; - to.tv_sec = 0; - to.tv_usec = 1; // so it updates next event round - m_focus_timer.setCommand(timer_cmd); - m_focus_timer.setTimeout(to); - m_focus_timer.fireOnce(true); } @@ -560,11 +551,8 @@ void IconbarTool::update(FbTk::Subject *subj) { FluxboxWindow::WinSubject *winsubj = static_cast(subj); if (subj == &(winsubj->win().workspaceSig())) { // we can ignore this signal if we're in ALLWINDOWS mode - // unless the window was focused and has nothing to revert to - if (mode() == ALLWINDOWS || mode() == ICONS || mode() == NOICONS) { - m_focus_timer.start(); + if (mode() == ALLWINDOWS || mode() == ICONS || mode() == NOICONS) return; - } // workspace changed for this window, and if it's not on current workspace we remove it if (m_screen.currentWorkspaceID() != winsubj->win().workspaceNumber()) { @@ -579,23 +567,13 @@ void IconbarTool::update(FbTk::Subject *subj) { } return; - } else if (subj == &(winsubj->win().attentionSig())) { - // render with titlebar focus, on attention - IconButton *button = findButton(winsubj->win()); - if (button) - renderButton(*button, true); - return; } else { // signal not handled return; } } else if (subj != 0 && typeid(*subj) == typeid(Focusable::FocusSubject)) { Focusable::FocusSubject *winsubj = static_cast(subj); - if (subj == &(winsubj->win().focusSig())) { - // start focus timer, so we can update without flicker - m_focus_timer.start(); - return; - } else if (subj == &(winsubj->win().dieSig())) { // die sig + if (subj == &(winsubj->win().dieSig())) { // die sig removeWindow(winsubj->win()); renderTheme(); return; // we don't need to update the entire list @@ -697,16 +675,6 @@ void IconbarTool::renderButton(IconButton &button, bool clear) { button.setPixmap(*m_rc_use_pixmap); button.setTextPadding(*m_rc_client_padding); - - if (button.win().isFocused()) { - - // focused texture - if (button.win().isFocused()) - m_icon_container.setSelected(m_icon_container.find(&button)); - - } else if (m_icon_container.selected() == &button) - m_icon_container.setSelected(-1); - button.reconfigTheme(); if (clear) button.clear(); // the clear also updates transparent @@ -736,12 +704,10 @@ void IconbarTool::removeWindow(Focusable &win) { cerr<<"IconbarTool::"<<__FUNCTION__<<"( 0x"<<&win<<" title = "<workspaceSig().detach(this); win.fbwindow()->stateSig().detach(this); - win.fbwindow()->attentionSig().detach(this); } // remove from list and render theme again @@ -784,11 +750,9 @@ void IconbarTool::addWindow(Focusable &win) { m_icon_list.push_back(button); // dont forget to detach signal in removeWindow - win.focusSig().attach(this); win.dieSig().attach(this); fbwin->workspaceSig().attach(this); fbwin->stateSig().attach(this); - fbwin->attentionSig().attach(this); } void IconbarTool::updateList() { @@ -815,27 +779,6 @@ bool IconbarTool::checkDuplicate(Focusable &win) { return false; } -void IconbarTool::timedRender() { - WinClient *client = FocusControl::focusedWindow(); - IconButton *current_button = static_cast(m_icon_container.selected()); - - if (client == 0 || client->fbwindow() == 0) { - if (current_button != 0) - renderButton(*current_button); - return; - } - - IconButton *button = findButton(*client->fbwindow()); - // if old window is the same as the new focused window then ignore this render - // else render old client and new client - if (button == current_button) - return; - if (button != 0) - renderButton(*button); - if (current_button != 0) - renderButton(*current_button); -} - void IconbarTool::setOrientation(FbTk::Orientation orient) { m_icon_container.setOrientation(orient); ToolbarItem::setOrientation(orient); diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index d218b91..afa2182 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -114,8 +114,6 @@ private: void updateList(); /// check if window is already in the list bool checkDuplicate(Focusable &win); - /// so we can update current window without flicker - void timedRender(); BScreen &m_screen; Container m_icon_container; @@ -130,7 +128,6 @@ private: FbTk::Resource m_rc_client_width; ///< size of client button in LEFT/RIGHT mode FbTk::Resource m_rc_client_padding; ///< padding of the text FbTk::Resource m_rc_use_pixmap; ///< if iconbar should use win pixmap or not - FbTk::Timer m_focus_timer; ///< so we can update current window without flicker while changing attached clients FbMenu m_menu; unsigned char m_alpha; }; diff --git a/src/WinClient.cc b/src/WinClient.cc index 1cdd4ae..8877a2a 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -723,6 +723,12 @@ bool WinClient::isFocused() const { false); } +void WinClient::setAttentionState(bool value) { + Focusable::setAttentionState(value); + if (fbwindow() && !fbwindow()->isFocused()) + fbwindow()->setAttentionState(value); +} + void WinClient::updateWMProtocols() { Atom *proto = 0; int num_return = 0; diff --git a/src/WinClient.hh b/src/WinClient.hh index 6b22b49..4395f63 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -83,6 +83,7 @@ public: bool focus(); // calls Window->setCurrentClient to give focus to this client bool isFocused() const; + void setAttentionState(bool value); const std::string &title() const; /** diff --git a/src/Window.cc b/src/Window.cc index fcea7e6..2943366 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -245,7 +245,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, m_statesig(*this), m_layersig(*this), m_workspacesig(*this), - m_attentionsig(*this), m_themelistener(*this), moving(false), resizing(false), shaded(false), iconic(false), stuck(false), m_initialized(false), fullscreen(false), @@ -985,24 +984,7 @@ bool FluxboxWindow::setCurrentClient(WinClient &client, bool setinput) { // frame focused doesn't necessarily mean input focused frame().setLabelButtonFocus(*m_labelbuttons[m_client]); - if (setinput && focus()) { - return true; - } - - return false; -} - -void FluxboxWindow::setLabelButtonFocus(WinClient &client, bool value) { - // make sure it's in our list - if (client.fbwindow() != this) - return; - - frame().setLabelButtonFocus(*m_labelbuttons[&client], value); -} - -void FluxboxWindow::setAttentionState(bool value) { - m_attention_state = value; - m_attentionsig.notify(); + return setinput && focus(); } bool FluxboxWindow::isGroupable() const { @@ -2008,6 +1990,7 @@ void FluxboxWindow::setFocusFlag(bool focus) { // did focus change? notify listeners if (was_focused != focus) { + m_attention_state = false; m_focussig.notify(); if (m_client) m_client->focusSig().notify(); diff --git a/src/Window.hh b/src/Window.hh index cecb33b..c2f36c1 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -184,23 +184,6 @@ public: /// set new current client and raise it bool setCurrentClient(WinClient &client, bool setinput = true); /** - * Sets the label associated with the client to focused - * @param client the client associated with the label - * @param value the focus state - */ - void setLabelButtonFocus(WinClient &client, bool value = true); - /** - * Sets the attention state ("flashing") - * @see AttentionNoticeHandler - * @param value the new state value - */ - void setAttentionState(bool value); - /** - * Gets the attention state - * @return current attiontion state - */ - bool getAttentionState() { return m_attention_state; } - /** * Searches for a client * @param win the client X window * @return pointer to client matching the window or NULL @@ -492,7 +475,6 @@ public: const FbTk::Subject &hintSig() const { return m_hintsig; } FbTk::Subject &workspaceSig() { return m_workspacesig; } const FbTk::Subject &workspaceSig() const { return m_workspacesig; } - FbTk::Subject &attentionSig() { return m_attentionsig; } /** @} */ // end group signals void reconfigTheme(); @@ -560,8 +542,7 @@ private: WinSubject m_hintsig, m_statesig, m_layersig, - m_workspacesig, - m_attentionsig; + m_workspacesig; class ThemeListener: public FbTk::Observer { public: @@ -582,7 +563,6 @@ private: WinClient *m_attaching_tab; - bool m_attention_state; FbTk::Timer m_timer; Display *display; /// display connection BlackboxAttributes m_blackbox_attrib; -- cgit v0.11.2