Have yutani messages built on the stack instead of malloc/free

This commit is contained in:
K. Lange 2018-04-25 17:30:28 +09:00 committed by Kevin Lange
parent 8e07883088
commit 0c4b4e3344
3 changed files with 474 additions and 126 deletions

View File

@ -40,6 +40,8 @@
#include <toaru/list.h>
#include <toaru/spinlock.h>
#include <toaru/yutani_ext.h>
#define _DEBUG_YUTANI
#ifdef _DEBUG_YUTANI
#include <toaru/trace.h>
@ -363,16 +365,16 @@ static void set_focused_window(yutani_globals_t * yg, yutani_server_window_t * w
if (yg->focused_window) {
/* Send focus change to old focused window */
yutani_msg_t * response = yutani_msg_build_window_focus_change(yg->focused_window->wid, 0);
yutani_msg_buildx_window_focus_change_alloc(response);
yutani_msg_buildx_window_focus_change(response, yg->focused_window->wid, 0);
pex_send(yg->server, yg->focused_window->owner, response->size, (char *)response);
free(response);
}
yg->focused_window = w;
if (w) {
/* Send focus change to new focused window */
yutani_msg_t * response = yutani_msg_build_window_focus_change(w->wid, 1);
yutani_msg_buildx_window_focus_change_alloc(response);
yutani_msg_buildx_window_focus_change(response, w->wid, 1);
pex_send(yg->server, w->owner, response->size, (char *)response);
free(response);
make_top(yg, w);
mark_window(yg, w);
} else {
@ -836,9 +838,9 @@ static void redraw_windows(yutani_globals_t * yg) {
mark_screen(yg, 0, 0, yg->width, yg->height);
TRACE("Sending welcome messages...");
yutani_msg_t * response = yutani_msg_build_welcome(yg->width, yg->height);
yutani_msg_buildx_welcome_alloc(response);
yutani_msg_buildx_welcome(response, yg->width, yg->height);
pex_broadcast(yg->server, response->size, (char *)response);
free(response);
TRACE("Done.");
spin_unlock(&yg->redraw_lock);
@ -1155,9 +1157,9 @@ static uint32_t ad_flags(yutani_globals_t * yg, yutani_server_window_t * win) {
*/
static void yutani_query_result(yutani_globals_t * yg, uint32_t dest, yutani_server_window_t * win) {
if (win && win->client_length) {
yutani_msg_t * response = yutani_msg_build_window_advertise(win->wid, ad_flags(yg, win), win->client_offsets, win->client_length, win->client_strings);
yutani_msg_buildx_window_advertise_alloc(response, win->client_length);
yutani_msg_buildx_window_advertise(response, win->wid, ad_flags(yg, win), win->client_offsets, win->client_length, win->client_strings);
pex_send(yg->server, dest, response->size, (char *)response);
free(response);
}
}
@ -1165,7 +1167,8 @@ static void yutani_query_result(yutani_globals_t * yg, uint32_t dest, yutani_ser
* Send a notice to all subscribed clients that windows have updated.
*/
static void notify_subscribers(yutani_globals_t * yg) {
yutani_msg_t * response = yutani_msg_build_notify();
yutani_msg_buildx_notify_alloc(response);
yutani_msg_buildx_notify(response);
list_t * remove = NULL;
foreach(node, yg->window_subscribers) {
uint32_t subscriber = (uint32_t)node->value;
@ -1186,7 +1189,6 @@ static void notify_subscribers(yutani_globals_t * yg) {
}
free(remove);
}
free(response);
}
static void window_move(yutani_globals_t * yg, yutani_server_window_t * window, int x, int y) {
@ -1195,7 +1197,8 @@ static void window_move(yutani_globals_t * yg, yutani_server_window_t * window,
window->y = y;
mark_window(yg, window);
yutani_msg_t * response = yutani_msg_build_window_move(window->wid, x, y);
yutani_msg_buildx_window_move_alloc(response);
yutani_msg_buildx_window_move(response, window->wid, x, y);
pex_send(yg->server, window->owner, response->size, (char *)response);
}
@ -1236,9 +1239,9 @@ static void window_tile(yutani_globals_t * yg, yutani_server_window_t * window,
h = (yg->height - panel_h) - h * y;
}
yutani_msg_t * response = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_OFFER, window->wid, w, h, 0);
yutani_msg_buildx_window_resize_alloc(response);
yutani_msg_buildx_window_resize(response, YUTANI_MSG_RESIZE_OFFER, window->wid, w, h, 0);
pex_send(yg->server, window->owner, response->size, (char *)response);
free(response);
}
/**
@ -1247,9 +1250,9 @@ static void window_tile(yutani_globals_t * yg, yutani_server_window_t * window,
static void window_untile(yutani_globals_t * yg, yutani_server_window_t * window) {
window->tiled = 0;
yutani_msg_t * response = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_OFFER, window->wid, window->untiled_width, window->untiled_height, 0);
yutani_msg_buildx_window_resize_alloc(response);
yutani_msg_buildx_window_resize(response,YUTANI_MSG_RESIZE_OFFER, window->wid, window->untiled_width, window->untiled_height, 0);
pex_send(yg->server, window->owner, response->size, (char *)response);
free(response);
}
/**
@ -1306,9 +1309,9 @@ static void handle_key_event(yutani_globals_t * yg, struct yutani_msg_key_event
(ke->event.modifiers & KEY_MOD_LEFT_ALT) &&
(ke->event.keycode == KEY_F4)) {
if (focused->z != YUTANI_ZORDER_BOTTOM && focused->z != YUTANI_ZORDER_TOP) {
yutani_msg_t * response = yutani_msg_build_session_end();
yutani_msg_buildx_session_end_alloc(response);
yutani_msg_buildx_session_end(response);
pex_send(yg->server, focused->owner, response->size, (char *)response);
free(response);
return;
}
}
@ -1408,9 +1411,9 @@ static void handle_key_event(yutani_globals_t * yg, struct yutani_msg_key_event
if (hashmap_has(yg->key_binds, (void*)key_code)) {
struct key_bind * bind = hashmap_get(yg->key_binds, (void*)key_code);
yutani_msg_t * response = yutani_msg_build_key_event(focused ? focused->wid : UINT32_MAX, &ke->event, &ke->state);
yutani_msg_buildx_key_event_alloc(response);
yutani_msg_buildx_key_event(response,focused ? focused->wid : UINT32_MAX, &ke->event, &ke->state);
pex_send(yg->server, bind->owner, response->size, (char *)response);
free(response);
if (bind->response == YUTANI_BIND_STEAL) {
/* If this keybinding was registered as "steal", we'll stop here. */
@ -1421,9 +1424,9 @@ static void handle_key_event(yutani_globals_t * yg, struct yutani_msg_key_event
/* Finally, send the key to the focused client. */
if (focused) {
yutani_msg_t * response = yutani_msg_build_key_event(focused->wid, &ke->event, &ke->state);
yutani_msg_buildx_key_event_alloc(response);
yutani_msg_buildx_key_event(response,focused->wid, &ke->event, &ke->state);
pex_send(yg->server, focused->owner, response->size, (char *)response);
free(response);
}
}
@ -1614,11 +1617,11 @@ static void handle_mouse_event(yutani_globals_t * yg, struct yutani_msg_mouse_ev
yg->mouse_drag_button = YUTANI_MOUSE_BUTTON_LEFT;
if (yg->mouse_window) {
device_to_window(yg->mouse_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &yg->mouse_click_x, &yg->mouse_click_y);
yutani_msg_t * response = yutani_msg_build_window_mouse_event(yg->mouse_window->wid, yg->mouse_click_x, yg->mouse_click_y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_DOWN);
yutani_msg_buildx_window_mouse_event_alloc(response);
yutani_msg_buildx_window_mouse_event(response,yg->mouse_window->wid, yg->mouse_click_x, yg->mouse_click_y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_DOWN);
yg->mouse_click_x_orig = yg->mouse_click_x;
yg->mouse_click_y_orig = yg->mouse_click_y;
pex_send(yg->server, yg->mouse_window->owner, response->size, (char *)response);
free(response);
}
} else {
yg->mouse_window = get_focused(yg);
@ -1626,31 +1629,28 @@ static void handle_mouse_event(yutani_globals_t * yg, struct yutani_msg_mouse_ev
if (yg->mouse_window) {
int32_t x, y;
device_to_window(yg->mouse_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &x, &y);
yutani_msg_t * response = yutani_msg_build_window_mouse_event(yg->mouse_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_MOVE);
yutani_msg_buildx_window_mouse_event_alloc(response);
yutani_msg_buildx_window_mouse_event(response,yg->mouse_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_MOVE);
pex_send(yg->server, yg->mouse_window->owner, response->size, (char *)response);
free(response);
}
if (tmp_window) {
int32_t x, y;
yutani_msg_t * response;
yutani_msg_buildx_window_mouse_event_alloc(response);
if (tmp_window != yg->old_hover_window) {
device_to_window(tmp_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &x, &y);
response = yutani_msg_build_window_mouse_event(tmp_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_ENTER);
yutani_msg_buildx_window_mouse_event(response, tmp_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_ENTER);
pex_send(yg->server, tmp_window->owner, response->size, (char *)response);
free(response);
if (yg->old_hover_window) {
device_to_window(yg->old_hover_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &x, &y);
response = yutani_msg_build_window_mouse_event(yg->old_hover_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_LEAVE);
yutani_msg_buildx_window_mouse_event(response, yg->old_hover_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_LEAVE);
pex_send(yg->server, yg->old_hover_window->owner, response->size, (char *)response);
free(response);
}
yg->old_hover_window = tmp_window;
}
if (tmp_window != yg->mouse_window) {
device_to_window(tmp_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &x, &y);
response = yutani_msg_build_window_mouse_event(tmp_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_MOVE);
yutani_msg_buildx_window_mouse_event(response, tmp_window->wid, x, y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_MOVE);
pex_send(yg->server, tmp_window->owner, response->size, (char *)response);
free(response);
}
}
}
@ -1725,13 +1725,13 @@ static void handle_mouse_event(yutani_globals_t * yg, struct yutani_msg_mouse_ev
if (yg->mouse_window) {
device_to_window(yg->mouse_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &yg->mouse_click_x, &yg->mouse_click_y);
if (!yg->mouse_moved) {
yutani_msg_t * response = yutani_msg_build_window_mouse_event(yg->mouse_window->wid, yg->mouse_click_x, yg->mouse_click_y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_CLICK);
yutani_msg_buildx_window_mouse_event_alloc(response);
yutani_msg_buildx_window_mouse_event(response,yg->mouse_window->wid, yg->mouse_click_x, yg->mouse_click_y, -1, -1, me->event.buttons, YUTANI_MOUSE_EVENT_CLICK);
pex_send(yg->server, yg->mouse_window->owner, response->size, (char *)response);
free(response);
} else {
yutani_msg_t * response = yutani_msg_build_window_mouse_event(yg->mouse_window->wid, yg->mouse_click_x, yg->mouse_click_y, old_x, old_y, me->event.buttons, YUTANI_MOUSE_EVENT_RAISE);
yutani_msg_buildx_window_mouse_event_alloc(response);
yutani_msg_buildx_window_mouse_event(response,yg->mouse_window->wid, yg->mouse_click_x, yg->mouse_click_y, old_x, old_y, me->event.buttons, YUTANI_MOUSE_EVENT_RAISE);
pex_send(yg->server, yg->mouse_window->owner, response->size, (char *)response);
free(response);
}
}
} else {
@ -1742,9 +1742,9 @@ static void handle_mouse_event(yutani_globals_t * yg, struct yutani_msg_mouse_ev
if (yg->mouse_window) {
device_to_window(yg->mouse_window, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE, &yg->mouse_click_x, &yg->mouse_click_y);
if (old_x != yg->mouse_click_x || old_y != yg->mouse_click_y) {
yutani_msg_t * response = yutani_msg_build_window_mouse_event(yg->mouse_window->wid, yg->mouse_click_x, yg->mouse_click_y, old_x, old_y, me->event.buttons, YUTANI_MOUSE_EVENT_DRAG);
yutani_msg_buildx_window_mouse_event_alloc(response);
yutani_msg_buildx_window_mouse_event(response,yg->mouse_window->wid, yg->mouse_click_x, yg->mouse_click_y, old_x, old_y, me->event.buttons, YUTANI_MOUSE_EVENT_DRAG);
pex_send(yg->server, yg->mouse_window->owner, response->size, (char *)response);
free(response);
}
}
}
@ -1829,9 +1829,9 @@ static void handle_mouse_event(yutani_globals_t * yg, struct yutani_msg_mouse_ev
}
TRACE("resize complete, now %d x %d", yg->resizing_w, yg->resizing_h);
window_move(yg, yg->resizing_window, x,y);
yutani_msg_t * response = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_OFFER, yg->resizing_window->wid, yg->resizing_w, yg->resizing_h, 0);
yutani_msg_buildx_window_resize_alloc(response);
yutani_msg_buildx_window_resize(response,YUTANI_MSG_RESIZE_OFFER, yg->resizing_window->wid, yg->resizing_w, yg->resizing_h, 0);
pex_send(yg->server, yg->resizing_window->owner, response->size, (char *)response);
free(response);
yg->resizing_window = NULL;
yg->mouse_window = NULL;
yg->mouse_state = YUTANI_MOUSE_STATE_NORMAL;
@ -2040,9 +2040,9 @@ int main(int argc, char * argv[]) {
case YUTANI_MSG_KEY_EVENT:
{
struct yutani_msg_key_event * ke = (void*)m->data;
yutani_msg_t * m_ = yutani_msg_build_key_event(0, &ke->event, &ke->state);
yutani_msg_buildx_key_event_alloc(m_);
yutani_msg_buildx_key_event(m_, 0, &ke->event, &ke->state);
handle_key_event(yg, (struct yutani_msg_key_event *)m_->data);
free(m_);
}
break;
case YUTANI_MSG_WINDOW_MOUSE_EVENT:
@ -2056,9 +2056,9 @@ int main(int argc, char * argv[]) {
yg->last_mouse_buttons = packet.buttons;
yutani_msg_t * m_ = yutani_msg_build_mouse_event(0, &packet, YUTANI_MOUSE_EVENT_TYPE_ABSOLUTE);
yutani_msg_buildx_mouse_event_alloc(m_);
yutani_msg_buildx_mouse_event(m_, 0, &packet, YUTANI_MOUSE_EVENT_TYPE_ABSOLUTE);
handle_mouse_event(yg, (struct yutani_msg_mouse_event *)m_->data);
free(m_);
}
break;
case YUTANI_MSG_RESIZE_OFFER:
@ -2072,9 +2072,9 @@ int main(int argc, char * argv[]) {
case YUTANI_MSG_SESSION_END:
{
TRACE("Host session ended. Should exit.");
yutani_msg_t * response = yutani_msg_build_session_end();
yutani_msg_buildx_session_end_alloc(response);
yutani_msg_buildx_session_end(response);
pex_broadcast(server, response->size, (char *)response);
free(response);
kill(render_thread.id, SIGINT);
exit(0);
}
@ -2094,18 +2094,18 @@ int main(int argc, char * argv[]) {
int r = read(kfd, buf, 1);
if (r > 0) {
kbd_scancode(&state, buf[0], &event);
yutani_msg_t * m = yutani_msg_build_key_event(0, &event, &state);
yutani_msg_buildx_key_event_alloc(m);
yutani_msg_buildx_key_event(m,0, &event, &state);
handle_key_event(yg, (struct yutani_msg_key_event *)m->data);
free(m);
}
continue;
} else if (index == 1) {
int r = read(mfd, (char *)&packet, sizeof(mouse_device_packet_t));
if (r > 0) {
yg->last_mouse_buttons = packet.buttons;
yutani_msg_t * m = yutani_msg_build_mouse_event(0, &packet, YUTANI_MOUSE_EVENT_TYPE_RELATIVE);
yutani_msg_buildx_mouse_event_alloc(m);
yutani_msg_buildx_mouse_event(m,0, &packet, YUTANI_MOUSE_EVENT_TYPE_RELATIVE);
handle_mouse_event(yg, (struct yutani_msg_mouse_event *)m->data);
free(m);
}
continue;
} else if (index == 3) {
@ -2116,9 +2116,9 @@ int main(int argc, char * argv[]) {
} else {
yg->last_mouse_buttons = packet.buttons;
}
yutani_msg_t * m = yutani_msg_build_mouse_event(0, &packet, YUTANI_MOUSE_EVENT_TYPE_ABSOLUTE);
yutani_msg_buildx_mouse_event_alloc(m);
yutani_msg_buildx_mouse_event(m,0, &packet, YUTANI_MOUSE_EVENT_TYPE_ABSOLUTE);
handle_mouse_event(yg, (struct yutani_msg_mouse_event *)m->data);
free(m);
}
continue;
}
@ -2165,9 +2165,9 @@ int main(int argc, char * argv[]) {
client_list = list_create();
hashmap_set(yg->clients_to_windows, (void *)p->source, client_list);
}
yutani_msg_t * response = yutani_msg_build_welcome(yg->width, yg->height);
yutani_msg_buildx_welcome_alloc(response);
yutani_msg_buildx_welcome(response,yg->width, yg->height);
pex_send(server, p->source, response->size, (char *)response);
free(response);
}
break;
case YUTANI_MSG_WINDOW_NEW:
@ -2176,9 +2176,9 @@ int main(int argc, char * argv[]) {
struct yutani_msg_window_new_flags * wn = (void *)m->data;
TRACE("Client %08x requested a new window (%dx%d).", p->source, wn->width, wn->height);
yutani_server_window_t * w = server_window_create(yg, wn->width, wn->height, p->source, m->type != YUTANI_MSG_WINDOW_NEW ? wn->flags : 0);
yutani_msg_t * response = yutani_msg_build_window_init(w->wid, w->width, w->height, w->bufid);
yutani_msg_buildx_window_init_alloc(response);
yutani_msg_buildx_window_init(response,w->wid, w->width, w->height, w->bufid);
pex_send(server, p->source, response->size, (char *)response);
free(response);
if (!(w->server_flags & YUTANI_WINDOW_FLAG_NO_STEAL_FOCUS)) {
set_focused_window(yg, w);
@ -2259,9 +2259,9 @@ int main(int argc, char * argv[]) {
struct yutani_msg_window_resize * wr = (void *)m->data;
yutani_server_window_t * w = hashmap_get(yg->wids_to_windows, (void *)wr->wid);
if (w) {
yutani_msg_t * response = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_OFFER, w->wid, wr->width, wr->height, 0);
yutani_msg_buildx_window_resize_alloc(response);
yutani_msg_buildx_window_resize(response,YUTANI_MSG_RESIZE_OFFER, w->wid, wr->width, wr->height, 0);
pex_send(server, p->source, response->size, (char *)response);
free(response);
}
}
break;
@ -2270,9 +2270,9 @@ int main(int argc, char * argv[]) {
struct yutani_msg_window_resize * wr = (void *)m->data;
yutani_server_window_t * w = hashmap_get(yg->wids_to_windows, (void *)wr->wid);
if (w) {
yutani_msg_t * response = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_OFFER, w->wid, wr->width, wr->height, 0);
yutani_msg_buildx_window_resize_alloc(response);
yutani_msg_buildx_window_resize(response,YUTANI_MSG_RESIZE_OFFER, w->wid, wr->width, wr->height, 0);
pex_send(server, p->source, response->size, (char *)response);
free(response);
}
}
break;
@ -2282,9 +2282,9 @@ int main(int argc, char * argv[]) {
yutani_server_window_t * w = hashmap_get(yg->wids_to_windows, (void *)wr->wid);
if (w) {
uint32_t newbufid = server_window_resize(yg, w, wr->width, wr->height);
yutani_msg_t * response = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_BUFID, w->wid, wr->width, wr->height, newbufid);
yutani_msg_buildx_window_resize_alloc(response);
yutani_msg_buildx_window_resize(response,YUTANI_MSG_RESIZE_BUFID, w->wid, wr->width, wr->height, newbufid);
pex_send(server, p->source, response->size, (char *)response);
free(response);
}
}
break;
@ -2304,9 +2304,9 @@ int main(int argc, char * argv[]) {
yutani_query_result(yg, p->source, node->value);
}
yutani_query_result(yg, p->source, yg->top_z);
yutani_msg_t * response = yutani_msg_build_window_advertise(0, 0, NULL, 0, NULL);
yutani_msg_buildx_window_advertise_alloc(response, 0);
yutani_msg_buildx_window_advertise(response,0, 0, NULL, 0, NULL);
pex_send(server, p->source, response->size, (char *)response);
free(response);
}
break;
case YUTANI_MSG_SUBSCRIBE:
@ -2349,9 +2349,9 @@ int main(int argc, char * argv[]) {
break;
case YUTANI_MSG_SESSION_END:
{
yutani_msg_t * response = yutani_msg_build_session_end();
yutani_msg_buildx_session_end_alloc(response);
yutani_msg_buildx_session_end(response);
pex_broadcast(server, response->size, (char *)response);
free(response);
}
break;
case YUTANI_MSG_WINDOW_FOCUS:

View File

@ -0,0 +1,345 @@
#pragma once
#include <alloca.h>
#define yutani_msg_buildx_hello_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_hello(yutani_msg_t * msg) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_HELLO;
msg->size = sizeof(struct yutani_message);
}
#define yutani_msg_buildx_flip_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_flip)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_flip(yutani_msg_t * msg, yutani_wid_t wid) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_FLIP;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_flip);
struct yutani_msg_flip * mw = (void *)msg->data;
mw->wid = wid;
}
#define yutani_msg_buildx_welcome_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_welcome)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_welcome(yutani_msg_t * msg, uint32_t width, uint32_t height) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WELCOME;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_welcome);
struct yutani_msg_welcome * mw = (void *)msg->data;
mw->display_width = width;
mw->display_height = height;
}
#define yutani_msg_buildx_window_new_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_new)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_new(yutani_msg_t * msg, uint32_t width, uint32_t height) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_NEW;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_new);
struct yutani_msg_window_new * mw = (void *)msg->data;
mw->width = width;
mw->height = height;
}
#define yutani_msg_buildx_window_new_flags_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_new_flags)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_new_flags(yutani_msg_t * msg, uint32_t width, uint32_t height, uint32_t flags) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_NEW_FLAGS;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_new_flags);
struct yutani_msg_window_new_flags * mw = (void *)msg->data;
mw->width = width;
mw->height = height;
mw->flags = flags;
}
#define yutani_msg_buildx_window_init_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_init)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_init(yutani_msg_t * msg, yutani_wid_t wid, uint32_t width, uint32_t height, uint32_t bufid) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_INIT;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_init);
struct yutani_msg_window_init * mw = (void *)msg->data;
mw->wid = wid;
mw->width = width;
mw->height = height;
mw->bufid = bufid;
}
#define yutani_msg_buildx_window_close_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_close)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_close(yutani_msg_t * msg, yutani_wid_t wid) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_CLOSE;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_close);
struct yutani_msg_window_close * mw = (void *)msg->data;
mw->wid = wid;
}
#define yutani_msg_buildx_key_event_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_key_event)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_key_event(yutani_msg_t * msg, yutani_wid_t wid, key_event_t * event, key_event_state_t * state) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_KEY_EVENT;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_key_event);
struct yutani_msg_key_event * mw = (void *)msg->data;
mw->wid = wid;
memcpy(&mw->event, event, sizeof(key_event_t));
memcpy(&mw->state, state, sizeof(key_event_state_t));
}
#define yutani_msg_buildx_mouse_event_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_mouse_event)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_mouse_event(yutani_msg_t * msg, yutani_wid_t wid, mouse_device_packet_t * event, int32_t type) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_MOUSE_EVENT;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_mouse_event);
struct yutani_msg_mouse_event * mw = (void *)msg->data;
mw->wid = wid;
memcpy(&mw->event, event, sizeof(mouse_device_packet_t));
mw->type = type;
}
#define yutani_msg_buildx_window_move_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_move)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_move(yutani_msg_t * msg, yutani_wid_t wid, int32_t x, int32_t y) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_MOVE;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_move);
struct yutani_msg_window_move * mw = (void *)msg->data;
mw->wid = wid;
mw->x = x;
mw->y = y;
}
#define yutani_msg_buildx_window_stack_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_stack)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_stack(yutani_msg_t * msg, yutani_wid_t wid, int z) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_STACK;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_stack);
struct yutani_msg_window_stack * mw = (void *)msg->data;
mw->wid = wid;
mw->z = z;
}
#define yutani_msg_buildx_window_focus_change_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_focus_change)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_focus_change(yutani_msg_t * msg, yutani_wid_t wid, int focused) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_FOCUS_CHANGE;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_focus_change);
struct yutani_msg_window_focus_change * mw = (void *)msg->data;
mw->wid = wid;
mw->focused = focused;
}
#define yutani_msg_buildx_window_mouse_event_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_mouse_event)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_mouse_event(yutani_msg_t * msg, yutani_wid_t wid, int32_t new_x, int32_t new_y, int32_t old_x, int32_t old_y, uint8_t buttons, uint8_t command) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_MOUSE_EVENT;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_mouse_event);
struct yutani_msg_window_mouse_event * mw = (void *)msg->data;
mw->wid = wid;
mw->new_x = new_x;
mw->new_y = new_y;
mw->old_x = old_x;
mw->old_y = old_y;
mw->buttons = buttons;
mw->command = command;
}
#define yutani_msg_buildx_flip_region_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_flip_region)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_flip_region(yutani_msg_t * msg, yutani_wid_t wid, int32_t x, int32_t y, int32_t width, int32_t height) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_FLIP_REGION;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_flip_region);
struct yutani_msg_flip_region * mw = (void *)msg->data;
mw->wid = wid;
mw->x = x;
mw->y = y;
mw->width = width;
mw->height = height;
}
#define yutani_msg_buildx_window_resize_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_resize)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_resize(yutani_msg_t * msg, uint32_t type, yutani_wid_t wid, uint32_t width, uint32_t height, uint32_t bufid) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = type;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_resize);
struct yutani_msg_window_resize * mw = (void *)msg->data;
mw->wid = wid;
mw->width = width;
mw->height = height;
mw->bufid = bufid;
}
#define yutani_msg_buildx_window_advertise_alloc(out, length) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_advertise) + length]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_advertise(yutani_msg_t * msg, yutani_wid_t wid, uint32_t flags, uint16_t * offsets, size_t length, char * data) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_ADVERTISE;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_advertise) + length;
struct yutani_msg_window_advertise * mw = (void *)msg->data;
mw->wid = wid;
mw->flags = flags;
mw->size = length;
if (offsets) {
memcpy(mw->offsets, offsets, sizeof(uint16_t)*5);
} else {
memset(mw->offsets, 0, sizeof(uint16_t)*5);
}
if (data) {
memcpy(mw->strings, data, mw->size);
}
}
#define yutani_msg_buildx_subscribe_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_subscribe(yutani_msg_t * msg) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_SUBSCRIBE;
msg->size = sizeof(struct yutani_message);
}
#define yutani_msg_buildx_unsubscribe_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_unsubscribe(yutani_msg_t * msg) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_UNSUBSCRIBE;
msg->size = sizeof(struct yutani_message);
}
#define yutani_msg_buildx_query_windows_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_query_windows(yutani_msg_t * msg) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_QUERY_WINDOWS;
msg->size = sizeof(struct yutani_message);
}
#define yutani_msg_buildx_notify_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_notify(yutani_msg_t * msg) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_NOTIFY;
msg->size = sizeof(struct yutani_message);
}
#define yutani_msg_buildx_session_end_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_session_end(yutani_msg_t * msg) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_SESSION_END;
msg->size = sizeof(struct yutani_message);
}
#define yutani_msg_buildx_window_focus_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_focus)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_focus(yutani_msg_t * msg, yutani_wid_t wid) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_FOCUS;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_focus);
struct yutani_msg_window_focus * mw = (void *)msg->data;
mw->wid = wid;
}
#define yutani_msg_buildx_key_bind_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_key_bind)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_key_bind(yutani_msg_t * msg, kbd_key_t key, kbd_mod_t mod, int response) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_KEY_BIND;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_key_bind);
struct yutani_msg_key_bind * mw = (void *)msg->data;
mw->key = key;
mw->modifiers = mod;
mw->response = response;
}
#define yutani_msg_buildx_window_drag_start_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_drag_start)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_drag_start(yutani_msg_t * msg, yutani_wid_t wid) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_DRAG_START;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_drag_start);
struct yutani_msg_window_drag_start * mw = (void *)msg->data;
mw->wid = wid;
}
#define yutani_msg_buildx_window_update_shape_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_update_shape)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_update_shape(yutani_msg_t * msg, yutani_wid_t wid, int set_shape) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_UPDATE_SHAPE;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_update_shape);
struct yutani_msg_window_update_shape * mw = (void *)msg->data;
mw->wid = wid;
mw->set_shape = set_shape;
}
#define yutani_msg_buildx_window_warp_mouse_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_warp_mouse)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_warp_mouse(yutani_msg_t * msg, yutani_wid_t wid, int32_t x, int32_t y) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_WARP_MOUSE;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_warp_mouse);
struct yutani_msg_window_warp_mouse * mw = (void *)msg->data;
mw->wid = wid;
mw->x = x;
mw->y = y;
}
#define yutani_msg_buildx_window_show_mouse_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_show_mouse)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_show_mouse(yutani_msg_t * msg, yutani_wid_t wid, int32_t show_mouse) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_SHOW_MOUSE;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_show_mouse);
struct yutani_msg_window_show_mouse * mw = (void *)msg->data;
mw->wid = wid;
mw->show_mouse = show_mouse;
}
#define yutani_msg_buildx_window_resize_start_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_resize_start)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_window_resize_start(yutani_msg_t * msg, yutani_wid_t wid, yutani_scale_direction_t direction) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_WINDOW_RESIZE_START;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_window_resize_start);
struct yutani_msg_window_resize_start * mw = (void *)msg->data;
mw->wid = wid;
mw->direction = direction;
}
#define yutani_msg_buildx_special_request_alloc(out) char _yutani_tmp_ ## LINE [sizeof(struct yutani_message) + sizeof(struct yutani_msg_special_request)]; yutani_msg_t * out = (void *)&_yutani_tmp_ ## LINE;
static inline void yutani_msg_buildx_special_request(yutani_msg_t * msg, yutani_wid_t wid, uint32_t request) {
msg->magic = YUTANI_MSG__MAGIC;
msg->type = YUTANI_MSG_SPECIAL_REQUEST;
msg->size = sizeof(struct yutani_message) + sizeof(struct yutani_msg_special_request);
struct yutani_msg_special_request * sr = (void *)msg->data;
sr->wid = wid;
sr->request = request;
}

