-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split ipc connection and content
- Loading branch information
Showing
23 changed files
with
1,012 additions
and
171 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef SWAY_IPC_SERVER_H | ||
#define SWAY_IPC_SERVER_H | ||
#include <sys/socket.h> | ||
#include <wayland-server.h> | ||
|
||
#include "ipc/ipc.h" | ||
|
||
void ipc_init(struct wl_event_loop *wl_event_loop); | ||
bool ipc_send_reply(struct ipc_client *client, enum ipc_command_type payload_type, | ||
const char *payload, uint32_t payload_length); | ||
|
||
struct sockaddr_un *ipc_user_sockaddr(void); | ||
|
||
void ipc_event_tag(); | ||
void ipc_event_window(); | ||
int handle_client_payload(struct ipc_client *client); | ||
|
||
#endif //SWAY_IPC_SERVER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef IPC_H | ||
#define IPC_H | ||
|
||
#include <sys/socket.h> | ||
|
||
#include "server.h" | ||
|
||
#define CREATE_EVENT_BITMASK(ev) (1 << (ev & 0x7F)) | ||
|
||
static const char ipc_magic[] = {'i', '3', '-', 'i', 'p', 'c'}; | ||
|
||
#define IPC_HEADER_SIZE (sizeof(ipc_magic) + 8) | ||
|
||
enum ipc_command_type { | ||
IPC_COMMAND = 0, | ||
IPC_GET_TAGS = 1, | ||
IPC_SUBSCRIBE = 2, | ||
IPC_GET_TREE = 4, | ||
IPC_GET_BAR_CONFIG = 6, | ||
|
||
// Event Types | ||
IPC_EVENT_TAG = ((1<<31) | 0), | ||
IPC_EVENT_MODE = ((1<<31) | 2), | ||
IPC_EVENT_WINDOW = ((1<<31) | 3), | ||
IPC_EVENT_BARCONFIG_UPDATE = ((1<<31) | 4), | ||
IPC_EVENT_BINDING = ((1<<31) | 5), | ||
IPC_EVENT_SHUTDOWN = ((1<<31) | 6), | ||
IPC_EVENT_TICK = ((1<<31) | 7), | ||
}; | ||
; | ||
|
||
|
||
struct ipc_client { | ||
struct wl_event_source *event_source; | ||
struct wl_event_source *writable_event_source; | ||
int fd; | ||
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; | ||
}; | ||
|
||
|
||
int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data); | ||
int ipc_client_handle_writable(int client_fd, uint32_t mask, void *data); | ||
bool ipc_send_reply(struct ipc_client *client, | ||
enum ipc_command_type payload_type, const char *payload, | ||
uint32_t payload_length); | ||
void ipc_send_event(const char *json_string, enum ipc_command_type event); | ||
|
||
#endif // IPC_H |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.