bunch of cleanup, little bug fixes
markt markt
5 files changed,
45 insertions(+),
119 deletions(-)
M
src/FbTk/KeyUtil.cc
→
src/FbTk/KeyUtil.cc
@@ -118,44 +118,29 @@ const unsigned int capsmod = instance().capslock();
const unsigned int nummod = instance().numlock(); const unsigned int scrollmod = instance().scrolllock(); - XGrabKey(display, key, mod, - win, True, - GrabModeAsync, GrabModeAsync); - // Grab with numlock, capslock and scrlock + for (int i = 0; i < 8; i++) { + XGrabKey(display, key, mod | (i & 1 ? capsmod : 0) | + (i & 2 ? nummod : 0) | (i & 4 ? scrollmod : 0), + win, True, GrabModeAsync, GrabModeAsync); + } - //numlock - XGrabKey(display, key, mod|nummod, - win, True, - GrabModeAsync, GrabModeAsync); - //scrolllock - XGrabKey(display, key, mod|scrollmod, - win, True, - GrabModeAsync, GrabModeAsync); - //capslock - XGrabKey(display, key, mod|capsmod, - win, True, - GrabModeAsync, GrabModeAsync); +} - //capslock+numlock - XGrabKey(display, key, mod|capsmod|nummod, - win, True, - GrabModeAsync, GrabModeAsync); - - //capslock+scrolllock - XGrabKey(display, key, mod|capsmod|scrollmod, - win, True, - GrabModeAsync, GrabModeAsync); - - //capslock+numlock+scrolllock - XGrabKey(display, key, mod|capsmod|scrollmod|nummod, - win, True, - GrabModeAsync, GrabModeAsync); +void KeyUtil::grabButton(unsigned int button, unsigned int mod, Window win, + unsigned int event_mask, Cursor cursor) { + Display *display = App::instance()->display(); + const unsigned int capsmod = instance().capslock(); + const unsigned int nummod = instance().numlock(); + const unsigned int scrollmod = instance().scrolllock(); - //numlock+scrollLock - XGrabKey(display, key, mod|nummod|scrollmod, - win, True, - GrabModeAsync, GrabModeAsync); + // Grab with numlock, capslock and scrlock + for (int i = 0; i < 8; i++) { + XGrabButton(display, button, mod | (i & 1 ? capsmod : 0) | + (i & 2 ? nummod : 0) | (i & 4 ? scrollmod : 0), + win, True, event_mask, GrabModeAsync, GrabModeAsync, + None, cursor); + } }
M
src/FbTk/KeyUtil.hh
→
src/FbTk/KeyUtil.hh
@@ -44,6 +44,8 @@ /**
Grab the specified key */ static void grabKey(unsigned int key, unsigned int mod, Window win); + static void grabButton(unsigned int button, unsigned int mod, Window win, + unsigned int event_mask, Cursor cursor = None); /** convert the string to the keysym
M
src/FocusControl.cc
→
src/FocusControl.cc
@@ -193,6 +193,7 @@ if (m_cycling_creation_order && m_cycling_window != m_creation_order_list.end())
m_cycling_window = find(m_focused_list.begin(),m_focused_list.end(),*m_cycling_window); if (m_cycling_window != m_focused_list.end() && m_cycling_window != m_creation_order_list.end() && + (*m_cycling_window)->fbwindow() && (*m_cycling_window)->fbwindow()->isVisible()) { WinClient *client = *m_cycling_window; m_focused_list.erase(m_cycling_window);
M
src/Screen.cc
→
src/Screen.cc
@@ -1404,7 +1404,8 @@ }
} // add the window to the focus list - if (focusControl().focusNew()) + // always add to front on startup to keep the focus order the same + if (focusControl().focusNew() || Fluxbox::instance()->isStartup()) focusControl().addFocusFront(*winclient); else focusControl().addFocusBack(*winclient);@@ -1435,7 +1436,7 @@ *layerManager().getLayer(Layer::NORMAL));
#ifdef SLIT if (win->initialState() == WithdrawnState && slit() != 0) { - slit()->addClient(win->clientWindow()); + slit()->addClient(client.window()); } #endif // SLIT@@ -1445,8 +1446,11 @@ delete win;
return 0; } - // can't setInputFocus yet and mapNotifyEvent doesn't happen for the client - if (focusControl().focusNew() || FocusControl::focusedWindow() == &client) + win->show(); + // don't ask me why, but client doesn't seem to keep focus in new window + // and we don't seem to get a FocusIn event from setInputFocus + if ((focusControl().focusNew() || FocusControl::focusedWindow() == &client) + && win->setInputFocus()) FocusControl::setFocusedWindow(&client); m_clientlist_sig.notify();
M
src/Window.cc
→
src/Window.cc
@@ -104,57 +104,6 @@ #endif // DEBUG
namespace { -void grabButton(unsigned int button, - Window window, Cursor cursor) { - - static Display *display = App::instance()->display(); - - const int numlock = KeyUtil::instance().numlock(); - const int capslock = KeyUtil::instance().capslock(); - const int scrolllock = KeyUtil::instance().scrolllock(); - - // Grab with modkey and with all lock modifiers - // (num, scroll and caps) - - unsigned int modkey = Fluxbox::instance()->getModKey(); - - //numlock - XGrabButton(display, button, modkey|numlock, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); - //scrolllock - XGrabButton(display, button, modkey|scrolllock, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); - - //capslock - XGrabButton(display, button, modkey|capslock, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); - - //capslock+numlock - XGrabButton(display, Button1, modkey|capslock|numlock, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); - - //capslock+scrolllock - XGrabButton(display, button, modkey|capslock|scrolllock, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); - - //capslock+numlock+scrolllock - XGrabButton(display, button, modkey|capslock|numlock|scrolllock, window, - True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); - - //numlock+scrollLock - XGrabButton(display, button, modkey|numlock|scrolllock, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); - -} - // X event scanner for enter/leave notifies - adapted from twm typedef struct scanargs { Window w;@@ -402,8 +351,7 @@ m_old_pos_x = m_screen.width();
assert(m_client); m_client->setFluxboxWindow(this); - if (!m_client->hasGroupLeftWindow()) - m_client->setGroupLeftWindow(None); // nothing to the left. + m_client->setGroupLeftWindow(None); // nothing to the left. // check for shape extension and whether the window is shaped m_shaped = false;@@ -702,10 +650,10 @@ frame().clientArea().y(),
frame().clientArea().width(), frame().clientArea().height()); - if (&client == FocusControl::focusedWindow()) { - was_focused = true; + // right now, this block only happens with new windows or on restart + if (screen().focusControl().focusNew() || + Fluxbox::instance()->isStartup()) focused_win = &client; - } client.saveBlackboxAttribs(m_blackbox_attrib); m_clientlist.push_back(&client);@@ -718,16 +666,15 @@ m_statesig.notify();
m_workspacesig.notify(); m_layersig.notify(); - if (was_focused) - // already has focus, we're just assuming the state of the old window + if (was_focused) { + // don't ask me why, but client doesn't seem to keep focus in new window + // and we don't seem to get a FocusIn event from setInputFocus + setCurrentClient(client); FocusControl::setFocusedWindow(&client); + } else if (focused_win) + setCurrentClient(*focused_win, false); frame().reconfigure(); - - // keep the current window on top - if (focused_win) - m_client = focused_win; - m_client->raise(); }@@ -748,11 +695,7 @@ if (++client_it_after != clientList().end())
(*client_it_after)->setGroupLeftWindow(leftwin); removeClient(client); - - // m_client must be valid as there should be at least one other window - // otherwise this wouldn't be here (refer numClients() <= 1 return) - client.setFluxboxWindow(screen().createWindow(client)); - client.setGroupLeftWindow(None); + screen().createWindow(client); return true; }@@ -1123,22 +1066,16 @@
unsigned int modkey = Fluxbox::instance()->getModKey(); if (modkey) { - XGrabButton(display, Button1, modkey, frame().window().window(), True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, frame().theme().moveCursor()); - //----grab with "all" modifiers - grabButton(Button1, frame().window().window(), frame().theme().moveCursor()); + FbTk::KeyUtil::grabButton(Button1, modkey, frame().window().window(), + ButtonReleaseMask | ButtonMotionMask, frame().theme().moveCursor()); XGrabButton(display, Button2, modkey, frame().window().window(), True, ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); - XGrabButton(display, Button3, modkey, frame().window().window(), True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, None); - //---grab with "all" modifiers - grabButton(Button3, frame().window().window(), None); + FbTk::KeyUtil::grabButton(Button3, modkey, frame().window().window(), + ButtonReleaseMask | ButtonMotionMask); } }@@ -3641,9 +3578,6 @@ // move window by relative amount of mouse movement
// since just detached, move relative to old location if (client.fbwindow() != 0) { client.fbwindow()->move(frame().x() - m_last_resize_x + x, frame().y() - m_last_resize_y + y); - client.fbwindow()->show(); - FocusControl::setFocusedWindow(&client); - client.fbwindow()->setInputFocus(); } } else if( attach_to_win == this && attach_to_win->isTabable()) { //reording of tabs within a frame