// File: /workspace/github_c_makefile_star2_O0/comfies[P]custard/src/wm/handlers.c
// Function: handle_window_message
void handle_window_message(xcb_generic_event_t *generic_event) {
    xcb_client_message_event_t *event;
    event = (xcb_client_message_event_t*)generic_event;

    xcb_window_t window_id = event->window;

    if (event->type == ewmh_connection->_NET_CLOSE_WINDOW) {
        if (window_is_managed(window_id))
            unmanage_window(window_id);
        close_window(window_id);
        return;
    }

    if (event->type == ewmh_connection->_NET_WM_STATE) {
        if (!window_is_managed(window_id))
            return;
        window_t *window = get_window_by_id(window_id);

        xcb_ewmh_wm_state_action_t state_action = event->data.data32[0];
        xcb_atom_t attribute = event->data.data32[1];

        if (attribute == ewmh_connection->_NET_WM_STATE_FULLSCREEN) {
            if (state_action == XCB_EWMH_WM_STATE_TOGGLE)
                window->fullscreen = !window->fullscreen;
            else
                window->fullscreen = state_action;

            monitor_t *monitor = window->monitor;

            if (window->fullscreen) {
                change_window_geometry(window->parent,
                    0, 0,
                    (unsigned int)monitor->geometry->height,
                    (unsigned int)monitor->geometry->width
                );
            } else
                set_window_geometry(window, window->geometry);

            apply();
        }

        return;
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
leaq 0x62b4(%rip), %rcx      # 0xd920
movq (%rcx), %rcx
cmpl 0x58(%rcx), %eax
jne 0x7697
movl -0x14(%rbp), %edi
callq 0x8050
cmpw $0x0, %ax
je 0x768a
movl -0x14(%rbp), %edi
callq 0x8680
movl -0x14(%rbp), %edi
callq 0x9100
jmp 0x778c
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
leaq 0x627b(%rip), %rcx      # 0xd920
movq (%rcx), %rcx
cmpl 0x84(%rcx), %eax
jne 0x778c
movl -0x14(%rbp), %edi
callq 0x8050
cmpw $0x0, %ax
jne 0x76c7
jmp 0x778c
movl -0x14(%rbp), %edi
callq 0x8090
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
leaq 0x622f(%rip), %rcx      # 0xd920
movq (%rcx), %rcx
cmpl 0x128(%rcx), %eax
jne 0x778a
cmpl $0x2, -0x24(%rbp)
jne 0x7726
movq -0x20(%rbp), %rax
cmpw $0x0, 0x20(%rax)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x20(%rax)
jmp 0x7734
movl -0x24(%rbp), %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x20(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpw $0x0, 0x20(%rax)
je 0x7774
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
cvttss2si 0x8(%rax), %rcx
cvttss2si 0xc(%rax), %rax
movl %eax, %r8d
xorl %edx, %edx
movl %edx, %esi
callq 0x92c0
jmp 0x7785
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x8520
callq 0x8ac0
jmp 0x778c
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)