// File: /workspace/github_c_makefile_star2_O3/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 $0x258, %rsp            # imm = 0x258
movq %rdi, %rbx
movb 0xb5920(%rip), %al      # 0x176e88
testb %al, %al
je 0xc1898
movb 0xb5922(%rip), %al      # 0x176e98
testb %al, %al
je 0xc18d9
movb 0xb5974(%rip), %al      # 0x176ef8
testb %al, %al
je 0xc191a
leaq 0xb590d(%rip), %rdi     # 0x176ea0
callq 0x64126
movq 0xb58f1(%rip), %rsi     # 0x176e90
movq 0xb58da(%rip), %rdx     # 0x176e80
movq 0x120(%rbx), %rdi
movq 0x138(%rbx), %r8
movq 0x168(%rbx), %r9
movl $0x1, %ecx
callq 0x587e0
movq 0x120(%rbx), %rdi
callq 0x55e10
leaq 0x198(%rsp), %r14
movq 0x120(%rbx), %rdi
movq %r14, %rsi
callq 0x57ee0
movq 0x1b8(%rsp), %rdi
callq 0xbeb56
testq %rax, %rax
je 0xc1605
movq %rax, %rdi
movq %r14, %rsi
callq 0xbedc2
cmpl $0x1f, 0x198(%rsp)
jne 0xc15d9
xorl %eax, %eax
leaq 0x8(%rsp), %r15
movq %rax, (%r15)
movq 0x120(%rbx), %rdi
movq 0x138(%rbx), %rsi
leaq 0x10(%rsp), %r12
leaq 0x70(%rsp), %rbp
leaq 0x24(%rsp), %r13
leaq 0x18(%rsp), %r10
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r15
pushq %r12
pushq %rbp
pushq %r13
pushq %r10
pushq %rax
callq 0x58180
addq $0x30, %rsp
movq (%r15), %r14
testl %eax, %eax
jne 0xc16bb
testq %r14, %r14
je 0xc1678
movq %r14, %rdi
callq 0x57e80
movq $0x0, 0x8(%rsp)
movq 0x10(%rsp), %r8
testq %r8, %r8
je 0xc187f
movq 0x120(%rbx), %rdi
movq 0x138(%rbx), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r9d, %r9d
pushq %r15
pushq %r12
pushq %rbp
pushq %r13
leaq 0x38(%rsp), %rax
pushq %rax
pushq $0x0
callq 0x58180
addq $0x30, %rsp
movq 0x8(%rsp), %r14
testq %r14, %r14
je 0xc187f
movq %r14, %rdi
callq 0x56370
leaq 0x1(%rax), %rcx
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
movl $0x5, %esi
movq %r14, %rdx
callq 0x56590
cmpw $0x0, 0x8(%rbx)
je 0xc1851
leaq 0x78(%rsp), %rbx
leaq 0x5b2a3(%rip), %r15     # 0x11c9a2
leaq 0x28(%rsp), %r12
leaq 0x58(%rsp), %rbp
leaq 0x40(%rsp), %r13
movq 0xd8(%rsp), %rax
cmpq 0xa0(%rsp), %rax
jge 0xc185b
movq %rbx, %rdi
leaq 0x90(%rsp), %rsi
callq 0x57310
movq %r12, %rdi
movq %r15, %rsi
callq 0x579f0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x577d0
movl %eax, %r14d
movq %r12, %rdi
callq 0x59200
testb %r14b, %r14b
jne 0xc183a
movq %r12, %rdi
leaq 0x516ce(%rip), %rsi     # 0x112e36
callq 0x579f0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x577d0
movl %eax, %r14d
movq %r12, %rdi
callq 0x59200
testb %r14b, %r14b
je 0xc183a
movq %rbx, %rdi
callq 0x57180
addl $-0x7, %eax
movq %rbp, %rdi
movq %rbx, %rsi
movl %eax, %edx
callq 0x57f90
movq %r13, %rdi
leaq 0x31f3c(%rip), %rsi     # 0xf36ea
callq 0x579f0
movq %rbp, %rdi
movq %r13, %rsi
callq 0x57610
movq %r12, %rdi
movq %rbx, %rsi
movl $0x7, %edx
movl %eax, %ecx
callq 0x58f50
movq %r13, %rdi
callq 0x59200
movq %rbp, %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57180
movl %eax, %r14d
movq %r12, %rdi
callq 0x57180
subl %eax, %r14d
addl $-0x7, %r14d
movq %r13, %rdi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x57f90
movq %rbp, %rdi
movq %r13, %rsi
callq 0x56a40
leaq 0xb5686(%rip), %rdi     # 0x176ea0
movq %rbp, %rsi
callq 0x642ac
movq %rbp, %rdi
callq 0x59200
movq %r13, %rdi
callq 0x59200
movq %r12, %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x59200
cmpw $0x0, 0x98(%rsp)
jne 0xc170e
movw $0x5, 0x188(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x55310
movq 0x8(%rsp), %rdi
callq 0x57e80
leaq 0x90(%rsp), %rdi
callq 0x555b0
leaq 0xb561a(%rip), %rax     # 0x176ea0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb55e9(%rip), %rdi     # 0x176e88
callq 0x56120
testl %eax, %eax
je 0xc1570
movq 0x120(%rbx), %rdi
leaq 0x519a6(%rip), %rsi     # 0x113260
xorl %edx, %edx
callq 0x57ea0
movq %rax, 0xb55b8(%rip)     # 0x176e80
leaq 0xb55b9(%rip), %rdi     # 0x176e88
callq 0x56b80
jmp 0xc1570
leaq 0xb55b8(%rip), %rdi     # 0x176e98
callq 0x56120
testl %eax, %eax
je 0xc157e
movq 0x120(%rbx), %rdi
leaq 0x51b10(%rip), %rsi     # 0x11340b
xorl %edx, %edx
callq 0x57ea0
movq %rax, 0xb5587(%rip)     # 0x176e90
leaq 0xb5588(%rip), %rdi     # 0x176e98
callq 0x56b80
jmp 0xc157e
leaq 0xb55d7(%rip), %rdi     # 0x176ef8
callq 0x56120
testl %eax, %eax
je 0xc158c
leaq 0xb556b(%rip), %rdi     # 0x176ea0
callq 0x55d90
leaq 0x9e96f(%rip), %rax     # 0x1602b0
movq %rax, 0xb5598(%rip)     # 0x176ee0
leaq 0xb5551(%rip), %rsi     # 0x176ea0
xorps %xmm0, %xmm0
movups %xmm0, 0xb558f(%rip)    # 0x176ee8
leaq 0x9e8b0(%rip), %rax     # 0x160210
movq %rax, 0xb5539(%rip)     # 0x176ea0
leaq -0x5db32(%rip), %rdi    # 0x63e3c
leaq 0xac70b(%rip), %rdx     # 0x16e080
callq 0x57e10
leaq 0xb5577(%rip), %rdi     # 0x176ef8
callq 0x56b80
jmp 0xc158c
movq %rax, %rbx
leaq 0xb5563(%rip), %rdi     # 0x176ef8
jmp 0xc19ad
movq %rax, %rbx
leaq 0xb54f7(%rip), %rdi     # 0x176e98
jmp 0xc19ad
movq %rax, %rbx
leaq 0xb54db(%rip), %rdi     # 0x176e88
callq 0x56420
jmp 0xc1a26
jmp 0xc19fd
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x59200
jmp 0xc19c8
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x59200
jmp 0xc19f6
movq %rax, %rbx
jmp 0xc19ec
jmp 0xc19f8
jmp 0xc1a02
jmp 0xc19f8
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x59200
leaq 0x58(%rsp), %rdi
jmp 0xc1a0a
movq %rax, %rbx
jmp 0xc1a05
movq %rax, %rbx
jmp 0xc1a0f
movq %rax, %rbx
jmp 0xc1a19
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x59200
leaq 0x78(%rsp), %rdi
callq 0x59200
leaq 0x90(%rsp), %rdi
callq 0x555b0
movq %rbx, %rdi
callq 0x57090