remove wayland's widget-checking stuff in an effort to remove one of the last hacks from the wayland backend
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
637015e4d5
commit
14915e082a
3 changed files with 13 additions and 86 deletions
|
|
@ -601,9 +601,6 @@ void MwLLWaylandRegionInvalidate(MwLL handle);
|
|||
|
||||
void MwLLWaylandHangUntilConfigured(MwLL handle);
|
||||
|
||||
MwBool MwLLWaylandWidgetIsDestroyed(MwLL self);
|
||||
void MwLLWaylandWidgetUndestroy(MwLL self);
|
||||
|
||||
/* Function for setting up the callbacks/structs that will be registered upon the relevant interfaces being found. */
|
||||
void MwLLWaylandSetupCallbacks(struct _MwLLWayland* wayland);
|
||||
|
||||
|
|
@ -613,18 +610,10 @@ void MwLLWaylandClipboardRead(wl_clipboard_device_context_t* ctx, int clipboard_
|
|||
void MwLLWaylandFlush(MwLL handle);
|
||||
|
||||
/* Standard procedure before event callbacks in Wayland */
|
||||
#define WAYLAND_EVENT_OP_START(self) \
|
||||
if(MwLLWaylandWidgetIsDestroyed(self)) { \
|
||||
return; \
|
||||
}
|
||||
#define WAYLAND_EVENT_OP_START(self) pthread_mutex_lock(&self->wayland.eventsMutex);
|
||||
|
||||
/* Footer for WAYLAND_EVENT_OP_START */
|
||||
#define WAYLAND_EVENT_OP_END(self)
|
||||
|
||||
#define WIDGET_CHECK(handle) \
|
||||
if(!handle->wayland.valid) { \
|
||||
return; \
|
||||
}
|
||||
#define WAYLAND_EVENT_OP_END(self) pthread_mutex_unlock(&self->wayland.eventsMutex);
|
||||
|
||||
/* the two decoration manager constructs */
|
||||
typedef struct zxdg_decoration_manager_v1_context {
|
||||
|
|
|
|||
|
|
@ -18,31 +18,6 @@ static pthread_mutex_t destroyedWidgetsTableMutex;
|
|||
*/
|
||||
static MwLL* destroyedWidgetsTable;
|
||||
|
||||
MwBool MwLLWaylandWidgetIsDestroyed(MwLL self) {
|
||||
int i;
|
||||
pthread_mutex_lock(&destroyedWidgetsTableMutex);
|
||||
for(i = 0; i < arrlen(destroyedWidgetsTable); i++) {
|
||||
if(self == destroyedWidgetsTable[i]) {
|
||||
pthread_mutex_unlock(&destroyedWidgetsTableMutex);
|
||||
return MwTRUE;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&destroyedWidgetsTableMutex);
|
||||
return MwFALSE;
|
||||
}
|
||||
void MwLLWaylandWidgetUndestroy(MwLL self) {
|
||||
int i;
|
||||
pthread_mutex_lock(&destroyedWidgetsTableMutex);
|
||||
for(i = 0; i < arrlen(destroyedWidgetsTable); i++) {
|
||||
if(self == destroyedWidgetsTable[i]) {
|
||||
arrdel(destroyedWidgetsTable, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&destroyedWidgetsTableMutex);
|
||||
return;
|
||||
}
|
||||
|
||||
static int event_loop(MwLL handle);
|
||||
|
||||
/* Recursively dispatch a resize event to a widget and its children */
|
||||
|
|
@ -61,7 +36,6 @@ static void recursive_dispatch_resize(MwLL handle) {
|
|||
|
||||
static void recursive_render(MwLL handle) {
|
||||
int i;
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
for(i = 0; i < arrlen(((MwWidget)handle->common.user)->children); i++) recursive_render(((MwWidget)handle->common.user)->children[i]->lowlevel);
|
||||
|
||||
|
|
@ -628,12 +602,7 @@ static void widget_setup(MwLL r, MwLL parent, int x, int y, int width, int heigh
|
|||
r->wayland.x = x;
|
||||
r->wayland.y = y;
|
||||
r->wayland.parent = parent;
|
||||
if(MwLLWaylandWidgetIsDestroyed(parent)) {
|
||||
r->wayland.valid = MwFALSE;
|
||||
return;
|
||||
} else {
|
||||
r->wayland.valid = MwTRUE;
|
||||
}
|
||||
r->wayland.valid = MwTRUE;
|
||||
|
||||
if(ty == MwLL_WAYLAND_UNKNOWN) {
|
||||
if(parent == NULL) {
|
||||
|
|
@ -657,8 +626,6 @@ static void widget_setup(MwLL r, MwLL parent, int x, int y, int width, int heigh
|
|||
}
|
||||
}
|
||||
|
||||
WIDGET_CHECK(r);
|
||||
|
||||
MwLLWaylandFramebufferSetup(&r->wayland);
|
||||
MwLLWaylandBackbufferSetup(&r->wayland);
|
||||
|
||||
|
|
@ -702,10 +669,6 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||
memset(r, 0, sizeof(*r));
|
||||
MwLLCreateCommon(r);
|
||||
|
||||
if(MwLLWaylandWidgetIsDestroyed(r)) {
|
||||
MwLLWaylandWidgetUndestroy(r);
|
||||
}
|
||||
|
||||
r->wayland.is_toplevel = parent == NULL;
|
||||
r->wayland.is_clipping = 0;
|
||||
|
||||
|
|
@ -791,10 +754,6 @@ static void MwLLDestroyImpl(MwLL handle) {
|
|||
pthread_mutex_unlock(&destroyedWidgetsTableMutex);
|
||||
|
||||
free(handle);
|
||||
|
||||
// if(topmost_parent->wayland.currentlyHeldWidget == handle) {
|
||||
// topmost_parent->wayland.currentlyHeldWidget = NULL;
|
||||
// }
|
||||
}
|
||||
|
||||
static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
|
||||
|
|
@ -812,7 +771,6 @@ static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsign
|
|||
}
|
||||
|
||||
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
||||
WIDGET_CHECK(handle);
|
||||
MwLLWaylandRegionInvalidate(handle);
|
||||
handle->wayland.x = x;
|
||||
handle->wayland.y = y;
|
||||
|
|
@ -863,7 +821,6 @@ static void actually_set_wh(MwLL handle) {
|
|||
}
|
||||
|
||||
static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
if(handle->wayland.ww == w && handle->wayland.wh == h) {
|
||||
return;
|
||||
|
|
@ -886,7 +843,6 @@ static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
|||
}
|
||||
|
||||
static void MwLLBeginDrawImpl(MwLL handle) {
|
||||
WIDGET_CHECK(handle);
|
||||
cairo_save(handle->wayland.front_cairo);
|
||||
cairo_set_source_rgba(handle->wayland.front_cairo, 0, 0, 0, 0);
|
||||
cairo_set_operator(handle->wayland.front_cairo, CAIRO_OPERATOR_SOURCE);
|
||||
|
|
@ -995,7 +951,6 @@ static void MwLLEndDrawImpl(MwLL handle) {
|
|||
|
||||
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||
int i;
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
clip(handle);
|
||||
|
||||
|
|
@ -1019,7 +974,6 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLL
|
|||
|
||||
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
||||
int i;
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
clip(handle);
|
||||
|
||||
|
|
@ -1073,10 +1027,6 @@ static int MwLLPendingImpl(MwLL handle) {
|
|||
};
|
||||
int pending = 0;
|
||||
|
||||
if(MwLLWaylandWidgetIsDestroyed(handle) || !handle->wayland.valid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
handle->wayland.resizing = 0;
|
||||
|
||||
if(handle->wayland.setting_wh) {
|
||||
|
|
@ -1128,7 +1078,6 @@ static int MwLLPendingImpl(MwLL handle) {
|
|||
}
|
||||
|
||||
static void MwLLNextEventImpl(MwLL handle) {
|
||||
WIDGET_CHECK(handle);
|
||||
if(!MwWaylandVulkan) {
|
||||
if(handle->wayland.did_event_loop_early) {
|
||||
handle->wayland.did_event_loop_early = MwFALSE;
|
||||
|
|
@ -1148,7 +1097,6 @@ static void MwLLNextEventImpl(MwLL handle) {
|
|||
}
|
||||
|
||||
static void MwLLSetTitleImpl(MwLL handle, const char* title) {
|
||||
WIDGET_CHECK(handle);
|
||||
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
|
||||
xdg_toplevel_set_title(handle->wayland.toplevel->xdg_top_level, title);
|
||||
}
|
||||
|
|
@ -1213,8 +1161,6 @@ static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
|||
if(rect->width >= INT16_MAX) rect->width = INT16_MAX;
|
||||
if(rect->height >= INT16_MAX) rect->height = INT16_MAX;
|
||||
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, rect->width, rect->height);
|
||||
c = cairo_create(cs);
|
||||
|
||||
|
|
@ -1239,7 +1185,6 @@ static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
|||
wl_surface_damage(handle->wayland.framebuffer.surface, 0, 0, handle->wayland.ww, handle->wayland.wh);
|
||||
}
|
||||
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
|
||||
WIDGET_CHECK(handle);
|
||||
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
|
||||
if(WAYLAND_GET_INTERFACE(handle->wayland, xdg_toplevel_icon_manager_v1) != NULL) {
|
||||
struct xdg_toplevel_icon_manager_v1* icon_manager = WAYLAND_GET_INTERFACE(handle->wayland, xdg_toplevel_icon_manager_v1)->context;
|
||||
|
|
@ -1282,7 +1227,6 @@ static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
|
|||
}
|
||||
|
||||
static void MwLLForceRenderImpl(MwLL handle) {
|
||||
WIDGET_CHECK(handle);
|
||||
wl_surface_damage(handle->wayland.framebuffer.surface, 0, 0, handle->wayland.ww, handle->wayland.wh);
|
||||
|
||||
handle->wayland.force_render = MwTRUE;
|
||||
|
|
@ -1294,8 +1238,6 @@ static void MwLLForceRenderImpl(MwLL handle) {
|
|||
static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
|
||||
int x, y, xs, ys;
|
||||
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
if(handle->wayland.cursor.setup) {
|
||||
MwLLWaylandBufferDestroy(&handle->wayland.cursor);
|
||||
wl_surface_destroy(handle->wayland.cursor.surface);
|
||||
|
|
@ -1346,7 +1288,6 @@ static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
|
|||
static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
|
||||
MwLL p = handle->wayland.parent;
|
||||
int x = 0, y = 0;
|
||||
WIDGET_CHECK(handle);
|
||||
while(p != NULL) {
|
||||
x += p->wayland.x;
|
||||
y += p->wayland.y;
|
||||
|
|
@ -1363,7 +1304,6 @@ static void MwLLShowImpl(MwLL handle, int show) {
|
|||
if(!handle->wayland.configured) {
|
||||
return;
|
||||
}
|
||||
WIDGET_CHECK(handle);
|
||||
/* Some guy on a mailing list said that "abusing" wl_surface_attach for this purpose is bad? This is documented behavior so please I beg of you let me know if there's a compositor that actually has a problem with this. */
|
||||
if(handle->wayland.framebuffer.surface) {
|
||||
wl_surface_attach(handle->wayland.framebuffer.surface, show ? handle->wayland.framebuffer.shm_buffer : NULL, 0, 0);
|
||||
|
|
@ -1382,7 +1322,6 @@ static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
|
|||
}
|
||||
|
||||
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
|
||||
WIDGET_CHECK(handle);
|
||||
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
|
||||
xdg_toplevel_set_min_size(handle->wayland.toplevel->xdg_top_level, minx, miny);
|
||||
xdg_toplevel_set_max_size(handle->wayland.toplevel->xdg_top_level, maxx, maxy);
|
||||
|
|
@ -1391,7 +1330,6 @@ static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int
|
|||
|
||||
static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
|
||||
(void)toggle;
|
||||
WIDGET_CHECK(handle);
|
||||
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
|
||||
if(WAYLAND_GET_INTERFACE(handle->wayland, zxdg_decoration_manager_v1) != NULL) {
|
||||
zxdg_decoration_manager_v1_context_t* dec = WAYLAND_GET_INTERFACE(handle->wayland, zxdg_decoration_manager_v1)->context;
|
||||
|
|
@ -1412,7 +1350,6 @@ static void MwLLFocusImpl(MwLL handle) {
|
|||
|
||||
static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
||||
MwLL topmost_parent = handle;
|
||||
WIDGET_CHECK(handle);
|
||||
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
|
||||
if(handle->wayland.pointer_constraints && handle->wayland.relative_pointer_manager) {
|
||||
if(toggle) {
|
||||
|
|
@ -1439,7 +1376,6 @@ static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
|||
|
||||
static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {
|
||||
int i;
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
if(handle->wayland.clipboard_buffer != NULL) {
|
||||
free(handle->wayland.clipboard_buffer);
|
||||
|
|
@ -1466,7 +1402,6 @@ static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_ty
|
|||
|
||||
static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
|
||||
int i;
|
||||
WIDGET_CHECK(handle);
|
||||
if(clipboard_type == MwCLIPBOARD_PRIMARY) {
|
||||
if(handle->wayland.supports_zwp) {
|
||||
for(i = 0; i < arrlen(handle->wayland.clipboard_devices_zwp); i++) {
|
||||
|
|
@ -1486,7 +1421,6 @@ static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
|
|||
}
|
||||
|
||||
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
handle->wayland.type_to_be = MwLL_WAYLAND_POPUP;
|
||||
}
|
||||
|
|
@ -1494,14 +1428,12 @@ static void MwLLMakeToolWindowImpl(MwLL handle) {
|
|||
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
|
||||
MwLL topmost_parent = handle;
|
||||
|
||||
WIDGET_CHECK(handle);
|
||||
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
|
||||
|
||||
*point = topmost_parent->wayland.cur_mouse_pos;
|
||||
}
|
||||
|
||||
static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
|
|
@ -1515,7 +1447,6 @@ static void MwLLBeginStateChangeImpl(MwLL handle) {
|
|||
}
|
||||
|
||||
static void MwLLEndStateChangeImpl(MwLL handle) {
|
||||
WIDGET_CHECK(handle);
|
||||
|
||||
if(handle->wayland.detatching) {
|
||||
MwLL topmost_parent = handle->wayland.parent;
|
||||
|
|
@ -1588,8 +1519,7 @@ static MwBool MwLLDoModernImpl(MwLL handle) {
|
|||
|
||||
static void MwLLRaiseImpl(MwLL handle) {
|
||||
(void)handle;
|
||||
/* WIDGET_CHECK(handle);
|
||||
|
||||
/*
|
||||
if(handle->wayland.type == MwLL_WAYLAND_SUBLEVEL) {
|
||||
MwLL topmost_parent = handle;
|
||||
int children_num;
|
||||
|
|
|
|||
10
src/core.c
10
src/core.c
|
|
@ -18,7 +18,7 @@
|
|||
MwLLEndDraw(handle->lowlevel); \
|
||||
}
|
||||
|
||||
static void MWAPI MwVaListApply_Internal(MwWidget handle, va_list va, int only_early);
|
||||
static void MWAPI MwVaListApply_Internal(MwWidget handle, va_list va, int only_early);
|
||||
static MwWidget MWAPI MwCreateWidget_Internal(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, int do_prop, va_list prop);
|
||||
|
||||
static void lldrawhandler(MwLL handle, void* data) {
|
||||
|
|
@ -392,6 +392,14 @@ void MwFreeWidget(MwWidget handle) {
|
|||
if(handle->root_monofont != NULL) MwFontFree(handle->root_monofont);
|
||||
if(handle->root_boldmonofont != NULL) MwFontFree(handle->root_boldmonofont);
|
||||
|
||||
if(handle->parent) {
|
||||
for(i = 0; i < arrlen(handle->parent->children); i++) {
|
||||
if(handle->parent->children[i] == handle) {
|
||||
arrdel(handle->parent->children, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(handle);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue