catch window close event [X connection to :1.0 broken (explicit killor server shutdown)] - Xwindows

This is a discussion on catch window close event [X connection to :1.0 broken (explicit killor server shutdown)] - Xwindows ; Hello, I'm new to X (using xlib on Linux). I create a window and want to be notified whenever some event happens. I knot that I have to specify the events of interest by using XSelectInput. But how can I ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: catch window close event [X connection to :1.0 broken (explicit killor server shutdown)]

  1. catch window close event [X connection to :1.0 broken (explicit killor server shutdown)]

    Hello,

    I'm new to X (using xlib on Linux). I create a window and want to be
    notified whenever some event happens. I knot that I have to specify the
    events of interest by using XSelectInput.
    But how can I catch the event that a user closes the window with the
    "x"-button from the window manager?
    When a user pushes the button, i get
    X connection to :1.0 broken (explicit kill or server shutdown)
    in the console where i stared my program.
    XNextEvent does not return at this point. My program is simply terminated.

    Thanks in advance!


    --
    Regards,
    Christof Krueger

    Remove "donotspam" if you want to email me.

  2. Re: catch window close event [X connection to :1.0 broken (explicit kill or server shutdown)]

    In comp.windows.x, Christof Krueger

    wrote
    on Sun, 18 Jan 2004 19:13:41 +0100
    :
    > Hello,
    >
    > I'm new to X (using xlib on Linux). I create a window and want to be
    > notified whenever some event happens. I knot that I have to specify the
    > events of interest by using XSelectInput.
    > But how can I catch the event that a user closes the window with the
    > "x"-button from the window manager?
    > When a user pushes the button, i get
    > X connection to :1.0 broken (explicit kill or server shutdown)
    > in the console where i stared my program.
    > XNextEvent does not return at this point. My program is simply terminated.
    >
    > Thanks in advance!
    >


    Things get mildly interesting at this level. First, one should
    use XSetWMProtocols on the window; this takes an array of Atoms.

    These atoms include:

    "WM_TAKE_FOCUS" -- program is expecting to handle keyboard input
    from this window.
    "WM_DELETE_WINDOW" -- program will want to see the close request
    on this window.
    "WM_SAVE_YOURSELF" -- I'm not sure exactly when this gets used,
    but it probably has to do with session management; when the
    session manager goes down each window is asked to save its
    position and/or settings so that when the user logs in again
    and asks to resume his session, the program can oblige.
    At least, that's my understanding; you may want to find
    the ICCCM specifications for a clearer response.

    These are not pre-registered atoms; use XInternAtom() if you need to.
    You need only use XInternAtom() once for each new Atom.

    Once you've registered these protocols (which, BTW, is
    merely a convenient abbreviation for a certain property
    name on the toplevel window; I'd have to look), you will
    receive ClientMessage events. Once you've registered
    WM_DELETE_WINDOW, the window manager will not terminate
    your Display connection -- your program gets to instead
    close the window (either by unmapping it or by destroying
    it), and whatever else it deems necessary. For example,
    the program can pop up a dialog box asking "you forgot
    to save the file: [save and close] [just close] [cancel]"
    or some such.

    Happy hacking. :-)

    --
    #191, ewill3@earthlink.net
    It's still legal to go .sigless.

  3. Re: catch window close event [X connection to :1.0 broken (explicitkill or server shutdown)]

    The Ghost In The Machine wrote:
    > In comp.windows.x, Christof Krueger
    >
    > wrote
    > on Sun, 18 Jan 2004 19:13:41 +0100
    > :
    >
    >>Hello,
    >>
    >>I'm new to X (using xlib on Linux). I create a window and want to be
    >>notified whenever some event happens. I knot that I have to specify the
    >>events of interest by using XSelectInput.
    >>But how can I catch the event that a user closes the window with the
    >>"x"-button from the window manager?
    >>When a user pushes the button, i get
    >>X connection to :1.0 broken (explicit kill or server shutdown)
    >>in the console where i stared my program.
    >>XNextEvent does not return at this point. My program is simply terminated.
    >>
    >>Thanks in advance!
    >>

    >
    >
    > Things get mildly interesting at this level. First, one should
    > use XSetWMProtocols on the window; this takes an array of Atoms.
    >
    > These atoms include:
    >
    > "WM_TAKE_FOCUS" -- program is expecting to handle keyboard input
    > from this window.
    > "WM_DELETE_WINDOW" -- program will want to see the close request
    > on this window.
    > "WM_SAVE_YOURSELF" -- I'm not sure exactly when this gets used,
    > but it probably has to do with session management; when the
    > session manager goes down each window is asked to save its
    > position and/or settings so that when the user logs in again
    > and asks to resume his session, the program can oblige.
    > At least, that's my understanding; you may want to find
    > the ICCCM specifications for a clearer response.
    >
    > These are not pre-registered atoms; use XInternAtom() if you need to.
    > You need only use XInternAtom() once for each new Atom.
    >
    > Once you've registered these protocols (which, BTW, is
    > merely a convenient abbreviation for a certain property
    > name on the toplevel window; I'd have to look), you will
    > receive ClientMessage events. Once you've registered
    > WM_DELETE_WINDOW, the window manager will not terminate
    > your Display connection -- your program gets to instead
    > close the window (either by unmapping it or by destroying
    > it), and whatever else it deems necessary. For example,
    > the program can pop up a dialog box asking "you forgot
    > to save the file: [save and close] [just close] [cancel]"
    > or some such.
    >
    > Happy hacking. :-)
    >


    Thank you very much!
    I googled a lot and even came across WM_DELETE_WINDOW but didn't read
    further because it looked like MS Windows API Messages to me. Now I
    understand that WM stands for WindowManager. =)

    Do you know a good reference site about such details? I'm using
    tronche.com as reference at the moment. It is good to look up functions,
    but it is difficult to learn from it.

    --
    Regards,
    Christof Krueger

    Remove "donotspam" if you want to email me.

  4. Re: catch window close event [X connection to :1.0 broken (explicit kill or server shutdown)]

    In comp.windows.x, Christof Krueger

    wrote
    on Mon, 19 Jan 2004 14:11:47 +0100
    :
    > The Ghost In The Machine wrote:
    >> In comp.windows.x, Christof Krueger
    >>
    >> wrote
    >> on Sun, 18 Jan 2004 19:13:41 +0100
    >> :
    >>
    >>>Hello,
    >>>
    >>>I'm new to X (using xlib on Linux). I create a window and want to be
    >>>notified whenever some event happens. I knot that I have to specify the
    >>>events of interest by using XSelectInput.
    >>>But how can I catch the event that a user closes the window with the
    >>>"x"-button from the window manager?
    >>>When a user pushes the button, i get
    >>>X connection to :1.0 broken (explicit kill or server shutdown)
    >>>in the console where i stared my program.
    >>>XNextEvent does not return at this point. My program is simply terminated.
    >>>
    >>>Thanks in advance!
    >>>

    >>
    >>
    >> Things get mildly interesting at this level. First, one should
    >> use XSetWMProtocols on the window; this takes an array of Atoms.
    >>
    >> These atoms include:
    >>
    >> "WM_TAKE_FOCUS" -- program is expecting to handle keyboard input
    >> from this window.
    >> "WM_DELETE_WINDOW" -- program will want to see the close request
    >> on this window.
    >> "WM_SAVE_YOURSELF" -- I'm not sure exactly when this gets used,
    >> but it probably has to do with session management; when the
    >> session manager goes down each window is asked to save its
    >> position and/or settings so that when the user logs in again
    >> and asks to resume his session, the program can oblige.
    >> At least, that's my understanding; you may want to find
    >> the ICCCM specifications for a clearer response.
    >>
    >> These are not pre-registered atoms; use XInternAtom() if you need to.
    >> You need only use XInternAtom() once for each new Atom.
    >>
    >> Once you've registered these protocols (which, BTW, is
    >> merely a convenient abbreviation for a certain property
    >> name on the toplevel window; I'd have to look), you will
    >> receive ClientMessage events. Once you've registered
    >> WM_DELETE_WINDOW, the window manager will not terminate
    >> your Display connection -- your program gets to instead
    >> close the window (either by unmapping it or by destroying
    >> it), and whatever else it deems necessary. For example,
    >> the program can pop up a dialog box asking "you forgot
    >> to save the file: [save and close] [just close] [cancel]"
    >> or some such.
    >>
    >> Happy hacking. :-)
    >>

    >
    > Thank you very much!
    > I googled a lot and even came across WM_DELETE_WINDOW but didn't read
    > further because it looked like MS Windows API Messages to me. Now I
    > understand that WM stands for WindowManager. =)
    >
    > Do you know a good reference site about such details? I'm using
    > tronche.com as reference at the moment. It is good to look up functions,
    > but it is difficult to learn from it.
    >


    Not sure how good it is but there's an ICCCM manual on that
    very site:

    http://tronche.com/gui/x/icccm/

    which a Google search on "ICCCM" turned up. Among many other things,
    it mentions the "WM_PROTOCOLS" property, which is the property I
    referred to earlier. It appears WM_SAVE_YOURSELF has been deprecated,
    so don't worry about it. Also, I'm in error (interesting!); the
    unmapping of the window is not an option although withdrawing it
    (XWithdrawWindow) is.

    Or you can try http://www.oreilly.com , although I for one can't seem
    to find X there and bumbled around to

    http://www.oreilly.com/catalog/prdindex.html

    The books for X are titled "Volume 0" through "Volume 6B"; the examples
    are apparently freely downloadable although it's not clear to me how
    much sense they'll make without the book. :-) Please bear in mind
    there are license restrictions.

    --
    #191, ewill3@earthlink.net
    It's still legal to go .sigless.

  5. Re: catch window close event [X connection to :1.0 broken (explicit kill or server shutdown)]

    Hi!

    I'm new to X programming too. A few days ago I found great source of
    specifiactions and manuals at
    http://www.xfree86.org/snapshot/specindex.html.

    The specs are avaiable in PDF and HTML. Altough it seems that HTML
    versions have been generated from the PDF so every HTML spec is one
    very long page. I prefer to use the original PDF versions. For ad-hoc
    search you can (when you know exactly what yoy search) use man pages
    (http://www.xfree86.org/current/manindex3.html).

    The most important stuff is:
    (1) Core X Protocol Library API
    This should cover what the manual at tronche.com does and probably
    more. The tronche doesn't cover some things at all (i18n) and it's a
    bit old too.

    (2) ICCCM (Inter-Client Communcations Conventions Manual)
    This specifies a set of conventions how the X clients would
    communicate (communication between regular clients as well as regular
    client to window manager communication). Here you can find answers to
    your original question.

    Also I found some useful texts at
    http://freedesktop.org/Standards/Home.
    For example if you would like support some drag-and-drop features, see
    http://freedesktop.org/Standards/XDND. It's de facto (not official)
    standard (Gtk+ and Qt toolkits use that for example).

    I hope it helps you.
    Mity

+ Reply to Thread