View File

@ -14,6 +14,8 @@
#include <toaru/yutani.h>
#include <toaru/mouse.h>
#include <toaru/yutani_ext.h>
yutani_msg_t * yutani_wait_for(yutani_t * y, uint32_t type) {
do {
yutani_msg_t * out;
@ -557,16 +559,16 @@ yutani_t * yutani_init(void) {
}
yutani_t * y = yutani_context_create(c);
yutani_msg_t * m = yutani_msg_build_hello();
yutani_msg_buildx_hello_alloc(m);
yutani_msg_buildx_hello(m);
yutani_msg_send(y, m);
free(m);
m = yutani_wait_for(y, YUTANI_MSG_WELCOME);
struct yutani_msg_welcome * mw = (void *)&m->data;
yutani_msg_t * mm = yutani_wait_for(y, YUTANI_MSG_WELCOME);
struct yutani_msg_welcome * mw = (void *)&mm->data;
y->display_width = mw->display_width;
y->display_height = mw->display_height;
y->server_ident = server_name;
free(m);
free(mm);
return y;
}
@ -574,18 +576,19 @@ yutani_t * yutani_init(void) {
yutani_window_t * yutani_window_create_flags(yutani_t * y, int width, int height, uint32_t flags) {
yutani_window_t * win = malloc(sizeof(yutani_window_t));
yutani_msg_t * m = yutani_msg_build_window_new_flags(width, height, flags);
yutani_msg_buildx_window_new_flags_alloc(m);
yutani_msg_buildx_window_new_flags(m, width, height, flags);
yutani_msg_send(y, m);
free(m);
m = yutani_wait_for(y, YUTANI_MSG_WINDOW_INIT);
struct yutani_msg_window_init * mw = (void *)&m->data;
yutani_msg_t * mm = yutani_wait_for(y, YUTANI_MSG_WINDOW_INIT);
struct yutani_msg_window_init * mw = (void *)&mm->data;
win->width = mw->width;
win->height = mw->height;
win->bufid = mw->bufid;
win->wid = mw->wid;
win->focused = 0;
free(mm);
hashmap_set(y->windows, (void*)win->wid, win);
@ -603,21 +606,21 @@ yutani_window_t * yutani_window_create(yutani_t * y, int width, int height) {
}
void yutani_flip(yutani_t * y, yutani_window_t * win) {
yutani_msg_t * m = yutani_msg_build_flip(win->wid);
yutani_msg_buildx_flip_alloc(m);
yutani_msg_buildx_flip(m, win->wid);
yutani_msg_send(y, m);
free(m);
}
void yutani_flip_region(yutani_t * yctx, yutani_window_t * win, int32_t x, int32_t y, int32_t width, int32_t height) {
yutani_msg_t * m = yutani_msg_build_flip_region(win->wid, x, y, width, height);
yutani_msg_buildx_flip_region_alloc(m);
yutani_msg_buildx_flip_region(m, win->wid, x, y, width, height);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_close(yutani_t * y, yutani_window_t * win) {
yutani_msg_t * m = yutani_msg_build_window_close(win->wid);
yutani_msg_buildx_window_close_alloc(m);
yutani_msg_buildx_window_close(m, win->wid);
yutani_msg_send(y, m);
free(m);
/* Now destroy our end of the window */
{
@ -631,37 +634,37 @@ void yutani_close(yutani_t * y, yutani_window_t * win) {
}
void yutani_window_move(yutani_t * yctx, yutani_window_t * window, int x, int y) {
yutani_msg_t * m = yutani_msg_build_window_move(window->wid, x, y);
yutani_msg_buildx_window_move_alloc(m);
yutani_msg_buildx_window_move(m, window->wid, x, y);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_set_stack(yutani_t * yctx, yutani_window_t * window, int z) {
yutani_msg_t * m = yutani_msg_build_window_stack(window->wid, z);
yutani_msg_buildx_window_stack_alloc(m);
yutani_msg_buildx_window_stack(m, window->wid, z);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_resize(yutani_t * yctx, yutani_window_t * window, uint32_t width, uint32_t height) {
yutani_msg_t * m = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_REQUEST, window->wid, width, height, 0);
yutani_msg_buildx_window_resize_alloc(m);
yutani_msg_buildx_window_resize(m, YUTANI_MSG_RESIZE_REQUEST, window->wid, width, height, 0);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_resize_offer(yutani_t * yctx, yutani_window_t * window, uint32_t width, uint32_t height) {
yutani_msg_t * m = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_OFFER, window->wid, width, height, 0);
yutani_msg_buildx_window_resize_alloc(m);
yutani_msg_buildx_window_resize(m, YUTANI_MSG_RESIZE_OFFER, window->wid, width, height, 0);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_resize_accept(yutani_t * yctx, yutani_window_t * window, uint32_t width, uint32_t height) {
yutani_msg_t * m = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_ACCEPT, window->wid, width, height, 0);
yutani_msg_buildx_window_resize_alloc(m);
yutani_msg_buildx_window_resize(m, YUTANI_MSG_RESIZE_ACCEPT, window->wid, width, height, 0);
yutani_msg_send(yctx, m);
free(m);
/* Now wait for the new bufid */
m = yutani_wait_for(yctx, YUTANI_MSG_RESIZE_BUFID);
struct yutani_msg_window_resize * wr = (void*)m->data;
yutani_msg_t * mm = yutani_wait_for(yctx, YUTANI_MSG_RESIZE_BUFID);
struct yutani_msg_window_resize * wr = (void*)mm->data;
if (window->wid != wr->wid) {
/* I am not sure what to do here. */
@ -673,7 +676,7 @@ void yutani_window_resize_accept(yutani_t * yctx, yutani_window_t * window, uint
window->height = wr->height;
window->oldbufid = window->bufid;
window->bufid = wr->bufid;
free(m);
free(mm);
/* Allocate the buffer */
{
@ -693,9 +696,9 @@ void yutani_window_resize_done(yutani_t * yctx, yutani_window_t * window) {
syscall_shm_release(key);
}
yutani_msg_t * m = yutani_msg_build_window_resize(YUTANI_MSG_RESIZE_DONE, window->wid, window->width, window->height, window->bufid);
yutani_msg_buildx_window_resize_alloc(m);
yutani_msg_buildx_window_resize(m, YUTANI_MSG_RESIZE_DONE, window->wid, window->width, window->height, window->bufid);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_advertise(yutani_t * yctx, yutani_window_t * window, char * name) {
@ -718,9 +721,9 @@ void yutani_window_advertise(yutani_t * yctx, yutani_window_t * window, char * n
offsets[4] = strlen(name);
}
yutani_msg_t * m = yutani_msg_build_window_advertise(window->wid, flags, offsets, length, strings);
yutani_msg_buildx_window_advertise_alloc(m, length);
yutani_msg_buildx_window_advertise(m, window->wid, flags, offsets, length, strings);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_advertise_icon(yutani_t * yctx, yutani_window_t * window, char * name, char * icon) {
@ -746,89 +749,89 @@ void yutani_window_advertise_icon(yutani_t * yctx, yutani_window_t * window, cha
offsets[4] = strlen(name)+1+strlen(icon);
}
yutani_msg_t * m = yutani_msg_build_window_advertise(window->wid, flags, offsets, length, strings);
yutani_msg_buildx_window_advertise_alloc(m, length);
yutani_msg_buildx_window_advertise(m, window->wid, flags, offsets, length, strings);
yutani_msg_send(yctx, m);
free(m);
free(strings);
}
void yutani_subscribe_windows(yutani_t * y) {
yutani_msg_t * m = yutani_msg_build_subscribe();
yutani_msg_buildx_subscribe_alloc(m);
yutani_msg_buildx_subscribe(m);
yutani_msg_send(y, m);
free(m);
}
void yutani_unsubscribe_windows(yutani_t * y) {
yutani_msg_t * m = yutani_msg_build_unsubscribe();
yutani_msg_buildx_unsubscribe_alloc(m);
yutani_msg_buildx_unsubscribe(m);
yutani_msg_send(y, m);
free(m);
}
void yutani_query_windows(yutani_t * y) {
yutani_msg_t * m = yutani_msg_build_query_windows();
yutani_msg_buildx_query_windows_alloc(m);
yutani_msg_buildx_query_windows(m);
yutani_msg_send(y, m);
free(m);
}
void yutani_session_end(yutani_t * y) {
yutani_msg_t * m = yutani_msg_build_session_end();
yutani_msg_buildx_session_end_alloc(m);
yutani_msg_buildx_session_end(m);
yutani_msg_send(y, m);
free(m);
}
void yutani_focus_window(yutani_t * yctx, yutani_wid_t wid) {
yutani_msg_t * m = yutani_msg_build_window_focus(wid);
yutani_msg_buildx_window_focus_alloc(m);
yutani_msg_buildx_window_focus(m, wid);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_key_bind(yutani_t * yctx, kbd_key_t key, kbd_mod_t mod, int response) {
yutani_msg_t * m = yutani_msg_build_key_bind(key,mod,response);
yutani_msg_buildx_key_bind_alloc(m);
yutani_msg_buildx_key_bind(m, key,mod,response);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_drag_start(yutani_t * yctx, yutani_window_t * window) {
yutani_msg_t * m = yutani_msg_build_window_drag_start(window->wid);
yutani_msg_buildx_window_drag_start_alloc(m);
yutani_msg_buildx_window_drag_start(m, window->wid);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_drag_start_wid(yutani_t * yctx, yutani_wid_t wid) {
yutani_msg_t * m = yutani_msg_build_window_drag_start(wid);
yutani_msg_buildx_window_drag_start_alloc(m);
yutani_msg_buildx_window_drag_start(m, wid);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_update_shape(yutani_t * yctx, yutani_window_t * window, int set_shape) {
yutani_msg_t * m = yutani_msg_build_window_update_shape(window->wid, set_shape);
yutani_msg_buildx_window_update_shape_alloc(m);
yutani_msg_buildx_window_update_shape(m, window->wid, set_shape);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_warp_mouse(yutani_t * yctx, yutani_window_t * window, int32_t x, int32_t y) {
yutani_msg_t * m = yutani_msg_build_window_warp_mouse(window->wid, x, y);
yutani_msg_buildx_window_warp_mouse_alloc(m);
yutani_msg_buildx_window_warp_mouse(m, window->wid, x, y);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_show_mouse(yutani_t * yctx, yutani_window_t * window, int32_t show_mouse) {
yutani_msg_t * m = yutani_msg_build_window_show_mouse(window->wid, show_mouse);
yutani_msg_buildx_window_show_mouse_alloc(m);
yutani_msg_buildx_window_show_mouse(m, window->wid, show_mouse);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_window_resize_start(yutani_t * yctx, yutani_window_t * window, yutani_scale_direction_t direction) {
yutani_msg_t * m = yutani_msg_build_window_resize_start(window->wid, direction);
yutani_msg_buildx_window_resize_start_alloc(m);
yutani_msg_buildx_window_resize_start(m, window->wid, direction);
yutani_msg_send(yctx, m);
free(m);
}
void yutani_special_request(yutani_t * yctx, yutani_window_t * window, uint32_t request) {
/* wid isn't necessary; if window is null, set to 0 */
yutani_msg_t * m = yutani_msg_build_special_request(window ? window->wid : 0, request);
yutani_msg_buildx_special_request_alloc(m);
yutani_msg_buildx_special_request(m, window ? window->wid : 0, request);
yutani_msg_send(yctx, m);
free(m);
}
gfx_context_t * init_graphics_yutani(yutani_window_t * window) {