diff options
| author | Drew DeVault <sir@cmpwn.com> | 2015-09-12 10:29:11 -0400 | 
|---|---|---|
| committer | Drew DeVault <sir@cmpwn.com> | 2015-09-12 10:29:11 -0400 | 
| commit | 9c8f1fb9649c5673cd6b42230c0784f099a62db7 (patch) | |
| tree | bb5eccfddb8b8d56e387327908490daeca2c42a7 /include | |
| parent | f5343adae4d631e4cdade7869b4d73fc97b4ac5f (diff) | |
| parent | f76f9e2eea15ee4606c23139e9a4c8ce41a4ab18 (diff) | |
| download | sway-9c8f1fb9649c5673cd6b42230c0784f099a62db7.tar.xz | |
Merge pull request #179 from taiyu-len/master
new_workspace null behavior + testmap functions + regex
Diffstat (limited to 'include')
| -rw-r--r-- | include/commands.h | 16 | ||||
| -rw-r--r-- | include/config.h | 4 | ||||
| -rw-r--r-- | include/container.h | 139 | ||||
| -rw-r--r-- | include/stringop.h | 2 | ||||
| -rw-r--r-- | include/workspace.h | 16 | 
5 files changed, 118 insertions, 59 deletions
diff --git a/include/commands.h b/include/commands.h index 5c87be51..69ab1380 100644 --- a/include/commands.h +++ b/include/commands.h @@ -3,19 +3,21 @@  #include <stdbool.h>  #include "config.h" +typedef enum  cmd_status { +	CMD_SUCCESS, +	CMD_FAILURE, +	CMD_DEFER, +} sway_cmd(char *criteria, int argc, char **argv); +  struct cmd_handler { -	char *command; -	enum  cmd_status { -		CMD_SUCCESS, -		CMD_FAILURE, -		CMD_DEFER, -	} (*handle)(int argc, char **argv); +	const char*command; +	sway_cmd  *handle;  };  enum cmd_status handle_command(char *command);  // Handles commands during config  enum cmd_status config_command(char *command); -void remove_view_from_scratchpad(); +void remove_view_from_scratchpad(swayc_t *view);  #endif diff --git a/include/config.h b/include/config.h index 676218c8..04db3e5c 100644 --- a/include/config.h +++ b/include/config.h @@ -63,6 +63,10 @@ bool load_config(const char *file);  bool read_config(FILE *file, bool is_active);  char *do_var_replacement(char *str); +// Find workspace_output from config by workspace or output name +struct workspace_output *wsop_find_workspace(const char *); +struct workspace_output *wsop_find_output(const char *); +  extern struct sway_config *config;  #endif diff --git a/include/container.h b/include/container.h index a9b95229..b164af95 100644 --- a/include/container.h +++ b/include/container.h @@ -2,29 +2,25 @@  #define _SWAY_CONTAINER_H  #include <wlc/wlc.h>  typedef struct sway_container swayc_t; -  #include "layout.h" -enum swayc_types{ -	C_ROOT, -	C_OUTPUT, -	C_WORKSPACE, -	C_CONTAINER, -	C_VIEW, -	// Keep last -	C_TYPES, +enum swayc_types { +	C_ROOT      = 1 << 0, +	C_OUTPUT    = 1 << 1, +	C_WORKSPACE = 1 << 2, +	C_CONTAINER = 1 << 3, +	C_VIEW      = 1 << 4, +	C_TYPES     = 5,  }; - -enum swayc_layouts{ -	L_NONE, -	L_HORIZ, -	L_VERT, -	L_STACKED, -	L_TABBED, -	L_FLOATING, -	// Keep last -	L_LAYOUTS, +enum swayc_layouts { +	L_NONE     = 1 << 0, +	L_HORIZ    = 1 << 1, +	L_VERT     = 1 << 2, +	L_STACKED  = 1 << 3, +	L_TABBED   = 1 << 4, +	L_FLOATING = 1 << 5, +	L_LAYOUTS  = 6,  };  struct sway_container { @@ -35,13 +31,16 @@ struct sway_container {  	// Not including borders or margins  	double width, height; +	double x, y;  	// Used for setting floating geometry  	int desired_width, desired_height; -	double x, y; +	enum visibility_mask { +		INVISIBLE = false, +		VISIBLE = true, +	} visible; -	bool visible;  	bool is_floating;  	bool is_focused; @@ -56,70 +55,120 @@ struct sway_container {  	struct sway_container *focused;  }; -enum visibility_mask { -	VISIBLE = 1 -}; - -// Container Creation +// swayc Creation +/* Creates and returns new, or an already created output. + * If it creates a new output, it also creates a workspace using + * `new_workspace(outputname, NULL);` */  swayc_t *new_output(wlc_handle handle); + +/* Creates workspace with given name, under given output. + * If workspace with that name already exists, returns that workspace + * If name is NULL, it will choose a name automatically. + * If output is NULL, it will choose an output automatically. */  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  swayc_t *new_floating_view(wlc_handle handle);  // Container Destroying - +// Destroys output and moves workspaces to another output  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 +// Container Mapping and testing functions +typedef bool swayc_test_func(swayc_t *view, void *data); +typedef void swayc_map_func(swayc_t *view, void *data); + +// Returns the first swayc that matches test() +swayc_t *swayc_by_test_r(swayc_t *root, swayc_test_func test, void *data); +swayc_t *swayc_by_test(swayc_test_func test, void *data); + +// Calls func for all children. +void swayc_map_r(swayc_t *root, swayc_map_func func, void *data); +void swayc_map(swayc_map_func func, void *data); + + +// Call func on container if test passes +void swayc_map_by_test_r(swayc_t *root, +		swayc_map_func func, swayc_test_func test, +		void *funcdata, void *testdata); +void swayc_map_by_test( +		swayc_map_func func, swayc_test_func test, +		void *funcdata, void *testdata); + +// Map functions +swayc_map_func set_gaps; +swayc_map_func add_gaps; + +// Test functions +// generic swayc tests +swayc_test_func test_name; +swayc_test_func test_name_regex; +swayc_test_func test_layout; +swayc_test_func test_type; +swayc_test_func test_visibility; +swayc_test_func test_handle; + +// C_VIEW tests +// See wlc_view_*_bit enums +swayc_test_func test_view_state; +swayc_test_func test_view_type; +swayc_test_func test_view_title; +swayc_test_func test_view_class; +swayc_test_func test_view_appid; +swayc_test_func test_view_title_regex; +swayc_test_func test_view_class_regex; +swayc_test_func test_view_appid_regex; + +// functions for test_*_regex +void *compile_regex(const char *regex); +void free_regex(void *); + +// these take a NULL terminated array of test_list struct. +struct test_list { swayc_test_func *test; void *data ; }; +swayc_test_func test_and; +swayc_test_func test_or; -swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);  swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);  swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);  // 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); - -swayc_t *swayc_by_handle(wlc_handle handle); -swayc_t *swayc_by_name(const char *name);  swayc_t *swayc_active_output(void);  swayc_t *swayc_active_workspace(void);  swayc_t *swayc_active_workspace_for(swayc_t *view);  // Container information - -bool swayc_is_fullscreen(swayc_t *view); -bool swayc_is_active(swayc_t *view); -// Is `parent` the parent of `child` +// if `parent` is the parent of `child`  bool swayc_is_parent_of(swayc_t *parent, swayc_t *child); -// Is `child` a child of `parent` +// If `child` is a child of `parent`  bool swayc_is_child_of(swayc_t *child, swayc_t *parent);  // Return gap of specified container  int swayc_gap(swayc_t *container); -// Mapping functions - -void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *); +bool swayc_is_fullscreen(swayc_t *view); +bool swayc_is_active(swayc_t *view); -// 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); +// Specialized mapping functions  void update_visibility(swayc_t *container);  #endif diff --git a/include/stringop.h b/include/stringop.h index dde50f13..6e80e729 100644 --- a/include/stringop.h +++ b/include/stringop.h @@ -19,7 +19,7 @@ void free_argv(int argc, char **argv);  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_args(int argc, char **argv);  char *join_list(list_t *list, char *separator);  char *strdup(const char *); diff --git a/include/workspace.h b/include/workspace.h index 7343b055..3a63ea38 100644 --- a/include/workspace.h +++ b/include/workspace.h @@ -7,13 +7,17 @@  extern char *prev_workspace_name; -char *workspace_next_name(void); -swayc_t *workspace_create(const char*); +// Search for available workspace name on output from config +const char *workspace_output_open_name(swayc_t *output); +// Search for any available workspace name +const char *workspace_next_name(void); + +  swayc_t *workspace_by_name(const char*);  void workspace_switch(swayc_t*); -swayc_t *workspace_output_next(); -swayc_t *workspace_next(); -swayc_t *workspace_output_prev(); -swayc_t *workspace_prev(); +swayc_t *workspace_output_next(void); +swayc_t *workspace_next(void); +swayc_t *workspace_output_prev(void); +swayc_t *workspace_prev(void);  #endif  | 
