Skip to content

Commit

Permalink
make changeLayer() work on all transients, similar to iconify(),
Browse files Browse the repository at this point in the history
changeWorkspace(), etc.
  • Loading branch information
bradleyhughes committed Dec 29, 2004
1 parent 9d906b2 commit 22effcb
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 87 deletions.
95 changes: 45 additions & 50 deletions src/Screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) :
_toolbar = 0;
if (_resource.isToolbarEnabled()) {
_toolbar = new Toolbar(this);
stackingList.insert(_toolbar);
_stackingList.insert(_toolbar);
}

InitMenu();
Expand Down Expand Up @@ -492,8 +492,8 @@ void BScreen::setCurrentWorkspace(unsigned int id) {

// withdraw windows in reverse order to minimize the number of
// Expose events
StackingList::const_reverse_iterator it = stackingList.rbegin();
const StackingList::const_reverse_iterator end = stackingList.rend();
StackingList::const_reverse_iterator it = _stackingList.rbegin();
const StackingList::const_reverse_iterator end = _stackingList.rend();
for (; it != end; ++it) {
BlackboxWindow *win = dynamic_cast<BlackboxWindow *>(*it);
if (win && win->workspace() == current_workspace)
Expand All @@ -515,8 +515,8 @@ void BScreen::setCurrentWorkspace(unsigned int id) {
{
_workspacemenu->setWorkspaceChecked(current_workspace, true);

StackingList::const_iterator it = stackingList.begin();
const StackingList::const_iterator end = stackingList.end();
StackingList::const_iterator it = _stackingList.begin();
const StackingList::const_iterator end = _stackingList.end();
for (; it != end; ++it) {
BlackboxWindow *win = dynamic_cast<BlackboxWindow *>(*it);
if (win && win->workspace() == current_workspace)
Expand All @@ -538,7 +538,7 @@ void BScreen::setCurrentWorkspace(unsigned int id) {
workspace->focusedWindow()->setInputFocus();
} else {
// focus the top-most window in the stack
for (it = stackingList.begin(); it != end; ++it) {
for (it = _stackingList.begin(); it != end; ++it) {
BlackboxWindow * const tmp = dynamic_cast<BlackboxWindow *>(*it);
if (!tmp
|| !tmp->isVisible()
Expand Down Expand Up @@ -627,7 +627,7 @@ void BScreen::manageWindow(Window w) {
windowList.push_back(win);

// insert window at the top of the stack
stackingList.insert(win);
_stackingList.insert(win);
if (!_blackbox->startingUp())
restackWindows();

Expand Down Expand Up @@ -683,7 +683,7 @@ void BScreen::unmanageWindow(BlackboxWindow *win) {
}

windowList.remove(win);
stackingList.remove(win);
_stackingList.remove(win);

delete win;
}
Expand All @@ -702,8 +702,8 @@ bool BScreen::focusFallback(const BlackboxWindow *win) {
// focus the top-most window in the group
BlackboxWindowList::const_iterator git = group->windows().begin(),
gend = group->windows().end();
StackingList::iterator it = stackingList.begin(),
end = stackingList.end();
StackingList::iterator it = _stackingList.begin(),
end = _stackingList.end();
for (; it != end; ++it) {
BlackboxWindow * const tmp = dynamic_cast<BlackboxWindow *>(*it);
if (!tmp
Expand Down Expand Up @@ -732,9 +732,9 @@ bool BScreen::focusFallback(const BlackboxWindow *win) {
}

// try to focus the top-most window in the same layer as win
StackingList::iterator it = stackingList.layer(win->layer()),
end = std::find(it, stackingList.end(), zero);
assert(it != stackingList.end() && end != stackingList.end());
StackingList::iterator it = _stackingList.layer(win->layer()),
end = std::find(it, _stackingList.end(), zero);
assert(it != _stackingList.end() && end != _stackingList.end());
for (; it != end; ++it) {
BlackboxWindow * const tmp = dynamic_cast<BlackboxWindow *>(*it);
if (!tmp)
Expand All @@ -750,8 +750,8 @@ bool BScreen::focusFallback(const BlackboxWindow *win) {
}

// focus the top-most window in the stack
StackingList::iterator it = stackingList.begin(),
end = stackingList.end();
StackingList::iterator it = _stackingList.begin(),
end = _stackingList.end();
for (; it != end; ++it) {
BlackboxWindow * const tmp = dynamic_cast<BlackboxWindow *>(*it);
if (!tmp
Expand Down Expand Up @@ -779,7 +779,8 @@ void BScreen::raiseWindow(StackEntity *entity) {

if (win->isFullScreen() && win->layer() != StackingList::LayerFullScreen) {
// move full-screen windows over all other windows when raising
changeLayer(win, StackingList::LayerFullScreen);
win->changeLayer(StackingList::LayerFullScreen);
restackWindows();
return;
}

Expand All @@ -789,8 +790,8 @@ void BScreen::raiseWindow(StackEntity *entity) {
// find the first window above us (if any)
StackEntity *above = 0;
{
StackingList::const_iterator begin = stackingList.begin(),
layer = stackingList.layer(top->layer()),
StackingList::const_iterator begin = _stackingList.begin(),
layer = _stackingList.layer(top->layer()),
it = layer;
if (*it == top) {
// entity already on top of layer
Expand All @@ -814,22 +815,22 @@ void BScreen::raiseWindow(StackEntity *entity) {
BlackboxWindow * const tmp = *it;
if (tmp->isTransient())
continue;
stackingList.raise(tmp);
_stackingList.raise(tmp);
raiseTransients(tmp->transients());
}
// ... and group transients on top
raiseTransients(group->transients());
} else {
// restack the window
stackingList.raise(win);
_stackingList.raise(win);
// ... with all transients above
raiseTransients(win->transients());
// ... and group transients on top
if (group)
raiseTransients(group->transients());
}
} else {
stackingList.raise(top);
_stackingList.raise(top);
}

WindowStack stack;
Expand Down Expand Up @@ -884,8 +885,8 @@ void BScreen::lowerWindow(StackEntity *entity) {
// find window at the bottom of the layer (if any)
StackEntity *above = 0;
{
StackingList::const_iterator it, layer = stackingList.layer(top->layer()),
end = stackingList.end();
StackingList::const_iterator it, layer = _stackingList.layer(top->layer()),
end = _stackingList.end();
it = std::find(layer, end, (StackEntity *) 0);
assert(it != end);

Expand All @@ -912,16 +913,16 @@ void BScreen::lowerWindow(StackEntity *entity) {
if (tmp == win || tmp->isTransient())
continue;
lowerTransients(tmp->transients());
stackingList.lower(tmp);
_stackingList.lower(tmp);
}
} else {
if (group)
lowerTransients(group->transients());
lowerTransients(win->transients());
stackingList.lower(win);
_stackingList.lower(win);
}
} else {
stackingList.lower(top);
_stackingList.lower(top);
}

WindowStack stack;
Expand Down Expand Up @@ -967,8 +968,8 @@ void BScreen::restackWindows(void) {
WindowStack stack;
stack.push_back(empty_window);

StackingList::const_iterator it, end = stackingList.end();
for (it = stackingList.begin(); it != end; ++it)
StackingList::const_iterator it, end = _stackingList.end();
for (it = _stackingList.begin(); it != end; ++it)
if (*it) stack.push_back((*it)->windowID());

XRestackWindows(_blackbox->XDisplay(), &stack[0], stack.size());
Expand All @@ -977,12 +978,6 @@ void BScreen::restackWindows(void) {
}


void BScreen::changeLayer(StackEntity *entity, StackingList::Layer new_layer) {
stackingList.changeLayer(entity, new_layer);
restackWindows();
}


void BScreen::propagateWindowName(const BlackboxWindow * const win) {
if (win->isIconic()) {
_iconmenu->changeItem(win->windowNumber(),
Expand Down Expand Up @@ -1725,8 +1720,8 @@ void BScreen::updateClientListStackingHint(void) const {

// we store windows in top-to-bottom order, but the EWMH wants
// bottom-to-top...
StackingList::const_reverse_iterator it = stackingList.rbegin(),
end = stackingList.rend();
StackingList::const_reverse_iterator it = _stackingList.rbegin(),
end = _stackingList.rend();
for (; it != end; ++it) {
const BlackboxWindow * const win = dynamic_cast<BlackboxWindow *>(*it);
if (win) stack.push_back(win->clientWindow());
Expand Down Expand Up @@ -1763,8 +1758,8 @@ void BScreen::readDesktopNames(void) {


BlackboxWindow *BScreen::window(unsigned int workspace, unsigned int id) {
StackingList::const_iterator it = stackingList.begin(),
end = stackingList.end();
StackingList::const_iterator it = _stackingList.begin(),
end = _stackingList.end();
for (; it != end; ++it) {
BlackboxWindow * const win = dynamic_cast<BlackboxWindow *>(*it);
if (win && win->workspace() == workspace && win->windowNumber() == id)
Expand All @@ -1784,7 +1779,7 @@ void BScreen::raiseTransients(const BlackboxWindowList &transients) {
BlackboxWindow * const tmp = *it;
if (tmp->workspace() == current_workspace
|| tmp->workspace() == bt::BSENTINEL) {
stackingList.raise(tmp);
_stackingList.raise(tmp);
raiseTransients(tmp->transients());
}
}
Expand All @@ -1801,7 +1796,7 @@ void BScreen::lowerTransients(const BlackboxWindowList &transients) {
if (tmp->workspace() == current_workspace
|| tmp->workspace() == bt::BSENTINEL) {
lowerTransients(tmp->transients());
stackingList.lower(tmp);
_stackingList.lower(tmp);
}
}
}
Expand Down Expand Up @@ -1909,11 +1904,11 @@ bool BScreen::smartPlacement(unsigned int workspace, bt::Rect& rect,
std::vector must do.. we allocate as much memory as we would need
in the worst case scenario and work with that
*/
std::vector<int> coords(stackingList.size() * 4 + 4);
std::vector<int> coords(_stackingList.size() * 4 + 4);
std::vector<int>::iterator
x_begin = coords.begin(),
x_end = x_begin,
y_begin = coords.begin() + stackingList.size() * 2 + 2,
y_begin = coords.begin() + _stackingList.size() * 2 + 2,
y_end = y_begin;

{
Expand All @@ -1928,7 +1923,7 @@ bool BScreen::smartPlacement(unsigned int workspace, bt::Rect& rect,
y_end += 2;


for (w_it = stackingList.begin(), w_end = stackingList.end();
for (w_it = _stackingList.begin(), w_end = _stackingList.end();
w_it != w_end; ++w_it) {
const BlackboxWindow * const win =
dynamic_cast<const BlackboxWindow *>(*w_it);
Expand Down Expand Up @@ -1971,7 +1966,7 @@ bool BScreen::smartPlacement(unsigned int workspace, bt::Rect& rect,
std::vector<bool> used_grid(gw * gh);
std::fill_n(used_grid.begin(), used_grid.size(), false);

for (w_it = stackingList.begin(), w_end = stackingList.end();
for (w_it = _stackingList.begin(), w_end = _stackingList.end();
w_it != w_end; ++w_it) {
const BlackboxWindow * const win =
dynamic_cast<const BlackboxWindow *>(*w_it);
Expand Down Expand Up @@ -2161,15 +2156,15 @@ void BScreen::createSlit(void) {
assert(_slit == 0);

_slit = new Slit(this);
stackingList.insert(_slit);
_stackingList.insert(_slit);
restackWindows();
}


void BScreen::destroySlit(void) {
assert(_slit != 0);

stackingList.remove(_slit);
_stackingList.remove(_slit);
delete _slit;
_slit = 0;
}
Expand All @@ -2179,15 +2174,15 @@ void BScreen::createToolbar(void) {
assert(_toolbar == 0);

_toolbar = new Toolbar(this);
stackingList.insert(_toolbar);
_stackingList.insert(_toolbar);
restackWindows();
}


void BScreen::destroyToolbar(void) {
assert(_toolbar != 0);

stackingList.remove(_toolbar);
_stackingList.remove(_toolbar);
delete _toolbar;
_toolbar = 0;
}
Expand Down Expand Up @@ -2238,8 +2233,8 @@ void BScreen::removeIcon(BlackboxWindow *win) {


BlackboxWindow *BScreen::icon(unsigned int id) {
StackingList::const_iterator it = stackingList.begin(),
end = stackingList.end();
StackingList::const_iterator it = _stackingList.begin(),
end = _stackingList.end();
for (; it != end; ++it) {
BlackboxWindow * const win = dynamic_cast<BlackboxWindow *>(*it);
if (win && win->isIconic() && win->windowNumber() == id)
Expand Down
7 changes: 4 additions & 3 deletions src/Screen.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private:
Workspacemenu *_workspacemenu;

BlackboxWindowList windowList;
StackingList stackingList;
StackingList _stackingList;
unsigned int current_workspace;

Slit *_slit;
Expand Down Expand Up @@ -193,9 +193,10 @@ public:

void raiseWindow(StackEntity *entity);
void lowerWindow(StackEntity *entity);
void restackWindows(void);

void changeLayer(StackEntity *entity, StackingList::Layer new_layer);
inline StackingList &stackingList()
{ return _stackingList; }
void restackWindows(void);

void addIcon(BlackboxWindow *win);
void removeIcon(BlackboxWindow *win);
Expand Down
8 changes: 5 additions & 3 deletions src/Slitmenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ void Slitmenu::itemClicked(unsigned int id, unsigned int button) {
res.saveSlitOnTop(!res.isSlitOnTop());
_bscreen->saveResource();
if (slit) {
_bscreen->changeLayer(slit, (res.isSlitOnTop()
? StackingList::LayerAbove
: StackingList::LayerNormal));
StackingList::Layer new_layer = (res.isSlitOnTop()
? StackingList::LayerAbove
: StackingList::LayerNormal);
_bscreen->stackingList().changeLayer(slit, new_layer);
_bscreen->restackWindows();
}
break;

Expand Down
8 changes: 5 additions & 3 deletions src/Toolbarmenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ void Toolbarmenu::itemClicked(unsigned int id, unsigned int button) {
res.saveToolbarOnTop(!res.isToolbarOnTop());
_bscreen->saveResource();
if (toolbar) {
_bscreen->changeLayer(toolbar, (res.isToolbarOnTop()
? StackingList::LayerAbove
: StackingList::LayerNormal));
StackingList::Layer new_layer = (res.isToolbarOnTop()
? StackingList::LayerAbove
: StackingList::LayerNormal);
_bscreen->stackingList().changeLayer(toolbar, new_layer);
_bscreen->restackWindows();
}
break;

Expand Down
Loading

0 comments on commit 22effcb

Please sign in to comment.