mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] x11: read the i3 IPC response
This commit is contained in:
parent
8d90c9c2a5
commit
82607a7d6f
@ -26,6 +26,7 @@
|
||||
#include "atoms.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/option.h"
|
||||
#include "common/util.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@ -146,7 +147,7 @@ static void wm_i3_setFullscreen(bool enable)
|
||||
while(msgSize)
|
||||
{
|
||||
int wrote = write(i3.sock, buf, msgSize);
|
||||
if (wrote < 0)
|
||||
if (wrote <= 0)
|
||||
{
|
||||
DEBUG_WARN("i3 IPC communication failure");
|
||||
return;
|
||||
@ -155,6 +156,31 @@ static void wm_i3_setFullscreen(bool enable)
|
||||
buf += wrote;
|
||||
msgSize -= wrote;
|
||||
}
|
||||
|
||||
if ((msgSize = read(i3.sock, msg, sizeof(*msg))) < 0)
|
||||
{
|
||||
DEBUG_WARN("i3 IPC read failure");
|
||||
return;
|
||||
}
|
||||
|
||||
if (memcmp(msg->magic, "i3-ipc", 6) != 0 ||
|
||||
msg->type != I3_IPC_TYPE_RUN_COMMAND)
|
||||
{
|
||||
DEBUG_WARN("i3 IPC unexpected reply");
|
||||
return;
|
||||
}
|
||||
|
||||
// read and discard the payload
|
||||
while(msg->length)
|
||||
{
|
||||
int len = read(i3.sock, cmd, min(msg->length, sizeof(cmd)));
|
||||
if (len <= 0)
|
||||
{
|
||||
DEBUG_WARN("i3 IPC failed to read payload");
|
||||
return;
|
||||
}
|
||||
msg->length -= len;
|
||||
}
|
||||
};
|
||||
|
||||
X11WM X11WM_i3 =
|
||||
|
Loading…
Reference in New Issue
Block a user