Next|PrevWorkspace 0 toggles former Workspace

REQUEST: 185
also PATCH 92
This commit is contained in:
Thomas Lübking 2016-09-03 22:57:21 +02:00
parent 36993a80f4
commit a2fc845d50
4 changed files with 20 additions and 8 deletions

View file

@ -359,6 +359,8 @@ called).
offset value 'n', which defaults to *1* and refers to the number of
workspaces to move at one time. {Next,Prev}Workspace wrap around when
going past the last workspace, whereas {Right,Left}Workspace do not.
The special offset "0" will toggle the former workspace for Next- and
PrevWorkspace
*Workspace* 'number'::
Jumps to the given workspace 'number'. The first workspace is *1*.

View file

@ -194,6 +194,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
m_layermanager(num_layers),
root_colormap_installed(false),
m_current_workspace(0),
m_former_workspace(0),
m_focused_windowtheme(new FbWinFrameTheme(scrn, ".focus", ".Focus")),
m_unfocused_windowtheme(new FbWinFrameTheme(scrn, ".unfocus", ".Unfocus")),
// the order of windowtheme and winbutton theme is important
@ -919,6 +920,8 @@ int BScreen::removeLastWorkspace() {
if (m_current_workspace->workspaceID() == wkspc->workspaceID())
changeWorkspaceID(m_current_workspace->workspaceID() - 1);
if (m_former_workspace && m_former_workspace->workspaceID() == wkspc->workspaceID())
m_former_workspace = 0;
wkspc->removeAll(wkspc->workspaceID()-1);
@ -950,6 +953,8 @@ void BScreen::changeWorkspaceID(unsigned int id, bool revert) {
id == m_current_workspace->workspaceID())
return;
m_former_workspace = m_current_workspace;
/* Ignore all EnterNotify events until the pointer actually moves */
this->focusControl().ignoreAtPointer();
@ -1524,14 +1529,20 @@ void BScreen::setLayer(FbTk::LayerItem &item, int layernum) {
Goes to the workspace "right" of the current
*/
void BScreen::nextWorkspace(int delta) {
changeWorkspaceID( (currentWorkspaceID() + delta) % numberOfWorkspaces());
if (delta)
changeWorkspaceID( (currentWorkspaceID() + delta) % numberOfWorkspaces());
else if (m_former_workspace)
changeWorkspaceID(m_former_workspace->workspaceID());
}
/**
Goes to the workspace "left" of the current
*/
void BScreen::prevWorkspace(int delta) {
changeWorkspaceID( (static_cast<signed>(numberOfWorkspaces()) + currentWorkspaceID() - (delta % numberOfWorkspaces())) % numberOfWorkspaces());
if (delta)
changeWorkspaceID( (static_cast<signed>(numberOfWorkspaces()) + currentWorkspaceID() - (delta % numberOfWorkspaces())) % numberOfWorkspaces());
else if (m_former_workspace)
changeWorkspaceID(m_former_workspace->workspaceID());
}
/**

View file

@ -502,6 +502,7 @@ private:
std::unique_ptr<ToolButtonMap> m_toolButtonMap;
Workspace *m_current_workspace;
Workspace *m_former_workspace;
WorkspaceNames m_workspace_names;
Workspaces m_workspaces_list;

View file

@ -357,15 +357,13 @@ REGISTER_COMMAND_PARSER(workspace, parseIntCmd, void);
} // end anonymous namespace
void NextWorkspaceCmd::execute() {
BScreen *screen = Fluxbox::instance()->mouseScreen();
if (screen != 0)
screen->nextWorkspace(m_option == 0 ? 1 : m_option);
if (BScreen *screen = Fluxbox::instance()->mouseScreen())
screen->nextWorkspace(m_option);
}
void PrevWorkspaceCmd::execute() {
BScreen *screen = Fluxbox::instance()->mouseScreen();
if (screen != 0)
screen->prevWorkspace(m_option == 0 ? 1 : m_option);
if (BScreen *screen = Fluxbox::instance()->mouseScreen())
screen->prevWorkspace(m_option);
}
void LeftWorkspaceCmd::execute() {