XMoveWindow 在 XMapWindow 之前不起作用 [英] XMoveWindow not Working before XMapWindow
问题描述
我有一个窗口,我希望能够控制它出现的位置.但是,在调用XMapWindow"之前调用XMoveWindow"似乎没有任何效果.
I have a window, and I'd like to be able to control where it appears. However, calling "XMoveWindow" seems to have no effect before "XMapWindow" is called.
文档 什么也没说.帮助?
推荐答案
在 XtCreateWindow 有 x 和 y 坐标,因此您可以在创建时指定位置.请注意,X 服务器在第一次映射之前不必知道窗口,因此移动未映射的窗口可能没有任何影响.
In XtCreateWindow there are x and y coordinates, so you could specify the location when creating it. Note that the X server doesn't have to know about a window before it is mapped for the first time, thus moving a window which is unmapped may not have any effect.
但 XtCreateWindow 仅适用于主窗口的子窗口;如果您想定位顶级窗口(您的主应用程序或弹出对话框),您必须与窗口管理器协商以放置窗口.以下代码片段使用主窗口的 Xt 库执行此操作:
But XtCreateWindow only works for subwindows of your main window; if you want to position a top-level window (either your main app or a popup dialog), you have to confer with the window manager to place the window. The following snippet of code does this using the Xt lib for the main window:
Arg args[] = {
{ XtNx, (dis_width - WIN_WIDTH) / 2},
{ XtNy, (dis_height - WIN_HEIGHT) / 2},
{ XtNwidth, WIN_WIDTH},
{ XtNheight, WIN_HEIGHT},
{ XtNborderWidth, 10},
{ "minWidth", WIN_WIDTH},
{ "minHeight", WIN_HEIGHT},
{ "maxWidth", WIN_WIDTH},
{ "maxHeight", WIN_HEIGHT},
{ "mwmDecorations", 0xA}, // border + title; see MWM_DECOR_ constants
{ "mappedWhenManaged", False},
};
shell = XtAppCreateShell (_ ("Welcome"), NULL, applicationShellWidgetClass, Dis, args, XtNumber (args));
它创建一个以屏幕为中心的窗口.
It creates a window centered on the screen.
对于弹出窗口,请参阅 XtCreatePopupShell,其中使用带参数的类似数组.
For popup windows, see XtCreatePopupShell, which uses a similar array with arguments.
这篇关于XMoveWindow 在 XMapWindow 之前不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!