From 940dabfe598c3788a9cfec59470c72a4dbb83ebf Mon Sep 17 00:00:00 2001 From: Scott Moynes Date: Tue, 31 Dec 2002 22:52:06 +0000 Subject: [PATCH] Added sendToNext/PrevWorkspace to send the active window to next/previous workspace. Takes a boolean parameter for whether to change workspaces as well. --- util/epist/actions.cc | 20 ++++++++++++++++++++ util/epist/actions.hh | 2 ++ util/epist/epistrc.5.in | 4 ++++ util/epist/parser.cc | 2 ++ util/epist/screen.cc | 24 +++++++++++++++++++++++- util/epist/screen.hh | 2 ++ util/epist/window.cc | 1 - 7 files changed, 53 insertions(+), 2 deletions(-) diff --git a/util/epist/actions.cc b/util/epist/actions.cc index e37ff247..86619af7 100644 --- a/util/epist/actions.cc +++ b/util/epist/actions.cc @@ -37,12 +37,32 @@ Action::Action(enum ActionType type, KeyCode keycode, unsigned int modifierMask, noaction }; + ActionType bool_types[] = { + sendToNextWorkspace, + sendToPrevWorkspace, + noaction + }; + for (int i = 0; str_types[i] != noaction; ++i) { if (type == str_types[i]) { _stringParam = str; return; } } + + for (int i = 0; bool_types[i] != noaction; ++i) { + if (type == bool_types[i]) { + const char *tmp = str.c_str(); + + + if (strcasecmp(tmp, "true") == 0 || strcasecmp(tmp, "1") == 0 || + strcasecmp(tmp, "on") == 0) + _numberParam = 1; + else + _numberParam = 0; + return; + } + } _numberParam = atoi( str.c_str() ); diff --git a/util/epist/actions.hh b/util/epist/actions.hh index ac6d62b5..78ab1007 100644 --- a/util/epist/actions.hh +++ b/util/epist/actions.hh @@ -53,6 +53,8 @@ public: toggleMaximizeHorizontal, //done sendToWorkspace, //done + sendToNextWorkspace, + sendToPrevWorkspace, nextWindow, //done for now prevWindow, //done for now diff --git a/util/epist/epistrc.5.in b/util/epist/epistrc.5.in index 06615768..e05e93cb 100644 --- a/util/epist/epistrc.5.in +++ b/util/epist/epistrc.5.in @@ -120,6 +120,10 @@ Maximizes and Unmaxizes the currently focused window horizontally. Sends the currently focused window to another workspace. This takes a single numberical parameter, which is the workspace to send the window to. Workspace numbers begin at 1. +.SS sendToNextWorkspace +.SS sendToPrevWorkspace +Sends the currently focused window to the next/previous workspace. Takes +boolean parameter that when true switches to that workspace as well. .SS nextWindow .SS prevWindow Cycles focus to the next/previous window on the workspace. This can take a diff --git a/util/epist/parser.cc b/util/epist/parser.cc index f6ed589e..c1b2ff83 100644 --- a/util/epist/parser.cc +++ b/util/epist/parser.cc @@ -102,6 +102,8 @@ void parser::setAction(string act) { "togglemaximizevertical", Action::toggleMaximizeVertical }, { "togglemaximizehorizontal", Action::toggleMaximizeHorizontal }, { "sendtoworkspace", Action::sendToWorkspace }, + { "sendtonextworkspace", Action::sendToNextWorkspace }, + { "sendtoprevworkspace", Action::sendToPrevWorkspace }, { "nextwindow", Action::nextWindow }, { "prevwindow", Action::prevWindow }, { "nextwindowonallworkspaces", Action::nextWindowOnAllWorkspaces }, diff --git a/util/epist/screen.cc b/util/epist/screen.cc index 63b9578d..f15b43f0 100644 --- a/util/epist/screen.cc +++ b/util/epist/screen.cc @@ -320,7 +320,15 @@ void screen::handleKeypress(const XEvent &e) { case Action::sendToWorkspace: window->sendTo(it->number()); return; + + case Action::sendToNextWorkspace: + sendToNextWorkspace(*window, true, (it->number() != 0)); + return; + case Action::sendToPrevWorkspace: + sendToNextWorkspace(*window, false, (it->number() != 0)); + return; + case Action::toggleOmnipresent: if (window->desktop() == 0xffffffff) window->sendTo(_active_desktop); @@ -694,7 +702,6 @@ void screen::cycleWorkspace(const bool forward, const int increment, changeWorkspace(destination); } - void screen::changeWorkspace(const int num) const { assert(_managed); @@ -766,6 +773,21 @@ void screen::changeWorkspaceHorz(const int num) const { changeWorkspace(wnum); } + void screen::sendToNextWorkspace(const XWindow &window, bool forward, + bool follow) const { + assert(_managed); + int dest = (signed) _active_desktop + (forward ? 1 : -1 ); + + if (dest >= (signed)_num_desktops) + dest = 0; + else if ( dest < 0) + dest = _num_desktops - 1; + + window.sendTo(dest); + if (follow) + changeWorkspace(dest); + } + void screen::grabKey(const KeyCode keyCode, const int modifierMask) const { Display *display = _epist->getXDisplay(); diff --git a/util/epist/screen.hh b/util/epist/screen.hh index f0f3de07..c9907b36 100644 --- a/util/epist/screen.hh +++ b/util/epist/screen.hh @@ -97,6 +97,8 @@ public: void changeWorkspaceVert(const int num) const; void changeWorkspaceHorz(const int num) const; + void sendToNextWorkspace(const XWindow& win, bool forward, + bool follow) const; void toggleShaded(const Window win) const; void execCommand(const std::string &cmd) const; diff --git a/util/epist/window.cc b/util/epist/window.cc index 6b3f2f5f..127ca3ef 100644 --- a/util/epist/window.cc +++ b/util/epist/window.cc @@ -279,7 +279,6 @@ void XWindow::sendTo(unsigned int dest) const { _window, dest); } - void XWindow::move(int x, int y) const { // get the window's decoration sizes (margins) Strut margins; -- 2.34.1