i3
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <xcb/xcb.h>
#include <assert.h>
#include <math.h>
#include "config.h"
#include "i3.h"
#include "xcb.h"
#include "table.h"
#include "util.h"
#include "randr.h"
#include "layout.h"
#include "client.h"
#include "floating.h"
#include "handlers.h"
#include "workspace.h"
#include "log.h"
#include "container.h"
Go to the source code of this file.
Functions | |
int | get_unoccupied_x (Workspace *workspace) |
Gets the unoccupied space (= space which is available for windows which were resized by the user) This is necessary to render both, customly resized windows and never touched windows correctly, meaning that the aspect ratio will be maintained when opening new windows. | |
int | get_unoccupied_y (Workspace *workspace) |
See get_unoccupied_x. | |
void | redecorate_window (xcb_connection_t *conn, Client *client) |
Redecorates the given client correctly by checking if it’s in a stacking container and re-rendering the stack window or just calling decorate_window if it’s not in a stacking container. | |
void | decorate_window (xcb_connection_t *conn, Client *client, xcb_drawable_t drawable, xcb_gcontext_t gc, int offset_x, int offset_y) |
(Re-)draws window decorations for a given Client onto the given drawable/graphic context. | |
void | reposition_client (xcb_connection_t *conn, Client *client) |
Pushes the client’s x and y coordinates to X11. | |
void | resize_client (xcb_connection_t *conn, Client *client) |
Pushes the client’s width/height to X11 and resizes the child window. | |
void | render_container (xcb_connection_t *conn, Container *container) |
Renders the given container. | |
static void | render_bars (xcb_connection_t *conn, Workspace *r_ws, int width, int *height) |
static void | render_internal_bar (xcb_connection_t *conn, Workspace *r_ws, int width, int height) |
void | ignore_enter_notify_forall (xcb_connection_t *conn, Workspace *workspace, bool ignore_enter_notify) |
Modifies the event mask of all clients on the given workspace to either ignore or to handle enter notifies. | |
void | render_workspace (xcb_connection_t *conn, Output *output, Workspace *r_ws) |
Renders the given workspace on the given screen. | |
void | render_layout (xcb_connection_t *conn) |
Renders the whole layout, that is: Go through each screen, each workspace, each container and render each client. |
void decorate_window | ( | xcb_connection_t * | conn, |
Client * | client, | ||
xcb_drawable_t | drawable, | ||
xcb_gcontext_t | gc, | ||
int | offset_x, | ||
int | offset_y | ||
) |
(Re-)draws window decorations for a given Client onto the given drawable/graphic context.
When in stacking mode, the window decorations are drawn onto an own window.
Definition at line 97 of file layout.c.
References Colortriple::background, Config::config_client::background, Colortriple::border, Client::borderless, c_ws, Config::client, client_is_floating(), config, Client::container, container_mode(), Container::currently_focused, Client::dock, Config::config_client::focused, Config::config_client::focused_inactive, Config::font, Client::frame, Rect::height, Font::height, Font::id, load_font(), Client::name, Client::name_len, Client::rect, SLIST_FIRST, Colortriple::text, Client::titlebar_position, Client::titlegc, Config::config_client::unfocused, Config::config_client::urgent, Client::urgent, Rect::width, Container::width, Client::workspace, xcb_change_gc_single(), and xcb_draw_line().
Referenced by handle_expose_event(), handle_windowname_change(), handle_windowname_change_legacy(), redecorate_window(), and render_container().
int get_unoccupied_x | ( | Workspace * | workspace | ) |
Gets the unoccupied space (= space which is available for windows which were resized by the user) This is necessary to render both, customly resized windows and never touched windows correctly, meaning that the aspect ratio will be maintained when opening new windows.
Definition at line 40 of file layout.c.
References Workspace::cols, DLOG, Workspace::rect, Rect::width, and Workspace::width_factor.
Referenced by render_workspace(), and resize_container().
int get_unoccupied_y | ( | Workspace * | workspace | ) |
See get_unoccupied_x.
Definition at line 57 of file layout.c.
References DLOG, height, Workspace::height_factor, Workspace::rows, and workspace_height().
Referenced by render_workspace(), and resize_container().
void ignore_enter_notify_forall | ( | xcb_connection_t * | conn, |
Workspace * | workspace, | ||
bool | ignore_enter_notify | ||
) |
Modifies the event mask of all clients on the given workspace to either ignore or to handle enter notifies.
It is handy to ignore notifies because they will be sent when a window is mapped under the cursor, thus when the user didn’t enter the window actively at all.
Definition at line 652 of file layout.c.
References Client::child, CHILD_EVENT_MASK, CIRCLEQ_FOREACH, FOR_TABLE, Client::frame, FRAME_EVENT_MASK, and Workspace::table.
Referenced by render_workspace(), workspace_map_clients(), and workspace_unmap_clients().
void redecorate_window | ( | xcb_connection_t * | conn, |
Client * | client | ||
) |
Redecorates the given client correctly by checking if it’s in a stacking container and re-rendering the stack window or just calling decorate_window if it’s not in a stacking container.
Definition at line 80 of file layout.c.
References Client::container, decorate_window(), Client::frame, Rect::height, Container::mode, Client::rect, render_container(), Client::titlegc, and Rect::width.
Referenced by client_change_border(), client_leave_fullscreen(), handle_hints(), reparent_window(), set_focus(), toggle_floating_mode(), and workspace_show().
static void render_bars | ( | xcb_connection_t * | conn, |
Workspace * | r_ws, | ||
int | width, | ||
int * | height | ||
) | [static] |
Definition at line 576 of file layout.c.
References Client::desired_height, DLOG, Client::force_reconfigure, Rect::height, Workspace::output, Workspace::rect, Client::rect, reposition_client(), resize_client(), SLIST_FOREACH, update_if_necessary(), Rect::width, Rect::x, and Rect::y.
Referenced by render_workspace().
void render_container | ( | xcb_connection_t * | conn, |
Container * | container | ||
) |
Renders the given container.
Is called by render_layout() or individually (for example when focus changes in a stacking container)
Definition at line 347 of file layout.c.
References Config::config_client::background, cached_pixmap_prepare(), CIRCLEQ_FOREACH, Config::client, config, current_col, current_row, decorate_window(), DLOG, Config::font, Client::force_reconfigure, Client::frame, Workspace::fullscreen_client, Cached_Pixmap::gc, Font::height, Rect::height, Container::height, height, Cached_Pixmap::id, load_font(), LOG, max(), min(), Container::mode, Stack_Window::pixmap, Stack_Window::rect, Client::rect, resize_client(), Container::stack_limit, Container::stack_limit_value, Container::stack_win, TAILQ_END, TAILQ_FIRST, Client::titlegc, update_if_necessary(), Container::width, Rect::width, Stack_Window::window, Container::workspace, Container::x, Rect::x, xcb_change_gc_single(), Container::y, and Rect::y.
Referenced by client_change_border(), handle_expose_event(), handle_normal_hints(), handle_windowname_change(), handle_windowname_change_legacy(), redecorate_window(), render_workspace(), reparent_window(), and toggle_floating_mode().
static void render_internal_bar | ( | xcb_connection_t * | conn, |
Workspace * | r_ws, | ||
int | width, | ||
int | height | ||
) | [static] |
Definition at line 596 of file layout.c.
References Colortriple::background, Config::bar, xoutput::bar, xoutput::bargc, Colortriple::border, config, xoutput::current_workspace, Config::config_bar::focused, Config::font, get_colorpixel(), Font::height, Font::id, load_font(), Workspace::name, Workspace::name_len, Workspace::output, Stack_Window::rect, TAILQ_FOREACH, Colortriple::text, Workspace::text_width, Config::config_bar::unfocused, Config::config_bar::urgent, Workspace::urgent, width, workspaces, xcb_change_gc_single(), and xcb_draw_rect().
Referenced by render_workspace().
void render_layout | ( | xcb_connection_t * | conn | ) |
Renders the whole layout, that is: Go through each screen, each workspace, each container and render each client.
This also renders the bars.
If you don’t need to render *everything*, you should call render_container on the container you want to refresh.
Definition at line 802 of file layout.c.
References xoutput::current_workspace, outputs, render_workspace(), and TAILQ_FOREACH.
Referenced by client_change_border(), client_leave_fullscreen(), handle_expose_event(), handle_unmap_notify_event(), init_workspaces(), move_current_container(), move_current_window_in_container(), move_current_window_to_workspace(), move_floating_window_to_workspace(), parse_command(), reparent_window(), resize_container(), snap_current_container(), switch_layout_mode(), and workspace_show().
Renders the given workspace on the given screen.
Definition at line 680 of file layout.c.
References Container::col, Workspace::cols, Container::colspan, config, Client::desired_height, Config::disable_workspace_bar, DLOG, Config::font, FOR_TABLE, Client::force_reconfigure, get_unoccupied_x(), get_unoccupied_y(), Container::height, Font::height, Rect::height, height, Workspace::height_factor, ignore_enter_notify_forall(), load_font(), Workspace::rect, render_bars(), render_container(), render_internal_bar(), reposition_client(), resize_client(), Container::row, Workspace::rows, Container::rowspan, SLIST_FOREACH, Workspace::table, TAILQ_FOREACH, Container::width, Rect::width, width, Workspace::width_factor, workspace_height(), Container::x, Rect::x, Container::y, and Rect::y.
Referenced by handle_configure_request(), handle_hints(), move_current_window(), parse_command(), render_layout(), and workspace_assign_to().
void reposition_client | ( | xcb_connection_t * | conn, |
Client * | client | ||
) |
Pushes the client’s x and y coordinates to X11.
Definition at line 205 of file layout.c.
References client_is_floating(), xoutput::current_workspace, DLOG, floating_assign_to_workspace(), Client::force_reconfigure, Client::frame, get_output_containing(), Rect::height, Workspace::output, Client::rect, set_focus(), Rect::width, Client::workspace, Rect::x, and Rect::y.
Referenced by client_leave_fullscreen(), DRAGGING_CB(), floating_move(), handle_configure_request(), move_floating_window_to_workspace(), render_bars(), render_workspace(), reparent_window(), and toggle_floating_mode().
void resize_client | ( | xcb_connection_t * | conn, |
Client * | client | ||
) |
Pushes the client’s width/height to X11 and resizes the child window.
This function also updates the client’s position, so if you work on tiling clients only, you can use this function instead of separate calls to reposition_client and resize_client to reduce flickering.
Definition at line 247 of file layout.c.
References Client::base_height, Client::base_width, Client::border_width, Client::borderless, Client::child, Client::child_rect, config, Client::container, container_mode(), DLOG, fake_absolute_configure_notify(), Config::font, Client::frame, handle_expose_event(), Font::height, Rect::height, Client::height_increment, load_font(), Client::proportional_height, Client::proportional_width, Client::rect, Client::titlebar_position, Rect::width, Client::width_increment, Rect::x, xcb_set_window_rect(), and Rect::y.
Referenced by client_change_border(), client_leave_fullscreen(), DRAGGING_CB(), handle_configure_request(), handle_normal_hints(), parse_resize_command(), render_bars(), render_container(), render_workspace(), reparent_window(), and toggle_floating_mode().