All pastes #1923220 Raw Edit

Something

public diff v1 · immutable
#1923220 ·published 2010-08-23 09:57 UTC
rendered paste body
From 14043c52e4cd2a3bd4ef921213c7feaa125b8fce Mon Sep 17 00:00:00 2001From: Matthew Kern <polypolyman@ibiblio.org>Date: Mon, 23 Aug 2010 05:38:15 -0400Subject: Changes screen config option .workspaces to .workspacerows and .workspacecols, and adds UpWorkspace and DownWorkspace functions--- src/Screen.cc       |   29 +++++++++++++++++++++++------ src/Screen.hh       |   19 ++++++++++++++++--- src/WorkspaceCmd.cc |   18 ++++++++++++++++++ src/WorkspaceCmd.hh |   16 ++++++++++++++++ 4 files changed, 73 insertions(+), 9 deletions(-)diff --git a/src/Screen.cc b/src/Screen.ccindex eab0f59..ac2314b 100644--- a/src/Screen.cc+++ b/src/Screen.cc@@ -303,7 +303,8 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,     tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"),     windowmenufile(rm, Fluxbox::instance()->getDefaultDataFilename("windowmenu"), scrname+".windowMenu", altscrname+".WindowMenu"),     typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay", altscrname+".NoFocusWhileTypingDelay"),-    workspaces(rm, 4, scrname+".workspaces", altscrname+".Workspaces"),+    workspacerows(rm, 2, scrname+".workspacerows", altscrname+".WorkspaceRows"),+    workspacecols(rm, 2, scrname+".workspacecols", altscrname+".WorkspaceCols"),     edge_snap_threshold(rm, 10, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"),     focused_alpha(rm, 255, scrname+".window.focus.alpha", altscrname+".Window.Focus.Alpha"),     unfocused_alpha(rm, 255, scrname+".window.unfocus.alpha", altscrname+".Window.Unfocus.Alpha"),@@ -473,7 +474,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm,     fluxbox->load_rc(*this);      // setup workspaces and workspace menu-    int nr_ws = *resource.workspaces;+    int nr_ws = *resource.workspacerows * *resource.workspacecols;     addWorkspace(); // at least one     for (int i = 1; i < nr_ws; ++i) {         addWorkspace();@@ -914,7 +915,7 @@ void BScreen::reconfigure() {     m_menutheme->setDelay(*resource.menu_delay);      // realize the number of workspaces from the init-file-    const unsigned int nr_ws = *resource.workspaces;+    const unsigned int nr_ws = *resource.workspacerows * *resource.workspacecols;     if (nr_ws > m_workspaces_list.size()) {         while(nr_ws != m_workspaces_list.size()) {             addWorkspace();@@ -1824,14 +1825,14 @@ void BScreen::setLayer(FbTk::XLayerItem &item, int layernum) {   /**- Goes to the workspace "right" of the current+ Goes to the workspace next sequentially */ void BScreen::nextWorkspace(const int delta) {     changeWorkspaceID( (currentWorkspaceID() + delta) % numberOfWorkspaces()); }  /**- Goes to the workspace "left" of the current+ Goes to the workspace previous sequentially */ void BScreen::prevWorkspace(const int delta) {     changeWorkspaceID( (static_cast<signed>(numberOfWorkspaces()) + currentWorkspaceID() - (delta % numberOfWorkspaces())) % numberOfWorkspaces());@@ -1841,7 +1842,7 @@ void BScreen::prevWorkspace(const int delta) {  Goes to the workspace "right" of the current */ void BScreen::rightWorkspace(const int delta) {-    if (currentWorkspaceID()+delta < numberOfWorkspaces())+    if ((currentWorkspaceID() % getWorkspaceCols())+delta < getWorkspaceCols())         changeWorkspaceID(currentWorkspaceID()+delta); } @@ -1853,6 +1854,22 @@ void BScreen::leftWorkspace(const int delta) {         changeWorkspaceID(currentWorkspaceID()-delta); } +/**+ Goes to the workspace "above" the current+*/+void BScreen::downWorkspace(const int delta) {+    if (((currentWorkspaceID() - (currentWorkspaceID() % getWorkspaceCols()))/getWorkspaceCols()) >= static_cast<unsigned int>(delta))+        changeWorkspaceID(currentWorkspaceID()-(delta*getWorkspaceCols()));+}++/**+ Goes to the workspace "below" the current+*/+void BScreen::upWorkspace(const int delta) {+    if (((currentWorkspaceID() - (currentWorkspaceID() % getWorkspaceCols()))/getWorkspaceCols())+delta < getWorkspaceRows())+        changeWorkspaceID(currentWorkspaceID()+(delta*getWorkspaceCols()));+}+  void BScreen::renderGeomWindow() { diff --git a/src/Screen.hh b/src/Screen.hhindex 2267d86..464d269 100644--- a/src/Screen.hh+++ b/src/Screen.hh@@ -98,7 +98,9 @@ public:      void initWindows();     void initMenus();-+    +    int getWorkspaceRows() const { return *resource.workspacerows; }+    int getWorkspaceCols() const { return *resource.workspacecols; }     bool isRootColormapInstalled() const { return root_colormap_installed; }     bool isScreenManaged() const { return managed; }     bool isWorkspaceWarping() const { return *resource.workspace_warping; }@@ -263,7 +265,7 @@ public:      void saveTabPlacement(FbWinFrame::TabPlacement place) { *resource.tab_placement = place; } -    void saveWorkspaces(int w) { *resource.workspaces = w;  }+    void saveWorkspaces(int w) { *resource.workspacecols = w; *resource.workspacerows = 1;  }      FbTk::ThemeProxy<FbWinFrameTheme> &focusedWinFrameTheme() { return *m_focused_windowtheme.get(); }     const FbTk::ThemeProxy<FbWinFrameTheme> &focusedWinFrameTheme() const { return *m_focused_windowtheme.get(); }@@ -326,6 +328,17 @@ public:      * @param delta number of steps to jump      */     void leftWorkspace(int delta);+    /**+     * Jump up to a workspace+     * @param delta number of steps to jump+     */+    void upWorkspace(int delta);+    /**+     * Jump down to a workspace+     * @param delta number of steps to jump+     */+    void downWorkspace(int delta);+      /// update workspace name for given workspace     void updateWorkspaceName(unsigned int w);@@ -544,7 +557,7 @@ private:         FbTk::Resource<FbWinFrame::TabPlacement> tab_placement;         FbTk::Resource<std::string> windowmenufile;         FbTk::Resource<unsigned int> typing_delay;-        FbTk::Resource<int> workspaces, edge_snap_threshold, focused_alpha,+        FbTk::Resource<int> workspacerows, workspacecols, edge_snap_threshold, focused_alpha,             unfocused_alpha, menu_alpha, menu_delay,             tab_width, tooltip_delay;         FbTk::Resource<bool> allow_remote_actions;diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.ccindex d72ef13..94d971f 100644--- a/src/WorkspaceCmd.cc+++ b/src/WorkspaceCmd.cc@@ -306,6 +306,10 @@ FbTk::Command<void> *parseIntCmd(const string &command, const string &args,         return new RightWorkspaceCmd(num);     else if (command == "leftworkspace")         return new LeftWorkspaceCmd(num);+    else if (command == "upworkspace")+	return new UpWorkspaceCmd(num);+    else if (command == "downworkspace")+	return new DownWorkspaceCmd(num);     else if (command == "workspace")         // workspaces appear 1-indexed to the user, hence the minus 1         return new JumpToWorkspaceCmd(num - 1);@@ -316,6 +320,8 @@ REGISTER_COMMAND_PARSER(nextworkspace, parseIntCmd, void); REGISTER_COMMAND_PARSER(prevworkspace, parseIntCmd, void); REGISTER_COMMAND_PARSER(rightworkspace, parseIntCmd, void); REGISTER_COMMAND_PARSER(leftworkspace, parseIntCmd, void);+REGISTER_COMMAND_PARSER(upworkspace, parseIntCmd, void);+REGISTER_COMMAND_PARSER(downworkspace, parseIntCmd, void); REGISTER_COMMAND_PARSER(workspace, parseIntCmd, void);  } // end anonymous namespace@@ -344,6 +350,18 @@ void RightWorkspaceCmd::execute() {         screen->rightWorkspace(m_param); } +void UpWorkspaceCmd::execute() {+    BScreen *screen = Fluxbox::instance()->mouseScreen();+    if (screen != 0)+        screen->upWorkspace(m_param);+}++void DownWorkspaceCmd::execute() {+    BScreen *screen = Fluxbox::instance()->mouseScreen();+    if (screen != 0)+        screen->downWorkspace(m_param);+}+ JumpToWorkspaceCmd::JumpToWorkspaceCmd(int workspace_num):m_workspace_num(workspace_num) { }  void JumpToWorkspaceCmd::execute() {diff --git a/src/WorkspaceCmd.hh b/src/WorkspaceCmd.hhindex ad63d04..3fbe404 100644--- a/src/WorkspaceCmd.hh+++ b/src/WorkspaceCmd.hh@@ -159,6 +159,22 @@ private:     const int m_param; }; +class UpWorkspaceCmd: public FbTk::Command<void> {+public:+    explicit UpWorkspaceCmd(int num=1):m_param(num == 0 ? 1 : num) { }+    void execute();+private:+    const int m_param;+};++class DownWorkspaceCmd: public FbTk::Command<void> {+public:+    explicit DownWorkspaceCmd(int num=1):m_param(num == 0 ? 1 : num) { }+    void execute();+private:+    const int m_param;+};+ class JumpToWorkspaceCmd: public FbTk::Command<void> { public:     explicit JumpToWorkspaceCmd(int workspace_num);-- 1.7.2