aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-06-16 15:38:19 (GMT)
committerrathnor <rathnor>2004-06-16 15:38:19 (GMT)
commit8f88c1fecb28dc15ecfd2ee210a8e466afe5456c (patch)
tree5adbb44deec68449ee216c10ff047d4446c2a510
parentdb6e78bba9fbd0e216f0ebbe5d4f55090ca62069 (diff)
downloadfluxbox_pavel-8f88c1fecb28dc15ecfd2ee210a8e466afe5456c.zip
fluxbox_pavel-8f88c1fecb28dc15ecfd2ee210a8e466afe5456c.tar.bz2
toolbar fixes, updates and optimisations
-rw-r--r--ChangeLog7
-rw-r--r--src/ClockTool.cc6
-rw-r--r--src/Container.cc10
-rw-r--r--src/IconButton.cc17
-rw-r--r--src/IconbarTool.cc31
-rw-r--r--src/IconbarTool.hh6
-rw-r--r--src/Toolbar.cc21
-rw-r--r--src/WorkspaceNameTool.cc3
8 files changed, 56 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index a59e9c8..34c3fd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.9.10: 2Changes for 0.9.10:
3*04/06/17:
4 * Improve rendering speed of toolbar (Simon)
5 - remove many redundant renders (esp. startup)
6 - only update clock if the text has changed
7 - fix transparency and border on most items
8 IconbarTool.hh/cc IconButton.cc Toolbar.cc Container.cc
9 ClockTool.cc WorkspaceNameTool.cc
3*04/06/14: 10*04/06/14:
4 * More menu transparency improvements (Henrik) 11 * More menu transparency improvements (Henrik)
5 Menu.cc 12 Menu.cc
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index a65a4ea..fc2bfc3 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.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: ClockTool.cc,v 1.10 2004/01/13 14:41:32 rathnor Exp $ 23// $Id: ClockTool.cc,v 1.11 2004/06/16 15:38:19 rathnor Exp $
24 24
25#include "ClockTool.hh" 25#include "ClockTool.hh"
26 26
@@ -231,7 +231,7 @@ void ClockTool::updateTime() {
231 return; 231 return;
232 232
233#ifdef HAVE_STRFTIME 233#ifdef HAVE_STRFTIME
234 if (!strftime(time_string, 255, m_timeformat->c_str(), time_type)) 234 if (!strftime(time_string, 255, m_timeformat->c_str(), time_type) || m_button.text() == time_string)
235 return; 235 return;
236 m_button.setText(time_string); 236 m_button.setText(time_string);
237#else // dont have strftime so we have to set it to hour:minut 237#else // dont have strftime so we have to set it to hour:minut
@@ -240,7 +240,6 @@ void ClockTool::updateTime() {
240 } 240 }
241 241
242 m_button.clear(); 242 m_button.clear();
243 m_button.updateTransparent();
244} 243}
245 244
246void ClockTool::renderTheme() { 245void ClockTool::renderTheme() {
@@ -261,5 +260,4 @@ void ClockTool::renderTheme() {
261 m_button.setBorderColor(m_theme.border().color()); 260 m_button.setBorderColor(m_theme.border().color());
262 m_button.setAlpha(m_theme.alpha()); 261 m_button.setAlpha(m_theme.alpha());
263 m_button.clear(); 262 m_button.clear();
264 m_button.updateTransparent();
265} 263}
diff --git a/src/Container.cc b/src/Container.cc
index 5d07552..d329052 100644
--- a/src/Container.cc
+++ b/src/Container.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: Container.cc,v 1.14 2004/05/04 14:33:37 rathnor Exp $ 23// $Id: Container.cc,v 1.15 2004/06/16 15:38:19 rathnor Exp $
24 24
25#include "Container.hh" 25#include "Container.hh"
26 26
@@ -160,10 +160,7 @@ void Container::setSelected(int pos) {
160 for (; pos != 0; --pos, ++it) 160 for (; pos != 0; --pos, ++it)
161 continue; 161 continue;
162 m_selected = *it; 162 m_selected = *it;
163 if (m_selected) { 163 // caller does any graphics stuff if appropriate
164 m_selected->clear();
165 m_selected->updateTransparent();
166 }
167 } 164 }
168 165
169} 166}
@@ -218,8 +215,7 @@ void Container::repositionItems() {
218 -borderW, 215 -borderW,
219 max_width_per_client + extra, 216 max_width_per_client + extra,
220 height()); 217 height());
221 (*it)->clear(); 218 // moveresize does a clear
222 (*it)->updateTransparent();
223 } 219 }
224 220
225} 221}
diff --git a/src/IconButton.cc b/src/IconButton.cc
index 6f0b0b7..748d87b 100644
--- a/src/IconButton.cc
+++ b/src/IconButton.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: IconButton.cc,v 1.20 2004/05/04 14:33:37 rathnor Exp $ 23// $Id: IconButton.cc,v 1.21 2004/06/16 15:38:19 rathnor Exp $
24 24
25#include "IconButton.hh" 25#include "IconButton.hh"
26 26
@@ -107,7 +107,7 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font,
107 m_win.hintSig().attach(this); 107 m_win.hintSig().attach(this);
108 108
109 FbTk::EventManager::instance()->add(*this, m_icon_window); 109 FbTk::EventManager::instance()->add(*this, m_icon_window);
110 110
111 update(0); 111 update(0);
112} 112}
113 113
@@ -122,21 +122,24 @@ void IconButton::exposeEvent(XExposeEvent &event) {
122 else 122 else
123 FbTk::TextButton::exposeEvent(event); 123 FbTk::TextButton::exposeEvent(event);
124} 124}
125
125void IconButton::moveResize(int x, int y, 126void IconButton::moveResize(int x, int y,
126 unsigned int width, unsigned int height) { 127 unsigned int width, unsigned int height) {
127 128
128 FbTk::TextButton::moveResize(x, y, width, height); 129 FbTk::TextButton::moveResize(x, y, width, height);
129 130
130 if (m_icon_window.width() != FbTk::Button::width() || 131 if (m_icon_window.width() != FbTk::Button::width() ||
131 m_icon_window.height() != FbTk::Button::height()) 132 m_icon_window.height() != FbTk::Button::height()) {
132 update(0); // update icon window 133 update(0); // update icon window
134 }
133} 135}
134 136
135void IconButton::resize(unsigned int width, unsigned int height) { 137void IconButton::resize(unsigned int width, unsigned int height) {
136 FbTk::TextButton::resize(width, height); 138 FbTk::TextButton::resize(width, height);
137 if (m_icon_window.width() != FbTk::Button::width() || 139 if (m_icon_window.width() != FbTk::Button::width() ||
138 m_icon_window.height() != FbTk::Button::height()) 140 m_icon_window.height() != FbTk::Button::height()) {
139 update(0); // update icon window 141 update(0); // update icon window
142 }
140} 143}
141 144
142void IconButton::clear() { 145void IconButton::clear() {
@@ -210,7 +213,11 @@ void IconButton::update(FbTk::Subject *subj) {
210 213
211#endif // SHAPE 214#endif // SHAPE
212 215
213 setupWindow(); 216 if (subj != 0) {
217 setupWindow();
218 } else {
219 m_icon_window.clear();
220 }
214} 221}
215 222
216void IconButton::setupWindow() { 223void IconButton::setupWindow() {
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 5434696..eaaa0fe 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.38 2004/06/07 21:43:02 fluxgen Exp $ 23// $Id: IconbarTool.cc,v 1.39 2004/06/16 15:38:19 rathnor Exp $
24 24
25#include "IconbarTool.hh" 25#include "IconbarTool.hh"
26 26
@@ -436,7 +436,6 @@ void IconbarTool::update(FbTk::Subject *subj) {
436 if (mode() == NONE) { 436 if (mode() == NONE) {
437 if (subj != 0 && typeid(*subj) == typeid(IconbarTheme)) 437 if (subj != 0 && typeid(*subj) == typeid(IconbarTheme))
438 renderTheme(); 438 renderTheme();
439
440 return; 439 return;
441 } 440 }
442 441
@@ -448,7 +447,6 @@ void IconbarTool::update(FbTk::Subject *subj) {
448 // start focus timer, so we can update without flicker 447 // start focus timer, so we can update without flicker
449 m_focus_timer.start(); 448 m_focus_timer.start();
450 449
451 //renderWindow(winsubj->win());
452 return; 450 return;
453 } else if (subj == &(winsubj->win().workspaceSig())) { 451 } else if (subj == &(winsubj->win().workspaceSig())) {
454 // we can ignore this signal if we're in ALLWINDOWS mode 452 // we can ignore this signal if we're in ALLWINDOWS mode
@@ -524,7 +522,9 @@ void IconbarTool::update(FbTk::Subject *subj) {
524 m_icon_container.update(); 522 m_icon_container.update();
525 m_icon_container.showSubwindows(); 523 m_icon_container.showSubwindows();
526 524
527 renderTheme(); 525 // another renderTheme we hopefully shouldn't need? These renders
526 // should be done individually above
527 // renderTheme();
528} 528}
529 529
530IconButton *IconbarTool::findButton(FluxboxWindow &win) { 530IconButton *IconbarTool::findButton(FluxboxWindow &win) {
@@ -613,17 +613,18 @@ void IconbarTool::renderTheme() {
613 if (tmp) 613 if (tmp)
614 m_screen.imageControl().removeImage(tmp); 614 m_screen.imageControl().removeImage(tmp);
615 615
616 m_icon_container.setBorderWidth(m_theme.border().width()); 616 // set to zero so its consistent and not ugly
617 m_icon_container.setBorderColor(m_theme.border().color()); 617 m_icon_container.setBorderWidth(0);
618 m_icon_container.setAlpha(m_theme.alpha()); 618 m_icon_container.setAlpha(m_theme.alpha());
619 619
620 // update buttons 620 // update buttons
621 icon_it = m_icon_list.begin(); 621 icon_it = m_icon_list.begin();
622 for (; icon_it != icon_it_end; ++icon_it) 622 for (; icon_it != icon_it_end; ++icon_it) {
623 renderButton(*(*icon_it)); 623 renderButton(*(*icon_it));
624 }
624} 625}
625 626
626void IconbarTool::renderButton(IconButton &button) { 627void IconbarTool::renderButton(IconButton &button, bool clear) {
627 628
628 button.setPixmap(*m_rc_use_pixmap); 629 button.setPixmap(*m_rc_use_pixmap);
629 button.setAlpha(m_theme.alpha()); 630 button.setAlpha(m_theme.alpha());
@@ -635,6 +636,7 @@ void IconbarTool::renderButton(IconButton &button) {
635 636
636 if (button.win().isFocused()) { // focused texture 637 if (button.win().isFocused()) { // focused texture
637 m_icon_container.setSelected(m_icon_container.find(&button)); 638 m_icon_container.setSelected(m_icon_container.find(&button));
639
638 button.setGC(m_theme.focusedText().textGC()); 640 button.setGC(m_theme.focusedText().textGC());
639 button.setFont(m_theme.focusedText().font()); 641 button.setFont(m_theme.focusedText().font());
640 button.setJustify(m_theme.focusedText().justify()); 642 button.setJustify(m_theme.focusedText().justify());
@@ -646,9 +648,7 @@ void IconbarTool::renderButton(IconButton &button) {
646 else if (wider_button && m_focused_err_pm != 0) 648 else if (wider_button && m_focused_err_pm != 0)
647 button.setBackgroundPixmap(m_focused_err_pm); 649 button.setBackgroundPixmap(m_focused_err_pm);
648 else 650 else
649 button.setBackgroundColor(m_theme.focusedTexture().color()); 651 button.setBackgroundColor(m_theme.focusedTexture().color());
650
651
652 652
653 } else { // unfocused 653 } else { // unfocused
654 if (m_icon_container.selected() == &button) 654 if (m_icon_container.selected() == &button)
@@ -666,11 +666,10 @@ void IconbarTool::renderButton(IconButton &button) {
666 button.setBackgroundPixmap(m_unfocused_err_pm); 666 button.setBackgroundPixmap(m_unfocused_err_pm);
667 else 667 else
668 button.setBackgroundColor(m_theme.unfocusedTexture().color()); 668 button.setBackgroundColor(m_theme.unfocusedTexture().color());
669
670 } 669 }
671 670
672 button.clear(); 671 if (clear)
673 button.updateTransparent(); 672 button.clear(); // the clear also updates transparent
674} 673}
675 674
676void IconbarTool::deleteIcons() { 675void IconbarTool::deleteIcons() {
@@ -717,7 +716,8 @@ void IconbarTool::addWindow(FluxboxWindow &win) {
717 return; 716 return;
718 717
719 IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), win); 718 IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), win);
720 renderButton(*button); 719
720 renderButton(*button, false);
721 m_icon_container.insertItem(button); 721 m_icon_container.insertItem(button);
722 m_icon_list.push_back(button); 722 m_icon_list.push_back(button);
723 723
@@ -809,6 +809,5 @@ void IconbarTool::timedRender() {
809 renderButton(*button); 809 renderButton(*button);
810 if (current_button != 0) 810 if (current_button != 0)
811 renderButton(*current_button); 811 renderButton(*current_button);
812
813} 812}
814 813
diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh
index bfcac34..600a862 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.13 2003/12/23 01:55:07 rathnor Exp $ 23// $Id: IconbarTool.hh,v 1.14 2004/06/16 15:38:19 rathnor Exp $
24 24
25#ifndef ICONBARTOOL_HH 25#ifndef ICONBARTOOL_HH
26#define ICONBARTOOL_HH 26#define ICONBARTOOL_HH
@@ -81,8 +81,8 @@ private:
81 81
82 /// render single button that holds win 82 /// render single button that holds win
83 void renderWindow(FluxboxWindow &win); 83 void renderWindow(FluxboxWindow &win);
84 /// render single button 84 /// render single button, and probably apply changes (clear)
85 void renderButton(IconButton &button); 85 void renderButton(IconButton &button, bool clear = true);
86 /// render all buttons 86 /// render all buttons
87 void renderTheme(); 87 void renderTheme();
88 /// destroy all icons 88 /// destroy all icons
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index b49dcc9..c6ab79c 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Toolbar.cc,v 1.143 2004/06/10 17:07:58 fluxgen Exp $ 25// $Id: Toolbar.cc,v 1.144 2004/06/16 15:38:19 rathnor Exp $
26 26
27#include "Toolbar.hh" 27#include "Toolbar.hh"
28 28
@@ -267,7 +267,8 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width):
267 // setup to listen to child events 267 // setup to listen to child events
268 FbTk::EventManager::instance()->addParent(*this, window()); 268 FbTk::EventManager::instance()->addParent(*this, window());
269 // get everything together 269 // get everything together
270 reconfigure(); 270 //reconfigure();
271 // this gets done by the screen later as it loads
271 272
272} 273}
273 274
@@ -423,7 +424,7 @@ void Toolbar::reconfigure() {
423 m_shape.reset(new Shape(frame.window, 0)); 424 m_shape.reset(new Shape(frame.window, 0));
424 } 425 }
425 426
426 // recallibrate size 427 // recalibrate size
427 setPlacement(placement()); 428 setPlacement(placement());
428 429
429 if (isHidden()) { 430 if (isHidden()) {
@@ -552,9 +553,13 @@ void Toolbar::exposeEvent(XExposeEvent &ee) {
552 553
553 554
554void Toolbar::handleEvent(XEvent &event) { 555void Toolbar::handleEvent(XEvent &event) {
556 /* Commented out by Simon 16jun04, since it causes LOTS of rearrangeItems
557 particularly on startup. Can't figure out why this is needed.
555 if (event.type == ConfigureNotify && 558 if (event.type == ConfigureNotify &&
556 event.xconfigure.window != window().window()) 559 event.xconfigure.window != window().window()) {
557 rearrangeItems(); 560 rearrangeItems();
561 }
562 */
558} 563}
559 564
560void Toolbar::update(FbTk::Subject *subj) { 565void Toolbar::update(FbTk::Subject *subj) {
@@ -911,7 +916,7 @@ void Toolbar::rearrangeItems() {
911 } 916 }
912 // now move and resize the items 917 // now move and resize the items
913 // borderWidth added back on straight away 918 // borderWidth added back on straight away
914 int next_x = -2*m_item_list.front()->borderWidth(); // list isn't empty 919 int next_x = -m_item_list.front()->borderWidth(); // list isn't empty
915 last_bw = 0; 920 last_bw = 0;
916 for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { 921 for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) {
917 if (!(*item_it)->active()) { 922 if (!(*item_it)->active()) {
@@ -934,9 +939,9 @@ void Toolbar::rearrangeItems() {
934 --rounding_error; 939 --rounding_error;
935 } 940 }
936 941
937 (*item_it)->moveResize(next_x, -borderW, extra + relative_width, height()); 942 (*item_it)->moveResize(next_x - borderW, -borderW, extra + relative_width, height());
938 } else { // fixed size 943 } else { // fixed size
939 (*item_it)->moveResize(next_x, -borderW, 944 (*item_it)->moveResize(next_x - borderW, -borderW,
940 (*item_it)->width(), height()); 945 (*item_it)->width(), height());
941 } 946 }
942 next_x += (*item_it)->width(); 947 next_x += (*item_it)->width();
diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc
index f2291e3..8509300 100644
--- a/src/WorkspaceNameTool.cc
+++ b/src/WorkspaceNameTool.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: WorkspaceNameTool.cc,v 1.7 2004/01/13 14:41:32 rathnor Exp $ 23// $Id: WorkspaceNameTool.cc,v 1.8 2004/06/16 15:38:19 rathnor Exp $
24 24
25#include "WorkspaceNameTool.hh" 25#include "WorkspaceNameTool.hh"
26 26
@@ -125,5 +125,4 @@ void WorkspaceNameTool::renderTheme() {
125 m_button.setBorderColor(m_theme.border().color()); 125 m_button.setBorderColor(m_theme.border().color());
126 m_button.setAlpha(m_theme.alpha()); 126 m_button.setAlpha(m_theme.alpha());
127 m_button.clear(); 127 m_button.clear();
128 m_button.updateTransparent();
129} 128}