X11窗口调整大小口吃 [英] X11 window resizing stutters

查看:106
本文介绍了X11窗口调整大小口吃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在X11中创建一个openGL窗口,并使用 glxswapbuffers 进行双重缓冲.

I'm creating an openGL window in X11 and using glxswapbuffers for double buffering.

问题是:渲染似乎很好,但是在调整大小时,我会弹出openGL内容,并且窗口边框变得卡住了.

The problem is: rendering seems fine but I get openGL contents bouncing around and the window border stuttering when resizing.

我尝试过滤ConfigureNotify事件,延迟事件,使用 glXSwapInterval 将vsync设置为关闭...无济于事.

I tried filtering the ConfigureNotify events, delaying them, setting vsync off with glXSwapInterval... nothing worked.

这是我正在使用的代码

void Window::redraw() { // Called by any control which needs redrawing
  XEvent event;
  memset(&event, 0, sizeof(event));
  event.type = Expose;
  event.xexpose.display = display;
  XSendEvent(display, window, False, ExposureMask, &event);
}

void Window::resize(int width, int height) {
  this->Width = width;
  this->Height = height;
}

bool Window::wndProc(XEvent *evt) {
  switch (evt->type) {

      case Expose: {

        if (evt->xexpose.count == 0) { // handle last one only

          while (XCheckTypedWindowEvent(display, window, Expose, evt));

            if (Width != oldWidth || Height != oldHeight)
              resizeViewportAndUpdateDimensions();

          Renderer.drawGLStuff();

          this->redraw();
        }

        return true;

      } break;

      case ConfigureNotify: {
        this->resize(evt->xconfigure.width, evt->xconfigure.height);

        this->redraw();
        return true;
      } break;
  }
}

请注意,这与我通过解决的此先前的帖子是一个不同的问题(严格地与调整大小相关)> XCheckTypedWindowEvent .

Notice that this is a different issue (strictly linked to resizing) than this previous post which I solved via XCheckTypedWindowEvent.

推荐答案

https://tronche.com/gui/x/xlib/events/window-state-change/configure.html

https://tronche.com/gui/x/xlib/events/structure-control/resize.html

从这两个链接中我可以读到,ConfigureNotify在更改完成时发生.尝试调整大小时会发生ResizeRequest.具体来说:

From what I can read from those two links ConfigureNotify happens when a change has completed. ResizeRequest happens when a resize is attempted. Specifically:

X服务器可以将ResizeRequest事件报告给需要的客户端有关其他客户端更改大小的尝试的信息窗口.

The X server can report ResizeRequest events to clients wanting information about another client's attempts to change the size of a window.

我不喜欢"CAN报告"的声音,但我想您应该试一试.不要忘记按照链接中的指示设置适当的事件位.至于捕获事件时应该怎么做,我不太确定……我会清除前端缓冲区,等待调整大小以完成操作.

I don´t like the sound of "CAN report", but I suppose you should give it a shot. Don´t forget to set proper event bit as instructed in the link. As for what you should do when capturing event I´m not too sure... I would clear the front buffer and await resize to complete.

这篇关于X11窗口调整大小口吃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