i3
Macros | Typedefs | Functions | Variables
randr.c File Reference
#include "all.h"
#include <time.h>
#include <xcb/randr.h>
Include dependency graph for randr.c:

Go to the source code of this file.

Macros

#define I3__FILE__   "randr.c"
#define WIN(variable, condition)

Typedefs

typedef
xcb_randr_get_crtc_info_reply_t 
crtc_info
typedef
xcb_randr_get_screen_resources_current_reply_t 
resources_reply

Functions

static Outputget_output_by_id (xcb_randr_output_t id)
Outputget_output_by_name (const char *name)
 Returns the output with the given name if it is active (!) or NULL.
Outputget_first_output (void)
 Returns the first output which is active.
Outputget_output_containing (int x, int y)
 Returns the active (!) output which contains the coordinates x, y or NULL if there is no output which contains these coordinates.
Outputget_output_most (direction_t direction, Output *current)
 Gets the output which is the last one in the given direction, for example the output on the most bottom when direction == D_DOWN, the output most right when direction == D_RIGHT and so on.
Outputget_output_next (direction_t direction, Output *current)
 Gets the output which is the next one in the given direction.
void disable_randr (xcb_connection_t *conn)
 Disables RandR support by creating exactly one output with the size of the X11 screen.
void output_init_con (Output *output)
 Initializes a CT_OUTPUT Con (searches existing ones from inplace restart before) to use for the given Output.
void init_ws_for_output (Output *output, Con *content)
 Initializes at least one workspace for this output, trying the following steps until there is at least one workspace:
static void output_change_mode (xcb_connection_t *conn, Output *output)
static void handle_output (xcb_connection_t *conn, xcb_randr_output_t id, xcb_randr_get_output_info_reply_t *output, xcb_timestamp_t cts, resources_reply *res)
void randr_query_outputs (void)
 Initializes the specified output, assigning the specified workspace to it.
void randr_init (int *event_base)
 We have just established a connection to the X server and need the initial XRandR information to setup workspaces for each screen.

Variables

xcb_randr_get_output_primary_reply_t * primary
struct outputs_head outputs = TAILQ_HEAD_INITIALIZER(outputs)
static bool randr_disabled = false

Macro Definition Documentation

#define I3__FILE__   "randr.c"

Definition at line 2 of file randr.c.

#define WIN (   variable,
  condition 
)
Value:
if (variable condition) { \
candidate = output; \
position = variable; \
} \
break;

Referenced by get_output_most().

Typedef Documentation

typedef xcb_randr_get_crtc_info_reply_t crtc_info

Definition at line 21 of file randr.c.

typedef xcb_randr_get_screen_resources_current_reply_t resources_reply

Definition at line 22 of file randr.c.

Function Documentation

void disable_randr ( xcb_connection_t *  conn)

Disables RandR support by creating exactly one output with the size of the X11 screen.

Definition at line 194 of file randr.c.

References xoutput::active, xoutput::con, DLOG, Rect::height, init_ws_for_output(), xoutput::name, output_get_content(), output_init_con(), outputs, randr_disabled, xoutput::rect, root_screen, scalloc(), TAILQ_INSERT_TAIL, Rect::width, Rect::x, and Rect::y.

Referenced by randr_init(), randr_query_outputs(), and xinerama_init().

Here is the call graph for this function:

Output* get_first_output ( void  )

Returns the first output which is active.

Definition at line 65 of file randr.c.

References xoutput::active, outputs, and TAILQ_FOREACH.

Referenced by main(), and randr_query_outputs().

static Output* get_output_by_id ( xcb_randr_output_t  id)
static

Definition at line 38 of file randr.c.

References xoutput::id, outputs, and TAILQ_FOREACH.

Referenced by handle_output().

Output* get_output_by_name ( const char *  name)

Returns the output with the given name if it is active (!) or NULL.

Definition at line 51 of file randr.c.

References xoutput::active, xoutput::name, outputs, and TAILQ_FOREACH.

Referenced by cmd_move_con_to_output(), get_output_from_string(), and init_ws_for_output().

Output* get_output_containing ( int  x,
int  y 
)

Returns the active (!) output which contains the coordinates x, y or NULL if there is no output which contains these coordinates.

Definition at line 80 of file randr.c.

References xoutput::active, DLOG, Rect::height, outputs, xoutput::rect, TAILQ_FOREACH, Rect::width, Rect::x, and Rect::y.

