背景:
我在xmonad下使用glfw。Glfw显然是在创建窗口之后设置窗口标题,因此不能使xmonad正确处理它。我想修改glfw源代码,以便在创建窗口之前设置窗口标题。
问题:
所以我下载了glfw-2.6,并查看 lib / x11 / x11_window.c; 导致麻烦的行是:
// Create a window
_glfwWin.Win = XCreateWindow(
_glfwLibrary.Dpy,
RootWindow( _glfwLibrary.Dpy, _glfwWin.VI->screen ),
0, 0, // Upper left corner
_glfwWin.Width, _glfwWin.Height, // Width, height
0, // Borderwidth
_glfwWin.VI->depth, // Depth
InputOutput,
_glfwWin.VI->visual,
CWBorderPixel | CWColormap | CWEventMask,
&wa
);
稍后跟随:
_glfwPlatformSetWindowTitle( "GLFW Window" );
在哪里
void _glfwPlatformSetWindowTitle( const char *title )
{
// Set window & icon title
XStoreName( _glfwLibrary.Dpy, _glfwWin.Win, title );
XSetIconName( _glfwLibrary.Dpy, _glfwWin.Win, title );
}
现在,如果我在CreateWindow调用之前尝试移动glfwPlatformSetWindowTitle调用,我会得到一个segfault -- 因为_glfwWin.win未定义,所以我应该这样做。
我不知道如何解决这个问题,因为要设置窗口标题,我需要_glfwWin.Win被初始化,但是为了初始化它,我需要创建窗口。
因此,我想问:在X11中,在创建窗口之前设置窗口标题的正确方法是什么?
谢谢!