From 3f33657fb721645292f798480e9e0b46d64aedf8 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sun, 21 Sep 2008 22:32:02 -0700 Subject: fix active menu item when inserting or removing other items --- src/FbTk/Menu.cc | 9 +++++++-- src/FbTk/Menu.hh | 2 +- src/WorkspaceMenu.cc | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 7d50302..7cb5599 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -219,6 +219,8 @@ int Menu::insert(MenuItem *item, int pos) { } else { menuitems.insert(menuitems.begin() + pos, item); fixMenuItemIndices(); + if (m_active_index >= pos) + m_active_index++; } m_need_update = true; // we need to redraw the menu return menuitems.size(); @@ -233,7 +235,7 @@ int Menu::remove(unsigned int index) { if (index >= menuitems.size()) { #ifdef DEBUG cout << "Bad index (" << index << ") given to Menu::remove()" - << " -- should be between 0 and " << menuitems.size() + << " -- should be between 0 and " << menuitems.size()-1 << " inclusive." << endl; #endif // DEBUG return -1; @@ -271,6 +273,9 @@ int Menu::remove(unsigned int index) { else if (static_cast(m_which_sub) > index) m_which_sub--; + if (static_cast(m_active_index) > index) + m_active_index--; + m_need_update = true; // we need to redraw the menu return menuitems.size(); @@ -366,7 +371,7 @@ void Menu::enableTitle() { setTitleVisibility(true); } -void Menu::updateMenu(int active_index) { +void Menu::updateMenu() { if (m_title_vis) { menu.item_w = theme()->titleFont().textWidth(menu.label, menu.label.size()); diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index ee57a23..519a78b 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -109,7 +109,7 @@ public: void setLabel(const FbString &labelstr); /// move menu to x,y virtual void move(int x, int y); - virtual void updateMenu(int active_index = -1); + virtual void updateMenu(); void setItemSelected(unsigned int index, bool val); void setItemEnabled(unsigned int index, bool val); void setMinimumSublevels(int m) { menu.minsub = m; } diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc index c343920..f03dd3c 100644 --- a/src/WorkspaceMenu.cc +++ b/src/WorkspaceMenu.cc @@ -80,7 +80,7 @@ void WorkspaceMenu::workspaceInfoChanged( BScreen& screen ) { insert(mb_menu, workspace + IDX_AFTER_ICONS); } - updateMenu(-1); + updateMenu(); } void WorkspaceMenu::workspaceChanged(BScreen& screen) { @@ -89,12 +89,12 @@ void WorkspaceMenu::workspaceChanged(BScreen& screen) { item = find(i + IDX_AFTER_ICONS); if (item && item->isSelected()) { setItemSelected(i + IDX_AFTER_ICONS, false); - updateMenu(i + IDX_AFTER_ICONS); + updateMenu(); break; } } setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); - updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS); + updateMenu(); } void WorkspaceMenu::init(BScreen &screen) { -- cgit v0.11.2 From 984fb5bef200cd7db7a9a13354f50b55919978af Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Mon, 22 Sep 2008 07:44:40 +0200 Subject: cosmetics --- src/Screen.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index 8746fd2..cde62cc 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1030,10 +1030,10 @@ void BScreen::addIcon(FluxboxWindow *w) { if (find(iconList().begin(), iconList().end(), w) != iconList().end()) return; - m_icon_list.push_back(w); + iconList().push_back(w); // notify listeners - m_iconlist_sig.emit(*this); + iconListSig().emit(*this); } @@ -1048,7 +1048,7 @@ void BScreen::removeIcon(FluxboxWindow *w) { // change the iconlist if (erase_it != m_icon_list.end()) { iconList().erase(erase_it); - m_iconlist_sig.emit(*this); + iconListSig().emit(*this); } } -- cgit v0.11.2 From acd690ff653d83e4a24f88445526449d345f81bd Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Tue, 23 Sep 2008 09:13:53 +0200 Subject: fixed detection of bad values in the _NET_WM_ICON property. eg, tvtime.sf.net is not aware of how to correctly feed icon data into the property on 64bit architecture which caused the dimensions of the icon beeing corrupt and due to overflow arithmetics fluxbox crashed. --- src/Ewmh.cc | 72 +++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/src/Ewmh.cc b/src/Ewmh.cc index 14c74c6..2a9e1ab 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -76,16 +76,30 @@ namespace { * byte being B. The first two cardinals are width, height. Data is in rows, * left to right and top to bottom. * + *** + * + * NOTE: the returned data for XA_CARDINAL is long if the rfmt equals + * 32. sizeof(long) on 64bit machines is 8. to quote from + * "man XGetWindowProperty": + * + * If the returned format is 32, the property data will be stored as + * an array of longs (which in a 64-bit application will be 64-bit + * values that are padded in the upper 4 bytes). + * + * this is especially true on 64bit machines when some of the clients + * (eg: tvtime, konqueror3) have problems to feed in the right data + * into the _NET_WM_ICON property. we faced some segfaults because + * width and height were not quite right because of ignoring 64bit + * behaviour on client side. + * * TODO: maybe move the pixmap-creation code to FbTk? */ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { typedef std::pair Size; typedef std::map IconContainer; - // attention: the returned data for XA_CARDINAL is long if the rfmt equals - // 32. sizeof(long) on 64bit machines is 8. unsigned long* raw_data = 0; - long nr_icon_data = 0; + unsigned long nr_icon_data = 0; { Atom rtype; @@ -106,7 +120,10 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { // actually there is some data in _NET_WM_ICON nr_icon_data = nr_bytes_left / sizeof(CARD32); - +#ifdef DEBUG + std::cerr << "extractNetWmIcon: " << winclient.title() << "\n"; + std::cerr << "nr_icon_data: " << nr_icon_data << "\n"; +#endif // read all the icons stored in _NET_WM_ICON if (raw_data) XFree(raw_data); @@ -118,30 +135,57 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { return; } +#ifdef DEBUG + std::cerr << "nr_read: " << nr_read << "|" << nr_bytes_left << "\n"; +#endif } IconContainer icon_data; // stores all available data, sorted by size (width x height) - int width; - int height; + unsigned long width; + unsigned long height; // analyze the available icons - long i; - + // + // check also for invalid values coming in from "bad" applications + unsigned long i; for (i = 0; i + 2 < nr_icon_data; i += width * height ) { width = raw_data[i++]; + if (width >= nr_icon_data) { +#ifdef DEBUG + std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON width (" + << width << ") for " << winclient.title() << "\n"; +#endif + break; + } + height = raw_data[i++]; + if (height >= nr_icon_data) { +#ifdef DEBUG + std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON height (" + << height << ") for " << winclient.title() << "\n"; +#endif + break; + } // strange values stored in the NETWM_ICON - if (width <= 0 || height <= 0 || i + width * height > nr_icon_data) { - std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions for " << winclient.title() << "\n"; - XFree(raw_data); - return; + if (i + width * height > nr_icon_data) { +#ifdef DEBUG + std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions (" + << width << "x" << height << ")for " << winclient.title() << "\n"; +#endif + break; } icon_data[Size(width, height)] = &raw_data[i]; } + // no valid icons found at all + if (icon_data.empty()) { + XFree(raw_data); + return; + } + Display* dpy = FbTk::App::instance()->display(); int scrn = winclient.screen().screenNumber(); @@ -178,8 +222,8 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { const unsigned long* src = icon_data.begin()->second; unsigned int rgba; unsigned long pixel; - int x; - int y; + unsigned long x; + unsigned long y; unsigned char r, g, b, a; for (y = 0; y < height; y++) { -- cgit v0.11.2 From 4018d088183bd77a2f8b6a775d05e849be3ffa75 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Thu, 25 Sep 2008 17:01:17 -0700 Subject: add some more default keybindings --- data/keys | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/data/keys b/data/keys index 2652e93..28519b9 100644 --- a/data/keys +++ b/data/keys @@ -7,20 +7,26 @@ OnDesktop Mouse3 :RootMenu OnDesktop Mouse4 :PrevWorkspace OnDesktop Mouse5 :NextWorkspace -# scroll on the toolbar to change workspaces -OnToolbar Mouse4 :PrevWorkspace -OnToolbar Mouse5 :NextWorkspace +# scroll on the toolbar to change current window +OnToolbar Mouse4 :PrevWindow {static groups} (iconhidden=no) +OnToolbar Mouse5 :NextWindow {static groups} (iconhidden=no) # alt + left/right click to move/resize a window OnWindow Mod1 Mouse1 :MacroCmd {Raise} {Focus} {StartMoving} OnWindow Mod1 Mouse3 :MacroCmd {Raise} {Focus} {StartResizing NearestCorner} -# middle click a window's titlebar and drag to attach windows -OnTitlebar Mouse2 :StartTabbing +# alt + middle click to lower the window +OnWindow Mod1 Mouse2 :Lower + +# control-click a window's titlebar and drag to attach windows +OnTitlebar Control Mouse1 :StartTabbing # double click on the titlebar to shade OnTitlebar Double Mouse1 :Shade +# middle click on the titlebar to lower +OnTitlebar Mouse2 :Lower + # right click on the titlebar for a menu of options OnTitlebar Mouse3 :WindowMenu @@ -57,6 +63,7 @@ Mod1 F2 :Exec fbrun # current window commands Mod1 F4 :Close +Mod1 F5 :Kill Mod1 F9 :Minimize Mod1 F10 :Maximize Mod1 F11 :Fullscreen @@ -67,6 +74,18 @@ Mod1 space :WindowMenu # exit fluxbox Control Mod1 Delete :Exit +# change to previous/next workspace +Control Mod1 Left :PrevWorkspace +Control Mod1 Right :NextWorkspace + +# send the current window to previous/next workspace +Mod4 Left :SendToPrevWorkspace +Mod4 Right :SendToNextWorkspace + +# send the current window and follow it to previous/next workspace +Control Mod4 Left :TakeToPrevWorkspace +Control Mod4 Right :TakeToNextWorkspace + # change to a specific workspace Control F1 :Workspace 1 Control F2 :Workspace 2 -- cgit v0.11.2 From bb70b144320084e99961f4537cb2cf3f0d6b72da Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Thu, 25 Sep 2008 20:51:37 -0700 Subject: fix rounded corners on restart --- ChangeLog | 3 +++ src/FbTk/Shape.cc | 7 +++++-- src/Screen.cc | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2bddf2..aa6e6f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.1.2 +*08/09/25: + * Fixed issues with round corners on restart, #2110455 (Mark) + FbTk/Shape.cc *08/09/21: * Changed icon list signal in BScreen to use the new signal system (Henrik) diff --git a/src/FbTk/Shape.cc b/src/FbTk/Shape.cc index 6cc46f8..7c14832 100644 --- a/src/FbTk/Shape.cc +++ b/src/FbTk/Shape.cc @@ -56,9 +56,9 @@ Pixmap makePixmap(FbWindow &drawable, const unsigned char rows[]) { Display *disp = App::instance()->display(); const size_t data_size = 8 * 8; - // we use calloc here so we get consistent C alloc/free with XDestroyImage + // we use malloc here so we get consistent C alloc/free with XDestroyImage // and no warnings in valgrind :) - char *data = (char *)calloc(data_size, sizeof (char)); + char *data = (char *)malloc(data_size * sizeof (char)); if (data == 0) return 0; @@ -141,6 +141,9 @@ Shape::~Shape() { } void Shape::initCorners(int screen_num) { + if (!m_win->window()) + return; + if (s_corners.size() == 0) s_corners.resize(ScreenCount(App::instance()->display())); diff --git a/src/Screen.cc b/src/Screen.cc index cde62cc..8b81529 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1557,7 +1557,8 @@ void BScreen::removeConfigMenu(FbTk::Menu &menu) { if (erase_it != m_configmenu_list.end()) m_configmenu_list.erase(erase_it); - setupConfigmenu(*m_configmenu.get()); + if (!isShuttingdown()) + setupConfigmenu(*m_configmenu.get()); } -- cgit v0.11.2 From 6f6cb15ce76972d28c3d56c40b35ce474d437d7d Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Fri, 26 Sep 2008 06:53:04 +0200 Subject: forgotten Changelog entry --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index aa6e6f6..1ebfa84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,9 @@ Changes for 1.1.2 system (Henrik) FocusableList.hh/cc, Screen.hh/cc, SendToMenu.hh/cc, WorkspaceMenu.hh/cc, WorkspaceNameTool.hh/cc, fluxbox.hh/cc +*08/09/23: + * Fix crashes when analyzing bad constructed _NET_WM_ICON data (Mathias) + (Ewmh.cc) *08/09/18: * Changed workspace count signal in BScreen to use the new signal system. (Henrik) -- cgit v0.11.2 From 01aa0b6f8f70b5afbdfee390aeb19c5555e1433c Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sat, 27 Sep 2008 00:59:12 -0700 Subject: fix some goofy code --- src/FbTk/TextBox.cc | 111 ++++++++++++++++++---------------------------------- 1 file changed, 38 insertions(+), 73 deletions(-) diff --git a/src/FbTk/TextBox.cc b/src/FbTk/TextBox.cc index b8cdcde..87ad609 100644 --- a/src/FbTk/TextBox.cc +++ b/src/FbTk/TextBox.cc @@ -230,31 +230,6 @@ void TextBox::keyPressEvent(XKeyEvent &event) { if ((event.state & ControlMask) == ControlMask) { switch (ks) { - case XK_b: - cursorBackward(); - break; - case XK_f: - cursorForward(); - break; - case XK_a: - cursorHome(); - break; - case XK_e: - cursorEnd(); - break; - case XK_d: - deleteForward(); - break; - case XK_k: - killToEnd(); - break; - case XK_c: - cursorHome(); - m_text = ""; - m_start_pos = 0; - m_cursor_pos = 0; - m_end_pos = 0; - break; case XK_Left: { unsigned int pos = findEmptySpaceLeft(); if (pos < m_start_pos){ @@ -311,13 +286,6 @@ void TextBox::keyPressEvent(XKeyEvent &event) { } break; } - } else if ((event.state & ShiftMask)== ShiftMask || - (event.state & 0x80) == 0x80) { // shif and altgr - if (isprint(keychar[0])) { - std::string val; - val += keychar[0]; - insertText(val); - } } } else { // no state @@ -341,49 +309,46 @@ void TextBox::keyPressEvent(XKeyEvent &event) { case XK_Delete: deleteForward(); break; - default: - switch (ks) { - case XK_KP_Insert: - keychar[0] = '0'; - break; - case XK_KP_End: - keychar[0] = '1'; - break; - case XK_KP_Down: - keychar[0] = '2'; - break; - case XK_KP_Page_Down: - keychar[0] = '3'; - break; - case XK_KP_Left: - keychar[0] = '4'; - break; - case XK_KP_Begin: - keychar[0] = '5'; - break; - case XK_KP_Right: - keychar[0] = '6'; - break; - case XK_KP_Home: - keychar[0] = '7'; - break; - case XK_KP_Up: - keychar[0] = '8'; - break; - case XK_KP_Page_Up: - keychar[0] = '9'; - break; - case XK_KP_Delete: - keychar[0] = ','; - break; - }; - if (isprint(keychar[0])) { - std::string val; - val += keychar[0]; - insertText(val); - } + case XK_KP_Insert: + keychar[0] = '0'; + break; + case XK_KP_End: + keychar[0] = '1'; + break; + case XK_KP_Down: + keychar[0] = '2'; + break; + case XK_KP_Page_Down: + keychar[0] = '3'; + break; + case XK_KP_Left: + keychar[0] = '4'; + break; + case XK_KP_Begin: + keychar[0] = '5'; + break; + case XK_KP_Right: + keychar[0] = '6'; + break; + case XK_KP_Home: + keychar[0] = '7'; + break; + case XK_KP_Up: + keychar[0] = '8'; + break; + case XK_KP_Page_Up: + keychar[0] = '9'; + break; + case XK_KP_Delete: + keychar[0] = ','; + break; } } + if (isprint(keychar[0])) { + std::string val; + val += keychar[0]; + insertText(val); + } clear(); } -- cgit v0.11.2 From c8022b3bdb90259352d08838576e98b559a9db68 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sat, 27 Sep 2008 13:37:04 -0700 Subject: turn off size/position display by default, move click raises to focus model menu --- src/Screen.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index 8b81529..a6e5e84 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -292,7 +292,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"), max_disable_resize(rm, false, scrname+".maxDisableResize", altscrname+".MaxDisableResize"), workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"), - show_window_pos(rm, true, scrname+".showwindowposition", altscrname+".ShowWindowPosition"), + show_window_pos(rm, false, scrname+".showwindowposition", altscrname+".ShowWindowPosition"), auto_raise(rm, true, scrname+".autoRaise", altscrname+".AutoRaise"), click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), default_deco(rm, "NORMAL", scrname+".defaultDeco", altscrname+".DefaultDeco"), @@ -1629,12 +1629,12 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { cerr<insert(new FbTk::BoolMenuItem(_FB_XTEXT(Configmenu, - AutoRaise, - "Auto Raise", - "Auto Raise windows on sloppy"), - resource.auto_raise, - save_and_reconfigure)); + _BOOLITEM(*focus_menu, Configmenu, AutoRaise, + "Auto Raise", "Auto Raise windows on sloppy", + resource.auto_raise, saverc_cmd); + _BOOLITEM(*focus_menu, Configmenu, ClickRaises, + "Click Raises", "Click Raises", + resource.click_raises, saverc_cmd); focus_menu->updateMenu(); @@ -1801,9 +1801,6 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { "Workspace Warping", "Workspace Warping - dragging windows to the edge and onto the next workspace", resource.workspace_warping, saverc_cmd); - _BOOLITEM(menu, Configmenu, ClickRaises, - "Click Raises", "Click Raises", - resource.click_raises, saverc_cmd); #undef _BOOLITEM -- cgit v0.11.2 From 04a1d2a83b96eb6d1b1958e4f3e25ffdf295aa4d Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sun, 28 Sep 2008 01:26:21 -0700 Subject: don't let KeyRelease events propagate to windows --- src/FbTk/EventHandler.hh | 1 - src/FbTk/EventManager.cc | 23 ++++++++--------------- src/FbTk/EventManager.hh | 3 +-- src/FocusControl.cc | 2 +- src/Keys.cc | 11 +++++------ src/Screen.cc | 30 ++++++++++++++++-------------- src/Screen.hh | 3 ++- 7 files changed, 33 insertions(+), 40 deletions(-) diff --git a/src/FbTk/EventHandler.hh b/src/FbTk/EventHandler.hh index 39ea294..b78e344 100644 --- a/src/FbTk/EventHandler.hh +++ b/src/FbTk/EventHandler.hh @@ -56,7 +56,6 @@ public: virtual void leaveNotifyEvent(XCrossingEvent &) { } virtual void enterNotifyEvent(XCrossingEvent &) { } - virtual void notifyUngrabKeyboard() { } virtual void grabButtons() { } }; diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc index 31d0293..ae52908 100644 --- a/src/FbTk/EventManager.cc +++ b/src/FbTk/EventManager.cc @@ -65,25 +65,14 @@ EventHandler *EventManager::find(Window win) { return m_eventhandlers[win]; } -bool EventManager::grabKeyboard(EventHandler &ev, Window win) { - if (m_grabbing_keyboard) - ungrabKeyboard(); - +bool EventManager::grabKeyboard(Window win) { int ret = XGrabKeyboard(App::instance()->display(), win, False, GrabModeAsync, GrabModeAsync, CurrentTime); - - if (ret == Success) { - m_grabbing_keyboard = &ev; - return true; - } - return false; + return (ret == Success); } void EventManager::ungrabKeyboard() { XUngrabKeyboard(App::instance()->display(), CurrentTime); - if (m_grabbing_keyboard) - m_grabbing_keyboard->notifyUngrabKeyboard(); - m_grabbing_keyboard = 0; } Window EventManager::getEventWindow(XEvent &ev) { @@ -190,10 +179,14 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) { evhand->exposeEvent(ev.xexpose); break; case EnterNotify: - evhand->enterNotifyEvent(ev.xcrossing); + if (ev.xcrossing.mode != NotifyGrab && + ev.xcrossing.mode != NotifyUngrab) + evhand->enterNotifyEvent(ev.xcrossing); break; case LeaveNotify: - evhand->leaveNotifyEvent(ev.xcrossing); + if (ev.xcrossing.mode != NotifyGrab && + ev.xcrossing.mode != NotifyUngrab) + evhand->leaveNotifyEvent(ev.xcrossing); break; default: evhand->handleEvent(ev); diff --git a/src/FbTk/EventManager.hh b/src/FbTk/EventManager.hh index 79a25ce..fdcfe9c 100644 --- a/src/FbTk/EventManager.hh +++ b/src/FbTk/EventManager.hh @@ -42,9 +42,8 @@ public: void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); } void remove(Window win) { unregisterEventHandler(win); } - bool grabKeyboard(EventHandler &ev, Window win); + bool grabKeyboard(Window win); void ungrabKeyboard(); - EventHandler *grabbingKeyboard() { return m_grabbing_keyboard; } EventHandler *find(Window win); diff --git a/src/FocusControl.cc b/src/FocusControl.cc index 6533ac1..8a49273 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -91,7 +91,7 @@ void FocusControl::cycleFocus(const FocusableList &window_list, const ClientPattern *pat, bool cycle_reverse) { if (!m_cycling_list) { - if (&m_screen == FbTk::EventManager::instance()->grabbingKeyboard()) + if (m_screen.isCycling()) // only set this when we're waiting for modifiers m_cycling_list = &window_list; m_was_iconic = 0; diff --git a/src/Keys.cc b/src/Keys.cc index b917989..05f1747 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -510,12 +510,6 @@ bool Keys::doAction(int type, unsigned int mods, unsigned int key, // grab "None Escape" to exit keychain in the middle unsigned int esc = FbTk::KeyUtil::getKey("Escape"); - // if focus changes, windows will get NotifyWhileGrabbed, - // which they tend to ignore - if (temp_key && type == KeyPress && - !FbTk::EventManager::instance()->grabbingKeyboard()) - XUngrabKeyboard(Fluxbox::instance()->display(), CurrentTime); - if (temp_key && !temp_key->keylist.empty()) { // emacs-style if (!saved_keymode) saved_keymode = m_keylist; @@ -536,6 +530,11 @@ bool Keys::doAction(int type, unsigned int mods, unsigned int key, return false; } + // if focus changes, windows will get NotifyWhileGrabbed, + // which they tend to ignore + if (type == KeyPress) + XUngrabKeyboard(Fluxbox::instance()->display(), CurrentTime); + WinClient *old = WindowCmd::client(); WindowCmd::setClient(current); temp_key->m_command->execute(); diff --git a/src/Screen.cc b/src/Screen.cc index a6e5e84..3d6d479 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -856,19 +856,26 @@ void BScreen::propertyNotify(Atom atom) { } void BScreen::keyPressEvent(XKeyEvent &ke) { - Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode, - Keys::GLOBAL|Keys::ON_DESKTOP); + if (Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode, + Keys::GLOBAL|Keys::ON_DESKTOP)) + // re-grab keyboard, so we don't pass KeyRelease to clients + FbTk::EventManager::instance()->grabKeyboard(rootWindow().window()); + } void BScreen::keyReleaseEvent(XKeyEvent &ke) { - if (!m_cycling) - return; + if (m_cycling) { + unsigned int state = FbTk::KeyUtil::instance().cleanMods(ke.state); + state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode); + + if (state) // still cycling + return; - unsigned int state = FbTk::KeyUtil::instance().cleanMods(ke.state); - state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode); + m_cycling = false; + focusControl().stopCyclingFocus(); + } - if (!state) // all modifiers were released - FbTk::EventManager::instance()->ungrabKeyboard(); + FbTk::EventManager::instance()->ungrabKeyboard(); } void BScreen::buttonPressEvent(XButtonEvent &be) { @@ -880,11 +887,6 @@ void BScreen::buttonPressEvent(XButtonEvent &be) { 0, be.time); } -void BScreen::notifyUngrabKeyboard() { - m_cycling = false; - focusControl().stopCyclingFocus(); -} - void BScreen::cycleFocus(int options, const ClientPattern *pat, bool reverse) { // get modifiers from event that causes this for focus order cycling XEvent ev = Fluxbox::instance()->lastEvent(); @@ -896,7 +898,7 @@ void BScreen::cycleFocus(int options, const ClientPattern *pat, bool reverse) { if (!m_cycling && mods) { m_cycling = true; - FbTk::EventManager::instance()->grabKeyboard(*this, rootWindow().window()); + FbTk::EventManager::instance()->grabKeyboard(rootWindow().window()); } if (mods == 0) // can't stacked cycle unless there is a mod to grab diff --git a/src/Screen.hh b/src/Screen.hh index a5e80ee..1a77ea6 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -237,7 +237,6 @@ public: void keyPressEvent(XKeyEvent &ke); void keyReleaseEvent(XKeyEvent &ke); void buttonPressEvent(XButtonEvent &be); - void notifyUngrabKeyboard(); /** * Cycles focus of windows @@ -247,6 +246,8 @@ public: */ void cycleFocus(int opts = 0, const ClientPattern *pat = 0, bool reverse = false); + bool isCycling() const { return m_cycling; } + /** * Creates an empty menu with specified label * @param label for the menu -- cgit v0.11.2