|
|
|
|
@@ -38,20 +38,18 @@ static void new_protocol(void* data, struct wl_registry* registry,
|
|
|
|
|
/* `wl_registry.global_remove` callback */
|
|
|
|
|
static void protocol_removed(void* data,
|
|
|
|
|
struct wl_registry* registry,
|
|
|
|
|
MwU32 name) {
|
|
|
|
|
MwU32 name){
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* `wl_pointer.enter` callback */
|
|
|
|
|
static void pointer_enter(void* data, struct wl_pointer* wl_pointer, MwU32 serial,
|
|
|
|
|
struct wl_surface* surface, wl_fixed_t surface_x,
|
|
|
|
|
wl_fixed_t surface_y) {
|
|
|
|
|
};
|
|
|
|
|
wl_fixed_t surface_y){};
|
|
|
|
|
|
|
|
|
|
/* `wl_pointer.leave` callback */
|
|
|
|
|
static void pointer_leave(void* data, struct wl_pointer* wl_pointer, MwU32 serial,
|
|
|
|
|
struct wl_surface* surface) {
|
|
|
|
|
};
|
|
|
|
|
struct wl_surface* surface){};
|
|
|
|
|
|
|
|
|
|
/* `wl_pointer.motion` callback */
|
|
|
|
|
static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time,
|
|
|
|
|
@@ -93,12 +91,13 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MwLLDispatch(self, draw, NULL);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* `wl_pointer.axis` callback */
|
|
|
|
|
static void pointer_axis(void* data, struct wl_pointer* wl_pointer, MwU32 time,
|
|
|
|
|
MwU32 axis, wl_fixed_t value) {};
|
|
|
|
|
MwU32 axis, wl_fixed_t value){};
|
|
|
|
|
|
|
|
|
|
struct wl_pointer_listener pointer_listener = {
|
|
|
|
|
.enter = pointer_enter,
|
|
|
|
|
@@ -267,7 +266,7 @@ static void keyboard_modifiers(void* data,
|
|
|
|
|
MwU32 mods_depressed,
|
|
|
|
|
MwU32 mods_latched,
|
|
|
|
|
MwU32 mods_locked,
|
|
|
|
|
MwU32 group) {};
|
|
|
|
|
MwU32 group){};
|
|
|
|
|
|
|
|
|
|
struct wl_keyboard_listener keyboard_listener = {
|
|
|
|
|
.keymap = keyboard_keymap,
|
|
|
|
|
@@ -279,7 +278,7 @@ struct wl_keyboard_listener keyboard_listener = {
|
|
|
|
|
|
|
|
|
|
/* `wl_seat.name` callback */
|
|
|
|
|
static void
|
|
|
|
|
wl_seat_name(void* data, struct wl_seat* wl_seat, const char* name) {};
|
|
|
|
|
wl_seat_name(void* data, struct wl_seat* wl_seat, const char* name){};
|
|
|
|
|
|
|
|
|
|
/* `wl_seat.capabilities` callback */
|
|
|
|
|
static void wl_seat_capabilities(void* data, struct wl_seat* wl_seat,
|
|
|
|
|
@@ -393,7 +392,13 @@ static void xdg_toplevel_configure(void* data,
|
|
|
|
|
self->wayland.wh = height;
|
|
|
|
|
xdg_surface_set_window_geometry(self->wayland.toplevel->xdg_surface, 0, 0, self->wayland.ww, self->wayland.wh);
|
|
|
|
|
|
|
|
|
|
cairo_destroy(self->wayland.cairo);
|
|
|
|
|
cairo_surface_destroy(self->wayland.cs);
|
|
|
|
|
self->wayland.cs = cairo_image_surface_create_for_data(self->wayland.mapped_shm_buf, CAIRO_FORMAT_ARGB32, width, height, 4 * width);
|
|
|
|
|
self->wayland.cairo = cairo_create(self->wayland.cs);
|
|
|
|
|
|
|
|
|
|
MwLLDispatch(self, resize, NULL);
|
|
|
|
|
MwLLDispatch(self, draw, NULL);
|
|
|
|
|
|
|
|
|
|
/*if(!self->wayland.egl_setup) {
|
|
|
|
|
self->wayland.egl_setup = egl_setup(self, self->wayland.x, self->wayland.y, width, height);
|
|
|
|
|
@@ -544,7 +549,6 @@ static int event_loop(MwLL handle) {
|
|
|
|
|
|
|
|
|
|
/* Function for setting up the callbacks/structs that will be registered upon the relevant interfaces being found. */
|
|
|
|
|
static void setup_callbacks(struct _MwLLWayland* wayland) {
|
|
|
|
|
|
|
|
|
|
/* Convience macro for adding the interface functions to the setup map */
|
|
|
|
|
#define WL_INTERFACE(interface) \
|
|
|
|
|
shput(wayland->wl_protocol_setup_map, interface##_interface.name, (wl_setup_func*)interface##_setup);
|
|
|
|
|
@@ -677,8 +681,8 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|
|
|
|
|
|
|
|
|
r->common.type = MwLLBackendWayland;
|
|
|
|
|
|
|
|
|
|
if(width == 0) width = 1;
|
|
|
|
|
if(height == 0) height = 1;
|
|
|
|
|
if(width < 2) width = 2;
|
|
|
|
|
if(height < 2) height = 2;
|
|
|
|
|
|
|
|
|
|
if(x == MwDEFAULT) {
|
|
|
|
|
x = 0;
|
|
|
|
|
@@ -701,15 +705,23 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* example of writing to the buffer */
|
|
|
|
|
memset(r->wayland.mapped_shm_buf, 127, r->wayland.mapped_shm_buf_size);
|
|
|
|
|
memset(r->wayland.mapped_shm_buf, 255, r->wayland.mapped_shm_buf_size);
|
|
|
|
|
update_buffer(r);
|
|
|
|
|
|
|
|
|
|
r->wayland.cs = cairo_image_surface_create_for_data(r->wayland.mapped_shm_buf, CAIRO_FORMAT_ARGB32, width, height, 4 * width);
|
|
|
|
|
r->wayland.cairo = cairo_create(r->wayland.cs);
|
|
|
|
|
|
|
|
|
|
MwLLForceRender(r);
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MwLLDestroyImpl(MwLL handle) {
|
|
|
|
|
MwLLDestroyCommon(handle);
|
|
|
|
|
|
|
|
|
|
cairo_destroy(handle->wayland.cairo);
|
|
|
|
|
cairo_surface_destroy(handle->wayland.cs);
|
|
|
|
|
|
|
|
|
|
munmap(handle->wayland.mapped_shm_buf, handle->wayland.mapped_shm_buf_size);
|
|
|
|
|
wl_buffer_destroy(handle->wayland.mapped_shm_buf);
|
|
|
|
|
wl_shm_pool_destroy(handle->wayland.shm_pool);
|
|
|
|
|
@@ -734,7 +746,10 @@ static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
|
|
|
|
} else if(x != 0 && y != 0) {
|
|
|
|
|
handle->wayland.has_set_xy = MwTRUE;
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
wl_subsurface_set_position(handle->wayland.sublevel->subsurface, x, y);
|
|
|
|
|
}
|
|
|
|
|
MwLLDispatch(handle, draw, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
|
|
|
|
@@ -753,40 +768,47 @@ static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
|
|
|
|
/* timed_redraw_by_epoch(handle->wayland.topmost_parent, 25);
|
|
|
|
|
recursive_draw(handle->wayland.topmost_parent); */
|
|
|
|
|
}
|
|
|
|
|
MwLLDispatch(handle, draw, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
|
|
|
|
/* todo */
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
cairo_set_source_rgb(handle->wayland.cairo, color->common.red / 255.0, color->common.green / 255.0, color->common.blue / 255.0);
|
|
|
|
|
cairo_new_path(handle->wayland.cairo);
|
|
|
|
|
for(i = 0; i < points_count; i++) {
|
|
|
|
|
if(i == 0) {
|
|
|
|
|
cairo_move_to(handle->wayland.cairo, points[i].x, points[i].y);
|
|
|
|
|
} else {
|
|
|
|
|
cairo_line_to(handle->wayland.cairo, points[i].x, points[i].y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cairo_close_path(handle->wayland.cairo);
|
|
|
|
|
cairo_fill(handle->wayland.cairo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
|
|
|
|
/* todo */
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
cairo_set_line_cap(handle->wayland.cairo, CAIRO_LINE_CAP_SQUARE);
|
|
|
|
|
cairo_set_source_rgb(handle->wayland.cairo, color->common.red / 255.0, color->common.green / 255.0, color->common.blue / 255.0);
|
|
|
|
|
cairo_new_path(handle->wayland.cairo);
|
|
|
|
|
for(i = 0; i < 2; i++) {
|
|
|
|
|
if(i == 0) {
|
|
|
|
|
cairo_move_to(handle->wayland.cairo, points[i].x, points[i].y);
|
|
|
|
|
} else {
|
|
|
|
|
cairo_line_to(handle->wayland.cairo, points[i].x, points[i].y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cairo_close_path(handle->wayland.cairo);
|
|
|
|
|
cairo_stroke(handle->wayland.cairo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MwLLBeginDrawImpl(MwLL handle) {
|
|
|
|
|
/* if(handle->wayland.parent == NULL) {
|
|
|
|
|
if(!eglMakeCurrent(handle->wayland.egl_display, handle->wayland.egl_surface, handle->wayland.egl_surface, handle->wayland.egl_context)) {
|
|
|
|
|
printf("ERROR: eglMakeCurrent, %0X\n", eglGetError());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MwLLEndDrawImpl(MwLL handle) {
|
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
|
|
/*recursive_draw(handle);*/
|
|
|
|
|
|
|
|
|
|
/* glClear(GL_COLOR_BUFFER_BIT); */
|
|
|
|
|
/* glClearColor(1.0, 0, 0, 1); */
|
|
|
|
|
|
|
|
|
|
/* if(handle->wayland.parent == NULL) {
|
|
|
|
|
if(!eglSwapBuffers(handle->wayland.egl_display, handle->wayland.egl_surface)) {
|
|
|
|
|
printf("error swapping buffers! %0X\n", eglGetError());
|
|
|
|
|
} else {
|
|
|
|
|
wl_surface_commit(handle->wayland.surface);
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
update_buffer(handle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
|
|
|
|
@@ -840,11 +862,21 @@ static void MwLLPixmapUpdateImpl(MwLLPixmap r) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
|
|
|
|
|
free(pixmap->common.raw);
|
|
|
|
|
free(pixmap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
|
|
|
|
/* todo */
|
|
|
|
|
int y, x;
|
|
|
|
|
for(y = rect->y; y < rect->y + rect->height; y++) {
|
|
|
|
|
if(y < 0 || y >= handle->wayland.wh) continue;
|
|
|
|
|
for(x = rect->x; x < rect->x + rect->width; x++) {
|
|
|
|
|
if(x < 0 || x >= handle->wayland.ww) continue;
|
|
|
|
|
|
|
|
|
|
/* TODO */
|
|
|
|
|
//((unsigned char*)handle->wayland.mapped_shm_buf)[(x + y * handle->wayland.ww) * 4 + 0] = 0x80;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
|
|
|
|
|
}
|
|
|
|
|
|