X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fscreen.cc;h=0bbcebc6d8d694de53f06a283ef53b7147e75d23;hb=6871cff3face4486055444a6c6218a552ddad461;hp=e7d559f1178ce6ad7b00c1d678b114bf08c3307e;hpb=d8aff44a6a639de83ba8f0957f9f9f17f2a05532;p=chaz%2Fopenbox diff --git a/src/screen.cc b/src/screen.cc index e7d559f1..0bbcebc6 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -125,7 +125,7 @@ Screen::Screen(int screen) _focuswindow = XCreateWindow(**otk::display, _info->rootWindow(), -100, -100, 1, 1, 0, 0, InputOnly, _info->visual(), CWOverrideRedirect, &attr); - XMapWindow(**otk::display, _focuswindow); + XMapRaised(**otk::display, _focuswindow); // these may be further updated if any pre-existing windows are found in // the manageExising() function @@ -328,16 +328,18 @@ void Screen::changeSupportedAtoms() otk::Property::atoms.net_wm_moveresize_size_bottomright, otk::Property::atoms.net_wm_moveresize_move, */ -/* otk::Property::atoms.net_wm_allowed_actions, otk::Property::atoms.net_wm_action_move, otk::Property::atoms.net_wm_action_resize, + otk::Property::atoms.net_wm_action_minimize, otk::Property::atoms.net_wm_action_shade, +/* otk::Property::atoms.net_wm_action_stick,*/ otk::Property::atoms.net_wm_action_maximize_horz, otk::Property::atoms.net_wm_action_maximize_vert, + otk::Property::atoms.net_wm_action_fullscreen, otk::Property::atoms.net_wm_action_change_desktop, otk::Property::atoms.net_wm_action_close, -*/ + otk::Property::atoms.net_wm_state, otk::Property::atoms.net_wm_state_modal, otk::Property::atoms.net_wm_state_maximized_vert, @@ -471,14 +473,6 @@ void Screen::manageWindow(Window window) // reparented back to root automatically XChangeSaveSet(**otk::display, window, SetModeInsert); - if (!(openbox->state() == Openbox::State_Starting || - client->positionRequested())) { - // position the window intelligenty .. hopefully :) - // call the python PLACEWINDOW binding - EventData data(_number, client, EventPlaceWindow, 0); - openbox->bindings()->fireEvent(&data); - } - // create the decoration frame for the client window client->frame = new Frame(client, &_style); @@ -498,13 +492,21 @@ void Screen::manageWindow(Window window) // reparent the client to the frame client->frame->grabClient(); + if (!(openbox->state() == Openbox::State_Starting || + client->positionRequested())) { + // position the window intelligenty .. hopefully :) + // call the python PLACEWINDOW binding + EventData data(_number, client, EventPlaceWindow, 0); + openbox->bindings()->fireEvent(&data); + } + // if on the current desktop.. (or all desktops) if (client->desktop() == _desktop || client->desktop() == (signed)0xffffffff) { client->frame->show(); } - - // XXX: handle any requested states such as maximized + + client->applyStartupState(); otk::display->ungrab(); @@ -512,7 +514,7 @@ void Screen::manageWindow(Window window) clients.push_back(client); // this puts into the stacking order, then raises it _stacking.push_back(client); - restack(true, client); + raiseWindow(client); // update the root properties changeClientList(); @@ -590,30 +592,54 @@ void Screen::unmanageWindow(Client *client) changeClientList(); } -void Screen::restack(bool raise, Client *client) +void Screen::lowerWindow(Client *client) { - const int layer = client->layer(); - std::vector wins; + Window wins[2]; // only ever restack 2 windows. + + assert(!_stacking.empty()); // this would be bad + + Client::List::iterator it = --_stacking.end(); + Client::List::const_iterator end = _stacking.begin(); + + for (; it != end && (*it)->layer() < client->layer(); --it); + if (*it == client) return; // already the bottom, return + + wins[0] = (*it)->frame->window(); + wins[1] = client->frame->window(); _stacking.remove(client); + _stacking.insert(++it, client); - // the stacking list is from highest to lowest + XRestackWindows(**otk::display, wins, 2); + changeStackingList(); +} + +void Screen::raiseWindow(Client *client) +{ + Window wins[2]; // only ever restack 2 windows. + + assert(!_stacking.empty()); // this would be bad + + // remove the client before looking so we can't run into ourselves + _stacking.remove(client); - Client::List::iterator it = _stacking.begin(), end = _stacking.end(); - // insert the windows above this window - for (; it != end; ++it) { - if ((*it)->layer() < layer || (raise && (*it)->layer() == layer)) - break; - wins.push_back((*it)->frame->window()); - } - // insert our client - wins.push_back(client->frame->window()); + Client::List::iterator it = _stacking.begin(); + Client::List::const_iterator end = _stacking.end(); + + // the stacking list is from highest to lowest + for (; it != end && (*it)->layer() > client->layer(); ++it); + + /* + if our new position is the top, we want to stack under the _focuswindow + otherwise, we want to stack under the previous window in the stack. + */ + wins[0] = (it == _stacking.begin() ? _focuswindow : + ((*(--Client::List::const_iterator(it)))->frame->window())); + wins[1] = client->frame->window(); + _stacking.insert(it, client); - // insert the remaining below this window - for (; it != end; ++it) - wins.push_back((*it)->frame->window()); - XRestackWindows(**otk::display, &wins[0], wins.size()); + XRestackWindows(**otk::display, wins, 2); changeStackingList(); }