aboutsummaryrefslogtreecommitdiff
path: root/src/Toolbar.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2008-08-14 05:52:39 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2008-08-14 05:52:39 (GMT)
commite169d33552c8e7070aa6e13da0187f2013b4cfc3 (patch)
treeae9e92c7e885791c7f47645184070cbcd441ab94 /src/Toolbar.cc
parentc82e7c0080f8a5c14dcf95ec92dc42f59ea9dd8b (diff)
parent91ca3bc5c8e2b892a9a81b18246f72aba7deebfd (diff)
downloadfluxbox_paul-e169d33552c8e7070aa6e13da0187f2013b4cfc3.zip
fluxbox_paul-e169d33552c8e7070aa6e13da0187f2013b4cfc3.tar.bz2
Merge branch 'master' into to_push
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r--src/Toolbar.cc72
1 files changed, 39 insertions, 33 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 61402f1..440eff5 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -50,7 +50,7 @@
50#include "FbTk/BoolMenuItem.hh" 50#include "FbTk/BoolMenuItem.hh"
51#include "FbTk/IntMenuItem.hh" 51#include "FbTk/IntMenuItem.hh"
52#include "FbTk/Shape.hh" 52#include "FbTk/Shape.hh"
53 53#include "FbTk/SimpleObserver.hh"
54 54
55// use GNU extensions 55// use GNU extensions
56#ifndef _GNU_SOURCE 56#ifndef _GNU_SOURCE
@@ -156,16 +156,22 @@ getString() const {
156} // end namespace FbTk 156} // end namespace FbTk
157 157
158namespace { 158namespace {
159class SetToolbarPlacementCmd: public FbTk::Command<void> { 159
160class PlaceToolbarMenuItem: public FbTk::RadioMenuItem {
160public: 161public:
161 SetToolbarPlacementCmd(Toolbar &tbar, Toolbar::Placement place):m_tbar(tbar), m_place(place) { } 162 PlaceToolbarMenuItem(const FbTk::FbString &label, Toolbar &toolbar,
162 void execute() { 163 Toolbar::Placement place):
163 m_tbar.setPlacement(m_place); 164 FbTk::RadioMenuItem(label), m_toolbar(toolbar), m_place(place) {
164 m_tbar.reconfigure(); 165 setCloseOnClick(false);
166 }
167 bool isSelected() const { return m_toolbar.placement() == m_place; }
168 void click(int button, int time, unsigned int mods) {
169 m_toolbar.setPlacement(m_place);
170 m_toolbar.reconfigure();
165 Fluxbox::instance()->save_rc(); 171 Fluxbox::instance()->save_rc();
166 } 172 }
167private: 173private:
168 Toolbar &m_tbar; 174 Toolbar &m_toolbar;
169 Toolbar::Placement m_place; 175 Toolbar::Placement m_place;
170}; 176};
171 177
@@ -240,11 +246,15 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width):
240 m_shape(new FbTk::Shape(frame.window, 0)), 246 m_shape(new FbTk::Shape(frame.window, 0)),
241 m_resize_lock(false) { 247 m_resize_lock(false) {
242 _FB_USES_NLS; 248 _FB_USES_NLS;
249 // NOTE: first subject is always the rearrangeItem !
250 m_observers.push_back(makeObserver(*this, &Toolbar::rearrangeItems));
243 // we need to get notified when the theme is reloaded 251 // we need to get notified when the theme is reloaded
244 m_theme.reconfigSig().attach(this); 252 m_observers.push_back(makeObserver(*this, &Toolbar::reconfigure));
253 m_theme.reconfigSig().attach(m_observers.back());
254 screen().reconfigureSig().attach(m_observers.back()); // get this on antialias change
245 // listen to screen size changes 255 // listen to screen size changes
246 screen().resizeSig().attach(this); 256 screen().resizeSig().attach(m_observers.back());
247 screen().reconfigureSig().attach(this); // get this on antialias change 257
248 258
249 moveToLayer((*m_rc_layernum).getNum()); 259 moveToLayer((*m_rc_layernum).getNum());
250 260
@@ -370,6 +380,7 @@ void Toolbar::lower() {
370} 380}
371 381
372void Toolbar::reconfigure() { 382void Toolbar::reconfigure() {
383
373 updateVisibleState(); 384 updateVisibleState();
374 385
375 if (!doAutoHide() && isHidden()) 386 if (!doAutoHide() && isHidden())
@@ -426,7 +437,8 @@ void Toolbar::reconfigure() {
426 if (item == 0) 437 if (item == 0)
427 continue; 438 continue;
428 m_item_list.push_back(item); 439 m_item_list.push_back(item);
429 item->resizeSig().attach(this); 440 // attach to first observer ( which must be rearrangeItems )
441 item->resizeSig().attach(m_observers[0]);
430 442
431 } 443 }
432 // show all items 444 // show all items
@@ -515,6 +527,11 @@ void Toolbar::reconfigure() {
515 // area to be reserved on screen 527 // area to be reserved on screen
516 updateStrut(); 528 updateStrut();
517 529
530#ifdef XINERAMA
531 if (m_xineramaheadmenu)
532 m_xineramaheadmenu->reloadHeads();
533#endif // XINERAMA
534
518} 535}
519 536
520 537
@@ -567,10 +584,16 @@ void Toolbar::enterNotifyEvent(XCrossingEvent &ce) {
567} 584}
568 585
569void Toolbar::leaveNotifyEvent(XCrossingEvent &event) { 586void Toolbar::leaveNotifyEvent(XCrossingEvent &event) {
570 // still inside? 587
588 // in autoHide mode we'll receive a leaveNotifyEvent when activating
589 // the toolbar. so check if we are still inside the toolbar area.
590 // event.subwindow gets != None if we really left the window (eg the Slit
591 // was entered ontop of the toolbar)
571 if (event.x_root > x() && event.x_root <= (int)(x() + width()) && 592 if (event.x_root > x() && event.x_root <= (int)(x() + width()) &&
572 event.y_root > y() && event.y_root <= (int)(y() + height())) 593 event.y_root > y() && event.y_root <= (int)(y() + height()) &&
594 event.subwindow == None ) {
573 return; 595 return;
596 }
574 597
575 Fluxbox::instance()->keys()->doAction(event.type, event.state, 0, 598 Fluxbox::instance()->keys()->doAction(event.type, event.state, 0,
576 Keys::ON_TOOLBAR); 599 Keys::ON_TOOLBAR);
@@ -607,22 +630,6 @@ void Toolbar::handleEvent(XEvent &event) {
607*/ 630*/
608} 631}
609 632
610void Toolbar::update(FbTk::Subject *subj) {
611
612 // either screen reconfigured, theme was reloaded
613 // or a tool resized itself
614
615 if (typeid(*subj) == typeid(ToolbarItem::ToolbarItemSubject))
616 rearrangeItems();
617 else
618 reconfigure();
619
620#ifdef XINERAMA
621 if (subj == &m_screen.resizeSig() && m_xineramaheadmenu)
622 m_xineramaheadmenu->reloadHeads();
623#endif // XINERAMA
624}
625
626void Toolbar::setPlacement(Toolbar::Placement where) { 633void Toolbar::setPlacement(Toolbar::Placement where) {
627 // disable vertical toolbar 634 // disable vertical toolbar
628 635
@@ -908,11 +915,10 @@ void Toolbar::setupMenus(bool skip_new_placement) {
908 if (str == "") { 915 if (str == "") {
909 placementMenu().insert(""); 916 placementMenu().insert("");
910 placementMenu().setItemEnabled(i, false); 917 placementMenu().setItemEnabled(i, false);
911 } else { 918 } else
912 RefCommand setplace(new SetToolbarPlacementCmd(*this, placement)); 919 placementMenu().insert(new PlaceToolbarMenuItem(str, *this,
913 placementMenu().insert(str, setplace); 920 placement));
914 921
915 }
916 place_menu.pop_front(); 922 place_menu.pop_front();
917 } 923 }
918 } 924 }