// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/classes/gui/window/window.cpp
// Function: smooth::GUI::Window::Process(int, int, int)
S::Int S::GUI::Window::Process(Int message, Int wParam, Int lParam)
{
	if (!created) return MessageUnknown;

	EnterProtectedRegion();

	/* Forward event to subscribers.
	 */
	onEvent.Emit(message, wParam, lParam);

	/* Process events we are interested in.
	 */
	Int	 rVal = MessageUnknown;

	switch (message)
	{
		case SM_GETFOCUS:
			if (!focussed)
			{
				focussed = True;

				onGetFocus.Emit();
			}

			break;
		case SM_LOSEFOCUS:
			if (focussed)
			{
				Window	*focusWnd = (Window *) Object::GetObject(wParam, Window::classID);

				if (focusWnd != NIL)
				{
					if (focusWnd->GetObjectType() == ToolWindow::classID && focusWnd->GetOrder() >= GetOrder())
					{
						LeaveProtectedRegion();

						return MessageProcessed;
					}
				}

				focussed = False;

				onLoseFocus.Emit();
			}

			break;
		case SM_WINDOWMETRICS:
			{
				Point	 nPos((unsigned(wParam) >> 16) - 32768, (unsigned(wParam) & 65535) - 32768);
				Size	 nSize((unsigned(lParam) >> 16) - 32768, (unsigned(lParam) & 65535) - 32768);

				Bool	 moved	 = (GetPosition() != nPos);
				Bool	 resized = (GetSize()	  != nSize);

				if (moved || resized)
				{
					DeactivateTooltip();
					InvalidateMetrics();

					if (moved)   { pos  = nPos;  onChangePosition.Emit(pos); }
					if (resized) { size = nSize; onChangeSize.Emit(size);    }

					Bool	 prevVisible = visible;

					visible = False;

					if (resized) { CalculateOffsets(); updateRect = Rect(Point(-1, -1), Size(0, 0)); }

					visible = prevVisible;
				}
			}

			rVal = MessageProcessed;

			break;
		case SM_PAINT:
			{
				Bool	 resized = (updateRect == Rect(Point(-1, -1), Size(0, 0)));

				if (resized) updateRect = Rect(Point(0, 0), GetRealSize());
				else	     updateRect = backend->GetUpdateRect();

				Paint(resized ? SP_PAINT : SP_UPDATE);

				updateRect = Rect(Point(0, 0), GetRealSize());
			}

			rVal = MessageProcessed;

			break;
	}

	if (rVal != MessageUnknown)
	{
		LeaveProtectedRegion();

		return rVal;
	}

	/* Delegate event to main layer.
	 */
	if (mainLayer->Process(message, wParam, lParam) == MessageProcessed)
	{
		LeaveProtectedRegion();

		return MessageProcessed;
	}

	/* Delegate event to other widgets.
	 */
	for (Int i = GetNOfObjects() - 1; i >= 0; i--)
	{
		Widget	*object = GetNthObject(i);

		if (object == NIL || object == mainLayer) continue;

		if (object->Process(message, wParam, lParam) == MessageProcessed)
		{
			rVal = MessageProcessed;

			break;
		}
	}

	/* Invoke callback for application message handling.
	 */
	if (rVal == MessageUnknown) rVal = handleSystemMessage.Call(message, wParam, lParam);

	LeaveProtectedRegion();

	return rVal;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
cmpb $0x1, 0x5ca(%rdi)
jne 0x98b53
movl %ecx, %r15d
movl %edx, %r12d
movl %esi, %r13d
movq %rdi, %r14
leaq 0x1c(%rdi), %rbp
movq %rbp, %rdi
callq 0x578f0
leaq 0x668(%r14), %rdi
movl %r13d, %esi
movl %r12d, %edx
movl %r15d, %ecx
callq 0x9983a
leal -0x780d(%r13), %eax
cmpl $0x6, %eax
ja 0x9899a
leaq 0x5e8bc(%rip), %rcx     # 0xf7110
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movdqu 0x5ec(%r14), %xmm0
pcmpeqd %xmm1, %xmm1
pcmpeqd %xmm0, %xmm1
movmskps %xmm1, %ebx
xorl $0xf, %ebx
je 0x98ad6
leaq 0x5ec(%r14), %r15
movq 0x5c0(%r14), %rdi
callq 0x9a4fc
movdqu (%rax), %xmm0
movdqu %xmm0, (%r15)
jmp 0x98afc
cmpb $0x0, 0xcd(%r14)
jne 0x9899a
movb $0x1, 0xcd(%r14)
movl $0x4d8, %edi            # imm = 0x4D8
jmp 0x98992
movq %rbp, 0x10(%rsp)
movl %r12d, %r13d
shrl $0x10, %r13d
movl $0xffff8000, %eax       # imm = 0xFFFF8000
addl %eax, %r13d
movl $0xffff, %ecx           # imm = 0xFFFF
andl %ecx, %r12d
addl %eax, %r12d
movl %r15d, %ebx
shrl $0x10, %ebx
addl %eax, %ebx
andl %ecx, %r15d
addl %eax, %r15d
movl 0xa8(%r14), %eax
xorl %r13d, %eax
movl 0xac(%r14), %ecx
xorl %r12d, %ecx
movl 0xb0(%r14), %edx
xorl %ebx, %edx
movl 0xb4(%r14), %esi
xorl %r15d, %esi
orl %edx, %esi
setne %dl
orl %eax, %ecx
setne %bpl
jne 0x98a36
testb %dl, %dl
jne 0x98a36
movq 0x10(%rsp), %rbp
jmp 0x98b46
cmpb $0x1, 0xcd(%r14)
jne 0x9899a
movq 0xd2ee5(%rip), %rax     # 0x16b828
movswl (%rax), %esi
movl %r12d, %edi
callq 0x57710
testq %rax, %rax
je 0x98985
movq %rax, %rbx
leaq 0x20(%rax), %rdi
movq 0xd3377(%rip), %rax     # 0x16bcd8
movswl (%rax), %esi
callq 0x57520
testb %al, %al
je 0x98985
movl 0x5b8(%rbx), %eax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl 0x5b8(%r14), %eax
jge 0x98b4b
movb $0x0, 0xcd(%r14)
movl $0x518, %edi            # imm = 0x518
addq %r14, %rdi
callq 0x701aa
movq 0x620(%r14), %rdi
movq (%rdi), %rax
movl %r13d, %esi
movl %r12d, %edx
movl %r15d, %ecx
callq *0x80(%rax)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x98b4b
movq %rbp, 0x10(%rsp)
movl 0x40(%r14), %ebp
testl %ebp, %ebp
jle 0x98a12
leaq 0x38(%r14), %rbx
incl %ebp
leal -0x2(%rbp), %esi
movq %rbx, %rdi
callq 0x5b074
movq (%rax), %rdi
testq %rdi, %rdi
je 0x98a0b
cmpq 0x620(%r14), %rdi
je 0x98a0b
movq (%rdi), %rax
movl %r13d, %esi
movl %r12d, %edx
movl %r15d, %ecx
callq *0x80(%rax)
cmpl $-0x1, %eax
je 0x98928
decl %ebp
cmpl $0x1, %ebp
ja 0x989d4
addq $0x6b0, %r14            # imm = 0x6B0
movq %r14, %rdi
movl %r13d, %esi
movl %r12d, %edx
movl %r15d, %ecx
callq 0x9a086
movl %eax, %ebx
movq 0x10(%rsp), %rbp
jmp 0x98b4b
movb %dl, 0xf(%rsp)
movq %r14, %rdi
callq 0x59208
movq %r14, %rdi
callq 0x58740
testb %bpl, %bpl
je 0x98a73
leaq 0xa8(%r14), %rsi
shlq $0x20, %r12
movl %r13d, %eax
orq %r12, %rax
movq %rax, 0xa8(%r14)
leaq 0x278(%r14), %rdi
callq 0x703b0
cmpb $0x0, 0xf(%rsp)
movq 0x10(%rsp), %rbp
je 0x98b35
leaq 0xb0(%r14), %rsi
shlq $0x20, %r15
movl %ebx, %eax
orq %r15, %rax
movq %rax, 0xb0(%r14)
leaq 0x298(%r14), %rdi
callq 0x70698
leaq 0xcb(%r14), %r15
movb 0xcb(%r14), %bl
movb $0x0, 0xcb(%r14)
movq %r14, %rdi
callq 0x55ef0
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x5ec(%r14)
movq %r15, %r14
jmp 0x98b43
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq $0x0, 0x5ec(%r14)
movl %eax, 0x5f4(%r14)
shrq $0x20, %rax
movl %eax, 0x5f8(%r14)
xorl %esi, %esi
testb %bl, %bl
setne %sil
movq (%r14), %rax
movq %r14, %rdi
callq *0x78(%rax)
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq $0x0, 0x5ec(%r14)
movl %eax, 0x5f4(%r14)
shrq $0x20, %rax
movl %eax, 0x5f8(%r14)
jmp 0x98b46
movb 0xcb(%r14), %bl
addq $0xcb, %r14
movb %bl, (%r14)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
callq 0x55cc0
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq