Remove nvnc_set_dimensions()
This information is now figured out based on the nvnc_fb passed into nvnc_set_buffer()pull/30/head
parent
97899ed045
commit
737dd311a0
|
@ -139,7 +139,6 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
struct nvnc* server = nvnc_open("127.0.0.1", 5900);
|
struct nvnc* server = nvnc_open("127.0.0.1", 5900);
|
||||||
|
|
||||||
nvnc_set_dimensions(server, width, height, format);
|
|
||||||
nvnc_set_name(server, "Draw");
|
nvnc_set_name(server, "Draw");
|
||||||
nvnc_set_pointer_fn(server, on_pointer_event);
|
nvnc_set_pointer_fn(server, on_pointer_event);
|
||||||
nvnc_set_userdata(server, &draw);
|
nvnc_set_userdata(server, &draw);
|
||||||
|
|
|
@ -49,11 +49,6 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
struct nvnc* server = nvnc_open("127.0.0.1", 5900);
|
struct nvnc* server = nvnc_open("127.0.0.1", 5900);
|
||||||
|
|
||||||
int width = nvnc_fb_get_width(fb);
|
|
||||||
int height = nvnc_fb_get_height(fb);
|
|
||||||
uint32_t fourcc_format = nvnc_fb_get_fourcc_format(fb);
|
|
||||||
|
|
||||||
nvnc_set_dimensions(server, width, height, fourcc_format);
|
|
||||||
nvnc_set_buffer(server, fb);
|
nvnc_set_buffer(server, fb);
|
||||||
nvnc_set_name(server, file);
|
nvnc_set_name(server, file);
|
||||||
|
|
||||||
|
|
|
@ -81,20 +81,13 @@ struct nvnc_client {
|
||||||
|
|
||||||
LIST_HEAD(nvnc_client_list, nvnc_client);
|
LIST_HEAD(nvnc_client_list, nvnc_client);
|
||||||
|
|
||||||
struct vnc_display {
|
|
||||||
uint16_t width;
|
|
||||||
uint16_t height;
|
|
||||||
uint32_t pixfmt; /* fourcc pixel format */
|
|
||||||
char name[256];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct nvnc {
|
struct nvnc {
|
||||||
struct nvnc_common common;
|
struct nvnc_common common;
|
||||||
int fd;
|
int fd;
|
||||||
struct aml_handler* poll_handle;
|
struct aml_handler* poll_handle;
|
||||||
struct aml_idle* dispatch_handler;
|
struct aml_idle* dispatch_handler;
|
||||||
struct nvnc_client_list clients;
|
struct nvnc_client_list clients;
|
||||||
struct vnc_display display;
|
char name[256];
|
||||||
void* userdata;
|
void* userdata;
|
||||||
nvnc_key_fn key_fn;
|
nvnc_key_fn key_fn;
|
||||||
nvnc_pointer_fn pointer_fn;
|
nvnc_pointer_fn pointer_fn;
|
||||||
|
|
|
@ -57,9 +57,6 @@ void* nvnc_get_userdata(const void* self);
|
||||||
|
|
||||||
struct nvnc* nvnc_get_server(const struct nvnc_client* client);
|
struct nvnc* nvnc_get_server(const struct nvnc_client* client);
|
||||||
|
|
||||||
void nvnc_set_dimensions(struct nvnc* self, uint16_t width, uint16_t height,
|
|
||||||
uint32_t fourcc_format);
|
|
||||||
|
|
||||||
void nvnc_set_buffer(struct nvnc*, struct nvnc_fb*);
|
void nvnc_set_buffer(struct nvnc*, struct nvnc_fb*);
|
||||||
|
|
||||||
void nvnc_set_name(struct nvnc* self, const char* name);
|
void nvnc_set_name(struct nvnc* self, const char* name);
|
||||||
|
|
66
src/server.c
66
src/server.c
|
@ -348,28 +348,31 @@ static void disconnect_all_other_clients(struct nvnc_client* client)
|
||||||
static void send_server_init_message(struct nvnc_client* client)
|
static void send_server_init_message(struct nvnc_client* client)
|
||||||
{
|
{
|
||||||
struct nvnc* server = client->server;
|
struct nvnc* server = client->server;
|
||||||
struct vnc_display* display = &server->display;
|
|
||||||
|
|
||||||
size_t name_len = strlen(display->name);
|
size_t name_len = strlen(server->name);
|
||||||
size_t size = sizeof(struct rfb_server_init_msg) + name_len;
|
size_t size = sizeof(struct rfb_server_init_msg) + name_len;
|
||||||
|
|
||||||
|
if (!server->buffer) {
|
||||||
|
log_debug("Tried to send init message, but not buffer has been set\n");
|
||||||
|
goto close;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t width = nvnc_fb_get_width(server->buffer);
|
||||||
|
uint16_t height = nvnc_fb_get_height(server->buffer);
|
||||||
|
uint32_t fourcc = nvnc_fb_get_fourcc_format(server->buffer);
|
||||||
|
|
||||||
struct rfb_server_init_msg* msg = calloc(1, size);
|
struct rfb_server_init_msg* msg = calloc(1, size);
|
||||||
if (!msg) {
|
if (!msg)
|
||||||
stream_close(client->net_stream);
|
goto close;
|
||||||
client_unref(client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg->width = htons(display->width),
|
msg->width = htons(width);
|
||||||
msg->height = htons(display->height), msg->name_length = htonl(name_len),
|
msg->height = htons(height);
|
||||||
memcpy(msg->name_string, display->name, name_len);
|
msg->name_length = htonl(name_len);
|
||||||
|
memcpy(msg->name_string, server->name, name_len);
|
||||||
|
|
||||||
int rc = rfb_pixfmt_from_fourcc(&msg->pixel_format, display->pixfmt);
|
int rc = rfb_pixfmt_from_fourcc(&msg->pixel_format, fourcc);
|
||||||
if (rc < 0) {
|
if (rc < 0)
|
||||||
stream_close(client->net_stream);
|
goto pixfmt_failure;
|
||||||
client_unref(client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg->pixel_format.red_max = htons(msg->pixel_format.red_max);
|
msg->pixel_format.red_max = htons(msg->pixel_format.red_max);
|
||||||
msg->pixel_format.green_max = htons(msg->pixel_format.green_max);
|
msg->pixel_format.green_max = htons(msg->pixel_format.green_max);
|
||||||
|
@ -377,6 +380,14 @@ static void send_server_init_message(struct nvnc_client* client)
|
||||||
|
|
||||||
struct rcbuf* payload = rcbuf_new(msg, size);
|
struct rcbuf* payload = rcbuf_new(msg, size);
|
||||||
stream_send(client->net_stream, payload, NULL, NULL);
|
stream_send(client->net_stream, payload, NULL, NULL);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
pixfmt_failure:
|
||||||
|
free(msg);
|
||||||
|
close:
|
||||||
|
stream_close(client->net_stream);
|
||||||
|
client_unref(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int on_init_message(struct nvnc_client* client)
|
static int on_init_message(struct nvnc_client* client)
|
||||||
|
@ -834,7 +845,7 @@ struct nvnc* nvnc_open(const char* address, uint16_t port)
|
||||||
if (!self)
|
if (!self)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
strcpy(self->display.name, DEFAULT_NAME);
|
strcpy(self->name, DEFAULT_NAME);
|
||||||
|
|
||||||
LIST_INIT(&self->clients);
|
LIST_INIT(&self->clients);
|
||||||
|
|
||||||
|
@ -1063,9 +1074,13 @@ void nvnc_damage_region(struct nvnc* self, const struct pixman_region16* damage)
|
||||||
EXPORT
|
EXPORT
|
||||||
void nvnc_damage_whole(struct nvnc* self)
|
void nvnc_damage_whole(struct nvnc* self)
|
||||||
{
|
{
|
||||||
|
assert(self->buffer);
|
||||||
|
|
||||||
|
uint16_t width = nvnc_fb_get_width(self->buffer);
|
||||||
|
uint16_t height = nvnc_fb_get_height(self->buffer);
|
||||||
|
|
||||||
struct pixman_region16 damage;
|
struct pixman_region16 damage;
|
||||||
pixman_region_init_rect(&damage, 0, 0, self->display.width,
|
pixman_region_init_rect(&damage, 0, 0, width, height);
|
||||||
self->display.height);
|
|
||||||
nvnc_damage_region(self, &damage);
|
nvnc_damage_region(self, &damage);
|
||||||
pixman_region_fini(&damage);
|
pixman_region_fini(&damage);
|
||||||
}
|
}
|
||||||
|
@ -1120,15 +1135,6 @@ void nvnc_set_client_cleanup_fn(struct nvnc_client* self, nvnc_client_fn fn)
|
||||||
self->cleanup_fn = fn;
|
self->cleanup_fn = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT
|
|
||||||
void nvnc_set_dimensions(struct nvnc* self, uint16_t width, uint16_t height,
|
|
||||||
uint32_t fourcc_format)
|
|
||||||
{
|
|
||||||
self->display.width = width;
|
|
||||||
self->display.height = height;
|
|
||||||
self->display.pixfmt = fourcc_format;
|
|
||||||
}
|
|
||||||
|
|
||||||
EXPORT
|
EXPORT
|
||||||
void nvnc_set_buffer(struct nvnc* self, struct nvnc_fb* fb)
|
void nvnc_set_buffer(struct nvnc* self, struct nvnc_fb* fb)
|
||||||
{
|
{
|
||||||
|
@ -1148,8 +1154,8 @@ struct nvnc* nvnc_get_server(const struct nvnc_client* client)
|
||||||
EXPORT
|
EXPORT
|
||||||
void nvnc_set_name(struct nvnc* self, const char* name)
|
void nvnc_set_name(struct nvnc* self, const char* name)
|
||||||
{
|
{
|
||||||
strncpy(self->display.name, name, sizeof(self->display.name));
|
strncpy(self->name, name, sizeof(self->name));
|
||||||
self->display.name[sizeof(self->display.name) - 1] = '\0';
|
self->name[sizeof(self->name) - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT
|
EXPORT
|
||||||
|
|
Loading…
Reference in New Issue