// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/gui/window/backends/xlib/windowxlib.cpp
// Function: smooth::GUI::WindowXLib::GetDroppedFiles() const
const S::Array<S::String> &S::GUI::WindowXLib::GetDroppedFiles() const
{
	static Atom	 mimeURIListAtom   = XInternAtom(display, "text/uri-list", False);

	static Atom	 xdndSelectionAtom = XInternAtom(display, "XdndSelection", False);

	static Array<String>	 fileNames;

	fileNames.RemoveAll();

	XConvertSelection(display, xdndSelectionAtom, mimeURIListAtom, XA_PRIMARY, wnd, xdndTimeStamp);
	XFlush(display);

	/* Wait for SelectionNotify event to be sent.
	 */
	XEvent	 event;

	do
	{
		XNextEvent(display, &event);

		WindowXLib	*backend = GUI::WindowXLib::GetWindowBackend(event.xany.window);

		if (backend != NIL) backend->ProcessSystemMessages(&event);
	}
	while (event.type != SelectionNotify);

	Atom		 type;
	int		 format;
	unsigned long	 items, bytes;
	unsigned char	*data = NIL;

	/* Do not get any data yet, see how much data is there.
	 */
	if (XGetWindowProperty(display, wnd, XA_PRIMARY, 0, 0, 0, AnyPropertyType, &type, &format, &items, &bytes, &data) == 0)
	{
		if (data != NIL) { XFree(data); data = NIL; }

		/* Data is there!
		 */
		if (bytes > 0) XGetWindowProperty(display, wnd, XA_PRIMARY, 0, bytes, 0, AnyPropertyType, &type, &format, &items, &bytes, &data);
	}

	if (data == NIL) return fileNames;

	/* Query data.
	 */
	IO::InStream	 in(IO::STREAM_BUFFER, data, strlen((char *) data) + 1);

	while (in.GetPos() < in.Size())
	{
		String	 line = in.InputLine();

		if (line.StartsWith("#")) continue;

		if (line.StartsWith("file://"))
		{
			String	 host = line.SubString(7, line.Tail(line.Length() - 7).Find("/"));

			fileNames.Add(Encoding::URLEncode::Decode(line.Tail(line.Length() - 7 - host.Length())));
		}
	}

	in.Close();

	XFree(data);

	return fileNames;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdi, %rbx
movb 0xb1b6a(%rip), %al      # 0x16d048
testb %al, %al
je 0xbb81b
movb 0xb1b6c(%rip), %al      # 0x16d058
testb %al, %al
je 0xbb85c
movb 0xb1bbe(%rip), %al      # 0x16d0b8
testb %al, %al
je 0xbb89d
leaq 0xb1b57(%rip), %rdi     # 0x16d060
callq 0x64c8c
movq 0xb1b3b(%rip), %rsi     # 0x16d050
movq 0xb1b24(%rip), %rdx     # 0x16d040
movq 0x120(%rbx), %rdi
movq 0x138(%rbx), %r8
movq 0x168(%rbx), %r9
pushq $0x1
popq %rcx
callq 0x59ae0
movq 0x120(%rbx), %rdi
callq 0x56ed0
leaq 0x1c8(%rsp), %r14
movq 0x120(%rbx), %rdi
movq %r14, %rsi
callq 0x59170
movq 0x1e8(%rsp), %rdi
callq 0xb8c8e
testq %rax, %rax
je 0xbb579
movq %rax, %rdi
movq %r14, %rsi
callq 0xb8e6e
cmpl $0x1f, 0x1c8(%rsp)
jne 0xbb54d
leaq 0x38(%rsp), %r15
andq $0x0, (%r15)
movq 0x120(%rbx), %rdi
movq 0x138(%rbx), %rsi
movq %r15, 0x28(%rsp)
leaq 0x40(%rsp), %r13
movq %r13, 0x20(%rsp)
leaq 0xa0(%rsp), %rbp
movq %rbp, 0x18(%rsp)
leaq 0x54(%rsp), %r12
movq %r12, 0x10(%rsp)
leaq 0x48(%rsp), %rax
andq $0x0, (%rsp)
movq %rax, 0x8(%rsp)
pushq $0x1
popq %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x59410
movq (%r15), %r14
testl %eax, %eax
jne 0xbb64a
testq %r14, %r14
je 0xbb5f9
movq %r14, %rdi
callq 0x59110
andq $0x0, 0x38(%rsp)
movq 0x40(%rsp), %r8
testq %r8, %r8
je 0xbb802
movq 0x120(%rbx), %rdi
movq 0x138(%rbx), %rsi
movq %r15, 0x28(%rsp)
movq %r13, 0x20(%rsp)
movq %rbp, 0x18(%rsp)
movq %r12, 0x10(%rsp)
andq $0x0, (%rsp)
leaq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
pushq $0x1
popq %rdx
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0x59410
movq 0x38(%rsp), %r14
testq %r14, %r14
je 0xbb802
movq %r14, %rdi
callq 0x57460
leaq 0x1(%rax), %rcx
leaq 0xc0(%rsp), %rbx
pushq $0x5
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x576a0
leaq 0xa8(%rsp), %r14
leaq 0x58(%rsp), %r12
leaq 0x88(%rsp), %rbp
leaq 0x70(%rsp), %r13
cmpw $0x0, 0xc8(%rsp)
je 0xbb7d4
movq 0x108(%rsp), %rax
cmpq 0xd0(%rsp), %rax
jge 0xbb7de
movq %r14, %rdi
movq %rbx, %rsi
callq 0x58500
movq %r12, %rdi
leaq 0x51169(%rip), %rsi     # 0x10c832
callq 0x58c40
movq %r14, %rdi
movq %r12, %rsi
callq 0x58a10
movl %eax, %r15d
movq %r12, %rdi
callq 0x5a588
testb %r15b, %r15b
jne 0xbb7c7
movq %r12, %rdi
leaq 0x475f3(%rip), %rsi     # 0x102cea
callq 0x58c40
movq %r14, %rdi
movq %r12, %rsi
callq 0x58a10
movl %eax, %r15d
movq %r12, %rdi
callq 0x5a588
testb %r15b, %r15b
je 0xbb7c7
movq %r14, %rdi
callq 0x58370
addl $-0x7, %eax
movq %rbp, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x59220
movq %r13, %rdi
leaq 0x27f6b(%rip), %rsi     # 0xe36a8
callq 0x58c40
movq %rbp, %rdi
movq %r13, %rsi
callq 0x58830
movq %r12, %rdi
movq %r14, %rsi
pushq $0x7
popq %rdx
movl %eax, %ecx
callq 0x5a2c0
movq %r13, %rdi
callq 0x5a588
movq %rbp, %rdi
callq 0x5a588
movq %r14, %rdi
callq 0x58370
movl %eax, %r15d
movq %r12, %rdi
callq 0x58370
subl %eax, %r15d
addl $-0x7, %r15d
movq %r13, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x59220
movq %rbp, %rdi
movq %r13, %rsi
callq 0x57ba0
leaq 0xb18b9(%rip), %rdi     # 0x16d060
movq %rbp, %rsi
callq 0x64dee
movq %rbp, %rdi
callq 0x5a588
movq %r13, %rdi
callq 0x5a588
movq %r12, %rdi
callq 0x5a588
movq %r14, %rdi
callq 0x5a588
jmp 0xbb68f
movw $0x5, 0x1b8(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x56340
movq 0x38(%rsp), %rdi
callq 0x59110
leaq 0xc0(%rsp), %rdi
callq 0x565f0
leaq 0xb1857(%rip), %rax     # 0x16d060
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb1826(%rip), %rdi     # 0x16d048
callq 0x57210
testl %eax, %eax
je 0xbb4e6
movq 0x120(%rbx), %rdi
leaq 0x47903(%rip), %rsi     # 0x103140
xorl %edx, %edx
callq 0x59130
movq %rax, 0xb17f5(%rip)     # 0x16d040
leaq 0xb17f6(%rip), %rdi     # 0x16d048
callq 0x57cf0
jmp 0xbb4e6
leaq 0xb17f5(%rip), %rdi     # 0x16d058
callq 0x57210
testl %eax, %eax
je 0xbb4f4
movq 0x120(%rbx), %rdi
leaq 0x47a6d(%rip), %rsi     # 0x1032eb
xorl %edx, %edx
callq 0x59130
movq %rax, 0xb17c4(%rip)     # 0x16d050
leaq 0xb17c5(%rip), %rdi     # 0x16d058
callq 0x57cf0
jmp 0xbb4f4
leaq 0xb1814(%rip), %rdi     # 0x16d0b8
callq 0x57210
testl %eax, %eax
je 0xbb502
leaq 0xb17a8(%rip), %rdi     # 0x16d060
callq 0x64972
leaq -0x56f3c(%rip), %rdi    # 0x64988
leaq 0xb1795(%rip), %rsi     # 0x16d060
leaq 0xa896e(%rip), %rdx     # 0x164240
callq 0x590a0
leaq 0xb17da(%rip), %rdi     # 0x16d0b8
callq 0x57cf0
jmp 0xbb502
movq %rax, %rbx
leaq 0xb17c6(%rip), %rdi     # 0x16d0b8
jmp 0xbb90a
movq %rax, %rbx
leaq 0xb175a(%rip), %rdi     # 0x16d058
jmp 0xbb90a
movq %rax, %rbx
leaq 0xb173e(%rip), %rdi     # 0x16d048
callq 0x57520
jmp 0xbb989
jmp 0xbb958
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x5a588
jmp 0xbb928
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x5a588
jmp 0xbb960
movq %rax, %rbx
jmp 0xbb94c
jmp 0xbb96c
jmp 0xbb95d
jmp 0xbb96c
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x5a588
leaq 0x88(%rsp), %rdi
jmp 0xbb965
jmp 0xbb95d
movq %rax, %rbx
jmp 0xbb97c
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x5a588
jmp 0xbb96f
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x5a588
leaq 0xc0(%rsp), %rdi
callq 0x565f0
movq %rbx, %rdi
callq 0x58260
nop