X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=util%2Fepist%2Fscreen.cc;h=416bb9bdd1de097162447656aa2fdb4700e3bf17;hb=da8d6b3f60a3eb39ca47cfcb9aa5b2f445050102;hp=7773704dc8813103b0f4e093ae5e6ca98b33c0d1;hpb=fa301a99952a74545a5b399f0227f91fa66c0ab3;p=chaz%2Fopenbox diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 7773704d..416bb9bd 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -20,6 +20,17 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +/* A few comments about stacked cycling: + * When stacked cycling is turned on, the focused window is always at the top + * (front) of the list (_clients), EXCEPT for when we are in cycling mode. + * (_cycling is true) If we were to add the focused window to the top of the + * stack while we were cycling, we would end in a deadlock between 2 windows. + * When the modifiers are released, the window that has focus (but it's not + * at the top of the stack, since we are cycling) is placed at the top of the + * stack and raised. + * Hooray and Bummy. - Marius + */ + #ifdef HAVE_CONFIG_H # include "../../config.h" #endif // HAVE_CONFIG_H @@ -450,16 +461,21 @@ void screen::updateClientList() { const WindowList::iterator end = _clients.end(); unsigned long i; - // insert new clients after the active window for (i = 0; i < num; ++i) { for (it = _clients.begin(); it != end; ++it) if (**it == rootclients[i]) break; if (it == end) { // didn't already exist if (doAddWindow(rootclients[i])) { - // cout << "Added window: 0x" << hex << rootclients[i] << dec << endl; - _clients.insert(insert_point, new XWindow(_epist, this, - rootclients[i])); +// cout << "Added window: 0x" << hex << rootclients[i] << dec << endl; + if (_stacked_cycling) { + // insert new clients after the active window + _clients.insert(insert_point, new XWindow(_epist, this, + rootclients[i])); + } else { + // insert new clients at the front of the list + _clients.push_front(new XWindow(_epist, this, rootclients[i])); + } } } } @@ -522,9 +538,21 @@ void screen::updateActiveWindow() { break; } } + _active = it; - if (it != end) - _last_active = it; + + if (_active != end) { + /* if we're not cycling and a window gets focus, add it to the top of the + * cycle stack. + */ + if (_stacked_cycling && !_cycling) { + _clients.remove(*_active); + _clients.push_front(*_active); + _active = _clients.begin(); + } + + _last_active = _active; + } /* cout << "Active window is now: "; if (_active == _clients.end()) cout << "None\n"; @@ -617,8 +645,8 @@ void screen::cycleWindow(unsigned int state, const bool forward, } // if the window is on another desktop, we can't use XSetInputFocus, since - // it doesn't imply a woskpace change. - if (t->desktop() == _active_desktop) + // it doesn't imply a workspace change. + if (t->desktop() == _active_desktop || t->desktop() == 0xffffffff) t->focus(false); // focus, but don't raise else t->focus(); // change workspace and focus