我有一个窗口管理器代码,它可以做窗口移动,窗口调整大小。但是,当我尝试使用 XMoveResizeWindow 同时执行这两项操作时,它不起作用,并且也没有错误日志出现。
我的代码如下
void WindowMgrLib::MoveResizeWindow(Window window, int x, int y, int width, int height)
{
Display *display = XOpenDisplay(NULL);
XSetErrorHandler(catch_error);
XMoveResizeWindow(display, window, x, y, width, height);
printf("x = %d, y= %d, width = %d, height=%d\n", x, y, width, height);
XFlush(display);
XCloseDisplay(display);
}
void WindowMgrLib::MoveWindow(Window window, int x, int y)
{
Display *display = XOpenDisplay(NULL);
XSetErrorHandler(catch_error);
XMoveWindow(display, window, x, y);
XFlush(display);
XCloseDisplay(display);
}
void WindowMgrLib::ResizeWindow(Window window, int w, int h)
{
Display *display = XOpenDisplay(NULL);
XSetErrorHandler(catch_error);
XResizeWindow(display, window, w, h);
XFlush(display);
XCloseDisplay(display);
}
这里WindowMgrLib::MoveWindow
和 WindowMgrLib::ResizeWindow
工作正常。谁能告诉我
WindowMgrLib::MoveResizeWindow
有什么问题? ?
最佳答案
The XCloseDisplay function closes the connection to the X server for the display specified in the Display structure and destroys all windows, resource IDs (Window, Font, Pixmap, Colormap, Cursor, and GContext), or other resources that the client has created on this display, unless the close-down mode of the resource has been changed (see XSetCloseDownMode). Therefore, these windows, resource IDs, and other resources should never be referenced again or an error will be generated. Before exiting, you should call XCloseDisplay explicitly so that any pending errors are reported as XCloseDisplay performs a final XSync operation.
因此 :
关于c++ - 窗口没有响应 XMoveResizeWindow 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68651953/