diff options
author | markt <markt> | 2007-03-04 17:47:37 (GMT) |
---|---|---|
committer | markt <markt> | 2007-03-04 17:47:37 (GMT) |
commit | 4c1a242968dff12e504f281224819b7cd3850a04 (patch) | |
tree | 42a6e3de02153bc8f35cae43f89238d73e9b821a | |
parent | 9477af82a5835b7336fec8879967abb67f3bd848 (diff) | |
download | fluxbox_pavel-4c1a242968dff12e504f281224819b7cd3850a04.zip fluxbox_pavel-4c1a242968dff12e504f281224819b7cd3850a04.tar.bz2 |
moved some code around (regarding event handling) in preparation for upcoming features
-rw-r--r-- | src/FbTk/EventHandler.hh | 4 | ||||
-rw-r--r-- | src/FbTk/EventManager.cc | 22 | ||||
-rw-r--r-- | src/FbTk/EventManager.hh | 7 | ||||
-rw-r--r-- | src/FocusControl.cc | 4 | ||||
-rw-r--r-- | src/Screen.cc | 71 | ||||
-rw-r--r-- | src/Screen.hh | 16 | ||||
-rw-r--r-- | src/WorkspaceCmd.cc | 56 | ||||
-rw-r--r-- | src/fluxbox.cc | 80 | ||||
-rw-r--r-- | src/fluxbox.hh | 8 |
9 files changed, 110 insertions, 158 deletions
diff --git a/src/FbTk/EventHandler.hh b/src/FbTk/EventHandler.hh index 3d2e545..45c7a2a 100644 --- a/src/FbTk/EventHandler.hh +++ b/src/FbTk/EventHandler.hh | |||
@@ -54,11 +54,11 @@ public: | |||
54 | virtual void exposeEvent(XExposeEvent &) { } | 54 | virtual void exposeEvent(XExposeEvent &) { } |
55 | virtual void motionNotifyEvent(XMotionEvent &) { } | 55 | virtual void motionNotifyEvent(XMotionEvent &) { } |
56 | virtual void keyPressEvent(XKeyEvent &) { } | 56 | virtual void keyPressEvent(XKeyEvent &) { } |
57 | #ifdef NOT_USED | ||
58 | virtual void keyReleaseEvent(XKeyEvent &) { } | 57 | virtual void keyReleaseEvent(XKeyEvent &) { } |
59 | #endif | ||
60 | virtual void leaveNotifyEvent(XCrossingEvent &) { } | 58 | virtual void leaveNotifyEvent(XCrossingEvent &) { } |
61 | virtual void enterNotifyEvent(XCrossingEvent &) { } | 59 | virtual void enterNotifyEvent(XCrossingEvent &) { } |
60 | |||
61 | virtual void notifyUngrabKeyboard() { } | ||
62 | }; | 62 | }; |
63 | 63 | ||
64 | } // end namespace FbTk | 64 | } // end namespace FbTk |
diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc index 02259ac..fd26950 100644 --- a/src/FbTk/EventManager.cc +++ b/src/FbTk/EventManager.cc | |||
@@ -66,6 +66,26 @@ EventHandler *EventManager::find(Window win) { | |||
66 | return m_eventhandlers[win]; | 66 | return m_eventhandlers[win]; |
67 | } | 67 | } |
68 | 68 | ||
69 | bool EventManager::grabKeyboard(EventHandler &ev, Window win) { | ||
70 | if (m_grabbing_keyboard) | ||
71 | ungrabKeyboard(); | ||
72 | |||
73 | int ret = XGrabKeyboard(App::instance()->display(), win, False, | ||
74 | GrabModeAsync, GrabModeAsync, CurrentTime); | ||
75 | |||
76 | if (ret == Success) { | ||
77 | m_grabbing_keyboard = &ev; | ||
78 | return true; | ||
79 | } | ||
80 | return false; | ||
81 | } | ||
82 | |||
83 | void EventManager::ungrabKeyboard() { | ||
84 | XUngrabKeyboard(App::instance()->display(), CurrentTime); | ||
85 | if (m_grabbing_keyboard) | ||
86 | m_grabbing_keyboard->notifyUngrabKeyboard(); | ||
87 | m_grabbing_keyboard = 0; | ||
88 | } | ||
69 | 89 | ||
70 | Window EventManager::getEventWindow(XEvent &ev) { | 90 | Window EventManager::getEventWindow(XEvent &ev) { |
71 | // we only have cases for events that differ from xany | 91 | // we only have cases for events that differ from xany |
@@ -156,9 +176,7 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) { | |||
156 | evhand->keyPressEvent(ev.xkey); | 176 | evhand->keyPressEvent(ev.xkey); |
157 | break; | 177 | break; |
158 | case KeyRelease: | 178 | case KeyRelease: |
159 | #ifdef NOT_USED | ||
160 | evhand->keyReleaseEvent(ev.xkey); | 179 | evhand->keyReleaseEvent(ev.xkey); |
161 | #endif | ||
162 | break; | 180 | break; |
163 | case ButtonPress: | 181 | case ButtonPress: |
164 | evhand->buttonPressEvent(ev.xbutton); | 182 | evhand->buttonPressEvent(ev.xbutton); |
diff --git a/src/FbTk/EventManager.hh b/src/FbTk/EventManager.hh index 5bbaa00..149649b 100644 --- a/src/FbTk/EventManager.hh +++ b/src/FbTk/EventManager.hh | |||
@@ -43,6 +43,10 @@ public: | |||
43 | void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); } | 43 | void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); } |
44 | void remove(Window win) { unregisterEventHandler(win); } | 44 | void remove(Window win) { unregisterEventHandler(win); } |
45 | 45 | ||
46 | bool grabKeyboard(EventHandler &ev, Window win); | ||
47 | void ungrabKeyboard(); | ||
48 | EventHandler *grabbingKeyboard() { return m_grabbing_keyboard; } | ||
49 | |||
46 | EventHandler *find(Window win); | 50 | EventHandler *find(Window win); |
47 | 51 | ||
48 | // Some events have the parent window as the xany.window | 52 | // Some events have the parent window as the xany.window |
@@ -53,13 +57,14 @@ public: | |||
53 | void unregisterEventHandler(Window win); | 57 | void unregisterEventHandler(Window win); |
54 | 58 | ||
55 | private: | 59 | private: |
56 | EventManager() { } | 60 | EventManager(): m_grabbing_keyboard(0) { } |
57 | ~EventManager(); | 61 | ~EventManager(); |
58 | void dispatch(Window win, XEvent &event, bool parent = false); | 62 | void dispatch(Window win, XEvent &event, bool parent = false); |
59 | 63 | ||
60 | typedef std::map<Window, EventHandler *> EventHandlerMap; | 64 | typedef std::map<Window, EventHandler *> EventHandlerMap; |
61 | EventHandlerMap m_eventhandlers; | 65 | EventHandlerMap m_eventhandlers; |
62 | EventHandlerMap m_parent; | 66 | EventHandlerMap m_parent; |
67 | EventHandler *m_grabbing_keyboard; | ||
63 | }; | 68 | }; |
64 | 69 | ||
65 | } //end namespace FbTk | 70 | } //end namespace FbTk |
diff --git a/src/FocusControl.cc b/src/FocusControl.cc index f4c8cdf..e494d8f 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "fluxbox.hh" | 30 | #include "fluxbox.hh" |
31 | #include "FbWinFrameTheme.hh" | 31 | #include "FbWinFrameTheme.hh" |
32 | 32 | ||
33 | #include "FbTk/EventManager.hh" | ||
34 | |||
33 | #include <string> | 35 | #include <string> |
34 | #include <iostream> | 36 | #include <iostream> |
35 | 37 | ||
@@ -82,7 +84,7 @@ bool doSkipWindow(const WinClient &winclient, int opts) { | |||
82 | void FocusControl::cycleFocus(FocusedWindows *window_list, int opts, bool cycle_reverse) { | 84 | void FocusControl::cycleFocus(FocusedWindows *window_list, int opts, bool cycle_reverse) { |
83 | 85 | ||
84 | if (!m_cycling_list) { | 86 | if (!m_cycling_list) { |
85 | if (&m_screen == Fluxbox::instance()->watchingScreen()) | 87 | if (&m_screen == FbTk::EventManager::instance()->grabbingKeyboard()) |
86 | // only set this when we're waiting for modifiers | 88 | // only set this when we're waiting for modifiers |
87 | m_cycling_list = window_list; | 89 | m_cycling_list = window_list; |
88 | m_was_iconic = 0; | 90 | m_was_iconic = 0; |
diff --git a/src/Screen.cc b/src/Screen.cc index b676a8b..3dfe324 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
29 | 29 | ||
30 | #include "fluxbox.hh" | 30 | #include "fluxbox.hh" |
31 | #include "Keys.hh" | ||
31 | #include "Window.hh" | 32 | #include "Window.hh" |
32 | #include "Workspace.hh" | 33 | #include "Workspace.hh" |
33 | #include "Netizen.hh" | 34 | #include "Netizen.hh" |
@@ -364,6 +365,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, | |||
364 | m_altname(altscreenname), | 365 | m_altname(altscreenname), |
365 | m_focus_control(new FocusControl(*this)), | 366 | m_focus_control(new FocusControl(*this)), |
366 | m_placement_strategy(new ScreenPlacement(*this)), | 367 | m_placement_strategy(new ScreenPlacement(*this)), |
368 | m_cycling(false), | ||
367 | m_xinerama_headinfo(0), | 369 | m_xinerama_headinfo(0), |
368 | m_restart(false), | 370 | m_restart(false), |
369 | m_shutdown(false) { | 371 | m_shutdown(false) { |
@@ -416,7 +418,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm, | |||
416 | screenNumber(), XVisualIDFromVisual(rootWindow().visual()), | 418 | screenNumber(), XVisualIDFromVisual(rootWindow().visual()), |
417 | rootWindow().depth()); | 419 | rootWindow().depth()); |
418 | 420 | ||
419 | 421 | FbTk::EventManager *evm = FbTk::EventManager::instance(); | |
422 | evm->add(*this, rootWindow()); | ||
420 | rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); | 423 | rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); |
421 | 424 | ||
422 | // load this screens resources | 425 | // load this screens resources |
@@ -538,6 +541,9 @@ BScreen::~BScreen() { | |||
538 | if (! managed) | 541 | if (! managed) |
539 | return; | 542 | return; |
540 | 543 | ||
544 | FbTk::EventManager *evm = FbTk::EventManager::instance(); | ||
545 | evm->remove(rootWindow()); | ||
546 | |||
541 | if (m_rootmenu.get() != 0) | 547 | if (m_rootmenu.get() != 0) |
542 | m_rootmenu->removeAll(); | 548 | m_rootmenu->removeAll(); |
543 | 549 | ||
@@ -780,6 +786,59 @@ void BScreen::update(FbTk::Subject *subj) { | |||
780 | 786 | ||
781 | } | 787 | } |
782 | 788 | ||
789 | void BScreen::keyPressEvent(XKeyEvent &ke) { | ||
790 | Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode); | ||
791 | } | ||
792 | |||
793 | void BScreen::keyReleaseEvent(XKeyEvent &ke) { | ||
794 | if (!m_cycling) | ||
795 | return; | ||
796 | |||
797 | unsigned int state = FbTk::KeyUtil::instance().cleanMods(ke.state); | ||
798 | state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode); | ||
799 | |||
800 | if (!state) // all modifiers were released | ||
801 | FbTk::EventManager::instance()->ungrabKeyboard(); | ||
802 | } | ||
803 | |||
804 | void BScreen::buttonPressEvent(XButtonEvent &be) { | ||
805 | if (be.button == 1 && !isRootColormapInstalled()) | ||
806 | imageControl().installRootColormap(); | ||
807 | |||
808 | Keys *keys = Fluxbox::instance()->keys(); | ||
809 | keys->doAction(be.type, be.state, be.button); | ||
810 | } | ||
811 | |||
812 | void BScreen::notifyUngrabKeyboard() { | ||
813 | m_cycling = false; | ||
814 | focusControl().stopCyclingFocus(); | ||
815 | } | ||
816 | |||
817 | void BScreen::cycleFocus(int options, bool reverse) { | ||
818 | // get modifiers from event that causes this for focus order cycling | ||
819 | XEvent ev = Fluxbox::instance()->lastEvent(); | ||
820 | unsigned int mods = 0; | ||
821 | if (ev.type == KeyPress) | ||
822 | mods = FbTk::KeyUtil::instance().cleanMods(ev.xkey.state); | ||
823 | else if (ev.type == ButtonPress) | ||
824 | mods = FbTk::KeyUtil::instance().cleanMods(ev.xbutton.state); | ||
825 | |||
826 | if (!m_cycling && mods) { | ||
827 | m_cycling = true; | ||
828 | FbTk::EventManager::instance()->grabKeyboard(*this, rootWindow().window()); | ||
829 | } | ||
830 | |||
831 | if (mods == 0) // can't stacked cycle unless there is a mod to grab | ||
832 | options |= FocusControl::CYCLELINEAR; | ||
833 | |||
834 | FocusControl::FocusedWindows *win_list = | ||
835 | (options & FocusControl::CYCLELINEAR) ? | ||
836 | &focusControl().creationOrderList() : | ||
837 | &focusControl().focusedOrderList(); | ||
838 | |||
839 | focusControl().cycleFocus(win_list, options, reverse); | ||
840 | } | ||
841 | |||
783 | FbTk::Menu *BScreen::createMenu(const string &label) { | 842 | FbTk::Menu *BScreen::createMenu(const string &label) { |
784 | FbTk::Menu *menu = new FbMenu(menuTheme(), | 843 | FbTk::Menu *menu = new FbMenu(menuTheme(), |
785 | imageControl(), | 844 | imageControl(), |
@@ -2054,16 +2113,6 @@ void BScreen::renderPosWindow() { | |||
2054 | 2113 | ||
2055 | } | 2114 | } |
2056 | 2115 | ||
2057 | |||
2058 | |||
2059 | |||
2060 | /** | ||
2061 | Called when a set of watched modifiers has been released | ||
2062 | */ | ||
2063 | void BScreen::notifyReleasedKeys() { | ||
2064 | focusControl().stopCyclingFocus(); | ||
2065 | } | ||
2066 | |||
2067 | void BScreen::updateSize() { | 2116 | void BScreen::updateSize() { |
2068 | // force update geometry | 2117 | // force update geometry |
2069 | rootWindow().updateGeometry(); | 2118 | rootWindow().updateGeometry(); |
diff --git a/src/Screen.hh b/src/Screen.hh index de1dc78..8694f6d 100644 --- a/src/Screen.hh +++ b/src/Screen.hh | |||
@@ -32,6 +32,8 @@ | |||
32 | #include "MenuTheme.hh" | 32 | #include "MenuTheme.hh" |
33 | #include "PlacementStrategy.hh" | 33 | #include "PlacementStrategy.hh" |
34 | 34 | ||
35 | #include "FbTk/EventHandler.hh" | ||
36 | #include "FbTk/TypeAhead.hh" | ||
35 | #include "FbTk/Resource.hh" | 37 | #include "FbTk/Resource.hh" |
36 | #include "FbTk/Subject.hh" | 38 | #include "FbTk/Subject.hh" |
37 | #include "FbTk/MultLayers.hh" | 39 | #include "FbTk/MultLayers.hh" |
@@ -78,7 +80,8 @@ class Subject; | |||
78 | /** | 80 | /** |
79 | Create workspaces, handles switching between workspaces and windows | 81 | Create workspaces, handles switching between workspaces and windows |
80 | */ | 82 | */ |
81 | class BScreen : public FbTk::Observer, private FbTk::NotCopyable { | 83 | class BScreen: public FbTk::EventHandler, public FbTk::Observer, |
84 | private FbTk::NotCopyable { | ||
82 | public: | 85 | public: |
83 | /// a window becomes active / focussed on a different workspace | 86 | /// a window becomes active / focussed on a different workspace |
84 | enum FollowModel { | 87 | enum FollowModel { |
@@ -209,6 +212,13 @@ public: | |||
209 | 212 | ||
210 | void update(FbTk::Subject *subj); | 213 | void update(FbTk::Subject *subj); |
211 | 214 | ||
215 | void keyPressEvent(XKeyEvent &ke); | ||
216 | void keyReleaseEvent(XKeyEvent &ke); | ||
217 | void buttonPressEvent(XButtonEvent &be); | ||
218 | void notifyUngrabKeyboard(); | ||
219 | |||
220 | void cycleFocus(int opts, bool reverse); | ||
221 | |||
212 | FbTk::Menu *createMenu(const std::string &label); | 222 | FbTk::Menu *createMenu(const std::string &label); |
213 | FbTk::Menu *createToggleMenu(const std::string &label); | 223 | FbTk::Menu *createToggleMenu(const std::string &label); |
214 | void hideMenus(); | 224 | void hideMenus(); |
@@ -294,8 +304,6 @@ public: | |||
294 | void showGeometry(int width, int height); | 304 | void showGeometry(int width, int height); |
295 | void hideGeometry(); | 305 | void hideGeometry(); |
296 | 306 | ||
297 | void notifyReleasedKeys(); | ||
298 | |||
299 | void setLayer(FbTk::XLayerItem &item, int layernum); | 307 | void setLayer(FbTk::XLayerItem &item, int layernum); |
300 | // remove? no, items are never removed from their layer until they die | 308 | // remove? no, items are never removed from their layer until they die |
301 | 309 | ||
@@ -477,6 +485,8 @@ private: | |||
477 | typedef std::map<Window, WinClient *> Groupables; | 485 | typedef std::map<Window, WinClient *> Groupables; |
478 | Groupables m_expecting_groups; | 486 | Groupables m_expecting_groups; |
479 | 487 | ||
488 | bool m_cycling; | ||
489 | |||
480 | // Xinerama related private data | 490 | // Xinerama related private data |
481 | bool m_xinerama_avail; | 491 | bool m_xinerama_avail; |
482 | int m_xinerama_num_heads; | 492 | int m_xinerama_num_heads; |
diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc index 7d384aa..0cbf5b9 100644 --- a/src/WorkspaceCmd.cc +++ b/src/WorkspaceCmd.cc | |||
@@ -42,59 +42,15 @@ | |||
42 | #include <functional> | 42 | #include <functional> |
43 | 43 | ||
44 | void NextWindowCmd::execute() { | 44 | void NextWindowCmd::execute() { |
45 | Fluxbox *fb = Fluxbox::instance(); | 45 | BScreen *screen = Fluxbox::instance()->keyScreen(); |
46 | BScreen *screen = fb->keyScreen(); | 46 | if (screen != 0) |
47 | if (screen != 0) { | 47 | screen->cycleFocus(m_option, false); |
48 | // get modifiers from event that causes this for focus order cycling | ||
49 | unsigned int mods = 0; | ||
50 | XEvent ev = fb->lastEvent(); | ||
51 | if (ev.type == KeyPress) { | ||
52 | mods = FbTk::KeyUtil::instance().cleanMods(ev.xkey.state); | ||
53 | } else if (ev.type == ButtonPress) { | ||
54 | mods = FbTk::KeyUtil::instance().cleanMods(ev.xbutton.state); | ||
55 | } | ||
56 | int options = m_option; | ||
57 | if (mods == 0) // can't stacked cycle unless there is a mod to grab | ||
58 | options |= FocusControl::CYCLELINEAR; | ||
59 | else | ||
60 | // set a watch for the release of exactly these modifiers | ||
61 | fb->watchKeyRelease(*screen, mods); | ||
62 | |||
63 | FocusControl::FocusedWindows *win_list = | ||
64 | (options & FocusControl::CYCLELINEAR) ? | ||
65 | &screen->focusControl().creationOrderList() : | ||
66 | &screen->focusControl().focusedOrderList(); | ||
67 | |||
68 | screen->focusControl().cycleFocus(win_list, m_option); | ||
69 | } | ||
70 | } | 48 | } |
71 | 49 | ||
72 | void PrevWindowCmd::execute() { | 50 | void PrevWindowCmd::execute() { |
73 | Fluxbox *fb = Fluxbox::instance(); | 51 | BScreen *screen = Fluxbox::instance()->keyScreen(); |
74 | BScreen *screen = fb->keyScreen(); | 52 | if (screen != 0) |
75 | if (screen != 0) { | 53 | screen->cycleFocus(m_option, true); |
76 | // get modifiers from event that causes this for focus order cycling | ||
77 | unsigned int mods = 0; | ||
78 | XEvent ev = fb->lastEvent(); | ||
79 | if (ev.type == KeyPress) { | ||
80 | mods = FbTk::KeyUtil::instance().cleanMods(ev.xkey.state); | ||
81 | } else if (ev.type == ButtonPress) { | ||
82 | mods = FbTk::KeyUtil::instance().cleanMods(ev.xbutton.state); | ||
83 | } | ||
84 | int options = m_option; | ||
85 | if (mods == 0) // can't stacked cycle unless there is a mod to grab | ||
86 | options |= FocusControl::CYCLELINEAR; | ||
87 | else | ||
88 | // set a watch for the release of exactly these modifiers | ||
89 | fb->watchKeyRelease(*screen, mods); | ||
90 | |||
91 | FocusControl::FocusedWindows *win_list = | ||
92 | (options & FocusControl::CYCLELINEAR) ? | ||
93 | &screen->focusControl().creationOrderList() : | ||
94 | &screen->focusControl().focusedOrderList(); | ||
95 | |||
96 | screen->focusControl().cycleFocus(win_list, m_option, true); | ||
97 | } | ||
98 | } | 54 | } |
99 | 55 | ||
100 | void DirFocusCmd::execute() { | 56 | void DirFocusCmd::execute() { |
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index c71e2f5..e4c68bf 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -228,7 +228,6 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile | |||
228 | m_masked_window(0), | 228 | m_masked_window(0), |
229 | m_mousescreen(0), | 229 | m_mousescreen(0), |
230 | m_keyscreen(0), | 230 | m_keyscreen(0), |
231 | m_watching_screen(0), m_watch_keyrelease(0), | ||
232 | m_last_time(0), | 231 | m_last_time(0), |
233 | m_masked(0), | 232 | m_masked(0), |
234 | m_rc_file(rcfilename ? rcfilename : ""), | 233 | m_rc_file(rcfilename ? rcfilename : ""), |
@@ -746,7 +745,6 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
746 | switch (e->type) { | 745 | switch (e->type) { |
747 | case ButtonRelease: | 746 | case ButtonRelease: |
748 | case ButtonPress: | 747 | case ButtonPress: |
749 | handleButtonEvent(e->xbutton); | ||
750 | break; | 748 | break; |
751 | case ConfigureRequest: { | 749 | case ConfigureRequest: { |
752 | 750 | ||
@@ -894,7 +892,6 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
894 | break; | 892 | break; |
895 | case KeyRelease: | 893 | case KeyRelease: |
896 | case KeyPress: | 894 | case KeyPress: |
897 | handleKeyEvent(e->xkey); | ||
898 | break; | 895 | break; |
899 | case ColormapNotify: { | 896 | case ColormapNotify: { |
900 | BScreen *screen = searchScreen(e->xcolormap.window); | 897 | BScreen *screen = searchScreen(e->xcolormap.window); |
@@ -958,20 +955,6 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
958 | } | 955 | } |
959 | } | 956 | } |
960 | 957 | ||
961 | void Fluxbox::handleButtonEvent(XButtonEvent &be) { | ||
962 | m_last_time = be.time; | ||
963 | |||
964 | BScreen *screen = searchScreen(be.window); | ||
965 | if (be.type == ButtonRelease || !screen) | ||
966 | // no bindings for this type yet | ||
967 | return; | ||
968 | |||
969 | if (be.button == 1 && !screen->isRootColormapInstalled()) | ||
970 | screen->imageControl().installRootColormap(); | ||
971 | |||
972 | m_key->doAction(be.type, be.state, be.button); | ||
973 | } | ||
974 | |||
975 | void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) { | 958 | void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) { |
976 | 959 | ||
977 | BScreen *screen = searchScreen(ue.event); | 960 | BScreen *screen = searchScreen(ue.event); |
@@ -1092,47 +1075,6 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) { | |||
1092 | } | 1075 | } |
1093 | } | 1076 | } |
1094 | 1077 | ||
1095 | /** | ||
1096 | Handles KeyRelease and KeyPress events | ||
1097 | */ | ||
1098 | void Fluxbox::handleKeyEvent(XKeyEvent &ke) { | ||
1099 | |||
1100 | if (keyScreen() == 0 || mouseScreen() == 0) | ||
1101 | return; | ||
1102 | |||
1103 | switch (ke.type) { | ||
1104 | case KeyPress: | ||
1105 | m_key->doAction(ke.type, ke.state, ke.keycode); | ||
1106 | break; | ||
1107 | case KeyRelease: { | ||
1108 | // we ignore most key releases unless we need to use | ||
1109 | // a release to stop something (e.g. window cycling). | ||
1110 | |||
1111 | // we notify if _all_ of the watched modifiers are released | ||
1112 | if (m_watching_screen && m_watch_keyrelease) { | ||
1113 | // mask the mod of the released key out | ||
1114 | // won't mask anything if it isn't a mod | ||
1115 | unsigned int state = FbTk::KeyUtil::instance().isolateModifierMask(ke.state); | ||
1116 | state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode); | ||
1117 | |||
1118 | if ((m_watch_keyrelease & state) == 0) { | ||
1119 | |||
1120 | m_watching_screen->notifyReleasedKeys(); | ||
1121 | XUngrabKeyboard(FbTk::App::instance()->display(), CurrentTime); | ||
1122 | |||
1123 | // once they are released, we drop the watch | ||
1124 | m_watching_screen = 0; | ||
1125 | m_watch_keyrelease = 0; | ||
1126 | } | ||
1127 | } | ||
1128 | |||
1129 | break; | ||
1130 | } | ||
1131 | default: | ||
1132 | break; | ||
1133 | } | ||
1134 | } | ||
1135 | |||
1136 | /// handle system signals | 1078 | /// handle system signals |
1137 | void Fluxbox::handleSignal(int signum) { | 1079 | void Fluxbox::handleSignal(int signum) { |
1138 | _FB_USES_NLS; | 1080 | _FB_USES_NLS; |
@@ -1810,28 +1752,6 @@ void Fluxbox::updateFocusedWindow(BScreen *screen, BScreen *old_screen) { | |||
1810 | } | 1752 | } |
1811 | } | 1753 | } |
1812 | 1754 | ||
1813 | void Fluxbox::watchKeyRelease(BScreen &screen, unsigned int mods) { | ||
1814 | |||
1815 | if (mods == 0) { | ||
1816 | cerr<<"WARNING: attempt to grab without modifiers!"<<endl; | ||
1817 | return; | ||
1818 | } | ||
1819 | // just make sure we are saving the mods with any other flags (xkb) | ||
1820 | m_watch_keyrelease = FbTk::KeyUtil::instance().isolateModifierMask(mods); | ||
1821 | |||
1822 | if (m_watching_screen == &screen) | ||
1823 | return; | ||
1824 | if (m_watching_screen) | ||
1825 | m_watching_screen->focusControl().stopCyclingFocus(); | ||
1826 | m_watching_screen = &screen; | ||
1827 | |||
1828 | // TODO: it's possible (and happens to me sometimes) for the mods to be | ||
1829 | // released before we grab the keyboard -- not sure of a good way to fix it | ||
1830 | XGrabKeyboard(FbTk::App::instance()->display(), | ||
1831 | screen.rootWindow().window(), True, | ||
1832 | GrabModeAsync, GrabModeAsync, CurrentTime); | ||
1833 | } | ||
1834 | |||
1835 | void Fluxbox::updateFrameExtents(FluxboxWindow &win) { | 1755 | void Fluxbox::updateFrameExtents(FluxboxWindow &win) { |
1836 | AtomHandlerContainerIt it = m_atomhandler.begin(); | 1756 | AtomHandlerContainerIt it = m_atomhandler.begin(); |
1837 | AtomHandlerContainerIt it_end = m_atomhandler.end(); | 1757 | AtomHandlerContainerIt it_end = m_atomhandler.end(); |
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 5613caa..66fdff5 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh | |||
@@ -141,8 +141,6 @@ public: | |||
141 | void maskWindowEvents(Window w, FluxboxWindow *bw) | 141 | void maskWindowEvents(Window w, FluxboxWindow *bw) |
142 | { m_masked = w; m_masked_window = bw; } | 142 | { m_masked = w; m_masked_window = bw; } |
143 | 143 | ||
144 | void watchKeyRelease(BScreen &screen, unsigned int mods); | ||
145 | |||
146 | void shutdown(); | 144 | void shutdown(); |
147 | void load_rc(BScreen &scr); | 145 | void load_rc(BScreen &scr); |
148 | void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } | 146 | void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } |
@@ -203,8 +201,6 @@ public: | |||
203 | BScreen *mouseScreen() { return m_mousescreen; } | 201 | BScreen *mouseScreen() { return m_mousescreen; } |
204 | // screen of window that last key event (i.e. focused window) went to | 202 | // screen of window that last key event (i.e. focused window) went to |
205 | BScreen *keyScreen() { return m_keyscreen; } | 203 | BScreen *keyScreen() { return m_keyscreen; } |
206 | // screen we are watching for modifier changes | ||
207 | BScreen *watchingScreen() { return m_watching_screen; } | ||
208 | const XEvent &lastEvent() const { return m_last_event; } | 204 | const XEvent &lastEvent() const { return m_last_event; } |
209 | 205 | ||
210 | AttentionNoticeHandler &attentionHandler() { return m_attention_handler; } | 206 | AttentionNoticeHandler &attentionHandler() { return m_attention_handler; } |
@@ -228,10 +224,8 @@ private: | |||
228 | void handleEvent(XEvent *xe); | 224 | void handleEvent(XEvent *xe); |
229 | 225 | ||
230 | void setupConfigFiles(); | 226 | void setupConfigFiles(); |
231 | void handleButtonEvent(XButtonEvent &be); | ||
232 | void handleUnmapNotify(XUnmapEvent &ue); | 227 | void handleUnmapNotify(XUnmapEvent &ue); |
233 | void handleClientMessage(XClientMessageEvent &ce); | 228 | void handleClientMessage(XClientMessageEvent &ce); |
234 | void handleKeyEvent(XKeyEvent &ke); | ||
235 | 229 | ||
236 | std::auto_ptr<FbAtoms> m_fbatoms; | 230 | std::auto_ptr<FbAtoms> m_fbatoms; |
237 | 231 | ||
@@ -272,8 +266,6 @@ private: | |||
272 | FluxboxWindow *m_masked_window; | 266 | FluxboxWindow *m_masked_window; |
273 | 267 | ||
274 | BScreen *m_mousescreen, *m_keyscreen; | 268 | BScreen *m_mousescreen, *m_keyscreen; |
275 | BScreen *m_watching_screen; | ||
276 | unsigned int m_watch_keyrelease; | ||
277 | 269 | ||
278 | Atom m_fluxbox_pid; | 270 | Atom m_fluxbox_pid; |
279 | 271 | ||