Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8693879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:38:46+00:00 2026-06-13T00:38:46+00:00

I am trying to make a very simple window manager for learning purposes. I

  • 0

I am trying to make a very simple window manager for learning purposes. I am using C and the xcb library. I am trying to get an event raised if a new application is launched.

For now, I create a root window where I can receive mouse and keyboard events. I also draw a colored bar on the top of the window. When I press enter, xterm will launch using fork and execvp. This all works great.

When xterm (or any application I think) launches, it gets drawn on top of the bar (x = 0, y = 0). I would like to move it a bit lower (x = 0, y = 16). I think I know how to move the window, using xcb_configure_window. But I don’t know how to get an event for the newly launched application.

Edit:
After some messing around I came to the following conclusions:
If I create my parent window like this:

xcb_window_t window_root = screen->root;
uint32_t mask = 0;    
uint32_t values[2];
mask = XCB_CW_EVENT_MASK;
values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY;
xcb_change_window_attributes_checked(connection, window_root, mask, values);
xcb_flush(connection);

i will receive a XCB_CREATE_NOTIFY when I spawn a new terminal. However, I am not able to draw anything on the screen, because I am not “subscribed” to the XCB_EVENT_MASK_EXPOSE event. If I change the values[0] line to this:

values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_EXPOSURE;

i will still receive creation events, but the expose event does not get called as soon as the program starts, so my bar will not get drawn. It will get an expose event as soon as I launch a new terminal though, but my initial drawing won’t happen.

My old method of creating a parent window was:

xcb_window_t window = xcb_generate_id(connection);
uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
uint32_t values[2] = {screen->white_pixel, XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY };
xcb_create_window(connection, 0, window, screen->root, 0, 0, screen->width_in_pixels, screen->height_in_pixels, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, mask, values);
xcb_map_window(connection, window);

This will draw a white background and draw my colored bar, because it immediately gets an XCB_EVENT_MASK_EXPOSURE event. But it won’t get an XCB_CREATE_NOTIFY event.

So what is the correct way to get both the XCB_CREATE_NOTIFY events and the XCB_EVENT_MASK_EXPOSURE events?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:38:47+00:00Added an answer on June 13, 2026 at 12:38 am

    I was being silly and I fixed it!

    I thought I only got expose events after I launched a new terminal. But I never even drew my bar and background before entering the event loop, I only drew them in my XCB_EXPOSE loop. So when a new terminal got launched, the expose event would get called, and my bar and background appeared.

    Now I placed the drawing functions before my event loop as well, and everything works like it should. I don’t know if this is the right/best way to go, but for future reference, use the following to create your root screen:

    xcb_window_t window_root = screen->root;
    uint32_t mask = 0;    
    uint32_t values[2];
    mask = XCB_CW_EVENT_MASK;
    values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY;
    xcb_change_window_attributes_checked(connection, window_root, mask, values);
    xcb_flush(connection);
    

    You will get expose events, and newly launched programs will appear in the XCB_CREATE_NOTIFY event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a very simple OSGi test but I can't get it
I'm learning Objective-C and trying to make a very simple command line calculator. 'S'
Hey i'm trying to make a very simple GUI using SFML, and i want
I'm trying to make a very simple updater app that reads current version.txt file
I am trying to make a very simple object rotate around a fixed point
I am trying to make a very simple web-service which does the following: The
i'm trying to make a very simple YACC parser on Pascal language which just
I am trying to make a (very) simple Data Binding test, but it doesn't
Trying to make a call and retrieve a very simple, one line, JSON file.
I'm trying to make a custom JDialog using windowBuilder, but at the very beginning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.