mirror of
https://github.com/swaywm/sway.git
synced 2026-04-27 06:46:25 -04:00
ipc: refactor ipc handlers into ipc-sway.c
This is preparative work for the backward-compatible I3SOCK implementation. Signed-off-by: Franklin "Snaipe" Mathieu <me@snai.pe>
This commit is contained in:
parent
5fb5984e94
commit
91c1a52595
9 changed files with 371 additions and 315 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _SWAY_COMMANDS_H
|
||||
#define _SWAY_COMMANDS_H
|
||||
|
||||
#include <json-c/json.h>
|
||||
#include <wlr/util/edges.h>
|
||||
#include "config.h"
|
||||
|
||||
|
|
@ -83,9 +84,9 @@ void free_cmd_results(struct cmd_results *results);
|
|||
/**
|
||||
* Serializes a list of cmd_results to a JSON string.
|
||||
*
|
||||
* Free the JSON string later on.
|
||||
* Free the JSON object later on.
|
||||
*/
|
||||
char *cmd_results_to_json(list_t *res_list);
|
||||
json_object *cmd_results_to_json(list_t *res_list);
|
||||
|
||||
struct cmd_results *add_color(char *buffer, const char *color);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include "sway/tree/container.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
|
||||
json_object *ipc_json_success(void);
|
||||
json_object *ipc_json_failure(const char *error);
|
||||
|
||||
json_object *ipc_json_get_version(void);
|
||||
|
||||
json_object *ipc_json_describe_disabled_output(struct sway_output *o);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef _SWAY_IPC_SERVER_H
|
||||
#define _SWAY_IPC_SERVER_H
|
||||
#include <json-c/json.h>
|
||||
#include <sys/socket.h>
|
||||
#include "sway/config.h"
|
||||
#include "sway/tree/container.h"
|
||||
|
|
@ -19,5 +20,35 @@ void ipc_event_bar_state_update(struct bar_config *bar);
|
|||
void ipc_event_mode(const char *mode, bool pango);
|
||||
void ipc_event_shutdown(const char *reason);
|
||||
void ipc_event_binding(struct sway_binding *binding);
|
||||
void ipc_event_tick(const char *payload);
|
||||
|
||||
struct ipc_client {
|
||||
struct wl_event_source *event_source;
|
||||
struct wl_event_source *writable_event_source;
|
||||
struct sway_server *server;
|
||||
int fd;
|
||||
uint32_t security_policy;
|
||||
enum ipc_command_type subscribed_events;
|
||||
size_t write_buffer_len;
|
||||
size_t write_buffer_size;
|
||||
char *write_buffer;
|
||||
// The following are for storing data between event_loop calls
|
||||
uint32_t pending_length;
|
||||
enum ipc_command_type pending_type;
|
||||
const struct ipc_client_impl *impl;
|
||||
};
|
||||
|
||||
bool ipc_send_reply(struct ipc_client *client, enum ipc_command_type payload_type,
|
||||
const char *payload, uint32_t payload_length);
|
||||
|
||||
typedef json_object *(*ipc_handler)(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *data);
|
||||
|
||||
struct ipc_client_impl {
|
||||
size_t num_commands;
|
||||
const ipc_handler *commands;
|
||||
};
|
||||
|
||||
extern const struct ipc_client_impl ipc_client_sway;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
34
include/sway/ipc-sway.h
Normal file
34
include/sway/ipc-sway.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef _SWAY_IPC_SWAY_H
|
||||
#define _SWAY_IPC_SWAY_H
|
||||
|
||||
#include <json-c/json.h>
|
||||
#include "sway/ipc-server.h"
|
||||
|
||||
json_object *ipc_sway_command(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_bar_config(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_binding_modes(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_config(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_inputs(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_marks(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_outputs(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_seats(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_tree(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_version(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_get_workspaces(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_send_tick(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
json_object *ipc_sway_subscribe(struct ipc_client *client,
|
||||
enum ipc_command_type *type, char *buf);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue