gpt4 book ai didi

c++ - 窗口没有响应 XMoveResizeWindow 请求

转载 作者:行者123 更新时间:2023-12-04 19:06:20 25 4
gpt4 key购买 nike

我有一个窗口管理器代码,它可以做窗口移动,窗口调整大小。但是,当我尝试使用 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::MoveWindowWindowMgrLib::ResizeWindow工作正常。
谁能告诉我 WindowMgrLib::MoveResizeWindow 有什么问题? ?

最佳答案

XCloseDisplay

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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com