almost working

This commit is contained in:
Zandr Martin 2016-07-21 21:08:01 -05:00
parent 095353d91d
commit 05366ddf53
No known key found for this signature in database
GPG key ID: AA2BB8EF77F7BBDC
5 changed files with 26 additions and 1 deletions

View file

@ -13,6 +13,10 @@ void ipc_bar_init(struct bar *bar, const char *bar_id);
*/
bool handle_ipc_event(struct bar *bar);
/**
* Tell Sway to rearrange layout (after Swaybar has rendered itself).
*/
void ipc_send_arrange_command();
/**
* Send workspace command to sway
@ -20,4 +24,3 @@ bool handle_ipc_event(struct bar *bar);
void ipc_send_workspace_command(const char *workspace_name);
#endif /* _SWAYBAR_IPC_H */

View file

@ -11,6 +11,7 @@ enum ipc_command_type {
IPC_GET_BAR_CONFIG = 6,
IPC_GET_VERSION = 7,
IPC_GET_INPUTS = 8,
IPC_ARRANGE_LAYOUT = 9,
// Events send from sway to clients. Events have the highest bits set.
IPC_EVENT_WORKSPACE = ((1<<31) | 0),
IPC_EVENT_OUTPUT = ((1<<31) | 1),

View file

@ -471,6 +471,14 @@ void ipc_client_handle_command(struct ipc_client *client) {
goto exit_cleanup;
}
case IPC_ARRANGE_LAYOUT:
{
sway_log(L_DEBUG, "received arrange command");
arrange_windows(&root_container, -1, -1);
ipc_send_reply(client, "{\"success\": true}", 17);
goto exit_cleanup;
}
default:
sway_log(L_INFO, "Unknown IPC command type %i", client->current_command);
goto exit_cleanup;

View file

@ -202,6 +202,8 @@ void bar_run(struct bar *bar) {
render(output, bar->config, bar->status);
window_render(output->window);
wl_display_flush(output->registry->display);
sway_log(L_DEBUG, "sending arrange command");
ipc_send_arrange_command();
}
}
}

View file

@ -7,6 +7,17 @@
#include "bar/config.h"
#include "bar/ipc.h"
void ipc_send_arrange_command() {
sway_log(L_DEBUG, "sending arrange command");
sway_log(L_DEBUG, "socketfd is -> %d", swaybar.ipc_socketfd);
sway_log(L_DEBUG, "command is -> %d", IPC_ARRANGE_LAYOUT);
char *cmd = strdup("");
uint32_t len = strlen(cmd);
char *r = ipc_single_command(swaybar.ipc_socketfd, IPC_ARRANGE_LAYOUT, cmd, &len);
sway_log(L_DEBUG, "arrange command response is -> %s", r);
}
void ipc_send_workspace_command(const char *workspace_name) {
uint32_t size = strlen("workspace ") + strlen(workspace_name) + 1;