summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbMenu.cc19
-rw-r--r--src/FbMenu.hh10
-rw-r--r--src/IconbarTool.cc2
-rw-r--r--src/Keys.cc8
-rw-r--r--src/Keys.hh3
-rw-r--r--src/Screen.cc8
-rw-r--r--src/Toolbar.cc13
-rw-r--r--src/Window.cc30
8 files changed, 50 insertions, 43 deletions
diff --git a/src/FbMenu.cc b/src/FbMenu.cc
index 54b6c4a..12ee2f1 100644
--- a/src/FbMenu.cc
+++ b/src/FbMenu.cc
@@ -23,6 +23,9 @@
23 23
24#include "fluxbox.hh" 24#include "fluxbox.hh"
25#include "Screen.hh" 25#include "Screen.hh"
26#include "WindowCmd.hh"
27
28FluxboxWindow *FbMenu::s_window = 0;
26 29
27FbMenu::FbMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm, 30FbMenu::FbMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
28 FbTk::ImageControl &imgctrl, FbTk::XLayer &layer): 31 FbTk::ImageControl &imgctrl, FbTk::XLayer &layer):
@@ -31,6 +34,16 @@ FbMenu::FbMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
31 34
32} 35}
33 36
37void FbMenu::show() {
38 WindowCmd<void>::setWindow(s_window);
39 FbTk::Menu::show();
40}
41
42void FbMenu::buttonPressEvent(XButtonEvent &be) {
43 WindowCmd<void>::setWindow(s_window);
44 FbTk::Menu::buttonPressEvent(be);
45}
46
34void FbMenu::buttonReleaseEvent(XButtonEvent &be) { 47void FbMenu::buttonReleaseEvent(XButtonEvent &be) {
35 BScreen *screen = Fluxbox::instance()->findScreen(screenNumber()); 48 BScreen *screen = Fluxbox::instance()->findScreen(screenNumber());
36 if (be.window == titleWindow() && isMoving() && screen) { 49 if (be.window == titleWindow() && isMoving() && screen) {
@@ -41,7 +54,13 @@ void FbMenu::buttonReleaseEvent(XButtonEvent &be) {
41 screen->getHeadWidth(head), 54 screen->getHeadWidth(head),
42 screen->getHeadHeight(head)); 55 screen->getHeadHeight(head));
43 } 56 }
57 WindowCmd<void>::setWindow(s_window);
44 58
45 // now get on with the show 59 // now get on with the show
46 FbTk::Menu::buttonReleaseEvent(be); 60 FbTk::Menu::buttonReleaseEvent(be);
47} 61}
62
63void FbMenu::keyPressEvent(XKeyEvent &ke) {
64 WindowCmd<void>::setWindow(s_window);
65 FbTk::Menu::keyPressEvent(ke);
66}
diff --git a/src/FbMenu.hh b/src/FbMenu.hh
index 9114192..b9c4654 100644
--- a/src/FbMenu.hh
+++ b/src/FbMenu.hh
@@ -25,6 +25,8 @@
25#include "FbTk/Menu.hh" 25#include "FbTk/Menu.hh"
26#include "FbTk/XLayerItem.hh" 26#include "FbTk/XLayerItem.hh"
27 27
28class FluxboxWindow;
29
28namespace FbTk { 30namespace FbTk {
29class MenuTheme; 31class MenuTheme;
30} 32}
@@ -37,9 +39,17 @@ public:
37 virtual ~FbMenu() { } 39 virtual ~FbMenu() { }
38 void raise() { m_layeritem.raise(); } 40 void raise() { m_layeritem.raise(); }
39 void lower() { m_layeritem.lower(); } 41 void lower() { m_layeritem.lower(); }
42 void show();
43 void buttonPressEvent(XButtonEvent &be);
40 void buttonReleaseEvent(XButtonEvent &be); 44 void buttonReleaseEvent(XButtonEvent &be);
45 void keyPressEvent(XKeyEvent &ke);
46
47 static void setWindow(FluxboxWindow *win) { s_window = win; }
48 static FluxboxWindow *window() { return s_window; }
49
41private: 50private:
42 FbTk::XLayerItem m_layeritem; 51 FbTk::XLayerItem m_layeritem;
52 static FluxboxWindow *s_window;
43}; 53};
44 54
45#endif // FBMENU_HH 55#endif // FBMENU_HH
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 8aa0db8..b2a57d0 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -215,7 +215,7 @@ public:
215 explicit ShowMenu(FluxboxWindow &win):m_win(win) { } 215 explicit ShowMenu(FluxboxWindow &win):m_win(win) { }
216 void execute() { 216 void execute() {
217 // hide the menu if it's already showing for this FluxboxWindow 217 // hide the menu if it's already showing for this FluxboxWindow
218 if (m_win.menu().isVisible() && WindowCmd<void>::window() == &m_win) { 218 if (m_win.menu().isVisible() && FbMenu::window() == &m_win) {
219 m_win.menu().hide(); 219 m_win.menu().hide();
220 return; 220 return;
221 } 221 }
diff --git a/src/Keys.cc b/src/Keys.cc
index d85c696..76224ef 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -23,6 +23,8 @@
23 23
24#include "fluxbox.hh" 24#include "fluxbox.hh"
25#include "Screen.hh" 25#include "Screen.hh"
26#include "WinClient.hh"
27#include "WindowCmd.hh"
26 28
27#include "FbTk/EventManager.hh" 29#include "FbTk/EventManager.hh"
28#include "FbTk/StringUtil.hh" 30#include "FbTk/StringUtil.hh"
@@ -480,7 +482,7 @@ bool Keys::addBinding(const string &linebuffer) {
480 482
481// return true if bound to a command, else false 483// return true if bound to a command, else false
482bool Keys::doAction(int type, unsigned int mods, unsigned int key, 484bool Keys::doAction(int type, unsigned int mods, unsigned int key,
483 int context, Time time) { 485 int context, WinClient *current, Time time) {
484 486
485 static Time last_button_time = 0; 487 static Time last_button_time = 0;
486 static unsigned int last_button = 0; 488 static unsigned int last_button = 0;
@@ -546,7 +548,11 @@ bool Keys::doAction(int type, unsigned int mods, unsigned int key,
546 return false; 548 return false;
547 } 549 }
548 550
551 WinClient *old = WindowCmd<void>::client();
552 WindowCmd<void>::setClient(current);
549 temp_key->m_command->execute(); 553 temp_key->m_command->execute();
554 WindowCmd<void>::setClient(old);
555
550 if (saved_keymode) { 556 if (saved_keymode) {
551 if (next_key == m_keylist) // don't reset keymode if command changed it 557 if (next_key == m_keylist) // don't reset keymode if command changed it
552 setKeyMode(saved_keymode); 558 setKeyMode(saved_keymode);
diff --git a/src/Keys.hh b/src/Keys.hh
index 439ecac..7ebb0a7 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -28,6 +28,7 @@
28#include <string> 28#include <string>
29#include <map> 29#include <map>
30 30
31class WinClient;
31 32
32namespace FbTk { 33namespace FbTk {
33 class EventHandler; 34 class EventHandler;
@@ -75,7 +76,7 @@ public:
75 do action from XKeyEvent; return false if not bound to anything 76 do action from XKeyEvent; return false if not bound to anything
76 */ 77 */
77 bool doAction(int type, unsigned int mods, unsigned int key, int context, 78 bool doAction(int type, unsigned int mods, unsigned int key, int context,
78 Time time = 0); 79 WinClient *current = 0, Time time = 0);
79 80
80 /// register a window so that proper keys/buttons get grabbed on it 81 /// register a window so that proper keys/buttons get grabbed on it
81 void registerWindow(Window win, FbTk::EventHandler &handler, int context); 82 void registerWindow(Window win, FbTk::EventHandler &handler, int context);
diff --git a/src/Screen.cc b/src/Screen.cc
index a97f1aa..bf5a625 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -832,11 +832,8 @@ void BScreen::propertyNotify(Atom atom) {
832} 832}
833 833
834void BScreen::keyPressEvent(XKeyEvent &ke) { 834void BScreen::keyPressEvent(XKeyEvent &ke) {
835 WinClient *old = WindowCmd<void>::client();
836 WindowCmd<void>::setWindow(FocusControl::focusedFbWindow());
837 Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode, 835 Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode,
838 Keys::GLOBAL|Keys::ON_DESKTOP); 836 Keys::GLOBAL|Keys::ON_DESKTOP);
839 WindowCmd<void>::setClient(old);
840} 837}
841 838
842void BScreen::keyReleaseEvent(XKeyEvent &ke) { 839void BScreen::keyReleaseEvent(XKeyEvent &ke) {
@@ -855,11 +852,8 @@ void BScreen::buttonPressEvent(XButtonEvent &be) {
855 imageControl().installRootColormap(); 852 imageControl().installRootColormap();
856 853
857 Keys *keys = Fluxbox::instance()->keys(); 854 Keys *keys = Fluxbox::instance()->keys();
858 WinClient *old = WindowCmd<void>::client();
859 WindowCmd<void>::setWindow(FocusControl::focusedFbWindow());
860 keys->doAction(be.type, be.state, be.button, Keys::GLOBAL|Keys::ON_DESKTOP, 855 keys->doAction(be.type, be.state, be.button, Keys::GLOBAL|Keys::ON_DESKTOP,
861 be.time); 856 0, be.time);
862 WindowCmd<void>::setClient(old);
863} 857}
864 858
865void BScreen::notifyUngrabKeyboard() { 859void BScreen::notifyUngrabKeyboard() {
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 00cdfee..61402f1 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -520,14 +520,9 @@ void Toolbar::reconfigure() {
520 520
521 521
522void Toolbar::buttonPressEvent(XButtonEvent &be) { 522void Toolbar::buttonPressEvent(XButtonEvent &be) {
523 WinClient *old = WindowCmd<void>::client();
524 WindowCmd<void>::setWindow(0);
525 if (Fluxbox::instance()->keys()->doAction(be.type, be.state, be.button, 523 if (Fluxbox::instance()->keys()->doAction(be.type, be.state, be.button,
526 Keys::ON_TOOLBAR, be.time)) { 524 Keys::ON_TOOLBAR, 0, be.time))
527 WindowCmd<void>::setClient(old);
528 return; 525 return;
529 }
530 WindowCmd<void>::setClient(old);
531 526
532 if (be.button == 1) 527 if (be.button == 1)
533 raise(); 528 raise();
@@ -553,11 +548,8 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) {
553} 548}
554 549
555void Toolbar::enterNotifyEvent(XCrossingEvent &ce) { 550void Toolbar::enterNotifyEvent(XCrossingEvent &ce) {
556 WinClient *old = WindowCmd<void>::client();
557 WindowCmd<void>::setWindow(0);
558 Fluxbox::instance()->keys()->doAction(ce.type, ce.state, 0, 551 Fluxbox::instance()->keys()->doAction(ce.type, ce.state, 0,
559 Keys::ON_TOOLBAR); 552 Keys::ON_TOOLBAR);
560 WindowCmd<void>::setClient(old);
561 553
562 if (! doAutoHide()) { 554 if (! doAutoHide()) {
563 if (isHidden()) 555 if (isHidden())
@@ -580,11 +572,8 @@ void Toolbar::leaveNotifyEvent(XCrossingEvent &event) {
580 event.y_root > y() && event.y_root <= (int)(y() + height())) 572 event.y_root > y() && event.y_root <= (int)(y() + height()))
581 return; 573 return;
582 574
583 WinClient *old = WindowCmd<void>::client();
584 WindowCmd<void>::setWindow(0);
585 Fluxbox::instance()->keys()->doAction(event.type, event.state, 0, 575 Fluxbox::instance()->keys()->doAction(event.type, event.state, 0,
586 Keys::ON_TOOLBAR); 576 Keys::ON_TOOLBAR);
587 WindowCmd<void>::setClient(old);
588 577
589 if (! doAutoHide()) 578 if (! doAutoHide())
590 return; 579 return;
diff --git a/src/Window.cc b/src/Window.cc
index d4e79b1..133a84f 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -1986,11 +1986,8 @@ void FluxboxWindow::setFocusFlag(bool focus) {
1986 m_focussig.notify(); 1986 m_focussig.notify();
1987 if (m_client) 1987 if (m_client)
1988 m_client->focusSig().notify(); 1988 m_client->focusSig().notify();
1989 WinClient *old = WindowCmd<void>::client();
1990 WindowCmd<void>::setClient(m_client);
1991 Fluxbox::instance()->keys()->doAction(focus ? FocusIn : FocusOut, 0, 0, 1989 Fluxbox::instance()->keys()->doAction(focus ? FocusIn : FocusOut, 0, 0,
1992 Keys::ON_WINDOW); 1990 Keys::ON_WINDOW, m_client);
1993 WindowCmd<void>::setClient(old);
1994 } 1991 }
1995} 1992}
1996 1993
@@ -2168,7 +2165,7 @@ void FluxboxWindow::showMenu(int menu_x, int menu_y) {
2168 else if (menu_x + static_cast<signed>(menu().width()) >= static_cast<signed>(screen().maxRight(head))) 2165 else if (menu_x + static_cast<signed>(menu().width()) >= static_cast<signed>(screen().maxRight(head)))
2169 menu_x = screen().maxRight(head) - menu().width() - 1; 2166 menu_x = screen().maxRight(head) - menu().width() - 1;
2170 2167
2171 WindowCmd<void>::setWindow(this); 2168 FbMenu::setWindow(this);
2172 menu().move(menu_x, menu_y); 2169 menu().move(menu_x, menu_y);
2173 menu().show(); 2170 menu().show();
2174 menu().raise(); 2171 menu().raise();
@@ -2182,7 +2179,7 @@ void FluxboxWindow::showMenu(int menu_x, int menu_y) {
2182void FluxboxWindow::popupMenu() { 2179void FluxboxWindow::popupMenu() {
2183 2180
2184 // hide menu if it was opened for this window before 2181 // hide menu if it was opened for this window before
2185 if (menu().isVisible() && WindowCmd<void>::window() == this) { 2182 if (menu().isVisible() && FbMenu::window() == this) {
2186 menu().hide(); 2183 menu().hide();
2187 return; 2184 return;
2188 } 2185 }
@@ -2639,11 +2636,11 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
2639 raise(); 2636 raise();
2640 2637
2641 // check keys file first 2638 // check keys file first
2642 WindowCmd<void>::setWindow(this);
2643 Keys *k = Fluxbox::instance()->keys(); 2639 Keys *k = Fluxbox::instance()->keys();
2644 if (onTitlebar && k->doAction(be.type, be.state, be.button, 2640 if (onTitlebar && k->doAction(be.type, be.state, be.button,
2645 Keys::ON_TITLEBAR, be.time) || 2641 Keys::ON_TITLEBAR, m_client, be.time) ||
2646 k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, be.time)) { 2642 k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, m_client,
2643 be.time)) {
2647 return; 2644 return;
2648 } 2645 }
2649 2646
@@ -2926,14 +2923,9 @@ void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) {
2926 return; 2923 return;
2927 } 2924 }
2928 2925
2929 if (ev.window == frame().window()) { 2926 if (ev.window == frame().window())
2930 // save old value, so we can restore it later
2931 WinClient *old = WindowCmd<void>::client();
2932 WindowCmd<void>::setWindow(this);
2933 Fluxbox::instance()->keys()->doAction(ev.type, ev.state, 0, 2927 Fluxbox::instance()->keys()->doAction(ev.type, ev.state, 0,
2934 Keys::ON_WINDOW); 2928 Keys::ON_WINDOW, m_client);
2935 WindowCmd<void>::setClient(old);
2936 }
2937 2929
2938 WinClient *client = 0; 2930 WinClient *client = 0;
2939 if (screen().focusControl().isMouseTabFocus()) { 2931 if (screen().focusControl().isMouseTabFocus()) {
@@ -2989,12 +2981,8 @@ void FluxboxWindow::leaveNotifyEvent(XCrossingEvent &ev) {
2989 ev.y_root <= (int)(frame().y() + frame().height())) 2981 ev.y_root <= (int)(frame().y() + frame().height()))
2990 return; 2982 return;
2991 2983
2992 // save old value, so we can restore it later
2993 WinClient *old = WindowCmd<void>::client();
2994 WindowCmd<void>::setWindow(this);
2995 Fluxbox::instance()->keys()->doAction(ev.type, ev.state, 0, 2984 Fluxbox::instance()->keys()->doAction(ev.type, ev.state, 0,
2996 Keys::ON_WINDOW); 2985 Keys::ON_WINDOW, m_client);
2997 WindowCmd<void>::setClient(old);
2998 2986
2999 // I hope commenting this out is right - simon 21jul2003 2987 // I hope commenting this out is right - simon 21jul2003
3000 //if (ev.window == frame().window()) 2988 //if (ev.window == frame().window())