// File: /workspace/github_c_makefile_star2_O0/mati75[P]evilwm/screen.c
// Function: screen_init
void screen_init(struct screen *s) {
	int i = s->screen;

	// Used to set the DISPLAY environment variable to something like
	// ":0.x" depending on which screen a terminal is launched from.
	s->display = screen_to_display_str(i);

	s->root = RootWindow(display.dpy, i);
#ifdef RANDR
	s->nmonitors = 0;
	s->monitors = NULL;
        if (display.have_randr) {
		XRRSelectInput(display.dpy, s->root, RRScreenChangeNotifyMask);
	}
#endif
	screen_probe_monitors(s);

	// Default to first virtual desktop.  TODO: consider checking the
	// _NET_WM_DESKTOP property of the window with focus when we start to
	// change this default?
	s->vdesk = 0;

	// In case the visual for this screen uses a colourmap, ensure our
	// border colours are in it.
	XColor dummy;
	XAllocNamedColor(display.dpy, DefaultColormap(display.dpy, i), option.fg, &s->fg, &dummy);
	XAllocNamedColor(display.dpy, DefaultColormap(display.dpy, i), option.bg, &s->bg, &dummy);
	XAllocNamedColor(display.dpy, DefaultColormap(display.dpy, i), option.fc, &s->fc, &dummy);

	// When dragging an outline, we use an inverting graphics context
	// (GCFunction + GXinvert) so that simply drawing it again will erase
	// it from the screen.

	XGCValues gv;
	gv.function = GXinvert;
	gv.subwindow_mode = IncludeInferiors;
	gv.line_width = 1;  // option.bw
	gv.font = display.font->fid;
	s->invert_gc = XCreateGC(display.dpy, s->root,
				 GCFunction | GCSubwindowMode | GCLineWidth | GCFont, &gv);

	// We handle events to the root window:
	// SubstructureRedirectMask - create, destroy, configure window notifications
	// SubstructureNotifyMask - configure window requests
	// EnterWindowMask - enter events
	// ColormapChangeMask - when a new colourmap is needed

	XSetWindowAttributes attr;
	attr.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
	                  | EnterWindowMask | ColormapChangeMask;
	XChangeWindowAttributes(display.dpy, s->root, CWEventMask, &attr);

	// Grab the various keyboard shortcuts
	bind_grab_for_screen(s);

	s->active = None;
	s->docks_visible = 1;

	Atom supported[] = {
		X_ATOM(_NET_CLIENT_LIST),
		X_ATOM(_NET_CLIENT_LIST_STACKING),
		X_ATOM(_NET_NUMBER_OF_DESKTOPS),
		X_ATOM(_NET_DESKTOP_GEOMETRY),
		X_ATOM(_NET_DESKTOP_VIEWPORT),
		X_ATOM(_NET_CURRENT_DESKTOP),
		X_ATOM(_NET_ACTIVE_WINDOW),
		X_ATOM(_NET_WORKAREA),
		X_ATOM(_NET_SUPPORTING_WM_CHECK),

		X_ATOM(_NET_CLOSE_WINDOW),
		X_ATOM(_NET_MOVERESIZE_WINDOW),
		X_ATOM(_NET_RESTACK_WINDOW),
		X_ATOM(_NET_REQUEST_FRAME_EXTENTS),

		X_ATOM(_NET_WM_DESKTOP),
		X_ATOM(_NET_WM_WINDOW_TYPE),
		X_ATOM(_NET_WM_WINDOW_TYPE_DESKTOP),
		X_ATOM(_NET_WM_WINDOW_TYPE_DOCK),
		X_ATOM(_NET_WM_STATE),
		X_ATOM(_NET_WM_STATE_MAXIMIZED_VERT),
		X_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ),
		X_ATOM(_NET_WM_STATE_HIDDEN),
		X_ATOM(_NET_WM_STATE_FULLSCREEN),
		X_ATOM(_NET_WM_STATE_FOCUSED),
		X_ATOM(_NET_WM_ALLOWED_ACTIONS),

		// Not sure if it makes any sense including every action here
		// as they'll already be listed per-client in the
		// _NET_WM_ALLOWED_ACTIONS property, but EWMH spec is unclear.
		X_ATOM(_NET_WM_ACTION_MOVE),
		X_ATOM(_NET_WM_ACTION_RESIZE),
		X_ATOM(_NET_WM_ACTION_MAXIMIZE_HORZ),
		X_ATOM(_NET_WM_ACTION_MAXIMIZE_VERT),
		X_ATOM(_NET_WM_ACTION_FULLSCREEN),
		X_ATOM(_NET_WM_ACTION_CHANGE_DESKTOP),
		X_ATOM(_NET_WM_ACTION_CLOSE),
		X_ATOM(_NET_FRAME_EXTENTS),
	};

	unsigned long num_desktops = option.vdesks;
	unsigned long vdesk = s->vdesk;
	unsigned long pid = getpid();

	s->supporting = XCreateSimpleWindow(display.dpy, s->root, 0, 0, 1, 1, 0, 0, 0);
	XChangeProperty(display.dpy, s->root, X_ATOM(_NET_SUPPORTED),
			XA_ATOM, 32, PropModeReplace,
			(unsigned char *)&supported,
			sizeof(supported) / sizeof(Atom));
	XChangeProperty(display.dpy, s->root, X_ATOM(_NET_NUMBER_OF_DESKTOPS),
			XA_CARDINAL, 32, PropModeReplace,
			(unsigned char *)&num_desktops, 1);
	XChangeProperty(display.dpy, s->root, X_ATOM(_NET_CURRENT_DESKTOP),
			XA_CARDINAL, 32, PropModeReplace,
			(unsigned char *)&vdesk, 1);
	XChangeProperty(display.dpy, s->root, X_ATOM(_NET_ACTIVE_WINDOW),
	                XA_WINDOW, 32, PropModeReplace,
	                (unsigned char *)&s->active, 1);
	XChangeProperty(display.dpy, s->root, X_ATOM(_NET_SUPPORTING_WM_CHECK),
			XA_WINDOW, 32, PropModeReplace,
			(unsigned char *)&s->supporting, 1);
	XChangeProperty(display.dpy, s->supporting, X_ATOM(_NET_SUPPORTING_WM_CHECK),
			XA_WINDOW, 32, PropModeReplace,
			(unsigned char *)&s->supporting, 1);
	XChangeProperty(display.dpy, s->supporting, X_ATOM(_NET_WM_NAME),
			XA_STRING, 8, PropModeReplace,
			(const unsigned char *)"evilwm", 6);
	XChangeProperty(display.dpy, s->supporting, X_ATOM(_NET_WM_PID),
			XA_CARDINAL, 32, PropModeReplace,
			(unsigned char *)&pid, 1);

	ewmh_set_screen_workarea(s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %edi
callq 0xc070
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq 0x744e(%rip), %rax      # 0x12d80
movq (%rax), %rax
movq 0xe8(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x6c(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x70(%rax)
leaq 0x740f(%rip), %rax      # 0x12d80
cmpl $0x0, 0x180(%rax)
je 0xb996
leaq 0x73ff(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %edx
callq 0x42d0
movq -0x8(%rbp), %rdi
callq 0xc160
movq -0x8(%rbp), %rax
movl $0x0, 0x60(%rax)
leaq 0x73cf(%rip), %rax      # 0x12d80
movq (%rax), %rdi
leaq 0x73c5(%rip), %rax      # 0x12d80
movq (%rax), %rax
movq 0xe8(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x50(%rax), %rsi
leaq 0x756d(%rip), %rax      # 0x12f48
movq 0x10(%rax), %rdx
movq -0x8(%rbp), %rcx
addq $0x30, %rcx
leaq -0x20(%rbp), %r8
callq 0x4210
leaq 0x7389(%rip), %rax      # 0x12d80
movq (%rax), %rdi
leaq 0x737f(%rip), %rax      # 0x12d80
movq (%rax), %rax
movq 0xe8(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x50(%rax), %rsi
leaq 0x7527(%rip), %rax      # 0x12f48
movq 0x18(%rax), %rdx
movq -0x8(%rbp), %rcx
addq $0x40, %rcx
leaq -0x20(%rbp), %r8
callq 0x4210
leaq 0x7343(%rip), %rax      # 0x12d80
movq (%rax), %rdi
leaq 0x7339(%rip), %rax      # 0x12d80
movq (%rax), %rax
movq 0xe8(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x50(%rax), %rsi
leaq 0x74e1(%rip), %rax      # 0x12f48
movq 0x20(%rax), %rdx
movq -0x8(%rbp), %rcx
addq $0x50, %rcx
leaq -0x20(%rbp), %r8
callq 0x4210
movl $0xa, -0xa0(%rbp)
movl $0x1, -0x40(%rbp)
movl $0x1, -0x80(%rbp)
leaq 0x72e5(%rip), %rax      # 0x12d80
movq 0x160(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
leaq 0x72cf(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0xc011, %edx           # imm = 0xC011
leaq -0xa0(%rbp), %rcx
callq 0x44a0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq $0x980010, -0xc8(%rbp) # imm = 0x980010
leaq 0x7296(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0x800, %edx            # imm = 0x800
leaq -0x110(%rbp), %rcx
callq 0x4790
movq -0x8(%rbp), %rdi
callq 0x4fc0
movq -0x8(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x8(%rbp), %rax
movl $0x1, 0x68(%rax)
leaq 0x7253(%rip), %rax      # 0x12d80
movq 0x48(%rax), %rax
movq %rax, -0x210(%rbp)
leaq 0x7241(%rip), %rax      # 0x12d80
movq 0x50(%rax), %rax
movq %rax, -0x208(%rbp)
leaq 0x722f(%rip), %rax      # 0x12d80
movq 0x58(%rax), %rax
movq %rax, -0x200(%rbp)
leaq 0x721d(%rip), %rax      # 0x12d80
movq 0x60(%rax), %rax
movq %rax, -0x1f8(%rbp)
leaq 0x720b(%rip), %rax      # 0x12d80
movq 0x68(%rax), %rax
movq %rax, -0x1f0(%rbp)
leaq 0x71f9(%rip), %rax      # 0x12d80
movq 0x70(%rax), %rax
movq %rax, -0x1e8(%rbp)
leaq 0x71e7(%rip), %rax      # 0x12d80
movq 0x78(%rax), %rax
movq %rax, -0x1e0(%rbp)
leaq 0x71d5(%rip), %rax      # 0x12d80
movq 0x80(%rax), %rax
movq %rax, -0x1d8(%rbp)
leaq 0x71c0(%rip), %rax      # 0x12d80
movq 0x88(%rax), %rax
movq %rax, -0x1d0(%rbp)
leaq 0x71ab(%rip), %rax      # 0x12d80
movq 0x90(%rax), %rax
movq %rax, -0x1c8(%rbp)
leaq 0x7196(%rip), %rax      # 0x12d80
movq 0x98(%rax), %rax
movq %rax, -0x1c0(%rbp)
leaq 0x7181(%rip), %rax      # 0x12d80
movq 0xa0(%rax), %rax
movq %rax, -0x1b8(%rbp)
leaq 0x716c(%rip), %rax      # 0x12d80
movq 0xa8(%rax), %rax
movq %rax, -0x1b0(%rbp)
leaq 0x7157(%rip), %rax      # 0x12d80
movq 0xb8(%rax), %rax
movq %rax, -0x1a8(%rbp)
leaq 0x7142(%rip), %rax      # 0x12d80
movq 0xc0(%rax), %rax
movq %rax, -0x1a0(%rbp)
leaq 0x712d(%rip), %rax      # 0x12d80
movq 0xc8(%rax), %rax
movq %rax, -0x198(%rbp)
leaq 0x7118(%rip), %rax      # 0x12d80
movq 0xd0(%rax), %rax
movq %rax, -0x190(%rbp)
leaq 0x7103(%rip), %rax      # 0x12d80
movq 0xe0(%rax), %rax
movq %rax, -0x188(%rbp)
leaq 0x70ee(%rip), %rax      # 0x12d80
movq 0xe8(%rax), %rax
movq %rax, -0x180(%rbp)
leaq 0x70d9(%rip), %rax      # 0x12d80
movq 0xf0(%rax), %rax
movq %rax, -0x178(%rbp)
leaq 0x70c4(%rip), %rax      # 0x12d80
movq 0xf8(%rax), %rax
movq %rax, -0x170(%rbp)
leaq 0x70af(%rip), %rax      # 0x12d80
movq 0x100(%rax), %rax
movq %rax, -0x168(%rbp)
leaq 0x709a(%rip), %rax      # 0x12d80
movq 0x108(%rax), %rax
movq %rax, -0x160(%rbp)
leaq 0x7085(%rip), %rax      # 0x12d80
movq 0x110(%rax), %rax
movq %rax, -0x158(%rbp)
leaq 0x7070(%rip), %rax      # 0x12d80
movq 0x118(%rax), %rax
movq %rax, -0x150(%rbp)
leaq 0x705b(%rip), %rax      # 0x12d80
movq 0x120(%rax), %rax
movq %rax, -0x148(%rbp)
leaq 0x7046(%rip), %rax      # 0x12d80
movq 0x128(%rax), %rax
movq %rax, -0x140(%rbp)
leaq 0x7031(%rip), %rax      # 0x12d80
movq 0x130(%rax), %rax
movq %rax, -0x138(%rbp)
leaq 0x701c(%rip), %rax      # 0x12d80
movq 0x138(%rax), %rax
movq %rax, -0x130(%rbp)
leaq 0x7007(%rip), %rax      # 0x12d80
movq 0x140(%rax), %rax
movq %rax, -0x128(%rbp)
leaq 0x6ff2(%rip), %rax      # 0x12d80
movq 0x148(%rax), %rax
movq %rax, -0x120(%rbp)
leaq 0x6fdd(%rip), %rax      # 0x12d80
movq 0x158(%rax), %rax
movq %rax, -0x118(%rbp)
leaq 0x7190(%rip), %rax      # 0x12f48
movl 0x2c(%rax), %eax
movq %rax, -0x218(%rbp)
movq -0x8(%rbp), %rax
movl 0x60(%rax), %eax
movq %rax, -0x220(%rbp)
callq 0x4290
cltq
movq %rax, -0x228(%rbp)
leaq 0x6f9b(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
xorl %ecx, %ecx
movl $0x1, %r9d
xorl %eax, %eax
movl %ecx, %edx
movl %r9d, %r8d
movl $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
callq 0x4280
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
leaq 0x6f51(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x6f3f(%rip), %rax      # 0x12d80
movq 0x40(%rax), %rdx
movl $0x4, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
leaq -0x210(%rbp), %rax
movq %rax, (%rsp)
movl $0x20, 0x8(%rsp)
callq 0x4650
leaq 0x6f0e(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x6efc(%rip), %rax      # 0x12d80
movq 0x58(%rax), %rdx
movl $0x6, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
leaq -0x218(%rbp), %rax
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0x4650
leaq 0x6ecb(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x6eb9(%rip), %rax      # 0x12d80
movq 0x70(%rax), %rdx
movl $0x6, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
leaq -0x220(%rbp), %rax
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0x4650
leaq 0x6e88(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x6e76(%rip), %rax      # 0x12d80
movq 0x78(%rax), %rdx
movq -0x8(%rbp), %rax
addq $0x20, %rax
movl $0x21, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0x4650
leaq 0x6e44(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x6e32(%rip), %rax      # 0x12d80
movq 0x88(%rax), %rdx
movq -0x8(%rbp), %rax
addq $0x18, %rax
movl $0x21, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0x4650
leaq 0x6dfd(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
leaq 0x6deb(%rip), %rax      # 0x12d80
movq 0x88(%rax), %rdx
movq -0x8(%rbp), %rax
addq $0x18, %rax
movl $0x21, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0x4650
leaq 0x6db6(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
leaq 0x6da4(%rip), %rax      # 0x12d80
movq 0xb0(%rax), %rdx
movl $0x1f, %ecx
movl $0x8, %r8d
xorl %r9d, %r9d
leaq 0x326c(%rip), %rax      # 0xf264
movq %rax, (%rsp)
movl $0x6, 0x8(%rsp)
callq 0x4650
leaq 0x6d70(%rip), %rax      # 0x12d80
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
leaq 0x6d5e(%rip), %rax      # 0x12d80
movq 0x150(%rax), %rdx
movl $0x6, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
leaq -0x228(%rbp), %rax
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0x4650
movq -0x8(%rbp), %rdi
callq 0x9c10
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nopw %cs:(%rax,%rax)