// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/pointer.c
// Function: grab_pointer
bool grab_pointer(pointer_action_t pac)
{
	xcb_window_t win = XCB_NONE;
	xcb_point_t pos;

	query_pointer(&win, &pos);

	coordinates_t loc;

	if (!locate_window(win, &loc)) {
		if (pac == ACTION_FOCUS) {
			monitor_t *m = monitor_from_point(pos);
			if (m != NULL && m != mon && (win == XCB_NONE || win == m->root)) {
				focus_node(m, m->desk, m->desk->focus);
				return true;
			}
		}
		return false;
	}

	if (pac == ACTION_FOCUS) {
		if (loc.node != mon->desk->focus) {
			focus_node(loc.monitor, loc.desktop, loc.node);
			return true;
		} else if (focus_follows_pointer) {
			stack(loc.desktop, loc.node, true);
		}
		return false;
	}

	if (loc.node->client->state == STATE_FULLSCREEN) {
		return true;
	}

	xcb_grab_pointer_reply_t *reply = xcb_grab_pointer_reply(dpy, xcb_grab_pointer(dpy, 0, root, XCB_EVENT_MASK_BUTTON_RELEASE|XCB_EVENT_MASK_BUTTON_MOTION, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_CURRENT_TIME), NULL);

	if (reply == NULL || reply->status != XCB_GRAB_STATUS_SUCCESS) {
		free(reply);
		return true;
	}
	free(reply);

	if (pac == ACTION_MOVE) {
		put_status(SBSC_MASK_POINTER_ACTION, "pointer_action 0x%08X 0x%08X 0x%08X move begin\n", loc.monitor->id, loc.desktop->id, loc.node->id);
	} else if (pac == ACTION_RESIZE_CORNER) {
		put_status(SBSC_MASK_POINTER_ACTION, "pointer_action 0x%08X 0x%08X 0x%08X resize_corner begin\n", loc.monitor->id, loc.desktop->id, loc.node->id);
	} else if (pac == ACTION_RESIZE_SIDE) {
		put_status(SBSC_MASK_POINTER_ACTION, "pointer_action 0x%08X 0x%08X 0x%08X resize_side begin\n", loc.monitor->id, loc.desktop->id, loc.node->id);
	}

	track_pointer(loc, pac, pos);

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
leaq -0xc(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x176a0
movl -0xc(%rbp), %edi
leaq -0x28(%rbp), %rsi
callq 0x26b20
testb $0x1, %al
jne 0x154de
cmpl $0x1, -0x8(%rbp)
jne 0x154d5
movl -0x10(%rbp), %edi
callq 0x9080
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x154d3
movq -0x30(%rbp), %rax
leaq 0x2026d(%rip), %rcx     # 0x35700
cmpq (%rcx), %rax
je 0x154d3
movl -0xc(%rbp), %eax
cmpq $0x0, %rax
je 0x154ad
movl -0xc(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x154d3
movq -0x30(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rax), %rdx
callq 0xd720
movb $0x1, -0x1(%rbp)
jmp 0x156aa
jmp 0x154d5
movb $0x0, -0x1(%rbp)
jmp 0x156aa
cmpl $0x1, -0x8(%rbp)
jne 0x1553f
movq -0x18(%rbp), %rax
leaq 0x20211(%rip), %rcx     # 0x35700
movq (%rcx), %rcx
movq 0x58(%rcx), %rcx
cmpq 0x38(%rcx), %rax
je 0x15516
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0xd720
movb $0x1, -0x1(%rbp)
jmp 0x156aa
leaq 0x208cd(%rip), %rax     # 0x35dea
testb $0x1, (%rax)
je 0x15534
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x120e0
jmp 0x15536
movb $0x0, -0x1(%rbp)
jmp 0x156aa
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x3, 0x308(%rax)
jne 0x15559
movb $0x1, -0x1(%rbp)
jmp 0x156aa
leaq 0x20158(%rip), %rax     # 0x356b8
movq (%rax), %rax
movq %rax, -0x48(%rbp)
leaq 0x2014a(%rip), %rax     # 0x356b8
movq (%rax), %rdi
leaq 0x201f0(%rip), %rax     # 0x35768
movl (%rax), %edx
xorl %esi, %esi
movl $0x2008, %ecx           # imm = 0x2008
movl $0x1, %r9d
movl %r9d, %r8d
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x4260
movq -0x48(%rbp), %rdi
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x45e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x155d1
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0x155e3
movq -0x38(%rbp), %rdi
callq 0x4450
movb $0x1, -0x1(%rbp)
jmp 0x156aa
movq -0x38(%rbp), %rdi
callq 0x4450
cmpl $0x2, -0x8(%rbp)
jne 0x1561c
movq -0x28(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x20(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x18(%rbp), %rax
movl (%rax), %r8d
movl $0x8000000, %edi        # imm = 0x8000000
leaq 0x18615(%rip), %rsi     # 0x2dc28
movb $0x0, %al
callq 0x2c0b0
jmp 0x1567e
cmpl $0x4, -0x8(%rbp)
jne 0x1564c
movq -0x28(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x20(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x18(%rbp), %rax
movl (%rax), %r8d
movl $0x8000000, %edi        # imm = 0x8000000
leaq 0x18615(%rip), %rsi     # 0x2dc58
movb $0x0, %al
callq 0x2c0b0
jmp 0x1567c
cmpl $0x3, -0x8(%rbp)
jne 0x1567a
movq -0x28(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x20(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x18(%rbp), %rax
movl (%rax), %r8d
movl $0x8000000, %edi        # imm = 0x8000000
leaq 0x1861e(%rip), %rsi     # 0x2dc91
movb $0x0, %al
callq 0x2c0b0
jmp 0x1567c
jmp 0x1567e
movl -0x8(%rbp), %edi
movl -0x10(%rbp), %esi
leaq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x156c0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)