// File: /workspace/github_c_makefile_star2_O0/mati75[P]evilwm/client_new.c
// Function: client_manage_new
void client_manage_new(Window w, struct screen *s) {
	struct client *c;
	char *name;
	XClassHint *class;
	unsigned window_type;

	LOG_ENTER("client_manage_new(window=%lx)", (unsigned long)w);

	XGrabServer(display.dpy);

	// First a bit of interaction with the error handler due to X's
	// tendency to batch event notifications.  We set a global variable to
	// the id of the window we're initialising then do simple X call on
	// that window.  If an error is raised by this (and nothing else should
	// do so as we've grabbed the server), the error handler resets the
	// variable indicating the window has already disappeared, so we stop
	// trying to manage it.

	initialising = w;
	XFetchName(display.dpy, w, &name);
	XSync(display.dpy, False);

	// If 'initialising' is now set to None, that means doing the
	// XFetchName raised BadWindow - the window has been removed before
	// we got a chance to grab the server. */

	if (initialising == None) {
		LOG_DEBUG("XError occurred for initialising window - aborting...\n");
		XUngrabServer(display.dpy);
		LOG_LEAVE();
		return;
	}
	initialising = None;
	LOG_DEBUG("screen=%d\n", s->screen);
	LOG_DEBUG("name=%s\n", name ? name : "Untitled");
	if (name)
		XFree(name);

	window_type = ewmh_get_net_wm_window_type(w);
	// Don't manage DESKTOP type windows
	if (window_type & EWMH_WINDOW_TYPE_DESKTOP) {
		XMapWindow(display.dpy, w);
		XUngrabServer(display.dpy);
		return;
	}

	// If allocation fails, don't crash the window manager.  Just don't
	// manage the window.
	c = malloc(sizeof(struct client));
	if (!c) {
		LOG_ERROR("out of memory allocating new client\n");
		XMapWindow(display.dpy, w);
		XUngrabServer(display.dpy);
		LOG_LEAVE();
		return;
	}
	clients_tab_order = list_prepend(clients_tab_order, c);
	clients_mapping_order = list_append(clients_mapping_order, c);
	clients_stacking_order = list_append(clients_stacking_order, c);

	c->screen = s;
	c->window = w;
	c->ignore_unmap = 0;
	c->remove = 0;

	// Ungrab the X server as soon as possible. Now that the client is
	// malloc()ed and attached to the list, it is safe for any subsequent
	// X calls to raise an X error and thus flag it for removal.

	XUngrabServer(display.dpy);

	update_window_type_flags(c, window_type);
	init_geometry(c);

#ifdef DEBUG
	{
		int i = 0;
		for (struct list *iter = clients_tab_order; iter; iter = iter->next)
			i++;
		LOG_DEBUG("new window %dx%d+%d+%d, wincount=%d\n", c->width, c->height, c->x, c->y, i);
	}
#endif

	XSelectInput(display.dpy, c->window, ColormapChangeMask | EnterWindowMask | PropertyChangeMask);

	reparent(c);

#ifdef SHAPE
	if (display.have_shape) {
		XShapeSelectInput(display.dpy, c->window, ShapeNotifyMask);
		set_shape(c);
	}
#endif

	// Read name/class information for client and check against list built
	// with -app options.
	class = XAllocClassHint();
	if (class) {
		XGetClassHint(display.dpy, w, class);
		for (struct list *iter = applications; iter; iter = iter->next) {
			struct application *a = iter->data;
			// Does resource name and class match?
			if ((!a->res_name || (class->res_name && !strcmp(class->res_name, a->res_name)))
					&& (!a->res_class || (class->res_class && !strcmp(class->res_class, a->res_class)))) {

				// Override width or height?
				if (a->geometry_mask & WidthValue)
					c->width = a->width * c->width_inc;
				if (a->geometry_mask & HeightValue)
					c->height = a->height * c->height_inc;

				// Override X or Y?
				if (a->geometry_mask & XValue) {
					if (a->geometry_mask & XNegative)
						c->x = a->x + DisplayWidth(display.dpy, s->screen)-c->width-c->border;
					else
						c->x = a->x + c->border;
				}
				if (a->geometry_mask & YValue) {
					if (a->geometry_mask & YNegative)
						c->y = a->y + DisplayHeight(display.dpy, s->screen)-c->height-c->border;
					else
						c->y = a->y + c->border;
				}

				// XXX better way of updating window geometry?
				client_moveresizeraise(c);

				// Force treating this app as a dock?
				if (a->is_dock)
					c->is_dock = 1;

				// Force app to specific vdesk?
				if (a->vdesk != VDESK_NONE)
					c->vdesk = a->vdesk;
			}
		}
		XFree(class->res_name);
		XFree(class->res_class);
		XFree(class);
	}

	// Set EWMH property on client advertising WM features
	ewmh_set_allowed_actions(c);

	// Update EWMH client list hints for screen
	ewmh_set_net_client_list(c->screen);
	ewmh_set_net_client_list_stacking(c->screen);

	// Only map the window frame (and thus the window) if it's supposed
	// to be visible on this virtual desktop.  Otherwise, set it to
	// IconicState (hidden).
	if (is_fixed(c) || c->vdesk == s->vdesk) {
		client_show(c);
		client_raise(c);
		// Don't focus windows that aren't on the same display as the
		// pointer.
		if (get_pointer_root_xy(c->window, NULL, NULL) &&
		    !(window_type & (EWMH_WINDOW_TYPE_DOCK|EWMH_WINDOW_TYPE_NOTIFICATION))) {
			select_client(c);
#ifdef WARP_POINTER
			setmouse(c->window, c->width + c->border - 1,
				 c->height + c->border - 1);
#endif
			discard_enter_events(c);
		}
	} else {
		set_wm_state(c, IconicState);
	}

	// Ensure whichever vdesk it ended up on is reflected in the EWMH hints
	ewmh_set_net_wm_desktop(c);

	LOG_LEAVE();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0xaf19(%rip), %rax      # 0x12d80
movq (%rax), %rdi
callq 0x4120
movq -0x8(%rbp), %rcx
leaq 0xb13e(%rip), %rax      # 0x12fb8
movq %rcx, (%rax)
leaq 0xaefc(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x45c0
leaq 0xaee5(%rip), %rax      # 0x12d80
movq (%rax), %rdi
xorl %esi, %esi
callq 0x4510
leaq 0xb10c(%rip), %rax      # 0x12fb8
movq (%rax), %rax
cmpq $0x0, %rax
jne 0x7ec9
leaq 0xaec4(%rip), %rax      # 0x12d80
movq (%rax), %rdi
callq 0x43b0
jmp 0x8381
leaq 0xb0e8(%rip), %rax      # 0x12fb8
movq $0x0, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x7ee7
movq -0x20(%rbp), %rdi
callq 0x4050
movq -0x8(%rbp), %rdi
callq 0xa400
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7f25
leaq 0xae7b(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x4450
leaq 0xae68(%rip), %rax      # 0x12d80
movq (%rax), %rdi
callq 0x43b0
jmp 0x8381
movl $0x98, %edi
callq 0x41f0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x7f79
movq 0xa0af(%rip), %rax      # 0x11ff0
movq (%rax), %rdi
leaq 0x64d9(%rip), %rsi      # 0xe424
movb $0x0, %al
callq 0x4700
leaq 0xae27(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x4450
leaq 0xae14(%rip), %rax      # 0x12d80
movq (%rax), %rdi
callq 0x43b0
jmp 0x8381
leaq 0xade0(%rip), %rax      # 0x12d60
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xaf30
movq %rax, %rcx
leaq 0xadca(%rip), %rax      # 0x12d60
movq %rcx, (%rax)
leaq 0xadc8(%rip), %rax      # 0x12d68
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xaf60
movq %rax, %rcx
leaq 0xadb2(%rip), %rax      # 0x12d68
movq %rcx, (%rax)
leaq 0xadb0(%rip), %rax      # 0x12d70
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xaf60
movq %rax, %rcx
leaq 0xad9a(%rip), %rax      # 0x12d70
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x68(%rax)
leaq 0xad73(%rip), %rax      # 0x12d80
movq (%rax), %rdi
callq 0x43b0
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x57f0
movq -0x18(%rbp), %rdi
callq 0x8390
leaq 0xad4f(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl $0xc00010, %edx         # imm = 0xC00010
callq 0x44c0
movq -0x18(%rbp), %rdi
callq 0x87d0
leaq 0xad2b(%rip), %rax      # 0x12d80
cmpl $0x0, 0x178(%rax)
je 0x8082
leaq 0xad1b(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl $0x1, %edx
callq 0x4760
movq -0x18(%rbp), %rdi
callq 0x6400
callq 0x4100
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x82e4
leaq 0xace3(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x4380
leaq 0xae84(%rip), %rax      # 0x12f38
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x82c2
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, (%rax)
je 0x8106
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x82b0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rax
movq (%rax), %rsi
callq 0x4550
cmpl $0x0, %eax
jne 0x82b0
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x813e
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x82b0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x4550
cmpl $0x0, %eax
jne 0x82b0
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x8163
movq -0x40(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x18(%rbp), %rax
imull 0x7c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x818b
movq -0x40(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x18(%rbp), %rax
imull 0x80(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x8200
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x81e9
movq -0x40(%rbp), %rax
movl 0x14(%rax), %ecx
leaq 0xabc9(%rip), %rax      # 0x12d80
movq (%rax), %rax
movq 0xe8(%rax), %rax
movq -0x10(%rbp), %rdx
movslq (%rdx), %rdx
shlq $0x7, %rdx
addq %rdx, %rax
addl 0x18(%rax), %ecx
movq -0x18(%rbp), %rax
subl 0x30(%rax), %ecx
movq -0x18(%rbp), %rax
subl 0x3c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
jmp 0x81fe
movq -0x40(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x18(%rbp), %rax
addl 0x3c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
jmp 0x8200
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x8275
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x825e
movq -0x40(%rbp), %rax
movl 0x18(%rax), %ecx
leaq 0xab54(%rip), %rax      # 0x12d80
movq (%rax), %rax
movq 0xe8(%rax), %rax
movq -0x10(%rbp), %rdx
movslq (%rdx), %rdx
shlq $0x7, %rdx
addq %rdx, %rax
addl 0x1c(%rax), %ecx
movq -0x18(%rbp), %rax
subl 0x34(%rax), %ecx
movq -0x18(%rbp), %rax
subl 0x3c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x2c(%rax)
jmp 0x8273
movq -0x40(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x18(%rbp), %rax
addl 0x3c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x2c(%rax)
jmp 0x8275
movq -0x18(%rbp), %rdi
callq 0x6f40
movq -0x40(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x8296
movq -0x18(%rbp), %rax
movl $0x1, 0x94(%rax)
movq -0x40(%rbp), %rax
cmpl $-0x2, 0x28(%rax)
je 0x82ae
movq -0x40(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x20(%rax)
jmp 0x82b0
jmp 0x82b2
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x80bb
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0x4050
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x4050
movq -0x28(%rbp), %rdi
callq 0x4050
movq -0x18(%rbp), %rdi
callq 0x9fd0
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x9d50
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x9ea0
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x20(%rax)
je 0x8321
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x60(%rcx), %eax
jne 0x836a
movq -0x18(%rbp), %rdi
callq 0x5c70
movq -0x18(%rbp), %rdi
callq 0x5cb0
movq -0x18(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0xcc80
cmpl $0x0, %eax
je 0x8368
movl -0x2c(%rbp), %eax
andl $0x6, %eax
cmpl $0x0, %eax
jne 0x8368
movq -0x18(%rbp), %rdi
callq 0x5f40
movq -0x18(%rbp), %rdi
callq 0xcfa0
jmp 0x8378
movq -0x18(%rbp), %rdi
movl $0x3, %esi
callq 0x5c00
movq -0x18(%rbp), %rdi
callq 0xa3a0
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)