howm
howm
monitor.c File Reference

A monitor stores workspaces. The user can have multiple monitors. More...

#include <stdlib.h>
#include <xcb/randr.h>
#include "monitor.h"
#include "helper.h"
#include "howm.h"
#include "workspace.h"
#include "xcb_help.h"

Functions

monitor_tcreate_monitor (xcb_rectangle_t rect)
 Allocate memory for a monitor and update global state. More...
 
void remove_monitor (monitor_t *m)
 Remove a monitor and all of its workspaces. More...
 
void focus_monitor (monitor_t *m)
 Set a monitor as the focused monitor. More...
 
uint32_t monitor_to_index (const monitor_t *m)
 Find and return a monitor's index in the monitor list. More...
 
monitor_tindex_to_monitor (uint32_t index)
 Convert a monitor's index in a monitor list to an index. More...
 
static void scan_x11_monitor (void)
 Create a single monitor for use with default X11. More...
 
static bool scan_xrandr_monitors (void)
 Detect and initialise monitors for each Xrandr output. More...
 
static monitor_trandr_output_to_monitor (xcb_randr_output_t output)
 Convert an xcb output to a monitor. More...
 
monitor_tpoint_to_monitor (xcb_point_t point)
 Convert a point to a monitor that it is within. More...
 
void scan_monitors (void)
 Initialise a monitor for each supported screen. More...
 

Detailed Description

A monitor stores workspaces. The user can have multiple monitors.

Author
Harvey Hunt
Date
2015

Function Documentation

monitor_t* create_monitor ( xcb_rectangle_t  rect)

Allocate memory for a monitor and update global state.

Parameters
rectA rectangle representing the size of the monitor.
Returns
An initialised monitor.
void focus_monitor ( monitor_t m)

Set a monitor as the focused monitor.

Parameters
mThe monitor to be focused.
monitor_t* index_to_monitor ( uint32_t  index)

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

Parameters
indexThe index to search for.
Returns
The monitor stored at the index of the monitors list.
uint32_t monitor_to_index ( const monitor_t m)

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

Parameters
mThe monitor to search for.
Returns
The index of the monitor in the monitor list.
monitor_t* point_to_monitor ( xcb_point_t  point)

Convert a point to a monitor that it is within.

Parameters
pointThe point to be converted to a monitor.
Returns
The monitor containing the point, or NULL.
static monitor_t* randr_output_to_monitor ( xcb_randr_output_t  output)
static

Convert an xcb output to a monitor.

Parameters
outputThe xcb output to be searched for.
Returns
The monitor with an xcb output id matching the param.
void remove_monitor ( monitor_t m)

Remove a monitor and all of its workspaces.

Parameters
mThe monitor to be removed.
void scan_monitors ( void  )

Initialise a monitor for each supported screen.

static void scan_x11_monitor ( void  )
static

Create a single monitor for use with default X11.

static bool scan_xrandr_monitors ( void  )
static

Detect and initialise monitors for each Xrandr output.

We loop through outputs and then go "backwards" to find their CRTCs. This means we can skip CRTCs with no outputs.

XXX: I was sleep deprived when I wrote this, so I can imagine there being lots of memory leaks etc...

Returns
True if Xrandr is detected and monitors are created.