aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-12-19 14:58:48 (GMT)
committerfluxgen <fluxgen>2003-12-19 14:58:48 (GMT)
commit1dd4b27d30a9a96032dffa3946f478ce4cba85b9 (patch)
tree8bb819ac6fa7a214af12ccb36936d48b16e2c7a6 /src
parent9b88b1f2c7e2da1ec6a47518ded37c0eab36e738 (diff)
downloadfluxbox_paul-1dd4b27d30a9a96032dffa3946f478ce4cba85b9.zip
fluxbox_paul-1dd4b27d30a9a96032dffa3946f478ce4cba85b9.tar.bz2
timedRender so we can remove flicker while changing current client in window
Diffstat (limited to 'src')
-rw-r--r--src/IconbarTool.cc57
-rw-r--r--src/IconbarTool.hh8
2 files changed, 53 insertions, 12 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 1f6d491..8602a2b 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: IconbarTool.cc,v 1.23 2003/12/18 18:03:21 fluxgen Exp $ 23// $Id: IconbarTool.cc,v 1.24 2003/12/19 14:58:48 fluxgen Exp $
24 24
25#include "IconbarTool.hh" 25#include "IconbarTool.hh"
26 26
@@ -33,6 +33,7 @@
33#include "FbMenu.hh" 33#include "FbMenu.hh"
34#include "BoolMenuItem.hh" 34#include "BoolMenuItem.hh"
35#include "CommandParser.hh" 35#include "CommandParser.hh"
36#include "WinClient.hh"
36 37
37#include "FbTk/Menu.hh" 38#include "FbTk/Menu.hh"
38#include "FbTk/MenuItem.hh" 39#include "FbTk/MenuItem.hh"
@@ -272,6 +273,14 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr
272 screen.clientListSig().attach(this); 273 screen.clientListSig().attach(this);
273 screen.iconListSig().attach(this); 274 screen.iconListSig().attach(this);
274 screen.currentWorkspaceSig().attach(this); 275 screen.currentWorkspaceSig().attach(this);
276 // setup focus timer
277 FbTk::RefCount<FbTk::Command> timer_cmd(new FbTk::SimpleCommand<IconbarTool>(*this, &IconbarTool::timedRender));
278 timeval to;
279 to.tv_sec = 0;
280 to.tv_usec = 1; // so it updates next event round
281 m_focus_timer.setCommand(timer_cmd);
282 m_focus_timer.setTimeout(to);
283 m_focus_timer.fireOnce(true);
275 284
276 update(0); 285 update(0);
277} 286}
@@ -392,7 +401,10 @@ void IconbarTool::update(FbTk::Subject *subj) {
392 // we handle everything except die signal here 401 // we handle everything except die signal here
393 FluxboxWindow::WinSubject *winsubj = static_cast<FluxboxWindow::WinSubject *>(subj); 402 FluxboxWindow::WinSubject *winsubj = static_cast<FluxboxWindow::WinSubject *>(subj);
394 if (subj == &(winsubj->win().focusSig())) { 403 if (subj == &(winsubj->win().focusSig())) {
395 renderWindow(winsubj->win()); 404 // start focus timer, so we can update without flicker
405 m_focus_timer.start();
406
407 //renderWindow(winsubj->win());
396 return; 408 return;
397 } else if (subj == &(winsubj->win().workspaceSig())) { 409 } else if (subj == &(winsubj->win().workspaceSig())) {
398 // we can ignore this signal if we're in ALLWINDOWS mode 410 // we can ignore this signal if we're in ALLWINDOWS mode
@@ -441,9 +453,9 @@ void IconbarTool::update(FbTk::Subject *subj) {
441 mode() != ALLWINDOWS && mode() != ICONS) { 453 mode() != ALLWINDOWS && mode() != ICONS) {
442 remove_all = true; // remove and readd all windows 454 remove_all = true; // remove and readd all windows
443 }/* else if (&m_screen.iconListSig() == screen_subj && 455 }/* else if (&m_screen.iconListSig() == screen_subj &&
444 (mode() == ALLWINDOWS || mode() == ICONS || mode() == WORKSPACE)) { 456 (mode() == ALLWINDOWS || mode() == ICONS || mode() == WORKSPACE)) {
445 remove_all = true; 457 remove_all = true;
446 }*/ 458 }*/
447 } 459 }
448 460
449 // lock graphic update 461 // lock graphic update
@@ -477,19 +489,23 @@ void IconbarTool::update(FbTk::Subject *subj) {
477 489
478} 490}
479 491
480void IconbarTool::renderWindow(FluxboxWindow &win) { 492IconButton *IconbarTool::findButton(FluxboxWindow &win) {
481 493
482 IconList::iterator icon_it = m_icon_list.begin(); 494 IconList::iterator icon_it = m_icon_list.begin();
483 IconList::iterator icon_it_end = m_icon_list.end(); 495 IconList::iterator icon_it_end = m_icon_list.end();
484 for (; icon_it != icon_it_end; ++icon_it) { 496 for (; icon_it != icon_it_end; ++icon_it) {
485 if (&(*icon_it)->win() == &win) 497 if (&(*icon_it)->win() == &win)
486 break; 498 return *icon_it;
487 } 499 }
488 500
489 if (icon_it == m_icon_list.end()) 501 return 0;
490 return; 502}
491 503
492 renderButton(*(*icon_it)); 504void IconbarTool::renderWindow(FluxboxWindow &win) {
505 IconButton *button = findButton(win);
506 if (button == 0)
507 return;
508 renderButton(*button);
493} 509}
494 510
495void IconbarTool::renderTheme() { 511void IconbarTool::renderTheme() {
@@ -546,6 +562,7 @@ void IconbarTool::renderButton(IconButton &button) {
546 button.setPixmap(*m_rc_use_pixmap); 562 button.setPixmap(*m_rc_use_pixmap);
547 563
548 if (button.win().isFocused()) { // focused texture 564 if (button.win().isFocused()) { // focused texture
565 m_icon_container.setSelected(m_icon_container.find(&button));
549 button.setGC(m_theme.focusedText().textGC()); 566 button.setGC(m_theme.focusedText().textGC());
550 button.setFont(m_theme.focusedText().font()); 567 button.setFont(m_theme.focusedText().font());
551 button.setJustify(m_theme.focusedText().justify()); 568 button.setJustify(m_theme.focusedText().justify());
@@ -559,6 +576,9 @@ void IconbarTool::renderButton(IconButton &button) {
559 button.setBorderColor(m_theme.focusedBorder().color()); 576 button.setBorderColor(m_theme.focusedBorder().color());
560 577
561 } else { // unfocused 578 } else { // unfocused
579 if (m_icon_container.selected() == &button)
580 m_icon_container.setSelected(-1);
581
562 button.setGC(m_theme.unfocusedText().textGC()); 582 button.setGC(m_theme.unfocusedText().textGC());
563 button.setFont(m_theme.unfocusedText().font()); 583 button.setFont(m_theme.unfocusedText().font());
564 button.setJustify(m_theme.unfocusedText().justify()); 584 button.setJustify(m_theme.unfocusedText().justify());
@@ -696,4 +716,21 @@ void IconbarTool::addList(std::list<FluxboxWindow *> &winlist) {
696 addWindow(**it); 716 addWindow(**it);
697} 717}
698 718
719void IconbarTool::timedRender() {
720 WinClient *client = Fluxbox::instance()->getFocusedWindow();
721 if (client == 0 || client->fbwindow() == 0)
722 return;
723
724 IconButton *button = findButton(*client->fbwindow());
725 IconButton *current_button = static_cast<IconButton *>(m_icon_container.selected());
726 // if old window is the same as the new focused window then ignore this render
727 // else render old client and new client
728 if (button == current_button)
729 return;
730 if (button != 0)
731 renderButton(*button);
732 if (current_button != 0)
733 renderButton(*current_button);
734
735}
699 736
diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh
index d60d14b..0f2574e 100644
--- a/src/IconbarTool.hh
+++ b/src/IconbarTool.hh
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: IconbarTool.hh,v 1.11 2003/12/12 14:36:22 fluxgen Exp $ 23// $Id: IconbarTool.hh,v 1.12 2003/12/19 14:57:44 fluxgen Exp $
24 24
25#ifndef ICONBARTOOL_HH 25#ifndef ICONBARTOOL_HH
26#define ICONBARTOOL_HH 26#define ICONBARTOOL_HH
@@ -76,6 +76,8 @@ public:
76 Mode mode() const { return *m_rc_mode; } 76 Mode mode() const { return *m_rc_mode; }
77 Container::Alignment alignment() const { return m_icon_container.alignment(); } 77 Container::Alignment alignment() const { return m_icon_container.alignment(); }
78private: 78private:
79 /// @return button associated with window
80 IconButton *findButton(FluxboxWindow &win);
79 81
80 /// render single button that holds win 82 /// render single button that holds win
81 void renderWindow(FluxboxWindow &win); 83 void renderWindow(FluxboxWindow &win);
@@ -97,6 +99,8 @@ private:
97 void updateAllWindows(); 99 void updateAllWindows();
98 /// add a list of windows 100 /// add a list of windows
99 void addList(std::list<FluxboxWindow *> &winlist); 101 void addList(std::list<FluxboxWindow *> &winlist);
102 /// so we can update current window without flicker
103 void timedRender();
100 104
101 BScreen &m_screen; 105 BScreen &m_screen;
102 Container m_icon_container; 106 Container m_icon_container;
@@ -111,7 +115,7 @@ private:
111 FbTk::Resource<Container::Alignment> m_rc_alignment; ///< alignment of buttons 115 FbTk::Resource<Container::Alignment> m_rc_alignment; ///< alignment of buttons
112 FbTk::Resource<int> m_rc_client_width; ///< size of client button in LEFT/RIGHT mode 116 FbTk::Resource<int> m_rc_client_width; ///< size of client button in LEFT/RIGHT mode
113 FbTk::Resource<bool> m_rc_use_pixmap; ///< if iconbar should use win pixmap or not 117 FbTk::Resource<bool> m_rc_use_pixmap; ///< if iconbar should use win pixmap or not
114 118 FbTk::Timer m_focus_timer; ///< so we can update current window without flicker while changing attached clients
115 FbMenu m_menu; 119 FbMenu m_menu;
116}; 120};
117 121