optimized rendering

This commit is contained in:
fluxgen 2003-09-12 22:49:14 +00:00
parent 48ea10e22f
commit a6b3e25679
3 changed files with 70 additions and 45 deletions

View file

@ -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();

View file

@ -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();
/**

View file

@ -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__<<")["<<this<<"] numClients = "<<numClients()<<endl;
#endif // DEBUG
@ -811,7 +818,7 @@ void FluxboxWindow::nextClient() {
m_client = *it;
m_client->raise();
frame().setLabelButtonFocus(*m_labelbuttons[m_client]);
setInputFocus();
frame().setFocus(setInputFocus());
}
void FluxboxWindow::prevClient() {
@ -830,7 +837,7 @@ void FluxboxWindow::prevClient() {
m_client->raise();
frame().setLabelButtonFocus(*m_labelbuttons[m_client]);
setInputFocus();
frame().setFocus(setInputFocus());
}
@ -908,8 +915,6 @@ void FluxboxWindow::associateClientWindow() {
frame().setClientWindow(*m_client);
frame().resizeForClient(m_client->width(), m_client->height());
// make sure the frame reconfigures
frame().reconfigure();
}
@ -955,6 +960,8 @@ void FluxboxWindow::reconfigure() {
frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
frame().setUpdateDelayTime(Fluxbox::instance()->getUpdateDelayTime());
frame().reconfigure();
m_windowmenu.reconfigure();
}
@ -1100,9 +1107,10 @@ void FluxboxWindow::moveResize(int new_x, int new_y,
new_width = width();
new_height = height();
}
frame().moveResize(new_x, new_y, new_width, new_height);
setFocusFlag(focused);
frame().moveResize(new_x, new_y, new_width, new_height);
shaded = false;
send_event = true;
} else {
@ -1258,13 +1266,8 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
frame().show();
if (was_iconic && screen().doFocusNew()) {
if (was_iconic && screen().doFocusNew())
setInputFocus();
}
if (focused != frame().focused())
frame().setFocus(focused);
if (reassoc && !m_client->transients.empty()) {
// deiconify all transients
@ -1281,7 +1284,9 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
}
}
}
oplock = false;
if (do_raise)
raise();
}
@ -1646,7 +1651,10 @@ void FluxboxWindow::setFocusFlag(bool focus) {
}
installColormap(focus);
frame().setFocus(focus);
if (focus != frame().focused()) {
frame().setFocus(focus);
}
if ((screen().isSloppyFocus() || screen().isSemiSloppyFocus())
&& screen().doAutoRaise()) {
@ -1712,8 +1720,7 @@ void FluxboxWindow::saveBlackboxAttribs() {
PropModeReplace,
(unsigned char *)&m_blackbox_attrib,
PropBlackboxAttributesElements
)
);
));
}
/**
@ -2013,11 +2020,10 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) {
setState(NormalState);
if (client->isTransient() || screen().doFocusNew()) {
if (client->isTransient() || screen().doFocusNew())
setCurrentClient(*client, true);
}
else
setFocusFlag(false);
setFocusFlag(false);
iconic = false;
@ -2169,7 +2175,6 @@ void FluxboxWindow::exposeEvent(XExposeEvent &ee) {
frame().exposeEvent(ee);
}
void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) {
WinClient *client = findClient(cr.window);
if (client == 0)
@ -2609,10 +2614,10 @@ void FluxboxWindow::applyDecorations(bool initial) {
if (decorations.handle) {
frame().showHandle();
frame().reconfigure(); // show handle requires reconfigure
} else
frame().hideHandle();
frame().reconfigure();
}
void FluxboxWindow::toggleDecoration() {