mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-08 10:23:27 +00:00
wayland: seperate MwLLPending and MwLLNextEvent
This commit is contained in:
@@ -42,6 +42,7 @@ struct _MwLLWaylandTopLevel {
|
|||||||
struct xdg_toplevel* xdg_top_level;
|
struct xdg_toplevel* xdg_top_level;
|
||||||
struct xdg_toplevel_listener xdg_toplevel_listener;
|
struct xdg_toplevel_listener xdg_toplevel_listener;
|
||||||
struct xdg_surface_listener xdg_surface_listener;
|
struct xdg_surface_listener xdg_surface_listener;
|
||||||
|
struct xdg_positioner* xdg_positioner;
|
||||||
|
|
||||||
struct xkb_context* xkb_context;
|
struct xkb_context* xkb_context;
|
||||||
struct xkb_keymap* xkb_keymap;
|
struct xkb_keymap* xkb_keymap;
|
||||||
@@ -111,6 +112,8 @@ struct _MwLLWayland {
|
|||||||
struct wl_pointer* pointer;
|
struct wl_pointer* pointer;
|
||||||
MwU32 pointer_serial;
|
MwU32 pointer_serial;
|
||||||
|
|
||||||
|
MwBool events_pending;
|
||||||
|
|
||||||
MwU32 mod_state;
|
MwU32 mod_state;
|
||||||
|
|
||||||
MwBool configured; /* Whether or not xdg_toplevel_configure has run once */
|
MwBool configured; /* Whether or not xdg_toplevel_configure has run once */
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
* - MwLLMakeToolWindowImpl
|
* - MwLLMakeToolWindowImpl
|
||||||
* - MwLLSetClipboardImpl
|
* - MwLLSetClipboardImpl
|
||||||
* - MwLLGrabPointerImpl
|
* - MwLLGrabPointerImpl
|
||||||
* - MwLLFocusImpl
|
|
||||||
* - MwLLMakePopupImpl
|
* - MwLLMakePopupImpl
|
||||||
* - MwLLShowImpl
|
* - MwLLShowImpl
|
||||||
* - MwLLDetachImpl
|
* - MwLLDetachImpl
|
||||||
@@ -146,6 +145,7 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time
|
|||||||
|
|
||||||
p.point = self->wayland.cur_mouse_pos;
|
p.point = self->wayland.cur_mouse_pos;
|
||||||
MwLLDispatch(self, move, &p);
|
MwLLDispatch(self, move, &p);
|
||||||
|
self->wayland.events_pending = MwTRUE;
|
||||||
|
|
||||||
/*timed_redraw(self, time, 50, &self->wayland.cooldown_timer);*/
|
/*timed_redraw(self, time, 50, &self->wayland.cooldown_timer);*/
|
||||||
};
|
};
|
||||||
@@ -178,6 +178,7 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
|
|||||||
}
|
}
|
||||||
|
|
||||||
MwLLDispatch(self, draw, NULL);
|
MwLLDispatch(self, draw, NULL);
|
||||||
|
self->wayland.events_pending = MwTRUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* `wl_pointer.axis` callback */
|
/* `wl_pointer.axis` callback */
|
||||||
@@ -229,6 +230,7 @@ static void keyboard_enter(void* data,
|
|||||||
struct wl_array* keys) {
|
struct wl_array* keys) {
|
||||||
MwLL self = data;
|
MwLL self = data;
|
||||||
MwLLDispatch(self, focus_in, NULL);
|
MwLLDispatch(self, focus_in, NULL);
|
||||||
|
self->wayland.events_pending = MwTRUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* `wl_keyboard.leave` callback */
|
/* `wl_keyboard.leave` callback */
|
||||||
@@ -238,6 +240,7 @@ static void keyboard_leave(void* data,
|
|||||||
struct wl_surface* surface) {
|
struct wl_surface* surface) {
|
||||||
MwLL self = data;
|
MwLL self = data;
|
||||||
MwLLDispatch(self, focus_out, NULL);
|
MwLLDispatch(self, focus_out, NULL);
|
||||||
|
self->wayland.events_pending = MwTRUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* `wl_keyboard.key` callback */
|
/* `wl_keyboard.key` callback */
|
||||||
@@ -324,6 +327,7 @@ static void keyboard_key(void* data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self->wayland.events_pending = MwTRUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* `wl_keyboard.modifiers` callback */
|
/* `wl_keyboard.modifiers` callback */
|
||||||
@@ -616,6 +620,7 @@ static void framebuffer_setup(struct _MwLLWayland* wayland) {
|
|||||||
|
|
||||||
memset(wayland->framebuffer.buf, 255, wayland->framebuffer.buf_size);
|
memset(wayland->framebuffer.buf, 255, wayland->framebuffer.buf_size);
|
||||||
update_buffer(&wayland->framebuffer);
|
update_buffer(&wayland->framebuffer);
|
||||||
|
wayland->events_pending = MwTRUE;
|
||||||
};
|
};
|
||||||
static void framebuffer_destroy(struct _MwLLWayland* wayland) {
|
static void framebuffer_destroy(struct _MwLLWayland* wayland) {
|
||||||
buffer_destroy(&wayland->framebuffer);
|
buffer_destroy(&wayland->framebuffer);
|
||||||
@@ -940,6 +945,7 @@ static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh:
|
refresh:
|
||||||
|
MwLLDispatch(handle, draw, NULL);
|
||||||
region_setup(handle);
|
region_setup(handle);
|
||||||
|
|
||||||
framebuffer_destroy(&handle->wayland);
|
framebuffer_destroy(&handle->wayland);
|
||||||
@@ -961,6 +967,7 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLL
|
|||||||
}
|
}
|
||||||
cairo_close_path(handle->wayland.cairo);
|
cairo_close_path(handle->wayland.cairo);
|
||||||
cairo_fill(handle->wayland.cairo);
|
cairo_fill(handle->wayland.cairo);
|
||||||
|
handle->wayland.events_pending = MwTRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
||||||
@@ -978,6 +985,7 @@ static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
|||||||
}
|
}
|
||||||
cairo_close_path(handle->wayland.cairo);
|
cairo_close_path(handle->wayland.cairo);
|
||||||
cairo_stroke(handle->wayland.cairo);
|
cairo_stroke(handle->wayland.cairo);
|
||||||
|
handle->wayland.events_pending = MwTRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLBeginDrawImpl(MwLL handle) {
|
static void MwLLBeginDrawImpl(MwLL handle) {
|
||||||
@@ -985,6 +993,7 @@ static void MwLLBeginDrawImpl(MwLL handle) {
|
|||||||
|
|
||||||
static void MwLLEndDrawImpl(MwLL handle) {
|
static void MwLLEndDrawImpl(MwLL handle) {
|
||||||
update_buffer(&handle->wayland.framebuffer);
|
update_buffer(&handle->wayland.framebuffer);
|
||||||
|
handle->wayland.events_pending = MwTRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
||||||
@@ -1008,10 +1017,11 @@ static void MwLLFreeColorImpl(MwLLColor color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int MwLLPendingImpl(MwLL handle) {
|
static int MwLLPendingImpl(MwLL handle) {
|
||||||
return event_loop(handle);
|
return handle->wayland.events_pending;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLNextEventImpl(MwLL handle) {
|
static void MwLLNextEventImpl(MwLL handle) {
|
||||||
|
event_loop(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLSetTitleImpl(MwLL handle, const char* title) {
|
static void MwLLSetTitleImpl(MwLL handle, const char* title) {
|
||||||
@@ -1185,6 +1195,13 @@ static void MwLLShowImpl(MwLL handle, int show) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
|
static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
|
||||||
|
if(handle->wayland.type == MWLL_WAYLAND_TOPLEVEL) {
|
||||||
|
struct xdg_wm_base* wm_base = WAYLAND_GET_INTERFACE(handle->wayland, xdg_wm_base)->context;
|
||||||
|
|
||||||
|
handle->wayland.toplevel->xdg_positioner = xdg_wm_base_create_positioner(wm_base);
|
||||||
|
xdg_surface_get_popup(handle->wayland.toplevel->xdg_surface, handle->wayland.toplevel->xdg_surface, handle->wayland.toplevel->xdg_positioner);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
|
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
|
||||||
@@ -1212,6 +1229,7 @@ static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLFocusImpl(MwLL handle) {
|
static void MwLLFocusImpl(MwLL handle) {
|
||||||
|
printf("[WARNING] MwLLFocus not supported on Wayland\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
||||||
@@ -1292,6 +1310,7 @@ static char* MwLLGetClipboardImpl(MwLL handle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||||
|
printf("sub menu\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
|
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
|
||||||
|
|||||||
Reference in New Issue
Block a user