git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@416 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-19 09:07:50 +00:00
parent 39101dbe08
commit ea3f8cfa54
2 changed files with 24 additions and 18 deletions

View File

@@ -40,6 +40,26 @@ static void destroy_pixmap(MwLL handle) {
XFreePixmap(handle->display, handle->pixmap);
}
static void wait_map(MwLL handle){
XEvent* queue = NULL;
XEvent ev;
while(1){
XNextEvent(handle->display, &ev);
if(ev.type == MapNotify && ev.xmap.window == handle->window){
printf("mapped!\n");
break;
}else{
arrput(queue, ev);
}
}
while(arrlen(queue) > 0){
XPutBackEvent(handle->display, &queue[0]);
arrdel(queue, 0);
}
arrfree(queue);
}
static unsigned long generate_color(XVisualInfo* xvi, unsigned long r, unsigned long g, unsigned long b) {
int i;
unsigned long n = 1;
@@ -93,7 +113,6 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
r->window = XCreateSimpleWindow(r->display, p, x, y, width, height, 0, 0, WhitePixel(r->display, DefaultScreen(r->display)));
r->visual = get_visual_info(r->display);
r->wait_map = 1;
XSetLocaleModifiers("");
if((r->xim = XOpenIM(r->display, 0, 0, 0)) == NULL) {
@@ -130,6 +149,7 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
XFlush(r->display);
XSync(r->display, False);
wait_map(r);
return r;
}
@@ -235,20 +255,9 @@ int MwLLPending(MwLL handle) {
void MwLLNextEvent(MwLL handle) {
XEvent ev;
XEvent* queue = NULL;
while(XCheckTypedWindowEvent(handle->display, handle->window, ClientMessage, &ev) || XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
int render = 0;
if(ev.type == MapNotify){
handle->wait_map = 0;
while(arrlen(queue) > 0){
XPutBackEvent(handle->display, &queue[0]);
arrdel(queue, 0);
}
arrfree(queue);
}else if(handle->wait_map){
arrput(queue, ev);
}else if(ev.type == Expose) {
if(ev.type == Expose) {
render = 1;
} else if(ev.type == ButtonPress) {
MwLLMouse p;
@@ -385,8 +394,6 @@ void MwLLNextEvent(MwLL handle) {
if(handle->copy_buffer) XCopyArea(handle->display, handle->pixmap, handle->window, handle->gc, 0, 0, w, h, 0, 0);
}
}
arrfree(queue);
}
void MwLLSleep(int ms) {
@@ -684,7 +691,7 @@ void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
XFlush(handle->display);
XSync(handle->display, False);
handle->wait_map = 1;
wait_map(handle);
}
void MwLLMakeBorderless(MwLL handle, int toggle) {
@@ -701,7 +708,7 @@ void MwLLMakeBorderless(MwLL handle, int toggle) {
XFlush(handle->display);
XSync(handle->display, False);
handle->wait_map = 1;
wait_map(handle);
}
long MwLLGetTick(void) {

View File

@@ -31,7 +31,6 @@ struct _MwLL {
MwLLHandler handler;
int grabbed;
int wait_map;
};
struct _MwLLColor {