all repos — fluxbox @ 611b6aa57e34ed8e52cb6b88c9adbafe4d67c6e2

custom fork of the fluxbox windowmanager

more fun with the window menu
Mark Tiefenbruck mark@fluxbox.org
commit

611b6aa57e34ed8e52cb6b88c9adbafe4d67c6e2

parent

cd128d7a3e19e0608b992d5211d7ea88a73ed3cd

M src/FbMenu.ccsrc/FbMenu.cc

@@ -23,6 +23,9 @@ #include "FbMenu.hh"

#include "fluxbox.hh" #include "Screen.hh" +#include "WindowCmd.hh" + +FluxboxWindow *FbMenu::s_window = 0; FbMenu::FbMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm, FbTk::ImageControl &imgctrl, FbTk::XLayer &layer):

@@ -31,6 +34,16 @@ m_layeritem(fbwindow(), layer) {

} +void FbMenu::show() { + WindowCmd<void>::setWindow(s_window); + FbTk::Menu::show(); +} + +void FbMenu::buttonPressEvent(XButtonEvent &be) { + WindowCmd<void>::setWindow(s_window); + FbTk::Menu::buttonPressEvent(be); +} + void FbMenu::buttonReleaseEvent(XButtonEvent &be) { BScreen *screen = Fluxbox::instance()->findScreen(screenNumber()); if (be.window == titleWindow() && isMoving() && screen) {

@@ -41,7 +54,13 @@ screen->getHeadY(head),

screen->getHeadWidth(head), screen->getHeadHeight(head)); } + WindowCmd<void>::setWindow(s_window); // now get on with the show FbTk::Menu::buttonReleaseEvent(be); } + +void FbMenu::keyPressEvent(XKeyEvent &ke) { + WindowCmd<void>::setWindow(s_window); + FbTk::Menu::keyPressEvent(ke); +}
M src/FbMenu.hhsrc/FbMenu.hh

@@ -25,6 +25,8 @@

#include "FbTk/Menu.hh" #include "FbTk/XLayerItem.hh" +class FluxboxWindow; + namespace FbTk { class MenuTheme; }

@@ -37,9 +39,17 @@ FbTk::XLayer &layer);

virtual ~FbMenu() { } void raise() { m_layeritem.raise(); } void lower() { m_layeritem.lower(); } + void show(); + void buttonPressEvent(XButtonEvent &be); void buttonReleaseEvent(XButtonEvent &be); + void keyPressEvent(XKeyEvent &ke); + + static void setWindow(FluxboxWindow *win) { s_window = win; } + static FluxboxWindow *window() { return s_window; } + private: FbTk::XLayerItem m_layeritem; + static FluxboxWindow *s_window; }; #endif // FBMENU_HH
M src/IconbarTool.ccsrc/IconbarTool.cc

@@ -215,7 +215,7 @@ public:

explicit ShowMenu(FluxboxWindow &win):m_win(win) { } void execute() { // hide the menu if it's already showing for this FluxboxWindow - if (m_win.menu().isVisible() && WindowCmd<void>::window() == &m_win) { + if (m_win.menu().isVisible() && FbMenu::window() == &m_win) { m_win.menu().hide(); return; }
M src/Keys.ccsrc/Keys.cc

@@ -23,6 +23,8 @@ #include "Keys.hh"

#include "fluxbox.hh" #include "Screen.hh" +#include "WinClient.hh" +#include "WindowCmd.hh" #include "FbTk/EventManager.hh" #include "FbTk/StringUtil.hh"

@@ -480,7 +482,7 @@ }

// return true if bound to a command, else false bool Keys::doAction(int type, unsigned int mods, unsigned int key, - int context, Time time) { + int context, WinClient *current, Time time) { static Time last_button_time = 0; static unsigned int last_button = 0;

@@ -546,7 +548,11 @@ }

return false; } + WinClient *old = WindowCmd<void>::client(); + WindowCmd<void>::setClient(current); temp_key->m_command->execute(); + WindowCmd<void>::setClient(old); + if (saved_keymode) { if (next_key == m_keylist) // don't reset keymode if command changed it setKeyMode(saved_keymode);
M src/Keys.hhsrc/Keys.hh

@@ -28,6 +28,7 @@ #include <X11/Xlib.h>

#include <string> #include <map> +class WinClient; namespace FbTk { class EventHandler;

@@ -75,7 +76,7 @@ /**

do action from XKeyEvent; return false if not bound to anything */ bool doAction(int type, unsigned int mods, unsigned int key, int context, - Time time = 0); + WinClient *current = 0, Time time = 0); /// register a window so that proper keys/buttons get grabbed on it void registerWindow(Window win, FbTk::EventHandler &handler, int context);
M src/Screen.ccsrc/Screen.cc

