sway/include/container.h

110 lines
2.6 KiB
C
Raw Normal View History

2015-08-10 22:31:23 +02:00
#ifndef _SWAY_CONTAINER_H
#define _SWAY_CONTAINER_H
#include <wlc/wlc.h>
typedef struct sway_container swayc_t;
2015-08-10 22:31:23 +02:00
#include "layout.h"
enum swayc_types{
C_ROOT,
C_OUTPUT,
C_WORKSPACE,
C_CONTAINER,
C_VIEW,
2015-08-20 14:06:22 +02:00
// Keep last
C_TYPES,
};
enum swayc_layouts{
L_NONE,
L_HORIZ,
L_VERT,
L_STACKED,
L_TABBED,
L_FLOATING,
2015-08-20 14:06:22 +02:00
// Keep last
L_LAYOUTS,
};
struct sway_container {
wlc_handle handle;
enum swayc_types type;
enum swayc_layouts layout;
// Not including borders or margins
double width, height;
2015-08-17 17:34:39 +02:00
// Used for setting floating geometry
int desired_width, desired_height;
2015-08-17 17:18:06 +02:00
double x, y;
bool visible;
2015-08-17 17:34:39 +02:00
bool is_floating;
bool is_focused;
char *name;
2015-08-18 23:53:57 +02:00
int gaps;
list_t *children;
2015-08-17 07:38:34 +02:00
list_t *floating;
struct sway_container *parent;
struct sway_container *focused;
};
2015-08-20 18:52:54 +02:00
// Container Creation
swayc_t *new_output(wlc_handle handle);
swayc_t *new_workspace(swayc_t *output, const char *name);
// Creates container Around child (parent child) -> (parent (container child))
swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
// Creates view as a sibling of current focused container, or as child of a workspace
swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
// Creates view as a new floating view which is in the active workspace
2015-08-17 17:18:06 +02:00
swayc_t *new_floating_view(wlc_handle handle);
2015-08-20 18:52:54 +02:00
// Container Destroying
swayc_t *destroy_output(swayc_t *output);
// Destroys workspace if empty and returns parent pointer, else returns NULL
swayc_t *destroy_workspace(swayc_t *workspace);
2015-08-20 18:52:54 +02:00
// Destroyes container and all parent container if they are empty, returns
// topmost non-empty parent. returns NULL otherwise
swayc_t *destroy_container(swayc_t *container);
2015-08-20 18:52:54 +02:00
// Destroys view and all empty parent containers. return topmost non-empty
// parent
swayc_t *destroy_view(swayc_t *view);
2015-08-20 18:52:54 +02:00
// Container Lookup
2015-08-21 19:28:37 +02:00
swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
2015-08-20 18:52:54 +02: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 10:11:21 +02: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-08-21 19:28:37 +02:00
swayc_t *swayc_by_handle(wlc_handle handle);
swayc_t *swayc_active_output(void);
swayc_t *swayc_active_workspace(void);
swayc_t *swayc_active_workspace_for(swayc_t *view);
2015-08-20 18:52:54 +02:00
2015-08-21 19:28:37 +02:00
// Container information
bool swayc_is_fullscreen(swayc_t *view);
2015-08-10 22:31:23 +02:00
2015-08-21 19:28:37 +02:00
// Mapping functions
void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
// Mappings
2015-08-17 04:06:31 +02:00
void set_view_visibility(swayc_t *view, void *data);
2015-08-19 04:06:41 +02:00
void reset_gaps(swayc_t *view, void *data);
2015-08-17 04:06:31 +02:00
2015-08-10 22:31:23 +02:00
#endif