// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/game-x11.cpp
// Function: gameview_x11::process_event(_XEvent*)
void process_event(XEvent* ev)
{
	got_event = true;
	switch (ev->type)
	{
		case Expose: break; // just set got_event, nothing else needed
		case FocusIn:
			focus = true;
			set_all_keys();
			break;
		case FocusOut:
			focus = false;
			break;
		case KeyPress:
		case KeyRelease:
			set_key(ev->xkey.keycode, (ev->type == KeyPress));
			break;
		case ButtonPress:
		case ButtonRelease:
			static_assert(Button1Mask == 256); // guaranteed by X11 spec
			static_assert(Button2Mask == 512);
			static_assert(Button3Mask == 1024);
			if (ev->xbutton.button >= 1 && ev->xbutton.button <= 3)
				send_mouse(ev->xbutton.x, ev->xbutton.y, ev->xbutton.state^(Button1Mask >> 1 << ev->xbutton.button));
			break;
		case MotionNotify:
			send_mouse(ev->xmotion.x, ev->xmotion.y, ev->xmotion.state);
			break;
		case LeaveNotify:
			if (!(ev->xcrossing.state & (Button1Mask | Button2Mask | Button3Mask))) // if a button is held, we'll get a MotionNotify soon
				send_mouse(-0x8000000, -0x8000000, ev->xcrossing.state);
			break;
		case ClientMessage:
			if (ev->xclient.message_type == atoms.WM_PROTOCOLS && ev->xclient.format == 32)
			{
				Atom subtype = ev->xclient.data.l[0];
				if (subtype == atoms.WM_DELETE_WINDOW)
				{
					cb_exit();
				}
				else if (subtype == atoms._NET_WM_PING)
				{
					ev->xclient.window = XRootWindow(display, window_x11.screen);
					XSendEvent(display, ev->xclient.window, false, SubstructureRedirectMask|SubstructureNotifyMask, ev);
				}
#ifndef ARLIB_OPT
				else puts("AAAAA unknown WM_PROTOCOLS");
#endif
			}
#ifndef ARLIB_OPT
			else puts("AAAAA unknown ClientMessage");
#endif
			break;
#ifndef ARLIB_OPT
		default:
			printf("AAAAA unknown event %d\n",ev->type);
			break;
#endif
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r8
movb $0x1, 0x1a(%rdi)
movl (%rsi), %esi
leal -0x2(%rsi), %eax
cmpl $0xa, %eax
ja 0x8d1e
leaq 0x1f7f9(%rip), %rcx     # 0x284c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0x54(%rbx), %eax
xorl %edx, %edx
cmpl $0x2, %esi
sete %dl
movq %r8, %rdi
movl %eax, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x8e82
movl 0x54(%rbx), %ecx
leal -0x1(%rcx), %eax
cmpl $0x2, %eax
ja 0x8d98
movl $0x80, %eax
shll %cl, %eax
movl 0x40(%rbx), %esi
movl 0x44(%rbx), %edx
xorl 0x50(%rbx), %eax
movq %r8, %rdi
movl %eax, %ecx
jmp 0x8dc0
cmpl $0x21, %esi
jne 0x8d50
movq 0x28(%rbx), %rax
cmpq 0x20(%r8), %rax
jne 0x8da0
cmpl $0x20, 0x30(%rbx)
jne 0x8da0
movq 0x38(%rbx), %rax
cmpq 0x28(%r8), %rax
jne 0x8dcc
movq 0x60(%r8), %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmpq *0x68(%r8)
leaq 0x1f817(%rip), %rdi     # 0x2856e
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3050
movb $0x1, 0x18(%r8)
movq %r8, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x8e0e
movb $0x0, 0x18(%r8)
jmp 0x8d98
movl 0x40(%rbx), %esi
movl 0x44(%rbx), %edx
movl 0x50(%rbx), %ecx
movq %r8, %rdi
jmp 0x8dc0
movl 0x60(%rbx), %ecx
testw $0x700, %cx             # imm = 0x700
je 0x8db3
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x1f7ab(%rip), %rdi     # 0x28552
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3590
movq %r8, %rdi
movl $0xf8000000, %esi       # imm = 0xF8000000
movl $0xf8000000, %edx       # imm = 0xF8000000
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x8ed8
cmpq 0x30(%r8), %rax
jne 0x8e05
movq 0x8(%r8), %rdi
movl 0x38574(%rip), %esi     # 0x41350
movq %r8, %r14
callq 0x35d0
movq %rax, 0x20(%rbx)
movq 0x8(%r14), %rdi
movl $0x180000, %ecx         # imm = 0x180000
movq %rax, %rsi
xorl %edx, %edx
movq %rbx, %r8
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x30c0
leaq 0x1f72b(%rip), %rdi     # 0x28537
jmp 0x8da7