[英]BadWindow (invalid Window parameter) when trying to close a Display in X11
I am writing in x86-64 NASM assembly and I wrote a function to close a window using X11 on Ubuntu via WSL我正在编写 x86-64 NASM 程序集,我写了一个 function 以通过 WSL 在 Ubuntu 上使用 X11 关闭 window
I keep getting this error:我不断收到此错误:
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 18 (X_ChangeProperty)
Resource id in failed request: 0xe002a0
Serial number of failed request: 8
Current serial number in output stream: 18
my code looks like this:我的代码如下所示:
section .bss
Ox: resd 1
Oy: resd 1
null: resq 1
dis: resq 1 ;pointer to dis
screen: resq 1
gc: resq 1
black: resq 1
white: resq 1
red: resq 1
blue: resq 1
win: resq 21
event: resb 0x60
section .text
extern printf, exit
extern XOpenDisplay, XCreateSimpleWindow, XSetStandardProperties, XSelectInput, XCreateGC, XSetBackground, XSetForeground, XClearWindow, XMapRaised, XFreeGC, XDestroyWindow, XCloseDisplay, XNextEvent
global main
main:
push rbp
mov rbp, rsp
call init
call closeWin
mov rsp, rbp
pop rbp
ret
init:
push rbp
mov rbp, rsp
mov dword [Ox], 100
mov dword [Oy], 100
mov qword [black], 0x000000
mov qword [white], 0xffffff
mov qword [red], 0xff0000
mov qword [blue], 0x0000ff
lea rdi, 0
call XOpenDisplay
mov qword [dis], rax
mov rax, [dis+0xe0]
mov qword [screen], rax
mov rax, [dis]
mov rdx, [rax +0xe8]
mov rax, [dis]
mov eax, [rax + 0xe0]
cdqe
shl rax, 7
add rax, rdx
mov rax, [rax + 0x10]
mov rdi, [dis]
mov rsi, rax
mov rdx, 0
mov rcx, 0
mov r8, 300
mov r9, 300
mov rax, [black]
push rax
mov rax, [white]
push rax
mov rax, 5
push rax
call XCreateSimpleWindow
mov [win], rax
add rsp, 24
mov rdi, [dis]
mov rsi, [dis]
mov rax, "Title"
push rax
mov rax, "Hi"
push rax
lea rdx, [rbp-8]
lea rcx, [rbp-16]
mov r8, 0
mov r9, 0x0
push r8
push r9
call XSetStandardProperties
add rsp, 0x20
mov rdi, [dis]
mov rsi, [win]
mov rdx, ExposureMask
mov rax, ButtonPressMask
or rdx, rax
mov rax, KeyPressMask
or rdx, rax
call XSelectInput
mov rdi, [dis]
mov rsi, [win]
xor rdx, rdx
xor rcx, rcx
call XCreateGC
mov [gc], rax
mov rdi, [dis]
mov rsi, [gc]
mov rdx, [white]
call XSetBackground
mov rdi, [dis]
mov rsi, [gc]
mov rdx, [black]
call XSetForeground
mov rdi, [dis]
mov rsi, [win]
call XClearWindow
mov rdi, [dis]
mov rsi, [win]
call XMapRaised
mov rsp, rbp
pop rbp
ret
closeWin:
push rbp
mov rbp, rsp
mov rdi, [dis]
mov rsi, [gc]
call XFreeGC
mov rdi, [dis]
mov rsi, [win]
call XDestroyWindow
mov rdi, [dis]
call XCloseDisplay
xor rdi, rdi
call exit
mov rsp, rbp
pop rbp
ret
the error seems to be coming from the XCloseDisplay
function call该错误似乎来自XCloseDisplay
function 调用
I have tried looking at my initialization of the window but I get no errors from there when I comment out the call XCloseDisplay
I don't get the error.我已经尝试查看我对 window 的初始化,但是当我注释掉call XCloseDisplay
时我没有从那里得到任何错误我没有得到错误。
I tried just commenting it out and ignoring it but got the same error trying to use XNextEvent
我试着把它注释掉并忽略它,但在尝试使用XNextEvent
时遇到了同样的错误
(also I am a bit of a noob at assembly so it may be a dumb thing I overlooked) (而且我在组装方面有点菜鸟所以这可能是我忽略的一件愚蠢的事情)
Nevermind, I just had passed the display into the window parameter of XSetStandardProperties
in my initialization, but I only got the error when I tried to close the display.没关系,我只是在初始化时将显示传递给 XSetStandardProperties 的XSetStandardProperties
参数,但是当我尝试关闭显示时才出现错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.