Disable close button and system menu action - Xwindows

This is a discussion on Disable close button and system menu action - Xwindows ; Hi guys, first off, I am not familiar to X11 programming, so please bear with me and take nothing for granted ;-) I need to temporarily disable the close button on a window's title bar (and thus the "close" action ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Disable close button and system menu action

  1. Disable close button and system menu action

    Hi guys,

    first off, I am not familiar to X11 programming, so please bear with
    me and take nothing for granted ;-)

    I need to temporarily disable the close button on a window's title bar
    (and thus the "close" action in the window menu).
    Is there any way to achieve this?

    Thanks in advance for your help and suggestions!
    Happy coding


  2. Re: Disable close button and system menu action

    On 2007-11-06, hippydream wrote:
    >
    > Hi guys,
    >
    > first off, I am not familiar to X11 programming, so please bear with
    > me and take nothing for granted ;-)
    >
    > I need to temporarily disable the close button on a window's title bar
    > (and thus the "close" action in the window menu).
    > Is there any way to achieve this?


    You need to read the ICCCM (Inter-Client Communication Conventions
    Manual).

    In a nutshell, if your application has registered to participate in the
    WM_DELETE_WINDOW protocol, by setting the appropriate WM_PROTOCOLS
    window property to its top level windows, it will recieve a
    ClientMessage from the window manager, each time the user presses "a
    close button of some sort", or does something that the WM interprets as
    wanting to close the window. The data[0] field of that ClientMessage
    event, contains the atom WM_DELETE_WINDOW.

    Upon reciept of this event, your application can do whatever it deems
    appropriate, like asking the user for confirmation, immediately exiting,
    or ignoring the event altogether (which in some circles is considered
    bad behaviour, but if it's to be temporary as you said, then it might be
    appropriate).

    Ask if you need any more details, after you've consulted the ICCCM and
    the Xlib documentation on these matters.

    --
    John Tsiombikas (Nuclear / Mindlapse)
    http://nuclear.sdf-eu.org/

  3. Re: Disable close button and system menu action

    First off, thanks for your reply.


    > Upon reciept of this event, your application can do whatever it deems
    > appropriate, like asking the user for confirmation, immediately exiting,
    > or ignoring the event altogether (which in some circles is considered
    > bad behaviour, but if it's to be temporary as you said, then it might be
    > appropriate).


    Actually I don't need to handle the button event but only to disable
    the button (if this is possible on X11), so I don't know if this is
    appropriate.


    > Ask if you need any more details, after you've consulted the ICCCM and
    > the Xlib documentation on these matters.



    I will do so, thank you.
    I didn't even know where to start with, so I'll go on having a look at
    Xlib and ICCCM now :-)


    PS: if anybody cares to know, I am using the Qt toolkit which will
    lets me handle window events in a platform independent way. The title
    bar buttons / menu however cannot be accessed using Qt. This is why I
    don't care about the window manager's event ;-)


  4. Re: Disable close button and system menu action

    hippydream wrote:
    >> Ask if you need any more details, after you've consulted the ICCCM and
    >> the Xlib documentation on these matters.

    >
    >
    > I will do so, thank you.
    > I didn't even know where to start with, so I'll go on having a look at
    > Xlib and ICCCM now :-)
    >
    >
    > PS: if anybody cares to know, I am using the Qt toolkit which will
    > lets me handle window events in a platform independent way. The title
    > bar buttons / menu however cannot be accessed using Qt. This is why I
    > don't care about the window manager's event ;-)
    >

    But by using directly Xlib and ICCM your application will
    become X Windows specific, and will not work on Windows.
    So you need to find a different solution which works
    entirely from Qt, or use #ifdef to cover platform specific
    issues.

    Best regards

    Dušan Peterc
    http://www.arahne.si

  5. Re: Disable close button and system menu action

    On 2007-11-07, hippydream wrote:
    >> Upon reciept of this event, your application can do whatever it deems
    >> appropriate, like asking the user for confirmation, immediately exiting,
    >> or ignoring the event altogether (which in some circles is considered
    >> bad behaviour, but if it's to be temporary as you said, then it might be
    >> appropriate).

    >
    > Actually I don't need to handle the button event but only to disable
    > the button (if this is possible on X11), so I don't know if this is
    > appropriate.


    Well, by handling the event in a way that it doesn't do anything, you
    effectively disable it.

    If you mean, that you need to provide a "graphical hint" to the user
    that the button is disabled. That's totally window manager specific. I
    know for a fact, that some window managers consider NOT registering for
    the WM_DELETE_WINDOW protocol, as a hint that the close button should be
    disabled. But the ICCCM explicitly allows a window manager to just kill
    any window that doesn't know about WM_DELETE_WINDOW. So that's not
    really safe.

    There is another generation of WM hints, not defined in ICCCM, called
    _NET_SOMETHING, or _NET_OTHER, if I'm not mistaken. Most modern window
    managers supports them, but I'm not familliar with them. Try searching
    there if there's something to tell the WM to disable the close button.

    Still, I know for a fact, that the WM I'm using (FVWM), allows me to
    override ANY application-specified hint So don't feel very confident
    that the WM will do what you want, about that sort of thing.

    >> Ask if you need any more details, after you've consulted the ICCCM and
    >> the Xlib documentation on these matters.

    >
    > I will do so, thank you.
    > I didn't even know where to start with, so I'll go on having a look at
    > Xlib and ICCCM now :-)
    >
    >
    > PS: if anybody cares to know, I am using the Qt toolkit which will
    > lets me handle window events in a platform independent way. The title
    > bar buttons / menu however cannot be accessed using Qt. This is why I
    > don't care about the window manager's event ;-)
    >


    Well you should have mentioned that before. As another poster pointed
    out, you might want to look into facilities provided by Qt before
    writing platform-specific X11 code. Unfortunately I can't help you as
    I'm not familliar with Qt. Your best bet is to find a Qt-specific
    newsgroup.


    --
    John Tsiombikas (Nuclear / Mindlapse)
    http://nuclear.sdf-eu.org/

  6. Re: Disable close button and system menu action


    > If you mean, that you need to provide a "graphical hint" to the user
    > that the button is disabled. That's totally window manager specific. I
    > know for a fact, that some window managers consider NOT registering for
    > the WM_DELETE_WINDOW protocol, as a hint that the close button should be
    > disabled. But the ICCCM explicitly allows a window manager to just kill
    > any window that doesn't know about WM_DELETE_WINDOW. So that's not
    > really safe.



    Well, I thought so ;-)
    I was just curious to know how to do that with common window managers
    like KDE's and Gnome's, even though I don't really think it's a good
    idea from a usability point of view..
    IOW it's sort of an excuse to start learning some X11 coding ;-)


    > Well you should have mentioned that before. As another poster pointed
    > out, you might want to look into facilities provided by Qt before
    > writing platform-specific X11 code. Unfortunately I can't help you as
    > I'm not familliar with Qt. Your best bet is to find a Qt-specific
    > newsgroup.


    I did. As to my Qt knowledge (which is quite good) there is no way to
    do this and that's why I was looking for some platform dependent code.
    And lots of annoying #ifdefs ;-)

    Nevertheless thanks for the hints!

+ Reply to Thread