Referenced by _tree_next(), check_crossing_screen_boundary(), cmd_focus_output(), cmd_move_con_to_output(), cmd_move_workspace_to_output(), floating_enable(), floating_maybe_reassign_ws(), floating_reposition(), main(), manage_window(), and x_push_changes().

Output* get_output_most ( direction_t  direction,
Output current 
)

Gets the output which is the last one in the given direction, for example the output on the most bottom when direction == D_DOWN, the output most right when direction == D_RIGHT and so on.

This function always returns a output.

Definition at line 103 of file randr.c.

References xoutput::active, D_DOWN, D_LEFT, D_RIGHT, D_UP, outputs, xoutput::rect, TAILQ_FOREACH, WIN, Rect::x, and Rect::y.

Referenced by get_output_from_string().

Output* get_output_next ( direction_t  direction,
Output current 
)

Gets the output which is the next one in the given direction.

Definition at line 147 of file randr.c.

References xoutput::active, D_DOWN, D_LEFT, D_RIGHT, D_UP, outputs, xoutput::rect, TAILQ_FOREACH, Rect::x, and Rect::y.

Referenced by _tree_next(), cmd_move_con_to_output(), and get_output_from_string().

static void handle_output ( xcb_connection_t *  conn,
xcb_randr_output_t  id,
xcb_randr_get_output_info_reply_t *  output,
xcb_timestamp_t  cts,
resources_reply res 
)
static

Definition at line 483 of file randr.c.

References DLOG, FREE, get_output_by_id(), outputs, primary, sasprintf(), scalloc(), TAILQ_INSERT_HEAD, TAILQ_INSERT_TAIL, and update_if_necessary().

Referenced by randr_query_outputs().

Here is the call graph for this function:

void init_ws_for_output ( Output output,
Con content 
)

Initializes at least one workspace for this output, trying the following steps until there is at least one workspace:

• Move existing workspaces, which are assigned to be on the given output, to the output. • Create the first assigned workspace for this output. • Create the first unused workspace.

Definition at line 322 of file randr.c.

References xoutput::con, con_attach(), con_detach(), con_focus(), con_get_output(), create_workspace_on_output(), croot, DLOG, floating_fix_coordinates(), focused, Con::fullscreen_mode, get_output_by_name(), GREP_FIRST, init_ws_for_output(), LOG, Workspace_Assignment::name, xoutput::name, Con::name, Workspace_Assignment::output, output_get_content(), Con::rect, render_con(), TAILQ_EMPTY, TAILQ_FIRST, TAILQ_FOREACH, TAILQ_NEXT, workspace_is_visible(), workspace_show(), workspace_show_by_name(), and ws_assignments.

Referenced by disable_randr(), fake_outputs_init(), init_ws_for_output(), query_screens(), and randr_query_outputs().

Here is the call graph for this function:

static void output_change_mode ( xcb_connection_t *  conn,
Output output 
)
static
void output_init_con ( Output output)

Initializes a CT_OUTPUT Con (searches existing ones from inplace restart before) to use for the given Output.

Definition at line 218 of file randr.c.

References xoutput::con, con_attach(), con_fix_percent(), con_new(), croot, DLOG, Match::dock, FREE, Match::insert_where, Con::layout, match_init(), xoutput::name, Con::name, xoutput::rect, Con::rect, sasprintf(), scalloc(), sstrdup(), TAILQ_FOREACH, TAILQ_INSERT_TAIL, Con::type, and x_set_name().

Referenced by disable_randr(), fake_outputs_init(), query_screens(), and randr_query_outputs().

Here is the call graph for this function:

void randr_init ( int *  event_base)

We have just established a connection to the X server and need the initial XRandR information to setup workspaces for each screen.

Definition at line 784 of file randr.c.

References conn, disable_randr(), randr_query_outputs(), and root.

Referenced by main().

Here is the call graph for this function:

void randr_query_outputs ( void  )

Variable Documentation

struct outputs_head outputs = TAILQ_HEAD_INITIALIZER(outputs)
xcb_randr_get_output_primary_reply_t* primary

Definition at line 25 of file randr.c.

Referenced by handle_output(), and randr_query_outputs().

bool randr_disabled = false
static

Definition at line 30 of file randr.c.

Referenced by disable_randr(), and randr_query_outputs().