@@ -832,11 +832,8 @@ m_bg_change_sig.notify();

} void BScreen::keyPressEvent(XKeyEvent &ke) { - WinClient *old = WindowCmd<void>::client(); - WindowCmd<void>::setWindow(FocusControl::focusedFbWindow()); Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode, Keys::GLOBAL|Keys::ON_DESKTOP); - WindowCmd<void>::setClient(old); } void BScreen::keyReleaseEvent(XKeyEvent &ke) {

@@ -855,11 +852,8 @@ if (be.button == 1 && !isRootColormapInstalled())

imageControl().installRootColormap(); Keys *keys = Fluxbox::instance()->keys(); - WinClient *old = WindowCmd<void>::client(); - WindowCmd<void>::setWindow(FocusControl::focusedFbWindow()); keys->doAction(be.type, be.state, be.button, Keys::GLOBAL|Keys::ON_DESKTOP, - be.time); - WindowCmd<void>::setClient(old); + 0, be.time); } void BScreen::notifyUngrabKeyboard() {
M src/Toolbar.ccsrc/Toolbar.cc

@@ -520,14 +520,9 @@

void Toolbar::buttonPressEvent(XButtonEvent &be) { - WinClient *old = WindowCmd<void>::client(); - WindowCmd<void>::setWindow(0); if (Fluxbox::instance()->keys()->doAction(be.type, be.state, be.button, - Keys::ON_TOOLBAR, be.time)) { - WindowCmd<void>::setClient(old); + Keys::ON_TOOLBAR, 0, be.time)) return; - } - WindowCmd<void>::setClient(old); if (be.button == 1) raise();

@@ -553,11 +548,8 @@

} void Toolbar::enterNotifyEvent(XCrossingEvent &ce) { - WinClient *old = WindowCmd<void>::client(); - WindowCmd<void>::setWindow(0); Fluxbox::instance()->keys()->doAction(ce.type, ce.state, 0, Keys::ON_TOOLBAR); - WindowCmd<void>::setClient(old); if (! doAutoHide()) { if (isHidden())

@@ -580,11 +572,8 @@ if (event.x_root > x() && event.x_root <= (int)(x() + width()) &&

event.y_root > y() && event.y_root <= (int)(y() + height())) return; - WinClient *old = WindowCmd<void>::client(); - WindowCmd<void>::setWindow(0); Fluxbox::instance()->keys()->doAction(event.type, event.state, 0, Keys::ON_TOOLBAR); - WindowCmd<void>::setClient(old); if (! doAutoHide()) return;
M src/Window.ccsrc/Window.cc

@@ -1986,11 +1986,8 @@ m_attention_state = false;

m_focussig.notify(); if (m_client) m_client->focusSig().notify(); - WinClient *old = WindowCmd<void>::client(); - WindowCmd<void>::setClient(m_client); Fluxbox::instance()->keys()->doAction(focus ? FocusIn : FocusOut, 0, 0, - Keys::ON_WINDOW); - WindowCmd<void>::setClient(old); + Keys::ON_WINDOW, m_client); } }

@@ -2168,7 +2165,7 @@ menu_x = screen().maxLeft(head);

else if (menu_x + static_cast<signed>(menu().width()) >= static_cast<signed>(screen().maxRight(head))) menu_x = screen().maxRight(head) - menu().width() - 1; - WindowCmd<void>::setWindow(this); + FbMenu::setWindow(this); menu().move(menu_x, menu_y); menu().show(); menu().raise();

@@ -2182,7 +2179,7 @@ */

void FluxboxWindow::popupMenu() { // hide menu if it was opened for this window before - if (menu().isVisible() && WindowCmd<void>::window() == this) { + if (menu().isVisible() && FbMenu::window() == this) { menu().hide(); return; }

@@ -2639,11 +2636,11 @@ if (onTitlebar && be.button == 1)

raise(); // check keys file first - WindowCmd<void>::setWindow(this); Keys *k = Fluxbox::instance()->keys(); if (onTitlebar && k->doAction(be.type, be.state, be.button, - Keys::ON_TITLEBAR, be.time) || - k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, be.time)) { + Keys::ON_TITLEBAR, m_client, be.time) || + k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, m_client, + be.time)) { return; }

@@ -2926,14 +2923,9 @@ !isVisible()) {

return; } - if (ev.window == frame().window()) { - // save old value, so we can restore it later - WinClient *old = WindowCmd<void>::client(); - WindowCmd<void>::setWindow(this); + if (ev.window == frame().window()) Fluxbox::instance()->keys()->doAction(ev.type, ev.state, 0, - Keys::ON_WINDOW); - WindowCmd<void>::setClient(old); - } + Keys::ON_WINDOW, m_client); WinClient *client = 0; if (screen().focusControl().isMouseTabFocus()) {

@@ -2989,12 +2981,8 @@ ev.x_root <= (int)(frame().x() + frame().width()) &&

ev.y_root <= (int)(frame().y() + frame().height())) return; - // save old value, so we can restore it later - WinClient *old = WindowCmd<void>::client(); - WindowCmd<void>::setWindow(this); Fluxbox::instance()->keys()->doAction(ev.type, ev.state, 0, - Keys::ON_WINDOW); - WindowCmd<void>::setClient(old); + Keys::ON_WINDOW, m_client); // I hope commenting this out is right - simon 21jul2003 //if (ev.window == frame().window())