// File: /workspace/github_c_makefile_star2_O1/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 0xb57ca(%rip), %al      # 0x177e88
testb %al, %al
je 0xc29f9
movb 0xb57cc(%rip), %al      # 0x177e98
testb %al, %al
je 0xc2a3a
movb 0xb581e(%rip), %al      # 0x177ef8
testb %al, %al
je 0xc2a7b
leaq 0xb57b7(%rip), %rdi     # 0x177ea0
callq 0x640f6
movq 0xb579b(%rip), %rsi     # 0x177e90
movq 0xb5784(%rip), %rdx     # 0x177e80
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 0xbfb44
testq %rax, %rax
je 0xc275b
movq %rax, %rdi
movq %r14, %rsi
callq 0xbfdd8
cmpl $0x1f, 0x198(%rsp)
jne 0xc272f
xorl %eax, %eax
leaq 0x8(%rsp), %r14
movq %rax, (%r14)
movq 0x120(%rbx), %rdi
movq 0x138(%rbx), %rsi
leaq 0x10(%rsp), %rbp
leaq 0x68(%rsp), %r13
leaq 0x1c(%rsp), %r12
leaq 0x70(%rsp), %r15
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r14
pushq %rbp
pushq %r13
pushq %r12
pushq %r15
pushq %rax
callq 0x58180
addq $0x30, %rsp
testl %eax, %eax
jne 0xc2803
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xc27cd
callq 0x57e80
movq $0x0, 0x8(%rsp)
movq 0x10(%rsp), %r8
testq %r8, %r8
je 0xc2803
movq 0x120(%rbx), %rdi
movq 0x138(%rbx), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r9d, %r9d
pushq %r14
pushq %rbp
pushq %r13
pushq %r12
pushq %r15
pushq $0x0
callq 0x58180
addq $0x30, %rsp
movq 0x8(%rsp), %r14
testq %r14, %r14
je 0xc29e0
movq %r14, %rdi
callq 0x56370
leaq 0x1(%rax), %rcx
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
movl $0x5, %esi
movq %r14, %rdx
callq 0x56590
leaq 0x78(%rsp), %r14
leaq 0x20(%rsp), %r12
leaq 0x50(%rsp), %rbp
leaq 0x38(%rsp), %r13
movzwl 0x98(%rsp), %ecx
testw %cx, %cx
je 0xc2860
movq 0xd8(%rsp), %rax
jmp 0xc2871
movw $0x5, 0x188(%rsp)
movq $-0x1, %rax
testw %cx, %cx
je 0xc2880
movq 0xa0(%rsp), %rcx
jmp 0xc2891
movw $0x5, 0x188(%rsp)
movq $-0x1, %rcx
cmpq %rcx, %rax
jge 0xc29bc
movq %r14, %rdi
movq %rbx, %rsi
callq 0x57310
movq %r12, %rdi
leaq 0x5aee3(%rip), %rsi     # 0x11d792
callq 0x579f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x577d0
movl %eax, %r15d
movq %r12, %rdi
callq 0x59200
testb %r15b, %r15b
jne 0xc29af
movq %r12, %rdi
leaq 0x51359(%rip), %rsi     # 0x113c36
callq 0x579f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x577d0
movl %eax, %r15d
movq %r12, %rdi
callq 0x59200
testb %r15b, %r15b
je 0xc29af
movq %r14, %rdi
callq 0x57180
addl $-0x7, %eax
movq %rbp, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x57f90
movq %r13, %rdi
leaq 0x31d65(%rip), %rsi     # 0xf4688
callq 0x579f0
movq %rbp, %rdi
movq %r13, %rsi
callq 0x57610
movq %r12, %rdi
movq %r14, %rsi
movl $0x7, %edx
movl %eax, %ecx
callq 0x58f50
movq %r13, %rdi
callq 0x59200
movq %rbp, %rdi
callq 0x59200
movq %r14, %rdi
callq 0x57180
movl %eax, %r15d
movq %r12, %rdi
callq 0x57180
subl %eax, %r15d
addl $-0x7, %r15d
movq %r13, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x57f90
movq %rbp, %rdi
movq %r13, %rsi
callq 0x56a40
leaq 0xb5511(%rip), %rdi     # 0x177ea0
movq %rbp, %rsi
callq 0x64280
movq %rbp, %rdi
callq 0x59200
movq %r13, %rdi
callq 0x59200
movq %r12, %rdi
callq 0x59200
movq %r14, %rdi
callq 0x59200
jmp 0xc2849
leaq 0x90(%rsp), %rdi
callq 0x55310
movq 0x8(%rsp), %rdi
callq 0x57e80
leaq 0x90(%rsp), %rdi
callq 0x555b0
leaq 0xb54b9(%rip), %rax     # 0x177ea0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb5488(%rip), %rdi     # 0x177e88
callq 0x56120
testl %eax, %eax
je 0xc26c6
movq 0x120(%rbx), %rdi
leaq 0x51639(%rip), %rsi     # 0x114054
xorl %edx, %edx
callq 0x57ea0
movq %rax, 0xb5457(%rip)     # 0x177e80
leaq 0xb5458(%rip), %rdi     # 0x177e88
callq 0x56b80
jmp 0xc26c6
leaq 0xb5457(%rip), %rdi     # 0x177e98
callq 0x56120
testl %eax, %eax
je 0xc26d4
movq 0x120(%rbx), %rdi
leaq 0x517a3(%rip), %rsi     # 0x1141ff
xorl %edx, %edx
callq 0x57ea0
movq %rax, 0xb5426(%rip)     # 0x177e90
leaq 0xb5427(%rip), %rdi     # 0x177e98
callq 0x56b80
jmp 0xc26d4
leaq 0xb5476(%rip), %rdi     # 0x177ef8
callq 0x56120
testl %eax, %eax
je 0xc26e2
leaq 0xb540a(%rip), %rdi     # 0x177ea0
callq 0x55d90
leaq 0xb53fe(%rip), %rsi     # 0x177ea0
leaq 0x9e7e7(%rip), %rax     # 0x161290
movq %rax, 0xb5430(%rip)     # 0x177ee0
xorps %xmm0, %xmm0
movups %xmm0, 0xb542e(%rip)    # 0x177ee8
leaq 0x9e72f(%rip), %rax     # 0x1611f0
movq %rax, 0xb53d8(%rip)     # 0x177ea0
leaq -0x5ecc7(%rip), %rdi    # 0x63e08
leaq 0xac5aa(%rip), %rdx     # 0x16f080
callq 0x57e10
leaq 0xb5416(%rip), %rdi     # 0x177ef8
callq 0x56b80
jmp 0xc26e2
movq %rax, %rbx
leaq 0xb5402(%rip), %rdi     # 0x177ef8
jmp 0xc2b0e
movq %rax, %rbx
leaq 0xb5396(%rip), %rdi     # 0x177e98
jmp 0xc2b0e
movq %rax, %rbx
leaq 0xb537a(%rip), %rdi     # 0x177e88
callq 0x56420
jmp 0xc2b82
jmp 0xc2b8a
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x59200
jmp 0xc2b29
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x59200
jmp 0xc2b57
movq %rax, %rbx
jmp 0xc2b4b
jmp 0xc2b59
jmp 0xc2b5e
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x59200
leaq 0x50(%rsp), %rdi
jmp 0xc2b66
jmp 0xc2b59
movq %rax, %rbx
jmp 0xc2b61
movq %rax, %rbx
jmp 0xc2b6b
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x59200
leaq 0x78(%rsp), %rdi
callq 0x59200
leaq 0x90(%rsp), %rdi
callq 0x555b0
movq %rbx, %rdi
callq 0x57090
movq %rax, %rbx
jmp 0xc2b75
nop