This commit is contained in:
Half-Shot 2015-08-20 21:32:08 +01:00
commit 5a9ba261bc
26 changed files with 1493 additions and 570 deletions

View file

@ -41,9 +41,12 @@ struct sway_config {
bool active;
bool failed;
bool reloading;
int gaps_inner;
int gaps_outer;
};
bool load_config(void);
bool load_config(const char *file);
bool read_config(FILE *file, bool is_active);
char *do_var_replacement(struct sway_config *config, char *str);

View file

@ -11,7 +11,7 @@ enum swayc_types{
C_WORKSPACE,
C_CONTAINER,
C_VIEW,
//Keep last
// Keep last
C_TYPES,
};
@ -23,7 +23,7 @@ enum swayc_layouts{
L_STACKED,
L_TABBED,
L_FLOATING,
//Keep last
// Keep last
L_LAYOUTS,
};
@ -45,10 +45,10 @@ struct sway_container {
bool is_floating;
bool is_focused;
int weight;
char *name;
int gaps;
list_t *children;
list_t *floating;
@ -56,6 +56,7 @@ struct sway_container {
struct sway_container *focused;
};
// Container Creation
swayc_t *new_output(wlc_handle handle);
swayc_t *new_workspace(swayc_t *output, const char *name);
@ -66,18 +67,29 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
// Creates view as a new floating view which is in the active workspace
swayc_t *new_floating_view(wlc_handle handle);
// 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);
// 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);
// Destroys view and all empty parent containers. return topmost non-empty
// parent
swayc_t *destroy_view(swayc_t *view);
// Container Lookup
swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
// Mappings
void set_view_visibility(swayc_t *view, void *data);
void reset_gaps(swayc_t *view, void *data);
#endif

View file

@ -1,7 +1,5 @@
#ifndef _SWAY_FOCUS_H
#define _SWAY_FOCUS_H
#include "container.h"
enum movement_direction {
MOVE_LEFT,
MOVE_RIGHT,
@ -10,6 +8,8 @@ enum movement_direction {
MOVE_PARENT
};
#include "container.h"
// focused_container - the container found by following the `focused` pointer
// from a given container to a container with `is_focused` boolean set
// ---

49
include/input_state.h Normal file
View file

@ -0,0 +1,49 @@
#ifndef _SWAY_KEY_STATE_H
#define _SWAY_KEY_STATE_H
#include <stdbool.h>
#include <stdint.h>
#include "container.h"
/* Keyboard state */
typedef uint32_t keycode;
// returns true if key has been pressed, otherwise false
bool check_key(keycode key);
// sets a key as pressed
void press_key(keycode key);
// unsets a key as pressed
void release_key(keycode key);
/* Pointer state */
enum pointer_values {
M_LEFT_CLICK = 272,
M_RIGHT_CLICK = 273,
M_SCROLL_CLICK = 274,
M_SCROLL_UP = 275,
M_SCROLL_DOWN = 276,
};
extern struct pointer_state {
bool l_held;
bool r_held;
struct pointer_floating {
bool drag;
bool resize;
} floating;
struct pointer_lock {
bool left;
bool right;
bool top;
bool bottom;
} lock;
} pointer_state;
void start_floating(swayc_t *view);
void reset_floating(swayc_t *view);
#endif

18
include/ipc.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef _SWAY_IPC_H
#define _SWAY_IPC_H
enum ipc_command_type {
IPC_COMMAND = 0,
IPC_GET_WORKSPACES = 1,
IPC_SUBSCRIBE = 2,
IPC_GET_OUTPUTS = 3,
IPC_GET_TREE = 4,
IPC_GET_MARKS = 5,
IPC_GET_BAR_CONFIG = 6,
IPC_GET_VERSION = 7,
};
void ipc_init(void);
void ipc_terminate(void);
#endif

View file

@ -4,12 +4,14 @@
#include <wlc/wlc.h>
#include "list.h"
#include "container.h"
#include "focus.h"
extern swayc_t root_container;
void init_layout(void);
void add_child(swayc_t *parent, swayc_t *child);
void add_floating(swayc_t *ws, swayc_t *child);
// Returns parent container which needs to be rearranged.
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
@ -28,5 +30,6 @@ void focus_view_for(swayc_t *ancestor, swayc_t *container);
swayc_t *get_focused_container(swayc_t *parent);
swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent);
swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir);
#endif

View file

@ -1,5 +1,7 @@
#ifndef _SWAY_LOG_H
#define _SWAY_LOG_H
#include <stdbool.h>
#include "container.h"
typedef enum {
L_SILENT = 0,
@ -10,7 +12,10 @@ typedef enum {
void init_log(int verbosity);
void sway_log_colors(int mode);
void sway_log(int verbosity, char* format, ...) __attribute__((format(printf,2,3)));
void sway_abort(char* format, ...)__attribute__((format(printf,1,2)));
void sway_log(int verbosity, const char* format, ...) __attribute__((format(printf,2,3)));
void sway_log_errno(int verbosity, char* format, ...) __attribute__((format(printf,2,3)));
void sway_abort(const char* format, ...) __attribute__((format(printf,1,2)));
bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3)));
void layout_log(const swayc_t *c, int depth);
#endif

View file

@ -10,5 +10,6 @@ char *code_strchr(const char *string, char delimiter);
char *code_strstr(const char *haystack, const char *needle);
int unescape_string(char *string);
char *join_args(char **argv, int argc);
char *join_list(list_t *list, char *separator);
#endif

6
include/sway.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef _SWAY_SWAY_H
#define _SWAY_SWAY_H
void sway_terminate(void);
#endif

View file

@ -15,6 +15,5 @@ void workspace_output_next();
void workspace_next();
void workspace_output_prev();
void workspace_prev();
void layout_log(const swayc_t *c, int depth);
#endif