简体   繁体   English

window 管理器:新启动的应用程序在 wm 运行时不可见

[英]window manager: Newly launched applications are not visible while the wm is running

TL;DR TL;博士

I'm writing a simple reparenting window manager.我正在编写一个简单的 window 管理器。 I'm testing it with the help of Xephyr.我正在 Xephyr 的帮助下对其进行测试。 While the window manager is running, any application launched during that time, is not shown (not visible) on the screen, whereas any application launched before the window manager was launched is shown (visible).当 window 管理器正在运行时,在此期间启动的任何应用程序都不会在屏幕上显示(不可见),而在启动 window 管理器之前启动的任何应用程序都会显示(可见)。

Full Question完整问题

I'm writing a simple reparenting window manager.我正在编写一个简单的 window 管理器。 Currently I'm handling only two events XCB_CREATE_NOTIFY and XCB_BUTTON_PRESS .目前我只处理两个事件XCB_CREATE_NOTIFYXCB_BUTTON_PRESS I've registered for XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT and XCB_EVENT_MASK_EXPOSURE on the root window.我已经在根 window 上注册了XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECTXCB_EVENT_MASK_EXPOSURE

I'm testing the wm with Xephyr.我正在用 Xephyr 测试 wm。 And while testing any application launched after the wm has launched, is not shown (not visible) on the screen, while applications that have been launched before launching the wm, are shown perfectly (visible).在测试 wm 启动后启动的任何应用程序时,屏幕上不会显示(不可见),而在启动 wm 之前启动的应用程序会完美显示(可见)。

I read somewhere that registering for EXPOSURE event on the root window will solve the problem, but that doesn't seem the case for me.我在某处读到在根 window 上注册 EXPOSURE 事件将解决问题,但对我来说似乎并非如此。 Below is my code for the CREATE_NOTIFY event, that attempts to reparent the client window and map it on screen (I think this is where I'm doing something wrong):下面是我的 CREATE_NOTIFY 事件代码,它试图在屏幕上重新设置客户端 window 和 map (我认为这是我做错的地方):

case XCB_CREATE_NOTIFY:
    {
        xcb_create_notify_event_t *cre;
        cre = (xcb_create_notify_event_t *)evt;

        xcb_window_t frame = xcb_generate_id(conn);
        uint32_t frameMask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
        uint32_t fM_values[2];
        fM_values[0] = custTeal->pixel; //custTeal is a custom Teal color that I've defined
        fM_values[1] = XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_POINTER_MOTION;

        xcb_window_t toBeMapped = cre->window;
        xcb_get_geometry_reply_t *tbm_window_geo = xcb_get_geometry_reply(conn,xcb_get_geometry(conn,toBeMapped),NULL);

        xcb_create_window(conn,0,frame,screen->root,tbm_window_geo->x,tbm_window_geo->y,(tbm_window_geo->width+4),(tbm_window_geo->height+4),1,XCB_WINDOW_CLASS_INPUT_OUTPUT,screen->root_visual,frameMask,fM_values);

        xcb_reparent_window(conn,toBeMapped,frame,2,2);

        xcb_map_window(conn,frame);
        xcb_map_window(conn,toBeMapped);

        xcb_flush(conn);
    }
    break;

I can't figure out what I'm doing wrong here (I'm pretty new to this).我无法弄清楚我在这里做错了什么(我对此很陌生)。 Do I have to handle the EXPOSE event too?我也必须处理 EXPOSE 事件吗? How do I handle it?我该如何处理?

Testing测试

Im launching Xephyr with我正在启动 Xephyr

Xephyr -br -ac -noreset -screen 1240x720 :2 &

and launching new applications with (take xterm as an example):并使用(以 xterm 为例)启动新应用程序:

DISPLAY=:2 xterm &

Now, any application launched before launching the wm (or when the wm is not running) is shown perfectly in Xephyr.现在,在启动 wm 之前(或当 wm 未运行时)启动的任何应用程序都可以在 Xephyr 中完美显示。 But after I launch the wm, any application launched is not showm.但是在我启动 wm 后,启动的任何应用程序都不会显示。

SubstructureRedirect means that when something else tries to map a window, the X11 server instead generated a MapRequest event and sends that to the WM. SubstructureRedirect 意味着当其他东西尝试 map 和 window 时,X11 服务器会生成 MapRequest 事件并将其发送到 WM。 Thus, you should handle XCB_MAP_REQUEST events.因此,您应该处理XCB_MAP_REQUEST事件。 The simplest way to do that would be to xcb_map_window the window from the event.最简单的方法是xcb_map_window事件中的 window。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM