From a6b3e25679d80c7d703682a85692f75a8f6a8f75 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 12 Sep 2003 22:49:14 +0000 Subject: optimized rendering --- src/FbWinFrame.cc | 62 +++++++++++++++++++++++++++++++++++-------------------- src/FbWinFrame.hh | 6 ++++-- src/Window.cc | 47 ++++++++++++++++++++++------------------- 3 files changed, 70 insertions(+), 45 deletions(-) diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 31dfae0..387b159 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.48 2003/09/11 19:55:27 rathnor Exp $ +// $Id: FbWinFrame.cc,v 1.49 2003/09/12 22:49:14 fluxgen Exp $ #include "FbWinFrame.hh" @@ -109,6 +109,7 @@ FbWinFrame::FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, */ FbWinFrame::~FbWinFrame() { + m_update_timer.stop(); removeEventHandler(); removeAllButtons(); } @@ -137,7 +138,6 @@ void FbWinFrame::hide() { void FbWinFrame::show() { m_visible = true; - reconfigure(); m_window.showSubwindows(); m_window.show(); } @@ -221,8 +221,17 @@ void FbWinFrame::setFocus(bool newvalue) { if (m_focused == newvalue) // no need to change focus return; + + + if (m_focused && !newvalue && currentLabel()) { + renderButtonUnfocus(*m_current_label); + } else if (!m_focused && newvalue && currentLabel()) { + renderButtonFocus(*m_current_label); + } + m_focused = newvalue; - reconfigure(); // reconfigure rendering for new focus value + renderButtons(); + renderHandles(); } void FbWinFrame::setDoubleClickTime(unsigned int time) { @@ -231,7 +240,6 @@ void FbWinFrame::setDoubleClickTime(unsigned int time) { void FbWinFrame::setBevel(int bevel) { m_bevel = bevel; - reconfigure(); } void FbWinFrame::addLeftButton(FbTk::Button *btn) { @@ -284,13 +292,16 @@ void FbWinFrame::removeLabelButton(FbTk::TextButton &btn) { return; m_labelbuttons.erase(erase_it); + + if (*erase_it == m_current_label) + m_current_label = 0; } void FbWinFrame::moveLabelButtonLeft(const FbTk::TextButton &btn) { LabelList::iterator it = find(m_labelbuttons.begin(), - m_labelbuttons.end(), - &btn); + m_labelbuttons.end(), + &btn); // make sure we found it and we're not at the begining if (it == m_labelbuttons.end() || it == m_labelbuttons.begin()) return; @@ -333,9 +344,7 @@ void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) { // render label buttons - - - if (m_current_label != 0) + if (currentLabel() != 0) renderButtonUnfocus(*m_current_label); m_current_label = *it; // current focused button @@ -528,9 +537,10 @@ void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { } void FbWinFrame::exposeEvent(XExposeEvent &event) { - if (m_label == event.window) - redrawTitle(); - else if (m_handle == event.window) { + if (m_label == event.window) { + m_label.clearArea(event.x, event.y, event.width, event.height); + m_label.updateTransparent(event.x, event.y, event.width, event.height); + } else if (m_handle == event.window) { m_handle.clearArea(event.x, event.y, event.width, event.height); m_handle.updateTransparent(); } else if (m_grip_left == event.window) { @@ -570,6 +580,7 @@ void FbWinFrame::exposeEvent(XExposeEvent &event) { if (it != m_buttons_right.end()) (*it)->exposeEvent(event); } + } void FbWinFrame::handleEvent(XEvent &event) { @@ -582,6 +593,8 @@ void FbWinFrame::configureNotifyEvent(XConfigureEvent &event) { } void FbWinFrame::reconfigure() { + if (m_labelbuttons.size() == 0) + return; // align titlebar and render it if (m_use_titlebar) @@ -660,14 +673,13 @@ unsigned int FbWinFrame::buttonHeight() const { return m_titlebar.height() - m_bevel*2; } - //--------------------- private area /** aligns and redraws title */ void FbWinFrame::redrawTitle() { - if (m_labelbuttons.size() == 0 || !m_visible) + if (m_labelbuttons.size() == 0) return; int button_width = label().width()/m_labelbuttons.size(); @@ -687,7 +699,7 @@ void FbWinFrame::redrawTitle() { button_width, label().height() + border_width); (*btn_it)->clear(); - (*btn_it)->updateTransparent(); + (*btn_it)->updateTransparent(); } m_titlebar.clear(); m_titlebar.updateTransparent(); @@ -696,7 +708,7 @@ void FbWinFrame::redrawTitle() { } void FbWinFrame::redrawTitlebar() { - if (!m_use_titlebar || !m_visible) + if (!m_use_titlebar) return; redrawTitle(); @@ -754,7 +766,7 @@ void FbWinFrame::reconfigureTitlebar() { } void FbWinFrame::renderTitlebar() { - if (!m_use_titlebar || !m_visible) + if (!m_use_titlebar) return; // render pixmaps @@ -918,7 +930,7 @@ void FbWinFrame::init() { // Note: we don't show clientarea yet setEventHandler(*this); - reconfigure(); + // reconfigure(); } /** @@ -1063,9 +1075,12 @@ void FbWinFrame::renderButtonFocus(FbTk::TextButton &button) { button.setBorderWidth(1); button.setAlpha(theme().alpha()); - if (m_label_focused_pm != 0) + if (m_label_focused_pm != 0) { + // already set + if (button.backgroundPixmap() == m_label_focused_pm) + return; button.setBackgroundPixmap(m_label_focused_pm); - else + } else button.setBackgroundColor(m_label_focused_color); button.clear(); @@ -1078,9 +1093,12 @@ void FbWinFrame::renderButtonUnfocus(FbTk::TextButton &button) { button.setBorderWidth(1); button.setAlpha(theme().alpha()); - if (m_label_unfocused_pm != 0) + if (m_label_unfocused_pm != 0) { + // already set + if (button.backgroundPixmap() == m_label_unfocused_pm) + return; button.setBackgroundPixmap(m_label_unfocused_pm); - else + } else button.setBackgroundColor(m_label_unfocused_color); button.clear(); diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 6906f2a..3040b68 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.17 2003/09/11 13:17:14 rathnor Exp $ +// $Id: FbWinFrame.hh,v 1.18 2003/09/12 22:49:14 fluxgen Exp $ #ifndef FBWINFRAME_HH #define FBWINFRAME_HH @@ -168,6 +168,7 @@ public: inline FbTk::FbWindow &gripLeft() { return m_grip_left; } inline const FbTk::FbWindow &gripRight() const { return m_grip_right; } inline FbTk::FbWindow &gripRight() { return m_grip_right; } + inline const FbTk::TextButton *currentLabel() const { return m_current_label; } inline bool focused() const { return m_focused; } inline bool isShaded() const { return m_shaded; } inline const FbWinFrameTheme &theme() const { return m_theme; } @@ -179,8 +180,9 @@ public: //@} private: - void redrawTitle(); void redrawTitlebar(); + void redrawTitle(); + /// reposition titlebar items void reconfigureTitlebar(); /** diff --git a/src/Window.cc b/src/Window.cc index cd97f16..1781dbf 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.225 2003/09/11 21:30:20 rathnor Exp $ +// $Id: Window.cc,v 1.226 2003/09/12 22:48:49 fluxgen Exp $ #include "Window.hh" @@ -362,7 +362,7 @@ void FluxboxWindow::init() { frame().gripLeft().setCursor(frame().theme().lowerLeftAngleCursor()); frame().gripRight().setCursor(frame().theme().lowerRightAngleCursor()); - frame().resize(m_client->width(), m_client->height()); + FbTk::TextButton *btn = new FbTk::TextButton(frame().label(), frame().theme().font(), m_client->title()); @@ -385,6 +385,8 @@ void FluxboxWindow::init() { frame().setEventHandler(*this); + frame().resize(m_client->width(), m_client->height()); + m_last_focus_time.tv_sec = m_last_focus_time.tv_usec = 0; // display connection @@ -510,6 +512,7 @@ void FluxboxWindow::init() { if (!place_window) moveResize(frame().x(), frame().y(), frame().width(), frame().height()); + screen().getWorkspace(m_workspace_number)->addWindow(*this, place_window); if (shaded) { // start shaded @@ -549,6 +552,8 @@ void FluxboxWindow::init() { if (m_shaped) shape(); + + } /// apply shape to this window @@ -777,6 +782,8 @@ bool FluxboxWindow::removeClient(WinClient &client) { m_labelbuttons.erase(&client); + frame().reconfigure(); + #ifdef DEBUG cerr<<__FILE__<<"("<<__FUNCTION__<<")["<