// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
testb $0x1, 0x5ca(%rax)
jne 0xd84f8
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0xd8a74
movq -0xd8(%rbp), %rdi
callq 0x5b7c0
movq -0xd8(%rbp), %rdi
addq $0x668, %rdi            # imm = 0x668
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
callq 0xdabb0
movl $0xfffffffe, -0x20(%rbp) # imm = 0xFFFFFFFE
movl -0x14(%rbp), %eax
addl $0xffff87f3, %eax       # imm = 0xFFFF87F3
movl %eax, %ecx
movq %rcx, -0xe0(%rbp)
subl $0x6, %eax
ja 0xd894f
movq -0xe0(%rbp), %rax
leaq 0xb2a01(%rip), %rcx     # 0x18af50
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0xd8(%rbp), %rax
testb $0x1, 0xcd(%rax)
jne 0xd8582
movq -0xd8(%rbp), %rdi
movb $0x1, 0xcd(%rdi)
addq $0x4d8, %rdi            # imm = 0x4D8
callq 0x8af60
jmp 0xd894f
movq -0xd8(%rbp), %rax
testb $0x1, 0xcd(%rax)
je 0xd8634
movl -0x18(%rbp), %edi
movq 0x13025b(%rip), %rax    # 0x208800
movswl (%rax), %esi
callq 0x5be90
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xd861a
movq -0x28(%rbp), %rdi
callq 0x5bb10
movq %rax, %rdi
movq 0x1306fd(%rip), %rax    # 0x208cc8
movswl (%rax), %esi
callq 0x5bc10
testb $0x1, %al
jne 0xd85d9
jmp 0xd8618
movq -0x28(%rbp), %rdi
callq 0x5bd20
movq -0xd8(%rbp), %rdi
movl %eax, -0xe4(%rbp)
callq 0x5bd20
movl %eax, %ecx
movl -0xe4(%rbp), %eax
cmpl %ecx, %eax
jl 0xd8618
movq -0xd8(%rbp), %rdi
callq 0x594d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd8a74
jmp 0xd861a
movq -0xd8(%rbp), %rdi
movb $0x0, 0xcd(%rdi)
addq $0x518, %rdi            # imm = 0x518
callq 0x8af60
jmp 0xd894f
movl -0x18(%rbp), %esi
shrl $0x10, %esi
subl $0x8000, %esi           # imm = 0x8000
movl -0x18(%rbp), %edx
andl $0xffff, %edx           # imm = 0xFFFF
subl $0x8000, %edx           # imm = 0x8000
leaq -0x30(%rbp), %rdi
callq 0x5c2c0
movl -0x1c(%rbp), %esi
shrl $0x10, %esi
subl $0x8000, %esi           # imm = 0x8000
movl -0x1c(%rbp), %edx
andl $0xffff, %edx           # imm = 0xFFFF
subl $0x8000, %edx           # imm = 0x8000
leaq -0x38(%rbp), %rdi
callq 0x59260
movq -0xd8(%rbp), %rdi
callq 0x5d740
movq %rax, %rdi
leaq -0x30(%rbp), %rsi
callq 0x5d770
movq -0xd8(%rbp), %rdi
andb $0x1, %al
movb %al, -0x39(%rbp)
callq 0x5bf70
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x5d9c0
andb $0x1, %al
movb %al, -0x3a(%rbp)
testb $0x1, -0x39(%rbp)
jne 0xd86cb
testb $0x1, -0x3a(%rbp)
je 0xd87c9
movq -0xd8(%rbp), %rdi
callq 0x5df08
movq -0xd8(%rbp), %rdi
callq 0x5d210
testb $0x1, -0x39(%rbp)
je 0xd8711
movq -0xd8(%rbp), %rsi
movq -0x30(%rbp), %rax
movq %rax, 0xa8(%rsi)
movq %rsi, %rdi
addq $0x278, %rdi            # imm = 0x278
addq $0xa8, %rsi
callq 0x8b580
testb $0x1, -0x3a(%rbp)
je 0xd873f
movq -0xd8(%rbp), %rsi
movq -0x38(%rbp), %rax
movq %rax, 0xb0(%rsi)
movq %rsi, %rdi
addq $0x298, %rdi            # imm = 0x298
addq $0xb0, %rsi
callq 0x8bd10
movq -0xd8(%rbp), %rax
movb 0xcb(%rax), %cl
andb $0x1, %cl
movb %cl, -0x3b(%rbp)
movb $0x0, 0xcb(%rax)
testb $0x1, -0x3a(%rbp)
je 0xd87b6
movq -0xd8(%rbp), %rdi
callq 0x5a1d0
leaq -0x54(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %esi
callq 0x5c2c0
leaq -0x5c(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x59260
leaq -0x4c(%rbp), %rdi
leaq -0x54(%rbp), %rsi
leaq -0x5c(%rbp), %rdx
callq 0x59ff0
movq -0xd8(%rbp), %rax
movq -0x4c(%rbp), %rcx
movq %rcx, 0x5ec(%rax)
movq -0x44(%rbp), %rcx
movq %rcx, 0x5f4(%rax)
movq -0xd8(%rbp), %rax
movb -0x3b(%rbp), %cl
andb $0x1, %cl
movb %cl, 0xcb(%rax)
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
jmp 0xd894f
movq -0xd8(%rbp), %rax
addq $0x5ec, %rax            # imm = 0x5EC
movq %rax, -0xf0(%rbp)
leaq -0x78(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %esi
callq 0x5c2c0
leaq -0x80(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x59260
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x59ff0
movq -0xf0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x5c350
andb $0x1, %al
movb %al, -0x5d(%rbp)
testb $0x1, -0x5d(%rbp)
je 0xd8895
leaq -0x98(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x5c2c0
movq -0xd8(%rbp), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, -0xa0(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x59ff0
movq -0xd8(%rbp), %rax
movq -0x90(%rbp), %rcx
movq %rcx, 0x5ec(%rax)
movq -0x88(%rbp), %rcx
movq %rcx, 0x5f4(%rax)
jmp 0xd88c7
movq -0xd8(%rbp), %rax
movq 0x5c0(%rax), %rdi
callq 0xdcdf0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, 0x5ec(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x5f4(%rax)
movq -0xd8(%rbp), %rdi
movb -0x5d(%rbp), %dl
movw $0x1, %ax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnew %cx, %ax
movswl %ax, %esi
movq (%rdi), %rax
callq *0x78(%rax)
leaq -0xb8(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x5c2c0
movq -0xd8(%rbp), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, -0xc0(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0x59ff0
movq -0xd8(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, 0x5ec(%rax)
movq -0xa8(%rbp), %rcx
movq %rcx, 0x5f4(%rax)
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
cmpl $-0x2, -0x20(%rbp)
je 0xd896c
movq -0xd8(%rbp), %rdi
callq 0x594d0
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd8a74
movq -0xd8(%rbp), %rax
movq 0x620(%rax), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movq (%rdi), %rax
callq *0x80(%rax)
cmpl $-0x1, %eax
jne 0xd89a9
movq -0xd8(%rbp), %rdi
callq 0x594d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd8a74
movq -0xd8(%rbp), %rdi
callq 0x5b470
subl $0x1, %eax
movl %eax, -0xc4(%rbp)
cmpl $0x0, -0xc4(%rbp)
jl 0xd8a3d
movq -0xd8(%rbp), %rdi
movl -0xc4(%rbp), %esi
callq 0x5c230
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0xd0(%rbp)
je 0xd8a01
movq -0xd8(%rbp), %rcx
movq -0xd0(%rbp), %rax
cmpq 0x620(%rcx), %rax
jne 0xd8a03
jmp 0xd8a2c
movq -0xd0(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movq (%rdi), %rax
callq *0x80(%rax)
cmpl $-0x1, %eax
jne 0xd8a2a
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
jmp 0xd8a3d
jmp 0xd8a2c
movl -0xc4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0xd89be
cmpl $-0x2, -0x20(%rbp)
jne 0xd8a62
movq -0xd8(%rbp), %rdi
addq $0x6b0, %rdi            # imm = 0x6B0
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
callq 0xdad40
movl %eax, -0x20(%rbp)
movq -0xd8(%rbp), %rdi
callq 0x594d0
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq