aboutsummaryrefslogtreecommitdiff
path: root/include/sway
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-01-22 01:16:23 +0100
committerGitHub <noreply@github.com>2018-01-22 01:16:23 +0100
commit0c58673c6a108ba241419a0f1d5fecd47f22370e (patch)
treec3e19af6dd70f04fc5c617e932b4afcc7a1b41d9 /include/sway
parenta6bc46eea9d7dec6a2b93f85bac2e3737e0c6725 (diff)
parentbeb3805cf0300bc2640290233aa763d757c12466 (diff)
Merge pull request #1574 from acrisci/config-refactor
Command criteria
Diffstat (limited to 'include/sway')
-rw-r--r--include/sway/config.h11
-rw-r--r--include/sway/container.h2
-rw-r--r--include/sway/criteria.h42
-rw-r--r--include/sway/input/input-manager.h6
-rw-r--r--include/sway/view.h17
5 files changed, 75 insertions, 3 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 967d3756..48a8b0ab 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -350,6 +350,14 @@ struct sway_config {
list_t *command_policies;
list_t *feature_policies;
list_t *ipc_policies;
+
+ // Context for command handlers
+ struct {
+ struct input_config *input_config;
+ struct seat_config *seat_config;
+ struct sway_seat *seat;
+ swayc_t *current_container;
+ } handler_context;
};
void pid_workspace_add(struct pid_workspace *pw);
@@ -375,6 +383,9 @@ bool read_config(FILE *file, struct sway_config *config);
* Free config struct
*/
void free_config(struct sway_config *config);
+
+void config_clear_handler_context(struct sway_config *config);
+
void free_sway_variable(struct sway_variable *var);
/**
* Does variable replacement for a string based on the config's currently loaded variables.
diff --git a/include/sway/container.h b/include/sway/container.h
index 9a5e312b..a99e2694 100644
--- a/include/sway/container.h
+++ b/include/sway/container.h
@@ -145,4 +145,6 @@ swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type);
swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy);
+void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data);
+
#endif
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
new file mode 100644
index 00000000..9b4b4bef
--- /dev/null
+++ b/include/sway/criteria.h
@@ -0,0 +1,42 @@
+#ifndef _SWAY_CRITERIA_H
+#define _SWAY_CRITERIA_H
+
+#include "container.h"
+#include "list.h"
+
+/**
+ * Maps criteria (as a list of criteria tokens) to a command list.
+ *
+ * A list of tokens together represent a single criteria string (e.g.
+ * '[class="abc" title="xyz"]' becomes two criteria tokens).
+ *
+ * for_window: Views matching all criteria will have the bound command list
+ * executed on them.
+ *
+ * Set via `for_window <criteria> <cmd list>`.
+ */
+struct criteria {
+ list_t *tokens; // struct crit_token, contains compiled regex.
+ char *crit_raw; // entire criteria string (for logging)
+
+ char *cmdlist;
+};
+
+int criteria_cmp(const void *item, const void *data);
+void free_criteria(struct criteria *crit);
+
+// Pouplate list with crit_tokens extracted from criteria string, returns error
+// string or NULL if successful.
+char *extract_crit_tokens(list_t *tokens, const char *criteria);
+
+// Returns list of criteria that match given container. These criteria have
+// been set with `for_window` commands and have an associated cmdlist.
+list_t *criteria_for(swayc_t *cont);
+
+// Returns a list of all containers that match the given list of tokens.
+list_t *container_for_crit_tokens(list_t *tokens);
+
+// Returns true if any criteria in the given list matches this container
+bool criteria_any(swayc_t *cont, list_t *criteria);
+
+#endif
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
index 53064eed..2bf297ce 100644
--- a/include/sway/input/input-manager.h
+++ b/include/sway/input/input-manager.h
@@ -5,9 +5,6 @@
#include "sway/config.h"
#include "list.h"
-extern struct input_config *current_input_config;
-extern struct seat_config *current_seat_config;
-
/**
* The global singleton input manager
* TODO: make me not a global
@@ -46,4 +43,7 @@ void sway_input_manager_apply_input_config(struct sway_input_manager *input,
void sway_input_manager_apply_seat_config(struct sway_input_manager *input,
struct seat_config *seat_config);
+struct sway_seat *sway_input_manager_get_default_seat(
+ struct sway_input_manager *input);
+
#endif
diff --git a/include/sway/view.h b/include/sway/view.h
index 08c5480b..ac33e11a 100644
--- a/include/sway/view.h
+++ b/include/sway/view.h
@@ -92,10 +92,27 @@ struct sway_view {
void (*set_position)(struct sway_view *view,
double ox, double oy);
void (*set_activated)(struct sway_view *view, bool activated);
+ void (*close)(struct sway_view *view);
} iface;
// only used for unmanaged views (shell specific)
struct wl_list unmanaged_view_link; // sway_root::unmanaged views
};
+const char *view_get_title(struct sway_view *view);
+
+const char *view_get_app_id(struct sway_view *view);
+
+const char *view_get_class(struct sway_view *view);
+
+const char *view_get_instance(struct sway_view *view);
+
+void view_set_size(struct sway_view *view, int width, int height);
+
+void view_set_position(struct sway_view *view, double ox, double oy);
+
+void view_set_activated(struct sway_view *view, bool activated);
+
+void view_close(struct sway_view *view);
+
#endif