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

	if (window->IsMaximized() && mousePos != startMousePos)
	{
		Rect	 nonMaxRect = window->GetRestoredWindowRect();
		Rect	 workArea   = System::Screen::GetActiveScreenWorkArea();

		window->Restore();
		window->SetPosition(Point(workArea.left + Math::Max(0, Math::Min(mousePos.x - nonMaxRect.GetWidth() / 2, workArea.GetWidth() - nonMaxRect.GetWidth())), workArea.top + mousePos.y - startMousePos.y));

		startMousePos.x -= window->GetX();
	}

	if (!window->IsMaximized()) window->SetPosition(window->GetPosition() - (Point((IsRightToLeft() ? window->GetWidth() - startMousePos.x : startMousePos.x), startMousePos.y) - Point((IsRightToLeft() ? window->GetWidth() - mousePos.x : mousePos.x), mousePos.y)));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq 0x190(%rax), %rdi
callq 0x59bc0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x59650
testb $0x1, %al
jne 0xa896d
jmp 0xa8a5c
movq -0x68(%rbp), %rsi
movq -0x10(%rbp), %rdi
addq $0x5bc, %rsi            # imm = 0x5BC
callq 0x5d770
testb $0x1, %al
jne 0xa898a
jmp 0xa8a5c
movq -0x18(%rbp), %rdi
callq 0x5be50
movq %rax, -0x28(%rbp)
movq %rdx, -0x20(%rbp)
callq 0x5c790
movq %rax, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5bad0
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x80(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5a5a0
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x80(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x78(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5a5a0
movl %eax, -0x7c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5a5a0
movl -0x7c(%rbp), %esi
movl -0x78(%rbp), %edi
subl %eax, %esi
callq 0x5ce90
movl %eax, %esi
xorl %edi, %edi
callq 0x5aae0
movl -0x74(%rbp), %esi
movl %eax, %ecx
movq -0x68(%rbp), %rax
addl %ecx, %esi
movl -0x34(%rbp), %edx
movq -0x10(%rbp), %rcx
addl 0x4(%rcx), %edx
subl 0x5c0(%rax), %edx
leaq -0x40(%rbp), %rdi
callq 0x5c2c0
movq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5d8c0
movq -0x18(%rbp), %rdi
callq 0x5dab0
movl %eax, %edx
movq -0x68(%rbp), %rax
movl 0x5bc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x5bc(%rax)
movq -0x18(%rbp), %rdi
callq 0x59650
testb $0x1, %al
jne 0xa8b60
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5d740
movq -0x68(%rbp), %rdi
movq %rax, -0x88(%rbp)
movq (%rdi), %rax
callq *0x160(%rax)
testb $0x1, %al
jne 0xa8a9b
jmp 0xa8ab6
movq -0x18(%rbp), %rdi
callq 0x5a210
movq -0x68(%rbp), %rcx
subl 0x5bc(%rcx), %eax
movl %eax, -0x94(%rbp)
jmp 0xa8ac6
movq -0x68(%rbp), %rax
movl 0x5bc(%rax), %eax
movl %eax, -0x94(%rbp)
movq -0x68(%rbp), %rax
movl -0x94(%rbp), %esi
movl 0x5c0(%rax), %edx
leaq -0x58(%rbp), %rdi
callq 0x5c2c0
movq -0x68(%rbp), %rdi
movq (%rdi), %rax
callq *0x160(%rax)
testb $0x1, %al
jne 0xa8af2
jmp 0xa8b09
movq -0x18(%rbp), %rdi
callq 0x5a210
movq -0x10(%rbp), %rcx
subl (%rcx), %eax
movl %eax, -0x98(%rbp)
jmp 0xa8b15
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x98(%rbp)
movl -0x98(%rbp), %esi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
leaq -0x60(%rbp), %rdi
callq 0x5c2c0
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x5cbd0
movq -0x88(%rbp), %rdi
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rsi
callq 0x5cbd0
movq -0x90(%rbp), %rdi
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rsi
callq 0x5d8c0
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)