// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/gui/widgets/basic/titlebar.cpp
// Function: smooth::GUI::Titlebar::DragHitTest(smooth::GUI::Point const&)
S::Bool S::GUI::Titlebar::DragHitTest(const Point &mousePos)
{
	Surface	*surface    = GetDrawSurface();
	Window	*window	    = container->GetContainerWindow();

#ifdef __WIN32__
	static Bool	 flatStyle = Backends::BackendWin32::IsWindowsVersionAtLeast(VER_PLATFORM_WIN32_NT, 6, 2);
#else
	static Bool	 flatStyle = False;
#endif

	Rect	 titleFrame = Rect(Point(0,0), GetRealSize());
	Rect	 buttonRect = Rect(Point(titleFrame.right - Math::Round(4 * surface->GetSurfaceDPI() / 96.0) - Math::Round((5 + 10 * (Binary::IsFlagSet(flags, TB_MINBUTTON) || Binary::IsFlagSet(flags, TB_MAXBUTTON) ? 3 : 1)) * surface->GetSurfaceDPI() / 96.0) + (flatStyle ? 2 : 0), titleFrame.top + (flatStyle ? 4 : 3)),
				   Size(Math::Round((5 + 10 * (Binary::IsFlagSet(flags, TB_MINBUTTON) || Binary::IsFlagSet(flags, TB_MAXBUTTON) ? 3 : 1)) * surface->GetSurfaceDPI() / 96.0) - (flatStyle ? 5 : 1), titleFrame.GetHeight() - (flatStyle ? 9 : 6)));

	if (!flatStyle && window->GetIcon() != NIL) titleFrame.left += titleFrame.GetHeight() - 1;

	if (flatStyle && (Binary::IsFlagSet(flags, TB_MINBUTTON) || Binary::IsFlagSet(flags, TB_MAXBUTTON))) buttonRect.left -= 2;

	return ((mousePos.x >= titleFrame.left && mousePos.y >= titleFrame.top && mousePos.x <= titleFrame.right && mousePos.y <= titleFrame.bottom) &&
	       !(mousePos.x >= buttonRect.left && mousePos.y >= buttonRect.top && mousePos.x <= buttonRect.right && mousePos.y <= buttonRect.bottom));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x28(%rsp)
movq %rdi, %r13
movq (%rdi), %rax
callq *0x40(%rax)
movq %rax, %r12
movq 0x190(%r13), %rdi
callq 0x56a50
movq %rax, %r15
movq (%r13), %rax
movq %r13, %rdi
callq *0x50(%rax)
movq %rax, 0x20(%rsp)
shrq $0x20, %rax
movq %rax, 0x30(%rsp)
movq %r12, %rdi
callq 0x59c60
cwtl
shll $0x2, %eax
cvtsi2sd %eax, %xmm0
divsd 0x65518(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
movsd %xmm0, 0x18(%rsp)
ucomisd %xmm0, %xmm1
seta 0x7(%rsp)
movl 0x30(%r13), %edi
pushq $0x1
popq %rsi
callq 0x596b0
pushq $0x23
popq %r14
pushq $0xf
popq %rbx
movl %r14d, %ebp
testb %al, %al
jne 0x7e039
movl 0x30(%r13), %edi
pushq $0x2
popq %rsi
callq 0x596b0
testb %al, %al
pushq $0x23
popq %rbp
cmovel %ebx, %ebp
movq %r12, %rdi
callq 0x59c60
cwtl
imull %ebp, %eax
cvtsi2sd %eax, %xmm0
divsd 0x654bf(%rip), %xmm0    # 0xe3510
movsd %xmm0, 0x10(%rsp)
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta 0x6(%rsp)
movl 0x30(%r13), %edi
pushq $0x1
popq %rsi
callq 0x596b0
testb %al, %al
jne 0x7e08b
movl 0x30(%r13), %edi
pushq $0x2
popq %rsi
callq 0x596b0
testb %al, %al
pushq $0x23
popq %rax
cmovnel %eax, %ebx
movl %ebx, %r14d
movq %r12, %rdi
callq 0x59c60
cwtl
imull %r14d, %eax
cvtsi2sd %eax, %xmm1
divsd 0x6546c(%rip), %xmm1    # 0xe3510
xorpd %xmm0, %xmm0
xorl %r12d, %r12d
movsd %xmm1, 0x8(%rsp)
ucomisd %xmm1, %xmm0
seta %r14b
addq $0x5d0, %r15            # imm = 0x5D0
xorl %ebp, %ebp
movq %r15, %rdi
xorl %esi, %esi
callq 0x574f0
movq 0x30(%rsp), %r8
leal -0x1(%r8), %ecx
testb %al, %al
cmovel %ebp, %ecx
movq 0x28(%rsp), %rdx
movl (%rdx), %eax
cmpl %ecx, %eax
jl 0x7e18e
movl 0x4(%rdx), %ecx
testl %ecx, %ecx
sets %dl
movq 0x20(%rsp), %r9
cmpl %r9d, %eax
setg %sil
cmpl %r8d, %ecx
setg %dil
orb %dl, %sil
orb %dil, %sil
je 0x7e110
xorl %ebp, %ebp
jmp 0x7e18e
xorl %esi, %esi
movb 0x7(%rsp), %dl
movb %dl, %sil
xorl %edi, %edi
movb 0x6(%rsp), %dl
movb %dl, %dil
leaq 0x65847(%rip), %rdx     # 0xe3970
movsd 0x18(%rsp), %xmm0
addsd (%rdx,%rsi,8), %xmm0
movsd 0x10(%rsp), %xmm1
addsd (%rdx,%rdi,8), %xmm1
cvttsd2si %xmm0, %rsi
cvttsd2si %xmm1, %rdi
addl %edi, %esi
movb %r14b, %r12b
movsd 0x8(%rsp), %xmm0
addsd (%rdx,%r12,8), %xmm0
subl %esi, %r9d
cvttsd2si %xmm0, %rdx
addl %r9d, %edx
decl %edx
addl $-0x3, %r8d
cmpl %r9d, %eax
setl %sil
cmpl $0x3, %ecx
setb %dil
orb %sil, %dil
cmpl %edx, %eax
setg %al
orb %dil, %al
cmpl %r8d, %ecx
setg %bpl
orb %al, %bpl
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop