// File: /workspace/github_c_makefile_star2_O2/kaugm[P]mmwm/mmwm.c
// Function: update_current
void update_current(client *newfocus)   // newfocus may be NULL
{
    if(!M_HEAD) {                // empty desktop. no clients
        nada();
        return;
    }

    if(!newfocus) {
        if(M_PREVFOCUS)
            M_CURRENT = M_PREVFOCUS;
        else
            M_CURRENT = M_HEAD;
        M_PREVFOCUS = M_GETPREV(M_CURRENT);             // get previous client in list, may be NULL
    }
    else {
        if(newfocus == M_PREVFOCUS) {
            M_CURRENT = M_PREVFOCUS;
            M_PREVFOCUS = M_GETPREV(M_CURRENT);         // get previous client in list, may be NULL
        }
        else {
            M_PREVFOCUS = M_CURRENT;
            M_CURRENT = newfocus;
        }
    }

    if(!M_CURRENT) {  // there is really really really nothing to focus.
        nada();
        return;
    }

	/* Setting window borders: xcb_border_width -----> client_borders(c) */
    for (client *c = M_HEAD; c; c = M_GETNEXT(c)) {
        if (!c->isfullscreen) {
            xcb_change_window_attributes(dis, c->win, XCB_CW_BORDER_PIXEL,
                                    (c == M_CURRENT ? &win_focus : &win_unfocus));
            xcb_border_width(dis, c->win, client_borders(c));
        }
    }

    tile();

    for (client *c = M_HEAD; c; c = M_GETNEXT(c)) {
        if (c->isfullscreen) {
//            xcb_border_width(dis, c->win, 0);
            xcb_lower_window(dis, c->win);
//            xcb_move_resize(dis, c->win, 0, 0,
//                            screen->width_in_pixels, screen->height_in_pixels, &c->position_info);
            break;
        }
    }

    client *rl = NULL;
    for (client *c = M_HEAD; c; c = M_GETNEXT(c)) {
        if (c->ismaximized || c->isfloating || c->istransient || c->type != ewmh->_NET_WM_WINDOW_TYPE_NORMAL) {
            if (c == M_CURRENT) {
                rl = c;
                continue;
            }
        }
        xcb_raise_window(dis, c->win);
    }
    if(rl)
        xcb_raise_window(dis, rl->win);

    if (check_head(&aliens)) {
        alien *a;
        for (a=(alien *)get_head(&aliens); a; a=(alien *)get_next(&a->link)) {
            if (M_CURRENT->isfullscreen
             && a->type != ewmh->_NET_WM_WINDOW_TYPE_NOTIFICATION)
                continue;
            xcb_raise_window(dis, a->win);
        }
    }

    if (M_CURRENT) {
        if (M_CURRENT->setfocus) {
            xcb_change_property(dis, XCB_PROP_MODE_REPLACE, screen->root,
                                ewmh->_NET_ACTIVE_WINDOW, XCB_ATOM_WINDOW, 32, 1,
                                &M_CURRENT->win);
            xcb_set_input_focus(dis, XCB_INPUT_FOCUS_POINTER_ROOT, M_CURRENT->win,
                                XCB_CURRENT_TIME);
            DEBUG("xcb_set_input_focus();");
        }
        else {
            sendevent(M_CURRENT->win, wmatoms[WM_TAKE_FOCUS]);
            DEBUG("send WM_TAKE_FOCUS");
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq 0x6a73(%rip), %rax      # 0xa780
movq 0x18(%rax), %r14
testq %r14, %r14
je 0x3d32
movq 0x38(%rax), %rcx
testq %rdi, %rdi
je 0x3d43
cmpq %rdi, %rcx
je 0x3d4a
movq 0x30(%rax), %rcx
movq %rcx, 0x38(%rax)
movq %rdi, 0x30(%rax)
jmp 0x3d55
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x4d2f
testq %rcx, %rcx
cmoveq %r14, %rcx
movq %rcx, 0x30(%rax)
movq (%rcx), %rcx
movq %rcx, 0x38(%rax)
leaq 0x6a74(%rip), %r15      # 0xa7d0
leaq 0x6a71(%rip), %r12      # 0xa7d4
pushq $0x8
popq %rbx
xorl %ebp, %ebp
testq %r14, %r14
je 0x3db7
cmpb $0x0, 0x1b(%r14)
jne 0x3db1
movq 0x69d5(%rip), %rdi      # 0xa750
movq 0x69fe(%rip), %rax      # 0xa780
cmpq 0x30(%rax), %r14
movl 0x20(%r14), %esi
movq %r12, %rcx
cmoveq %r15, %rcx
movl %ebx, %edx
callq 0x30f0
movq 0x69b1(%rip), %rdi      # 0xa750
movl 0x20(%r14), %esi
movl 0x40(%r14), %edx
testl %edx, %edx
cmovlel %ebp, %edx
callq 0x3beb
movq 0x8(%r14), %r14
jmp 0x3d68
callq 0x4d79
movq 0x69bd(%rip), %rbx      # 0xa780
leaq 0x18(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x3dff
cmpb $0x1, 0x1b(%rax)
je 0x3ddb
addq $0x8, %rax
jmp 0x3dc7
movq 0x696e(%rip), %rdi      # 0xa750
movl 0x20(%rax), %esi
leaq 0xc(%rsp), %rcx
movl $0x1, (%rcx)
pushq $0x40
popq %rdx
callq 0x32b0
movq 0x6981(%rip), %rbx      # 0xa780
addq $0x18, %rbx
xorl %r14d, %r14d
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x3e5d
cmpb $0x0, 0x1c(%rbx)
jne 0x3e32
cmpb $0x0, 0x1a(%rbx)
jne 0x3e32
cmpb $0x0, 0x19(%rbx)
jne 0x3e32
movl 0x24(%rbx), %eax
movq 0x693e(%rip), %rcx      # 0xa768
cmpl 0x104(%rcx), %eax
je 0x3e42
movq 0x6947(%rip), %rcx      # 0xa780
movq %rbx, %rax
cmpq 0x30(%rcx), %rbx
je 0x3e54
movq 0x6907(%rip), %rdi      # 0xa750
movl 0x20(%rbx), %esi
callq 0x4da1
movq %r14, %rax
addq $0x8, %rbx
movq %rax, %r14
jmp 0x3e06
testq %r14, %r14
je 0x3e72
movq 0x68e7(%rip), %rdi      # 0xa750
movl 0x20(%r14), %esi
callq 0x4da1
movq 0x6917(%rip), %rbx      # 0xa790
testq %rbx, %rbx
je 0x3ebb
testq %rbx, %rbx
je 0x3ebb
movq 0x68f6(%rip), %rax      # 0xa780
movq 0x30(%rax), %rax
cmpb $0x1, 0x1b(%rax)
jne 0x3ea6
movl 0x1c(%rbx), %eax
movq 0x68ca(%rip), %rcx      # 0xa768
cmpl 0xf8(%rcx), %eax
jne 0x3eb5
movq 0x68a3(%rip), %rdi      # 0xa750
movl 0x18(%rbx), %esi
callq 0x4da1
movq 0x8(%rbx), %rbx
jmp 0x3e7e
movq 0x68be(%rip), %rax      # 0xa780
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x3f32
cmpb $0x1, 0x44(%rax)
jne 0x3f24
movq 0x6878(%rip), %rdi      # 0xa750
movq 0x6891(%rip), %rcx      # 0xa770
movl (%rcx), %edx
movq 0x6880(%rip), %rcx      # 0xa768
movl 0x40(%rcx), %ecx
addq $0x20, %rax
pushq $0x21
popq %r8
pushq $0x20
popq %r9
xorl %esi, %esi
pushq %rax
pushq $0x1
callq 0x35c0
popq %rcx
popq %rdx
movq 0x6846(%rip), %rdi      # 0xa750
movq 0x686f(%rip), %rax      # 0xa780
movq 0x30(%rax), %rax
movl 0x20(%rax), %edx
pushq $0x1
popq %rsi
xorl %ecx, %ecx
callq 0x3580
jmp 0x3f32
movl 0x20(%rax), %edi
movl 0x68bf(%rip), %esi      # 0xa7ec
callq 0x4db4
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq