summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--src/Container.cc36
-rw-r--r--src/FbWinFrame.cc20
-rw-r--r--src/IconButton.cc18
-rw-r--r--src/Screen.cc12
-rw-r--r--src/SystemTray.hh4
-rw-r--r--src/Toolbar.cc42
-rw-r--r--src/ToolbarItem.hh4
8 files changed, 98 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index f2915a0..5570542 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.9.6: 2Changes for 0.9.6:
3*03/10/31:
4 * Fix iconbar button alignment and squash inactive tools (Simon)
5 - also fix a bunch of rounding issues
6 -> keep in mind that titlebar/iconbar width may not be exactly
7 divisible by the number of clients/labels in it
8 Container.cc FbWinFrame.cc SystemTray.hh Screen.cc ToolbarItem.hh
9 Toolbar.cc
3*03/10/30: 10*03/10/30:
4 * Fix handling of theme's with a zero handleWidth (Simon) 11 * Fix handling of theme's with a zero handleWidth (Simon)
5 FbWinFrame.cc 12 FbWinFrame.cc
diff --git a/src/Container.cc b/src/Container.cc
index 3eda052..242a7f1 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.6 2003/10/26 21:05:03 fluxgen Exp $ 23// $Id: Container.cc,v 1.7 2003/10/31 10:37:09 rathnor Exp $
24 24
25#include "Container.hh" 25#include "Container.hh"
26 26
@@ -30,7 +30,6 @@
30Container::Container(const FbTk::FbWindow &parent): 30Container::Container(const FbTk::FbWindow &parent):
31 FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask), m_selected(0), 31 FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask), m_selected(0),
32 m_update_lock(false) { 32 m_update_lock(false) {
33
34 FbTk::EventManager::instance()->add(*this, *this); 33 FbTk::EventManager::instance()->add(*this, *this);
35} 34}
36 35
@@ -177,18 +176,37 @@ void Container::repositionItems() {
177 176
178 ItemList::iterator it = m_item_list.begin(); 177 ItemList::iterator it = m_item_list.begin();
179 const ItemList::iterator it_end = m_item_list.end(); 178 const ItemList::iterator it_end = m_item_list.end();
180 int next_x = 0; 179 int borderW = m_item_list.front()->borderWidth();
181 for (; it != it_end; ++it, next_x += max_width_per_client) { 180
181 int rounding_error = width() - ((maxWidthPerClient() + borderW)* m_item_list.size() - borderW);
182
183 int next_x = -borderW; // zero so the border of the first shows
184 int extra = 0;
185 for (; it != it_end; ++it, next_x += max_width_per_client + borderW + extra) {
186 if (rounding_error != 0) {
187 --rounding_error;
188 extra = 1;
189 } else {
190 extra = 0;
191 }
182 // resize each clients including border in size 192 // resize each clients including border in size
183 (*it)->moveResize(next_x - (*it)->borderWidth(), 193 (*it)->moveResize(next_x,
184 -(*it)->borderWidth(), 194 -borderW,
185 max_width_per_client - (*it)->borderWidth(), 195 max_width_per_client + extra,
186 height() + (*it)->borderWidth()); 196 height());
187 (*it)->clear(); 197 (*it)->clear();
188 } 198 }
189} 199}
190 200
191 201
192unsigned int Container::maxWidthPerClient() const { 202unsigned int Container::maxWidthPerClient() const {
193 return (size() == 0 ? width() : (width() + size()*m_item_list.front()->borderWidth())/size()); 203 int count = size();
204 if (count == 0)
205 return width();
206 else {
207 int borderW = m_item_list.front()->borderWidth();
208 // there're count-1 borders to fit in with the windows
209 // -> 1 per window plus end
210 return (width() - (count - 1) * borderW) / count;
211 }
194} 212}
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 862ec29..1e3cb97 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbWinFrame.cc,v 1.61 2003/10/30 20:27:51 rathnor Exp $ 22// $Id: FbWinFrame.cc,v 1.62 2003/10/31 10:37:09 rathnor Exp $
23 23
24#include "FbWinFrame.hh" 24#include "FbWinFrame.hh"
25 25
@@ -229,6 +229,8 @@ void FbWinFrame::setFocus(bool newvalue) {
229 if (m_focused == newvalue) 229 if (m_focused == newvalue)
230 return; 230 return;
231 231
232 m_focused = newvalue;
233
232 if (currentLabel()) { 234 if (currentLabel()) {
233 if (newvalue) // focused 235 if (newvalue) // focused
234 renderButtonFocus(*m_current_label); 236 renderButtonFocus(*m_current_label);
@@ -236,10 +238,8 @@ void FbWinFrame::setFocus(bool newvalue) {
236 renderButtonUnfocus(*m_current_label); 238 renderButtonUnfocus(*m_current_label);
237 } 239 }
238 240
239 m_focused = newvalue;
240
241 renderButtons();
242 renderTitlebar(); 241 renderTitlebar();
242 renderButtons(); // parent relative buttons -> need render after titlebar
243 renderHandles(); 243 renderHandles();
244} 244}
245 245
@@ -713,6 +713,7 @@ void FbWinFrame::redrawTitle() {
713 return; 713 return;
714 714
715 int button_width = label().width()/m_labelbuttons.size(); 715 int button_width = label().width()/m_labelbuttons.size();
716 int rounding_error = label().width() - m_labelbuttons.size()*button_width;
716 //!! TODO: bevel 717 //!! TODO: bevel
717 //int border_width = m_labelbuttons.front()->window().borderWidth(); 718 //int border_width = m_labelbuttons.front()->window().borderWidth();
718 int border_width = m_labelbuttons.size() != 0 ? 719 int border_width = m_labelbuttons.size() != 0 ?
@@ -720,13 +721,20 @@ void FbWinFrame::redrawTitle() {
720 721
721 LabelList::iterator btn_it = m_labelbuttons.begin(); 722 LabelList::iterator btn_it = m_labelbuttons.begin();
722 LabelList::iterator btn_it_end = m_labelbuttons.end(); 723 LabelList::iterator btn_it_end = m_labelbuttons.end();
724 int extra = 0;
723 for (unsigned int last_x = 0; 725 for (unsigned int last_x = 0;
724 btn_it != btn_it_end; 726 btn_it != btn_it_end;
725 ++btn_it, last_x += button_width + border_width) { 727 ++btn_it, last_x += button_width + border_width + extra) {
726 // since we add border width pixel we should remove 728 // since we add border width pixel we should remove
727 // the same size for inside width so we can fit all buttons into label 729 // the same size for inside width so we can fit all buttons into label
730 if (rounding_error != 0) {
731 extra = 1;
732 --rounding_error;
733 } else
734 extra = 0;
735
728 (*btn_it)->moveResize(last_x - border_width, - border_width, 736 (*btn_it)->moveResize(last_x - border_width, - border_width,
729 button_width, 737 button_width + extra,
730 label().height() + border_width); 738 label().height() + border_width);
731 if (isVisible()) 739 if (isVisible())
732 (*btn_it)->clear(); 740 (*btn_it)->clear();
diff --git a/src/IconButton.cc b/src/IconButton.cc
index c6b876e..2f68ecf 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.8 2003/09/10 21:41:18 fluxgen Exp $ 23// $Id: IconButton.cc,v 1.9 2003/10/31 10:37:09 rathnor Exp $
24 24
25#include "IconButton.hh" 25#include "IconButton.hh"
26 26
@@ -118,7 +118,6 @@ void IconButton::resize(unsigned int width, unsigned int height) {
118} 118}
119 119
120void IconButton::clear() { 120void IconButton::clear() {
121 FbTk::TextButton::clear();
122 setupWindow(); 121 setupWindow();
123} 122}
124 123
@@ -152,7 +151,7 @@ void IconButton::update(FbTk::Subject *subj) {
152 m_icon_pixmap.copy(hints->icon_pixmap); 151 m_icon_pixmap.copy(hints->icon_pixmap);
153 m_icon_pixmap.scale(m_icon_window.height(), m_icon_window.height()); 152 m_icon_pixmap.scale(m_icon_window.height(), m_icon_window.height());
154 153
155 m_icon_window.setBackgroundPixmap(m_icon_pixmap.drawable()); 154 setBackgroundPixmap(m_icon_pixmap.drawable());
156 } else { 155 } else {
157 // no icon pixmap 156 // no icon pixmap
158 m_icon_window.move(0, 0); 157 m_icon_window.move(0, 0);
@@ -186,15 +185,12 @@ void IconButton::update(FbTk::Subject *subj) {
186} 185}
187 186
188void IconButton::setupWindow() { 187void IconButton::setupWindow() {
189
190 m_icon_window.clear();
191 188
192 if (m_win.clientList().size() == 0) 189 if (!m_win.clientList().empty()) {
193 return; 190 setText(m_win.winClient().title());
194 191 // draw with x offset and y offset
195 setText(m_win.winClient().title()); 192 }
196 // draw with x offset and y offset 193 FbTk::TextButton::clear();
197 drawText();
198} 194}
199 195
200void IconButton::drawText(int x, int y) { 196void IconButton::drawText(int x, int y) {
diff --git a/src/Screen.cc b/src/Screen.cc
index 34173a3..1aa2e73 100644
--- a/src/Screen.cc
+++ b/src/Screen.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: Screen.cc,v 1.239 2003/10/28 17:39:59 rathnor Exp $ 25// $Id: Screen.cc,v 1.240 2003/10/31 10:37:09 rathnor Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -328,17 +328,17 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
328 rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); 328 rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr));
329 329
330 Fluxbox *fluxbox = Fluxbox::instance(); 330 Fluxbox *fluxbox = Fluxbox::instance();
331 // load this screens resources
332 fluxbox->load_rc(*this);
333
334 FbTk::ThemeManager::instance().load(Fluxbox::instance()->getStyleFilename());
335
331 // setup image cache engine 336 // setup image cache engine
332 m_image_control.reset(new FbTk::ImageControl(scrn, true, fluxbox->colorsPerChannel(), 337 m_image_control.reset(new FbTk::ImageControl(scrn, true, fluxbox->colorsPerChannel(),
333 fluxbox->getCacheLife(), fluxbox->getCacheMax())); 338 fluxbox->getCacheLife(), fluxbox->getCacheMax()));
334 imageControl().installRootColormap(); 339 imageControl().installRootColormap();
335 root_colormap_installed = true; 340 root_colormap_installed = true;
336 341
337 // load this screens resources
338 fluxbox->load_rc(*this);
339
340 FbTk::ThemeManager::instance().load(Fluxbox::instance()->getStyleFilename());
341
342#ifdef SLIT 342#ifdef SLIT
343 if (slit()) // this will load theme and reconfigure slit 343 if (slit()) // this will load theme and reconfigure slit
344 FbTk::ThemeManager::instance().loadTheme(slit()->theme()); 344 FbTk::ThemeManager::instance().loadTheme(slit()->theme());
diff --git a/src/SystemTray.hh b/src/SystemTray.hh
index 82d163c..84d78fa 100644
--- a/src/SystemTray.hh
+++ b/src/SystemTray.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: SystemTray.hh,v 1.2 2003/08/16 12:12:21 fluxgen Exp $ 22// $Id: SystemTray.hh,v 1.3 2003/10/31 10:37:09 rathnor Exp $
23 23
24#ifndef SYSTEMTRAY_HH 24#ifndef SYSTEMTRAY_HH
25#define SYSTEMTRAY_HH 25#define SYSTEMTRAY_HH
@@ -49,6 +49,8 @@ public:
49 void show(); 49 void show();
50 void hide(); 50 void hide();
51 51
52 bool active() { return !m_clients.empty(); }
53
52 bool clientMessage(const XClientMessageEvent &event); 54 bool clientMessage(const XClientMessageEvent &event);
53 void exposeEvent(XExposeEvent &event); 55 void exposeEvent(XExposeEvent &event);
54 void handleEvent(XEvent &event); 56 void handleEvent(XEvent &event);
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index ded81e2..9b76ed6 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.125 2003/10/14 00:21:52 fluxgen Exp $ 25// $Id: Toolbar.cc,v 1.126 2003/10/31 10:37:09 rathnor Exp $
26 26
27#include "Toolbar.hh" 27#include "Toolbar.hh"
28 28
@@ -832,7 +832,7 @@ void Toolbar::saveOnHead(int head) {
832 832
833void Toolbar::rearrangeItems() { 833void Toolbar::rearrangeItems() {
834 if (m_resize_lock || screen().isShuttingdown() || 834 if (m_resize_lock || screen().isShuttingdown() ||
835 m_item_list.size() == 0) 835 m_item_list.empty())
836 return; 836 return;
837 // lock this 837 // lock this
838 m_resize_lock = true; 838 m_resize_lock = true;
@@ -841,37 +841,57 @@ void Toolbar::rearrangeItems() {
841 ItemList::iterator item_it_end = m_item_list.end(); 841 ItemList::iterator item_it_end = m_item_list.end();
842 int fixed_width = 0; // combined size of all fixed items 842 int fixed_width = 0; // combined size of all fixed items
843 int fixed_items = 0; // number of fixed items 843 int fixed_items = 0; // number of fixed items
844 int relative_items = 0;
844 for (; item_it != item_it_end; ++item_it) { 845 for (; item_it != item_it_end; ++item_it) {
845 if ((*item_it)->type() == ToolbarItem::FIXED) { 846 if ((*item_it)->type() == ToolbarItem::FIXED && (*item_it)->active()) {
846 fixed_width += (*item_it)->width() + (*item_it)->borderWidth()*2; 847 fixed_width += (*item_it)->width() + (*item_it)->borderWidth()*2;
847 fixed_items++; 848 fixed_items++;
849 } else if ((*item_it)->type() == ToolbarItem::RELATIVE && (*item_it)->active()) {
850 relative_items++;
848 } 851 }
849 } 852 }
850 // calculate what's going to be left over to the relative sized items 853
854 // calculate what's going to be le ft over to the relative sized items
851 int relative_width = 0; 855 int relative_width = 0;
856 int rounding_error = 0;
852 if (fixed_items == 0) // no fixed items, then the rest is the entire width 857 if (fixed_items == 0) // no fixed items, then the rest is the entire width
853 relative_width = width(); 858 relative_width = width();
854 else { 859 else {
855 const int relative_items = m_item_list.size() - fixed_items;
856 if (relative_items == 0) 860 if (relative_items == 0)
857 relative_width = 0; 861 relative_width = 0;
858 else // size left after fixed items / number of relative items 862 else { // size left after fixed items / number of relative items
859 relative_width = (width() - fixed_width)/relative_items; 863 relative_width = (width() - fixed_width)/relative_items;
864 rounding_error = width() - fixed_width - relative_items*relative_width;
865 }
860 } 866 }
861
862 // now move and resize the items 867 // now move and resize the items
863 int next_x = m_item_list.front()->borderWidth(); 868 int next_x = 0;
864 for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { 869 for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) {
870 if (!(*item_it)->active()) {
871 (*item_it)->hide();
872 continue;
873 }
874
875 int borderW = (*item_it)->borderWidth();
876 (*item_it)->show();
865 if ((*item_it)->type() == ToolbarItem::RELATIVE) { 877 if ((*item_it)->type() == ToolbarItem::RELATIVE) {
866 (*item_it)->moveResize(next_x, 0, relative_width, height()); 878 int extra = 0;
879 if (rounding_error != 0) { // distribute rounding error over all relatives
880 extra = 1;
881 --rounding_error;
882 }
883
884 (*item_it)->moveResize(next_x, -borderW, extra + relative_width-2*borderW, height());
867 } else { // fixed size 885 } else { // fixed size
868 (*item_it)->moveResize(next_x, 0, 886 (*item_it)->moveResize(next_x, -borderW,
869 (*item_it)->width(), height()); 887 (*item_it)->width(), height());
870 } 888 }
871 next_x += (*item_it)->width() + (*item_it)->borderWidth()*2; 889 next_x += (*item_it)->width() + borderW*2;
872 } 890 }
873 // unlock 891 // unlock
874 m_resize_lock = false; 892 m_resize_lock = false;
893 frame.window.clear();
894
875} 895}
876 896
877void Toolbar::deleteItems() { 897void Toolbar::deleteItems() {
diff --git a/src/ToolbarItem.hh b/src/ToolbarItem.hh
index dc60264..57088e0 100644
--- a/src/ToolbarItem.hh
+++ b/src/ToolbarItem.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: ToolbarItem.hh,v 1.2 2003/08/13 09:36:12 fluxgen Exp $ 23// $Id: ToolbarItem.hh,v 1.3 2003/10/31 10:37:09 rathnor Exp $
24 24
25#ifndef TOOLBARITEM_HH 25#ifndef TOOLBARITEM_HH
26#define TOOLBARITEM_HH 26#define TOOLBARITEM_HH
@@ -47,6 +47,8 @@ public:
47 virtual unsigned int width() const = 0; 47 virtual unsigned int width() const = 0;
48 virtual unsigned int height() const = 0; 48 virtual unsigned int height() const = 0;
49 virtual unsigned int borderWidth() const = 0; 49 virtual unsigned int borderWidth() const = 0;
50 // some items might be there, but effectively empty, so shouldn't appear
51 virtual bool active() { return true; }
50 52
51 void setType(Type type) { m_type = type; } 53 void setType(Type type) { m_type = type; }
52 Type type() const { return m_type; } 54 Type type() const { return m_type; }