diff options
author | John Ankarstr\xf6m <john@ankarstrom.se> | 2021-05-29 13:58:38 +0200 |
---|---|---|
committer | John Ankarstr\xf6m <john@ankarstrom.se> | 2021-05-29 13:58:38 +0200 |
commit | 1ab9d314968f84e5b7e6530424cf08017de1f3ae (patch) | |
tree | 8dbc526b126203391bae5083a4c9fcfa0d708450 | |
parent | d2c39c274907aef944ab47447c3515d1552d13e2 (diff) | |
download | jwm-1ab9d314968f84e5b7e6530424cf08017de1f3ae.tar.gz |
Implement 'prev' and 'prevstacked' actions
-rw-r--r-- | src/event.c | 6 | ||||
-rw-r--r-- | src/key.c | 2 | ||||
-rw-r--r-- | src/key.h | 26 | ||||
-rw-r--r-- | src/parse.c | 2 | ||||
-rw-r--r-- | src/taskbar.c | 65 | ||||
-rw-r--r-- | src/taskbar.h | 3 |
6 files changed, 92 insertions, 12 deletions
diff --git a/src/event.c b/src/event.c index 3c4f0bb..4918401 100644 --- a/src/event.c +++ b/src/event.c @@ -360,6 +360,12 @@ void HandleKeyPress(const XKeyEvent *event) { case KEY_NEXT_STACKED: FocusNextStackedCircular(); break; + case KEY_PREV: + FocusPrevious(); + break; + case KEY_PREV_STACKED: + FocusPreviousStackedCircular(); + break; case KEY_CLOSE: if(np) { DeleteClient(np); @@ -242,6 +242,8 @@ int ShouldGrab(KeyType key) { switch(key & 0xFF) { case KEY_NEXT: case KEY_NEXT_STACKED: + case KEY_PREV: + case KEY_PREV_STACKED: case KEY_CLOSE: case KEY_MIN: case KEY_MAX: @@ -22,18 +22,20 @@ typedef enum { KEY_ENTER = 6, KEY_NEXT = 7, KEY_NEXT_STACKED = 8, - KEY_CLOSE = 9, - KEY_MIN = 10, - KEY_MAX = 11, - KEY_SHADE = 12, - KEY_MOVE = 13, - KEY_RESIZE = 14, - KEY_ROOT = 15, - KEY_WIN = 16, - KEY_DESKTOP = 17, - KEY_EXEC = 18, - KEY_RESTART = 19, - KEY_EXIT = 20 + KEY_PREV = 9, + KEY_PREV_STACKED = 10, + KEY_CLOSE = 11, + KEY_MIN = 12, + KEY_MAX = 13, + KEY_SHADE = 14, + KEY_MOVE = 15, + KEY_RESIZE = 16, + KEY_ROOT = 17, + KEY_WIN = 18, + KEY_DESKTOP = 19, + KEY_EXEC = 20, + KEY_RESTART = 21, + KEY_EXIT = 22 } KeyType; void InitializeKeys(); diff --git a/src/parse.c b/src/parse.c index 5dd82af..023ae23 100644 --- a/src/parse.c +++ b/src/parse.c @@ -49,6 +49,8 @@ static const KeyMapType KEY_MAP[] = { { "select", KEY_ENTER }, { "next", KEY_NEXT }, { "nextstacked", KEY_NEXT_STACKED }, + { "prev", KEY_PREV }, + { "prevstacked", KEY_PREV_STACKED }, { "close", KEY_CLOSE }, { "minimize", KEY_MIN }, { "maximize", KEY_MAX }, diff --git a/src/taskbar.c b/src/taskbar.c index f8ab13c..c553652 100644 --- a/src/taskbar.c +++ b/src/taskbar.c @@ -701,6 +701,71 @@ void FocusNextStackedCircular() { /*************************************************************************** ***************************************************************************/ +void FocusPreviousStackedCircular() { + + ClientNode *ac; + ClientNode *np; + int x; + + ac = GetActiveClient(); + np = NULL; + + /* Check for a valid client below this client in the same layer. */ + if(ac) { + for(np = ac->prev; np; np = np->prev) { + if(ShouldFocusItem(np)) { + break; + } + } + } + + /* Check for a valid client in upper layers. */ + if(ac && !np) { + for(x = ac->state.layer + 1; x <= LAYER_TOP; x++) { + for(np = nodes[x]; np; np = np->next) { + if(!np->next) { + break; + } + } + for(; np; np = np->prev) { + if(ShouldFocusItem(np)) { + break; + } + } + if(np) { + break; + } + } + } + + + /* Revert to the bottom-most valid client. */ + if(!np) { + for(x = LAYER_BOTTOM; x <= LAYER_TOP; x++) { + for(np = nodes[x]; np; np = np->next) { + if(!np->next) { + break; + } + } + for(; np; np = np->prev) { + if(ShouldFocusItem(np)) { + break; + } + } + if(np) { + break; + } + } + } + + if(np) { + FocusClient(np); + } +} + + +/*************************************************************************** + ***************************************************************************/ Node *GetNode(TaskBarType *bar, int x) { Node *tp; diff --git a/src/taskbar.h b/src/taskbar.h index e65600f..1ac330d 100644 --- a/src/taskbar.h +++ b/src/taskbar.h @@ -46,6 +46,9 @@ void FocusPrevious(); /** Focus the next stacked client. */ void FocusNextStackedCircular(); +/** Focus the previous stacked client. */ +void FocusPreviousStackedCircular(); + /** Set the maximum width of task bar items. * @param cp The task bar component. * @param value The maximum width. |