From a2fc845d50e245ab3aa9f44d2ea8c559eaa1adbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sat, 3 Sep 2016 22:57:21 +0200 Subject: Next|PrevWorkspace 0 toggles former Workspace REQUEST: 185 also PATCH 92 --- doc/asciidoc/fluxbox-keys.txt | 2 ++ src/Screen.cc | 15 +++++++++++++-- src/Screen.hh | 1 + src/WorkspaceCmd.cc | 10 ++++------ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/doc/asciidoc/fluxbox-keys.txt b/doc/asciidoc/fluxbox-keys.txt index 52037ab..b7ae264 100644 --- a/doc/asciidoc/fluxbox-keys.txt +++ b/doc/asciidoc/fluxbox-keys.txt @@ -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*. diff --git a/src/Screen.cc b/src/Screen.cc index c24250a..17d8c23 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -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(numberOfWorkspaces()) + currentWorkspaceID() - (delta % numberOfWorkspaces())) % numberOfWorkspaces()); + if (delta) + changeWorkspaceID( (static_cast(numberOfWorkspaces()) + currentWorkspaceID() - (delta % numberOfWorkspaces())) % numberOfWorkspaces()); + else if (m_former_workspace) + changeWorkspaceID(m_former_workspace->workspaceID()); } /** diff --git a/src/Screen.hh b/src/Screen.hh index 30228ee..30fbb4a 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -502,6 +502,7 @@ private: std::unique_ptr m_toolButtonMap; Workspace *m_current_workspace; + Workspace *m_former_workspace; WorkspaceNames m_workspace_names; Workspaces m_workspaces_list; diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc index 3a1a3b4..bca56c6 100644 --- a/src/WorkspaceCmd.cc +++ b/src/WorkspaceCmd.cc @@ -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() { -- cgit v0.11.2