aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2016-09-03 20:57:21 (GMT)
committerThomas Lübking <thomas.luebking@gmail.com>2016-09-03 22:09:40 (GMT)
commita2fc845d50e245ab3aa9f44d2ea8c559eaa1adbe (patch)
treeba31e5ca3e3f806fc0d479e731e52e54ce1c4d7b
parent36993a80f4a246456429932abf596f2d2ef4b89d (diff)
downloadfluxbox-a2fc845d50e245ab3aa9f44d2ea8c559eaa1adbe.zip
fluxbox-a2fc845d50e245ab3aa9f44d2ea8c559eaa1adbe.tar.bz2
Next|PrevWorkspace 0 toggles former Workspace
REQUEST: 185 also PATCH 92
-rw-r--r--doc/asciidoc/fluxbox-keys.txt2
-rw-r--r--src/Screen.cc15
-rw-r--r--src/Screen.hh1
-rw-r--r--src/WorkspaceCmd.cc10
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).
359 offset value 'n', which defaults to *1* and refers to the number of 359 offset value 'n', which defaults to *1* and refers to the number of
360 workspaces to move at one time. {Next,Prev}Workspace wrap around when 360 workspaces to move at one time. {Next,Prev}Workspace wrap around when
361 going past the last workspace, whereas {Right,Left}Workspace do not. 361 going past the last workspace, whereas {Right,Left}Workspace do not.
362 The special offset "0" will toggle the former workspace for Next- and
363 PrevWorkspace
362 364
363*Workspace* 'number':: 365*Workspace* 'number'::
364 Jumps to the given workspace 'number'. The first workspace is *1*. 366 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,
194 m_layermanager(num_layers), 194 m_layermanager(num_layers),
195 root_colormap_installed(false), 195 root_colormap_installed(false),
196 m_current_workspace(0), 196 m_current_workspace(0),
197 m_former_workspace(0),
197 m_focused_windowtheme(new FbWinFrameTheme(scrn, ".focus", ".Focus")), 198 m_focused_windowtheme(new FbWinFrameTheme(scrn, ".focus", ".Focus")),
198 m_unfocused_windowtheme(new FbWinFrameTheme(scrn, ".unfocus", ".Unfocus")), 199 m_unfocused_windowtheme(new FbWinFrameTheme(scrn, ".unfocus", ".Unfocus")),
199 // the order of windowtheme and winbutton theme is important 200 // the order of windowtheme and winbutton theme is important
@@ -919,6 +920,8 @@ int BScreen::removeLastWorkspace() {
919 920
920 if (m_current_workspace->workspaceID() == wkspc->workspaceID()) 921 if (m_current_workspace->workspaceID() == wkspc->workspaceID())
921 changeWorkspaceID(m_current_workspace->workspaceID() - 1); 922 changeWorkspaceID(m_current_workspace->workspaceID() - 1);
923 if (m_former_workspace && m_former_workspace->workspaceID() == wkspc->workspaceID())
924 m_former_workspace = 0;
922 925
923 wkspc->removeAll(wkspc->workspaceID()-1); 926 wkspc->removeAll(wkspc->workspaceID()-1);
924 927
@@ -950,6 +953,8 @@ void BScreen::changeWorkspaceID(unsigned int id, bool revert) {
950 id == m_current_workspace->workspaceID()) 953 id == m_current_workspace->workspaceID())
951 return; 954 return;
952 955
956 m_former_workspace = m_current_workspace;
957
953 /* Ignore all EnterNotify events until the pointer actually moves */ 958 /* Ignore all EnterNotify events until the pointer actually moves */
954 this->focusControl().ignoreAtPointer(); 959 this->focusControl().ignoreAtPointer();
955 960
@@ -1524,14 +1529,20 @@ void BScreen::setLayer(FbTk::LayerItem &item, int layernum) {
1524 Goes to the workspace "right" of the current 1529 Goes to the workspace "right" of the current
1525*/ 1530*/
1526void BScreen::nextWorkspace(int delta) { 1531void BScreen::nextWorkspace(int delta) {
1527 changeWorkspaceID( (currentWorkspaceID() + delta) % numberOfWorkspaces()); 1532 if (delta)
1533 changeWorkspaceID( (currentWorkspaceID() + delta) % numberOfWorkspaces());
1534 else if (m_former_workspace)
1535 changeWorkspaceID(m_former_workspace->workspaceID());
1528} 1536}
1529 1537
1530/** 1538/**
1531 Goes to the workspace "left" of the current 1539 Goes to the workspace "left" of the current
1532*/ 1540*/
1533void BScreen::prevWorkspace(int delta) { 1541void BScreen::prevWorkspace(int delta) {
1534 changeWorkspaceID( (static_cast<signed>(numberOfWorkspaces()) + currentWorkspaceID() - (delta % numberOfWorkspaces())) % numberOfWorkspaces()); 1542 if (delta)
1543 changeWorkspaceID( (static_cast<signed>(numberOfWorkspaces()) + currentWorkspaceID() - (delta % numberOfWorkspaces())) % numberOfWorkspaces());
1544 else if (m_former_workspace)
1545 changeWorkspaceID(m_former_workspace->workspaceID());
1535} 1546}
1536 1547
1537/** 1548/**
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:
502 std::unique_ptr<ToolButtonMap> m_toolButtonMap; 502 std::unique_ptr<ToolButtonMap> m_toolButtonMap;
503 503
504 Workspace *m_current_workspace; 504 Workspace *m_current_workspace;
505 Workspace *m_former_workspace;
505 506
506 WorkspaceNames m_workspace_names; 507 WorkspaceNames m_workspace_names;
507 Workspaces m_workspaces_list; 508 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);
357} // end anonymous namespace 357} // end anonymous namespace
358 358
359void NextWorkspaceCmd::execute() { 359void NextWorkspaceCmd::execute() {
360 BScreen *screen = Fluxbox::instance()->mouseScreen(); 360 if (BScreen *screen = Fluxbox::instance()->mouseScreen())
361 if (screen != 0) 361 screen->nextWorkspace(m_option);
362 screen->nextWorkspace(m_option == 0 ? 1 : m_option);
363} 362}
364 363
365void PrevWorkspaceCmd::execute() { 364void PrevWorkspaceCmd::execute() {
366 BScreen *screen = Fluxbox::instance()->mouseScreen(); 365 if (BScreen *screen = Fluxbox::instance()->mouseScreen())
367 if (screen != 0) 366 screen->prevWorkspace(m_option);
368 screen->prevWorkspace(m_option == 0 ? 1 : m_option);
369} 367}
370 368
371void LeftWorkspaceCmd::execute() { 369void LeftWorkspaceCmd::execute() {