summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-23 15:42:48 (GMT)
committerfluxgen <fluxgen>2003-08-23 15:42:48 (GMT)
commitbc8e67136f9df2d0475f0e2f01e03976aabfa259 (patch)
tree86b7202b97c4f44b039d5c876b44db5bd9e22bb7
parent89a3b058d6d8f7ede6d3bb516f88c93d48c1bea5 (diff)
downloadfluxbox_lack-bc8e67136f9df2d0475f0e2f01e03976aabfa259.zip
fluxbox_lack-bc8e67136f9df2d0475f0e2f01e03976aabfa259.tar.bz2
fixed autohide issue and toolbar menu
-rw-r--r--src/Toolbar.cc39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 8d748d4..9834f06 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.112 2003/08/19 21:28:57 fluxgen Exp $ 25// $Id: Toolbar.cc,v 1.113 2003/08/23 15:42:48 fluxgen Exp $
26 26
27#include "Toolbar.hh" 27#include "Toolbar.hh"
28 28
@@ -161,7 +161,7 @@ getString() {
161namespace { 161namespace {
162class SetToolbarPlacementCmd: public FbTk::Command { 162class SetToolbarPlacementCmd: public FbTk::Command {
163public: 163public:
164 explicit SetToolbarPlacementCmd(Toolbar &tbar, Toolbar::Placement place):m_tbar(tbar), m_place(place) { } 164 SetToolbarPlacementCmd(Toolbar &tbar, Toolbar::Placement place):m_tbar(tbar), m_place(place) { }
165 void execute() { 165 void execute() {
166 m_tbar.setPlacement(m_place); 166 m_tbar.setPlacement(m_place);
167 m_tbar.reconfigure(); 167 m_tbar.reconfigure();
@@ -172,6 +172,32 @@ private:
172 Toolbar::Placement m_place; 172 Toolbar::Placement m_place;
173}; 173};
174 174
175class ShowMenuAboveToolbar: public FbTk::Command {
176public:
177 explicit ShowMenuAboveToolbar(Toolbar &tbar):m_tbar(tbar) { }
178 void execute() {
179
180 // get last button pos
181 const XEvent &event = Fluxbox::instance()->lastEvent();
182 int x = event.xbutton.x_root - (m_tbar.menu().width() / 2);
183 int y = event.xbutton.y_root - (m_tbar.menu().height() / 2);
184
185 if (x < 0)
186 x = 0;
187 else if (x + m_tbar.menu().width() > m_tbar.screen().width())
188 x = m_tbar.screen().width() - m_tbar.menu().width();
189
190 if (y < 0)
191 y = 0;
192 else if (y + m_tbar.menu().height() > m_tbar.screen().height())
193 y = m_tbar.screen().height() - m_tbar.menu().height();
194
195 m_tbar.menu().move(x, y);
196 m_tbar.menu().show();
197 }
198private:
199 Toolbar &m_tbar;
200};
175}; // end anonymous 201}; // end anonymous
176 202
177// toolbar frame 203// toolbar frame
@@ -258,7 +284,11 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t wi
258 frame.grab_x = frame.grab_y = 0; 284 frame.grab_x = frame.grab_y = 0;
259 285
260 // add toolbar items 286 // add toolbar items
261 m_item_list.push_back(new WorkspaceNameTool(frame.window, m_workspace_theme, screen())); 287 WorkspaceNameTool *item = new WorkspaceNameTool(frame.window, m_workspace_theme, screen());
288 using namespace FbTk;
289 RefCount<Command> showmenu(new ShowMenuAboveToolbar(*this));
290 item->button().setOnClick(showmenu);
291 m_item_list.push_back(item);
262 m_item_list.push_back(new IconbarTool(frame.window, m_iconbar_theme, screen())); 292 m_item_list.push_back(new IconbarTool(frame.window, m_iconbar_theme, screen()));
263 m_item_list.push_back(new SystemTray(frame.window)); 293 m_item_list.push_back(new SystemTray(frame.window));
264 m_item_list.push_back(new ClockTool(frame.window, m_clock_theme, screen())); 294 m_item_list.push_back(new ClockTool(frame.window, m_clock_theme, screen()));
@@ -279,7 +309,8 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t wi
279 frame.window.show(); 309 frame.window.show();
280 310
281 scrn.resourceManager().unlock(); 311 scrn.resourceManager().unlock();
282 312 // setup to listen to child events
313 FbTk::EventManager::instance()->addParent(*this, window());
283 // get everything together 314 // get everything together
284 reconfigure(); 315 reconfigure();
285 316