From 5bc85ad5b5c3f57880f2b1e3acec407eec0be6a4 Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 16 May 2007 17:27:01 +0000 Subject: added session.screen.noFocusWhileTypingDelay --- ChangeLog | 5 ++++ src/Screen.cc | 1 + src/Screen.hh | 2 ++ src/Window.cc | 86 ++++++++++++++++++++++++++++++++--------------------------- src/Window.hh | 6 +++++ 5 files changed, 61 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index deab2d9..a64421f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ (Format: Year/Month/Day) Changes for 1.1: +*07/05/16: + * Added new resource session.screen.noFocusWhileTypingDelay: (Mark) + - specifies a time in milliseconds that new windows should not gain focus + while the user is typing in the focused window + Window.cc/hh Screen.cc/hh *07/05/13: * Added new placement policies {Row,Col}MinOverlapPlacement. They behave the same as {Row,Col}SmartPlacement when the window fits but fall back on diff --git a/src/Screen.cc b/src/Screen.cc index 786daa1..2c24157 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -293,6 +293,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, resize_model(rm, BOTTOMRESIZE, scrname+".resizeMode", altscrname+".ResizeMode"), tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"), windowmenufile(rm, "", scrname+".windowMenu", altscrname+".WindowMenu"), + typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay", altscrname+".NoFocusWhileTypingDelay"), user_follow_model(rm, FOLLOW_ACTIVE_WINDOW, scrname+".userFollowModel", altscrname+".UserFollowModel"), workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), diff --git a/src/Screen.hh b/src/Screen.hh index b459f3f..2d1c31d 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -143,6 +143,7 @@ public: ResizeModel getResizeModel() const { return *resource.resize_model; } + inline unsigned int noFocusWhileTypingDelay() const { return *resource.typing_delay; } inline FollowModel getUserFollowModel() const { return *resource.user_follow_model; } inline const std::string &getScrollAction() const { return *resource.scroll_action; } @@ -567,6 +568,7 @@ private: FbTk::Resource resize_model; FbTk::Resource tab_placement; FbTk::Resource windowmenufile; + FbTk::Resource typing_delay; FbTk::Resource user_follow_model; bool ordered_dither; FbTk::Resource workspaces, edge_snap_threshold, focused_alpha, diff --git a/src/Window.cc b/src/Window.cc index b9e26bd..b9dd4a6 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -1363,10 +1363,8 @@ bool FluxboxWindow::focus() { if (screen().currentWorkspaceID() != workspaceNumber() && !isStuck()) { BScreen::FollowModel model = screen().getUserFollowModel(); - if (model == BScreen::IGNORE_OTHER_WORKSPACES) { - Fluxbox::instance()->attentionHandler().addAttention(*this); + if (model == BScreen::IGNORE_OTHER_WORKSPACES) return false; - } // fetch the window to the current workspace if (model == BScreen::FETCH_ACTIVE_WINDOW || @@ -1378,10 +1376,11 @@ bool FluxboxWindow::focus() { } FluxboxWindow *cur = FocusControl::focusedFbWindow(); - if (cur && cur != this && cur->isFullscreen()) { - Fluxbox::instance()->attentionHandler().addAttention(*this); + WinClient *client = FocusControl::focusedWindow(); + if (cur && client && cur != this && + getRootTransientFor(m_client) != getRootTransientFor(client) && + (cur->isFullscreen() || cur->isTyping())) return false; - } if (isIconic()) { deiconify(); @@ -1463,6 +1462,7 @@ void FluxboxWindow::hide(bool interrupt_moving) { void FluxboxWindow::show() { frame().show(); + setState(NormalState, false); } void FluxboxWindow::toggleIconic() { @@ -1484,8 +1484,6 @@ void FluxboxWindow::iconify() { iconic = true; - setState(IconicState, false); - hide(true); screen().focusControl().setFocusBack(this); @@ -1494,9 +1492,6 @@ void FluxboxWindow::iconify() { const ClientList::iterator client_it_end = m_clientlist.end(); for (; client_it != client_it_end; ++client_it) { WinClient &client = *(*client_it); - client.setEventMask(NoEventMask); - client.hide(); - client.setEventMask(PropertyChangeMask | StructureNotifyMask | FocusChangeMask); if (client.transientFor() && client.transientFor()->fbwindow()) { if (!client.transientFor()->fbwindow()->isIconic()) { @@ -1535,19 +1530,10 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) { m_blackbox_attrib.flags &= ~ATTRIB_HIDDEN; iconic = false; - setState(NormalState, false); - - ClientList::iterator client_it = clientList().begin(); - ClientList::iterator client_it_end = clientList().end(); - for (; client_it != client_it_end; ++client_it) { - (*client_it)->setEventMask(NoEventMask); - (*client_it)->show(); - (*client_it)->setEventMask(PropertyChangeMask | StructureNotifyMask | FocusChangeMask); - } - if (reassoc && !m_client->transients.empty()) { // deiconify all transients - client_it = clientList().begin(); + ClientList::iterator client_it = clientList().begin(); + ClientList::iterator client_it_end = clientList().end(); for (; client_it != client_it_end; ++client_it) { //TODO: Can this get stuck in a loop? WinClient::TransientList::iterator trans_it = @@ -1863,9 +1849,6 @@ void FluxboxWindow::raise() { // get root window WinClient *client = getRootTransientFor(m_client); - // if we don't have any root window use this as root - if (client == 0) - client = m_client; // if we have transient_for then we should put ourself last in // transients list so we get raised last and thus gets above the other transients if (m_client->transientFor() && m_client != m_client->transientFor()->transientList().back()) { @@ -1894,10 +1877,6 @@ void FluxboxWindow::lower() { // get root window WinClient *client = getRootTransientFor(m_client); - // if we don't have any root window use this as root - if (client == 0) - client = m_client; - if (client->fbwindow()) lowerFluxboxWindow(*client->fbwindow()); } @@ -1944,10 +1923,6 @@ void FluxboxWindow::moveToLayer(int layernum, bool force) { // get root window WinClient *client = getRootTransientFor(m_client); - // if we don't have any root window use this as root - if (client == 0) - client = m_client; - FluxboxWindow *win = client->fbwindow(); if (!win) return; @@ -2094,10 +2069,12 @@ void FluxboxWindow::setState(unsigned long new_state, bool setting_up) { ClientList::iterator it = clientList().begin(); ClientList::iterator it_end = clientList().end(); for (; it != it_end; ++it) { + (*it)->setEventMask(NoEventMask); if (new_state == IconicState) (*it)->hide(); else if (new_state == NormalState) (*it)->show(); + (*it)->setEventMask(PropertyChangeMask | StructureNotifyMask | FocusChangeMask | KeyPressMask); } saveBlackboxAttribs(); @@ -2376,7 +2353,7 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) { setState(NormalState, false); // we use m_focused as a signal that this should be focused when mapped - if (isFocused()) { + if (m_focused) { m_focused = false; focus(); } @@ -2397,11 +2374,7 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent &ue) { cerr<<__FILE__<<"("<<__FUNCTION__<<"): title="<title()< #include +#include #include #include #include @@ -337,6 +338,7 @@ public: */ //@{ void handleEvent(XEvent &event); + void keyPressEvent(XKeyEvent &ke); void buttonPressEvent(XButtonEvent &be); void buttonReleaseEvent(XButtonEvent &be); void motionNotifyEvent(XMotionEvent &me); @@ -419,6 +421,8 @@ public: inline WinClient &winClient() { return *m_client; } inline const WinClient &winClient() const { return *m_client; } + bool isTyping(); + inline const FbTk::XLayerItem &layerItem() const { return m_frame.layerItem(); } inline FbTk::XLayerItem &layerItem() { return m_frame.layerItem(); } @@ -572,6 +576,8 @@ private: int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving unsigned int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window" + timeval m_last_keypress_time; + unsigned int m_workspace_number; unsigned long m_current_state; // NormalState | IconicState | Withdrawn -- cgit v0.11.2