Skip to content

Commit

Permalink
introduce autotabplacement
Browse files Browse the repository at this point in the history
  • Loading branch information
luebking committed Sep 11, 2016
1 parent 4be68df commit ea466fa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/Screen.cc
Expand Up @@ -1138,6 +1138,8 @@ FluxboxWindow *BScreen::createWindow(Window client) {

// check if it should be grouped with something else
WinClient* other = findGroupLeft(*winclient);
if (!other && m_placement_strategy->placementPolicy() == ScreenPlacement::AUTOTABPLACEMENT)
other = FocusControl::focusedWindow();
FluxboxWindow* win = other ? other->fbwindow() : 0;

if (other && win) {
Expand Down
25 changes: 17 additions & 8 deletions src/ScreenPlacement.cc
Expand Up @@ -82,6 +82,9 @@ bool ScreenPlacement::placeWindow(const FluxboxWindow &win, int head,
case UNDERMOUSEPLACEMENT:
m_strategy.reset(new UnderMousePlacement());
break;
case AUTOTABPLACEMENT:
m_strategy.reset(0);
break;
}
}

Expand All @@ -96,14 +99,16 @@ bool ScreenPlacement::placeWindow(const FluxboxWindow &win, int head,
place_y = head_top;

bool placed = false;
try {
placed = m_strategy->placeWindow(win, head, place_x, place_y);
} catch (std::bad_cast & cast) {
// This should not happen.
// If for some reason we change the PlacementStrategy in Screen
// from ScreenPlacement to something else then we might get
// bad_cast from some placement strategies.
cerr<<"Failed to place window: "<<cast.what()<<endl;
if (m_strategy) {
try {
placed = m_strategy->placeWindow(win, head, place_x, place_y);
} catch (std::bad_cast & cast) {
// This should not happen.
// If for some reason we change the PlacementStrategy in Screen
// from ScreenPlacement to something else then we might get
// bad_cast from some placement strategies.
cerr<<"Failed to place window: "<<cast.what()<<endl;
}
}

if (!placed) {
Expand Down Expand Up @@ -194,6 +199,8 @@ std::string FbTk::Resource<ScreenPlacement::PlacementPolicy>::getString() const
return "UnderMousePlacement";
case ScreenPlacement::CASCADEPLACEMENT:
return "CascadePlacement";
case ScreenPlacement::AUTOTABPLACEMENT:
return "AutotabPlacement";
}

return "RowSmartPlacement";
Expand All @@ -213,6 +220,8 @@ void FbTk::Resource<ScreenPlacement::PlacementPolicy>::setFromString(const char
*(*this) = ScreenPlacement::UNDERMOUSEPLACEMENT;
else if (strcasecmp("CascadePlacement", str) == 0)
*(*this) = ScreenPlacement::CASCADEPLACEMENT;
else if (strcasecmp("AutotabPlacement", str) == 0)
*(*this) = ScreenPlacement::AUTOTABPLACEMENT;
else
setDefaultValue();
}
Expand Down
3 changes: 2 additions & 1 deletion src/ScreenPlacement.hh
Expand Up @@ -48,7 +48,8 @@ public:
COLMINOVERLAPPLACEMENT,
ROWMINOVERLAPPLACEMENT,
CASCADEPLACEMENT,
UNDERMOUSEPLACEMENT
UNDERMOUSEPLACEMENT,
AUTOTABPLACEMENT
};

enum RowDirection {
Expand Down

0 comments on commit ea466fa

Please sign in to comment.