2015-08-10 20:31:23 +00:00
|
|
|
#ifndef _SWAY_CONTAINER_H
|
|
|
|
#define _SWAY_CONTAINER_H
|
2015-08-14 19:42:19 +00:00
|
|
|
#include <wlc/wlc.h>
|
|
|
|
typedef struct sway_container swayc_t;
|
2015-09-13 23:46:16 +00:00
|
|
|
|
2015-08-10 20:31:23 +00:00
|
|
|
#include "layout.h"
|
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
enum swayc_types{
|
|
|
|
C_ROOT,
|
|
|
|
C_OUTPUT,
|
|
|
|
C_WORKSPACE,
|
|
|
|
C_CONTAINER,
|
|
|
|
C_VIEW,
|
|
|
|
// Keep last
|
|
|
|
C_TYPES,
|
2015-08-14 19:42:19 +00:00
|
|
|
};
|
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
|
|
|
|
enum swayc_layouts{
|
|
|
|
L_NONE,
|
|
|
|
L_HORIZ,
|
|
|
|
L_VERT,
|
|
|
|
L_STACKED,
|
|
|
|
L_TABBED,
|
|
|
|
L_FLOATING,
|
|
|
|
// Keep last
|
|
|
|
L_LAYOUTS,
|
2015-08-14 19:42:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sway_container {
|
|
|
|
wlc_handle handle;
|
|
|
|
|
|
|
|
enum swayc_types type;
|
|
|
|
enum swayc_layouts layout;
|
|
|
|
|
|
|
|
// Not including borders or margins
|
2015-08-21 02:37:59 +00:00
|
|
|
double width, height;
|
2015-08-14 19:42:19 +00:00
|
|
|
|
2015-08-17 15:34:39 +00:00
|
|
|
// Used for setting floating geometry
|
|
|
|
int desired_width, desired_height;
|
2015-08-17 15:18:06 +00:00
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
double x, y;
|
2015-08-14 19:42:19 +00:00
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
bool visible;
|
2015-08-17 15:34:39 +00:00
|
|
|
bool is_floating;
|
2015-08-18 07:28:44 +00:00
|
|
|
bool is_focused;
|
|
|
|
|
2015-08-14 19:42:19 +00:00
|
|
|
char *name;
|
|
|
|
|
2015-08-18 21:53:57 +00:00
|
|
|
int gaps;
|
|
|
|
|
2015-08-14 19:42:19 +00:00
|
|
|
list_t *children;
|
2015-08-17 05:38:34 +00:00
|
|
|
list_t *floating;
|
|
|
|
|
2015-08-14 19:42:19 +00:00
|
|
|
struct sway_container *parent;
|
|
|
|
struct sway_container *focused;
|
|
|
|
};
|
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
enum visibility_mask {
|
|
|
|
VISIBLE = true
|
|
|
|
} visible;
|
2015-08-14 19:42:19 +00:00
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
// Container Creation
|
2015-09-12 09:38:03 +00:00
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
swayc_t *new_output(wlc_handle handle);
|
2015-08-18 11:19:20 +00:00
|
|
|
swayc_t *new_workspace(swayc_t *output, const char *name);
|
|
|
|
// Creates container Around child (parent child) -> (parent (container child))
|
2015-08-14 19:42:19 +00:00
|
|
|
swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
|
2015-08-18 11:19:20 +00:00
|
|
|
// Creates view as a sibling of current focused container, or as child of a workspace
|
2015-08-14 19:42:19 +00:00
|
|
|
swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
|
2015-08-18 11:19:20 +00:00
|
|
|
// Creates view as a new floating view which is in the active workspace
|
2015-08-17 15:18:06 +00:00
|
|
|
swayc_t *new_floating_view(wlc_handle handle);
|
2015-08-14 19:42:19 +00:00
|
|
|
|
2015-08-20 16:52:54 +00:00
|
|
|
// Container Destroying
|
2015-09-12 09:38:03 +00:00
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
swayc_t *destroy_output(swayc_t *output);
|
2015-08-18 11:19:20 +00:00
|
|
|
// Destroys workspace if empty and returns parent pointer, else returns NULL
|
2015-08-14 19:42:19 +00:00
|
|
|
swayc_t *destroy_workspace(swayc_t *workspace);
|
2015-08-20 16:52:54 +00:00
|
|
|
// Destroyes container and all parent container if they are empty, returns
|
|
|
|
// topmost non-empty parent. returns NULL otherwise
|
2015-08-14 19:42:19 +00:00
|
|
|
swayc_t *destroy_container(swayc_t *container);
|
2015-08-20 16:52:54 +00:00
|
|
|
// Destroys view and all empty parent containers. return topmost non-empty
|
|
|
|
// parent
|
2015-08-14 19:42:19 +00:00
|
|
|
swayc_t *destroy_view(swayc_t *view);
|
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
// Container Lookup
|
2015-08-20 16:52:54 +00:00
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
|
2015-08-20 16:52:54 +00:00
|
|
|
swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
|
|
|
|
swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
|
2015-08-24 08:11:21 +00:00
|
|
|
// Follow focused until type/layout
|
|
|
|
swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types);
|
|
|
|
swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts);
|
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
|
|
|
|
swayc_t *swayc_by_handle(wlc_handle handle);
|
|
|
|
swayc_t *swayc_by_name(const char *name);
|
2015-08-21 17:28:37 +00:00
|
|
|
swayc_t *swayc_active_output(void);
|
|
|
|
swayc_t *swayc_active_workspace(void);
|
|
|
|
swayc_t *swayc_active_workspace_for(swayc_t *view);
|
2015-08-20 16:52:54 +00:00
|
|
|
|
2015-08-21 17:28:37 +00:00
|
|
|
// Container information
|
2015-09-13 23:46:16 +00:00
|
|
|
|
|
|
|
bool swayc_is_fullscreen(swayc_t *view);
|
|
|
|
bool swayc_is_active(swayc_t *view);
|
|
|
|
// Is `parent` the parent of `child`
|
2015-08-28 06:18:28 +00:00
|
|
|
bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
|
2015-09-13 23:46:16 +00:00
|
|
|
// Is `child` a child of `parent`
|
2015-08-28 06:18:28 +00:00
|
|
|
bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
|
2015-09-04 23:14:59 +00:00
|
|
|
// Return gap of specified container
|
|
|
|
int swayc_gap(swayc_t *container);
|
2015-08-10 20:31:23 +00:00
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
// Mapping functions
|
|
|
|
|
|
|
|
void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
|
2015-08-20 20:27:38 +00:00
|
|
|
|
2015-09-13 23:46:16 +00:00
|
|
|
// Mappings
|
|
|
|
void set_view_visibility(swayc_t *view, void *data);
|
|
|
|
// Set or add to gaps
|
|
|
|
void set_gaps(swayc_t *view, void *amount);
|
|
|
|
void add_gaps(swayc_t *view, void *amount);
|
2015-08-17 02:06:31 +00:00
|
|
|
|
2015-08-25 16:24:15 +00:00
|
|
|
void update_visibility(swayc_t *container);
|
|
|
|
|
2015-08-10 20:31:23 +00:00
|
|
|
#endif
|