howm
howm
workspace.c File Reference

Helper functions for dealing with an entire workspace or being able to correctly calculate a workspace index. More...

#include <xcb/xcb_ewmh.h>
#include <xcb/xproto.h>
#include "client.h"
#include "helper.h"
#include "howm.h"
#include "monitor.h"
#include "types.h"
#include "workspace.h"
#include "xcb_help.h"

Functions

void kill_ws (monitor_t *m, workspace_t *ws)
 Kills the given workspace. More...
 
int correct_ws (unsigned int ws)
 Correctly wrap a workspace number. More...
 
workspace_toffset_ws (workspace_t *ws, int offset)
 Return a workspace after offsetting. More...
 
void focus_prev_ws (void)
 Focus the previous workspace. More...
 
void focus_last_ws (void)
 Focus the last focused workspace. More...
 
void focus_next_ws (void)
 Focus the next workspace. More...
 
void change_ws (const workspace_t *ws)
 Change to a different workspace and map the correct windows. More...
 
uint32_t workspace_to_index (const workspace_t *ws)
 Find and return a workspace's index in the workspace list. More...
 
workspace_tindex_to_workspace (const monitor_t *m, uint32_t index)
 Convert a workspace's index in a workspace list to an index. More...
 
void add_ws (monitor_t *m)
 Create a new workspace and update global state. More...
 
void remove_ws (monitor_t *m, workspace_t *ws)
 Remove a workspace and update the global state. More...
 

Detailed Description

Helper functions for dealing with an entire workspace or being able to correctly calculate a workspace index.

Author
Harvey Hunt
Date
2015

Function Documentation

void add_ws ( monitor_t m)

Create a new workspace and update global state.

Parameters
mThe monitor that the workspace should be added on.
int correct_ws ( unsigned int  ws)
inline

Correctly wrap a workspace number.

This prevents workspace numbers from being greater than workspace_cnt or less than 1.

Parameters
wsThe value that needs to be corrected.
Returns
A corrected workspace number.
workspace_t* index_to_workspace ( const monitor_t m,
uint32_t  index 
)

Convert a workspace's index in a workspace list to an index.

Parameters
mThe monitor to search for the workspace on.
indexThe index to search for.
Returns
The workspace stored at the index of the workspaces list.
void kill_ws ( monitor_t m,
workspace_t ws 
)

Kills the given workspace.

Parameters
mThe monitor that the workspace to be killed is on.
wsThe workspace to be killed.
workspace_t* offset_ws ( workspace_t ws,
int  offset 
)
inline

Return a workspace after offsetting.

Use this to safely traverse the workspace list - instead of doing:

 ws->next->next

do:

 offset_ws(ws, 2)
Parameters
wsThe workspace to be offset from.
offsetThe offset to apply
Returns
The workspace at ws+offset.
void remove_ws ( monitor_t m,
workspace_t ws 
)

Remove a workspace and update the global state.

Parameters
mThe monitor that the workspace is on.
wsThe workspace to be removed.
uint32_t workspace_to_index ( const workspace_t ws)

Find and return a workspace's index in the workspace list.

Parameters
wsThe workspace to search for.
Returns
The index of the workspace in the workspace list.