[英]Context menu does not consistently work on arch linux?
I am using arch linux and a basic cpp xlib custom window manager.我正在使用 arch linux 和一个基本的 cpp xlib 自定义 window 管理器。 However, every time I right click to open the context menu it just flickers and disappears.
但是,每次我右键单击打开上下文菜单时,它都会闪烁并消失。 I cannot use it at all.
我根本无法使用它。 I also cannot use top drop down menus (file, edit, about, ect.) on any application.
我也不能在任何应用程序上使用顶部下拉菜单(文件、编辑、关于等)。 Is there anything in Xlib which I have to look out for to ensure I may use the context menus normally?
Xlib 中有什么我必须注意的,以确保我可以正常使用上下文菜单吗?
This is the case in every application I have tried.我尝试过的每个应用程序都是这种情况。 Only clue I have is in brave it occasionally displays the following message:
我唯一的线索是勇敢它偶尔会显示以下消息:
XGetWindowAttributes failed for window [WINDOW_ID]
The following simplified example also has this issue:以下简化示例也存在此问题:
int main()
{
display = XOpenDisplay(nullptr);
root = DefaultRootWindow(display);
XSelectInput(display, root, SubstructureRedirectMask | SubstructureNotifyMask | StructureNotifyMask);
XGrabServer(display);
Window returned_root;
Window returned_parent;
Window* top_level_windows;
unsigned int num_top_level_windows;
XQueryTree(display, root, &returned_root, &returned_parent, &top_level_windows, &num_top_level_windows);
for(unsigned int i = 0; i < num_top_level_windows; ++i)
{
Frame(top_level_windows[i], true);
}
XFree(top_level_windows);
XUngrabServer(display);
for(;;)
{
XEvent event;
XNextEvent(display, &event);
switch (event.type)
{
case MapRequest:
{
Frame(event.xmaprequest.window, false);
XMapWindow(display, event.xmaprequest.window);
break;
}
case ButtonPress:
XRaiseWindow(display, event.xbutton.window);
break;
}
}
return true;
}
void Frame(Window window, bool created_before_manager)
{
//Retrieve attributes of window to frame
XWindowAttributes attr = {0};
XGetWindowAttributes(display, window, &attr);
//If window was created before window manager started, we should frame it only if it is visible and does not set override_redirect
if(created_before_manager && (attr.override_redirect || attr.map_state != IsViewable))
{
return;
}
//Create frame
Window frame = XCreateSimpleWindow(display, root, attr.x, attr.y, attr.width, attr.height, 5, 0xff0000, 0xffffff);
XReparentWindow(display, window, frame, 0, 0);
XMapWindow(display, frame);
XGrabButton(display, Button1Mask, Mod1Mask, window, None, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
}
To be clear it also works with a super simple example such as:需要说明的是,它也适用于一个超级简单的示例,例如:
int main()
{
Display* display = XOpenDisplay(nullptr);
for(;;) {}
return true;
}
The reason I believe the window manager is at fault is because this issue only occurs after I run the window manager.我认为 window 管理器有问题的原因是因为此问题仅在我运行 window 管理器后出现。
I expected this to work out of the box.我希望这能开箱即用。 I have not found any information on context menus needing special treatment.
我还没有找到任何关于需要特殊处理的上下文菜单的信息。 They do have the override_redirect flag set to true, so I do not frame them.
他们确实将 override_redirect 标志设置为 true,因此我不会将它们框起来。 I cannot find information on any other special treatment required.
我找不到任何其他需要特殊处理的信息。
It is necessary to make sure the client window has input.需要确保客户端window有输入。 I had the input set to whatever was clicked (frame, title bar, or client) because it worked fine as far as normal input is concerned.
我将输入设置为单击的任何内容(框架、标题栏或客户端),因为就正常输入而言它工作正常。 However, the context menus will only work if you make sure the input is set to the client window directly.
但是,上下文菜单只有在您确保将输入直接设置为客户端 window 时才有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.