// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/gui/widgets/multi/menu/popupmenuentry.cpp
// Function: smooth::GUI::PopupMenuEntry::OpenPopupMenu()
S::Void S::GUI::PopupMenuEntry::OpenPopupMenu()
{
	if (popup == NIL) return;

	if (S::System::System::Clock() - popupMenuClosed < 100) return;

	Widget	*window	     = container->GetContainerWindow();
	Surface	*surface     = GetDrawSurface();

	if (window == NIL) return;

	if (timer != NIL)
	{
		DeleteObject(timer);

		timer = NIL;
	}

	hotspot->Deactivate();

	Rect	 monitor     = System::Screen::GetActiveScreenWorkArea();
	Float	 scaleFactor = surface->GetSurfaceDPI() / 96.0;

	popup->CalculateSize();

	Point	 realPos     = GetRealPosition();
	Size	 realSize    = GetRealSize();

	Point	 popupPos    = realPos + Point(realSize.cx, Math::Round(-3 * scaleFactor));
	Size	 popupSize   = popup->GetSize();

	if (!IsRightToLeft()) { if (window->GetX() + popupPos.x			       + Math::Round(popupSize.cx * scaleFactor) >= monitor.right) popupPos.x = realPos.x - Math::Round(popupSize.cx * scaleFactor); }
	else		      { if (window->GetX() + (window->GetWidth() - popupPos.x) - Math::Round(popupSize.cx * scaleFactor) <  monitor.left)  popupPos.x = realPos.x - Math::Round(popupSize.cx * scaleFactor); }

	if (window->GetY() + popupPos.y + Math::Round(popupSize.cy * scaleFactor) >= monitor.bottom) popupPos.y = realPos.y - Math::Round(popupSize.cy * scaleFactor) + realSize.cy + Math::Round(3 * scaleFactor);

	popup->SetPosition(popupPos);
	popup->internalRequestClose.Connect(&PopupMenuEntry::ClosePopupMenu, this);

	owner->SetFlags(owner->GetFlags() | MB_POPUPOPEN);

	Add(popup);

	/* Set the MB_POPUPOPEN flag again as it may have been unset by a
	 * closing sibling popup during PopupMenu::Show in the above Add call.
	 */
	owner->SetFlags(owner->GetFlags() | MB_POPUPOPEN);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, 0x5b8(%rax)
jne 0xc21f6
jmp 0xc2561
callq 0x5b700
movq -0x70(%rbp), %rcx
subq 0x5f0(%rcx), %rax
cmpq $0x64, %rax
jae 0xc2211
jmp 0xc2561
movq -0x70(%rbp), %rax
movq 0x190(%rax), %rdi
callq 0x59bc0
movq -0x70(%rbp), %rdi
movq %rax, -0x10(%rbp)
movq (%rdi), %rax
callq *0x40(%rax)
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xc223f
jmp 0xc2561
movq -0x70(%rbp), %rax
cmpq $0x0, 0x608(%rax)
je 0xc226c
movq -0x70(%rbp), %rax
movq 0x608(%rax), %rdi
callq 0x5d8d0
movq -0x70(%rbp), %rax
movq $0x0, 0x608(%rax)
movq -0x70(%rbp), %rax
movq 0x5f8(%rax), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
callq 0x5c790
movq %rax, -0x28(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5d470
movw %ax, %cx
movq -0x70(%rbp), %rax
movswl %cx, %ecx
cvtsi2sd %ecx, %xmm0
movsd 0xc5217(%rip), %xmm1    # 0x1874c0
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x5b8(%rax), %rdi
callq 0x5dbb0
movq -0x70(%rbp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq -0x70(%rbp), %rdi
movq %rax, -0x38(%rbp)
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x74(%rbp)
movsd 0xc8650(%rip), %xmm0    # 0x18a938
mulsd -0x30(%rbp), %xmm0
callq 0x5a970
movl -0x74(%rbp), %esi
movl %eax, %edx
leaq -0x50(%rbp), %rdi
callq 0x5c2c0
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5ca20
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, -0x48(%rbp)
movq 0x5b8(%rax), %rdi
callq 0x5bf70
movq -0x70(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq (%rdi), %rax
callq *0x160(%rax)
testb $0x1, %al
jne 0xc239c
movq -0x10(%rbp), %rdi
callq 0x5dab0
addl -0x48(%rbp), %eax
cltq
movq %rax, -0x80(%rbp)
cvtsi2sdl -0x58(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0x80(%rbp), %rax
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
cmpq %rcx, %rax
jl 0xc239a
movslq -0x38(%rbp), %rax
movq %rax, -0x88(%rbp)
cvtsi2sdl -0x58(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0x88(%rbp), %rax
subq %rcx, %rax
movl %eax, -0x48(%rbp)
jmp 0xc241b
movq -0x10(%rbp), %rdi
callq 0x5dab0
movl %eax, -0x94(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5a210
movl %eax, %ecx
movl -0x94(%rbp), %eax
subl -0x48(%rbp), %ecx
addl %ecx, %eax
cltq
movq %rax, -0x90(%rbp)
cvtsi2sdl -0x58(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0x90(%rbp), %rax
subq %rcx, %rax
movslq -0x28(%rbp), %rcx
cmpq %rcx, %rax
jge 0xc2419
movslq -0x38(%rbp), %rax
movq %rax, -0xa0(%rbp)
cvtsi2sdl -0x58(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xa0(%rbp), %rax
subq %rcx, %rax
movl %eax, -0x48(%rbp)
jmp 0xc241b
movq -0x10(%rbp), %rdi
callq 0x5ddb0
addl -0x44(%rbp), %eax
cltq
movq %rax, -0xa8(%rbp)
cvtsi2sdl -0x54(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xa8(%rbp), %rax
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
cmpq %rcx, %rax
jl 0xc24ac
movslq -0x34(%rbp), %rax
movq %rax, -0xb8(%rbp)
cvtsi2sdl -0x54(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xb8(%rbp), %rax
subq %rcx, %rax
movslq -0x3c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movsd 0xc509e(%rip), %xmm0    # 0x187530
mulsd -0x30(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xb0(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x44(%rbp)
movq -0x70(%rbp), %rax
movq 0x5b8(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5d8c0
movq -0x70(%rbp), %rcx
movq 0x5b8(%rcx), %rdi
addq $0x698, %rdi            # imm = 0x698
movq 0x14655f(%rip), %rax    # 0x208a38
movq %rax, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0xc3dc0
movq -0x70(%rbp), %rax
movq 0x600(%rax), %rcx
movq %rcx, -0xc8(%rbp)
movq 0x600(%rax), %rdi
callq 0x5a120
movq -0xc8(%rbp), %rdi
movl %eax, %esi
orl $0x2, %esi
callq 0x59730
movq -0x70(%rbp), %rdi
movq 0x5b8(%rdi), %rsi
movq (%rdi), %rax
callq *0x30(%rax)
movq -0x70(%rbp), %rax
movq 0x600(%rax), %rcx
movq %rcx, -0xc0(%rbp)
movq 0x600(%rax), %rdi
callq 0x5a120
movq -0xc0(%rbp), %rdi
movl %eax, %esi
orl $0x2, %esi
callq 0x59730
addq $0xd0, %rsp
popq %rbp
retq
nopw (%rax,%rax)