// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/system/backends/xlib/eventxlib.cpp
// Function: smooth::System::EventXLib::ProcessNextEvent()
S::Bool S::System::EventXLib::ProcessNextEvent()
{
	if (display == NIL) return False;

	/* Process events on main thread only.
	 */
	if (Threads::Thread::GetCurrentThreadID() != Threads::MainThreadID)
	{
		S::System::System::Sleep(1);

		return True;
	}

	/* Emulate a timeout of ~100ms by trying to find a message
	 * 10 times while sleeping for 10ms between trying.
	 */
	for (Int i = 0; i < 10; i++)
	{
		/* XEventsQueued with QueuedAfterFlush sometimes hanged,
		 * so we flush manually and use QueuedAfterReading then.
		 */
		XFlush(display);

		if (XEventsQueued(display, QueuedAfterReading))
		{
			XEvent		 e;

			XNextEvent(display, &e);

			if (XFilterEvent(&e, None)) break;

			/* Process only the most recent MotionNotify and ConfigureNotify events.
			 */
			if (e.type == MotionNotify)    while (XCheckIfEvent(display, &e, FindMotionEvent,    (XPointer) e.xany.window)) { }
			if (e.type == ConfigureNotify) while (XCheckIfEvent(display, &e, FindConfigureEvent, (XPointer) e.xany.window)) { }

			/* Find window and dispatch event.
			 */
			GUI::WindowXLib	*window = GUI::WindowXLib::GetWindowBackend(e.xany.window);

			if (window != NIL) window->ProcessSystemMessages(&e);

			break;
		}

		/* Allow timeouts to be processed.
		 */
		EventProcessor::allowTimerInterrupts.Call();

		/* Now sleep for 10ms.
		 */
		System::System::Sleep(10);

		/* Prevent timeouts from being processed.
		 */
		EventProcessor::denyTimerInterrupts.Call();
	}

	return True;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, 0x10(%rax)
jne 0x1290ca
movb $0x0, -0x1(%rbp)
jmp 0x12922f
callq 0x593f0
cmpl $0x0, %eax
je 0x1290e7
movl $0x1, %edi
callq 0x5c090
movb $0x1, -0x1(%rbp)
jmp 0x12922f
movl $0x0, -0x14(%rbp)
cmpl $0xa, -0x14(%rbp)
jge 0x12922b
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5a0d0
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %esi
callq 0x59e50
cmpl $0x0, %eax
je 0x1291fb
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x5c7e0
leaq -0xd8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x59080
cmpl $0x0, %eax
je 0x129157
jmp 0x12922b
cmpl $0x6, -0xd8(%rbp)
jne 0x129190
jmp 0x129162
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0xb8(%rbp), %rcx
leaq -0xd8(%rbp), %rsi
leaq -0x162(%rip), %rdx      # 0x129020
callq 0x5b1c0
cmpl $0x0, %eax
je 0x12918e
jmp 0x129162
jmp 0x129190
cmpl $0x16, -0xd8(%rbp)
jne 0x1291c9
jmp 0x12919b
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0xb8(%rbp), %rcx
leaq -0xd8(%rbp), %rsi
leaq -0x15b(%rip), %rdx      # 0x129060
callq 0x5b1c0
cmpl $0x0, %eax
je 0x1291c7
jmp 0x12919b
jmp 0x1291c9
movq -0xb8(%rbp), %rdi
callq 0x121de0
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0x1291f9
movq -0xe0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x1223c0
jmp 0x12922b
movq 0xdf956(%rip), %rdi     # 0x208b58
callq 0x129240
movl $0xa, %edi
callq 0x5c090
movq 0xdfa40(%rip), %rdi     # 0x208c58
callq 0x129240
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1290ee
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)