Just want to be able to close the window :( - X

This is a discussion on Just want to be able to close the window :( - X ; Hello, I have written an X application. I have created the window, and even managed to hide the cursor (took me 16 lines of c code just to hide the cursor!!!). I can not seem to get any kind of ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Just want to be able to close the window :(

  1. Just want to be able to close the window :(

    Hello,

    I have written an X application.

    I have created the window, and even managed to hide the cursor (took me 16
    lines of c code just to hide the cursor!!!).

    I can not seem to get any kind of event from the window manager when the
    "window close" buttom is pressed, or the "close alt-f4" option is selected
    from the window menu.

    I create the window with the following attributes:

    windowAttributes.event_mask = ExposureMask | KeyPressMask |
    ButtonPressMask | StructureNotifyMask | PointerMotionMask;
    XSelectInput(this->display, this->window, ExposureMask | KeyPressMask |
    ButtonPressMask | StructureNotifyMask | PointerMotionMask);

    and I have a loop in which I call:

    while (XCheckWindowEvent(this->display, this->window, StructureNotifyMask,
    &event)) {

    if (event.type == DestroyNotify) std::cout << "WINDOW CLOSE EVENT\n" <<
    std::flush;
    else std::cout << "EVENT\n" << std::flush;

    }

    Anyone tell me where I am going wrong here? Pulling my hair out just trying
    to get a simple event from the WM!

    Jamie.



  2. Re: Just want to be able to close the window :(

    Jamie Burns wrote:
    >Hello,
    >
    >I have written an X application.
    >
    >I have created the window, and even managed to hide the cursor (took me 16
    >lines of c code just to hide the cursor!!!).
    >
    >I can not seem to get any kind of event from the window manager when the
    >"window close" buttom is pressed, or the "close alt-f4" option is selected
    >from the window menu.
    >
    >I create the window with the following attributes:
    >
    > windowAttributes.event_mask = ExposureMask | KeyPressMask |
    >ButtonPressMask | StructureNotifyMask | PointerMotionMask;
    > XSelectInput(this->display, this->window, ExposureMask | KeyPressMask |
    >ButtonPressMask | StructureNotifyMask | PointerMotionMask);
    >
    >and I have a loop in which I call:
    >
    > while (XCheckWindowEvent(this->display, this->window, StructureNotifyMask,
    >&event)) {
    >
    > if (event.type == DestroyNotify) std::cout << "WINDOW CLOSE EVENT\n" <<
    >std::flush;
    > else std::cout << "EVENT\n" << std::flush;
    >
    > }
    >
    >Anyone tell me where I am going wrong here? Pulling my hair out just trying
    >to get a simple event from the WM!
    >
    >Jamie.
    >
    >


    Atom wmp = XInternAtom(d, "WM_PROTOCOLS", False);
    Atom wdw = XInternAtom(d, "WM_DELETE_WINDOW", False);
    XEvent e;

    XSetWMProtocols(dpy, win, &wdw, 1);

    while(1) {
    XNextEvent(dpy, &e);
    if (e.type == ClientMessage &&
    e.xclient.message_type == wmp &&
    e.xclient.data.l[0] == wdw) break;
    }


+ Reply to Thread