Results 1 to 5 of 5

Thread: setting EWM (extended window manager) hints via Qt4 (X11)

  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question setting EWM (extended window manager) hints via Qt4 (X11)

    In the Qt Namespace we can set a myriad Qt::WindowFlags. However is it possible to set some flags which are not mentioned/provided....eg. setting the EWM hints (extended window manager hints) a.k.a NETWM hints as per the ICCCM specification on:

    www.freedesktop.org/wiki/standards/wm-spec.html

    eg

    _NET_WM_WINDOW_TYPE_DOCK indicates a dock or panel feature. Typically a Window Manager would keep such windows on top of all other windows....i.e. what i want to know whether i can set NETWM hints via Qt especially which don't have a mention in the Qt4 Doc.



    Thanks

    Nupul

  2. #2
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setting EWM (extended window manager) hints via Qt4 (X11)

    You can use XSetWMHints like this :

    Qt Code:
    1. #include <X11/Xlib.h>
    2. #include <Q11Info>
    3.  
    4. // In widget constructor
    5.  
    6. // Allocate a hint structure - don't forget to XFree() in destructor!
    7. XWMHints* hints(XAllocWMHints());
    8.  
    9. // Populate the hints structure with the hints you want to activate here.
    10. // hints->flags = ...etc.
    11.  
    12. // Set the hints on the X11 window for the widget.
    13. XSetWMHints(QX11Info::display(), static_cast<Window>(this->winId()), hints);
    To copy to clipboard, switch view to plain text mode 

    Be careful though, it will hardly be portable...
    Last edited by Chicken Blood Machine; 28th March 2006 at 18:26.
    Save yourself some pain. Learn C++ before learning Qt.

  3. #3
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setting EWM (extended window manager) hints via Qt4 (X11)

    Actually, if you have problems with that, I've just found some code I implemented a long time ago when using Qt3. It created a non-resizable border for dialogs (now not required in Qt4 as it is done automatically). If you modify this to set your specific EWM hints, it should work:

    Qt Code:
    1. #include <X11/Xlib.h>
    2. #include <X11/Xutil.h>
    3. #include <X11/Xatom.h>
    4.  
    5. #include <QX11Info>
    6.  
    7. void MyWidget::callIfWidgetIsTopLevelAndNonResizeable()
    8. {
    9. struct PropMotifWmHints
    10. {
    11. unsigned long flags;
    12. unsigned long functions;
    13. unsigned long decorations;
    14. long inputMode;
    15. unsigned long status;
    16. };
    17. #define QT_XA_MOTIF_WM_HINTS "_MOTIF_WM_HINTS"
    18. #define QT_MWM_HINTS_FUNCTIONS 0x01
    19. #define QT_MWM_HINTS_DECORATIONS 0x10
    20. #define QT_MWM_ALL_FUNCS_WITHOUT_RESIZE 0x3C
    21. #define QT_MWM_ALL_DECOR_WITHOUT_RESIZE_HANDLE 0x7A
    22.  
    23. PropMotifWmHints prop = {0};
    24. prop.flags |= QT_MWM_HINTS_FUNCTIONS | QT_MWM_HINTS_DECORATIONS;
    25. prop.functions |= QT_MWM_ALL_FUNCS_WITHOUT_RESIZE;
    26. prop.decorations |= QT_MWM_ALL_DECOR_WITHOUT_RESIZE_HANDLE;
    27.  
    28. Atom atom = XInternAtom(x11Display(), QT_XA_MOTIF_WM_HINTS, false);
    29. XChangeProperty(QX11Info::display(),
    30. winId(),
    31. atom, atom,
    32. 32,
    33. PropModeReplace,
    34. (u_char*) &prop,
    35. sizeof(PropMotifWmHints) / sizeof(long));
    36. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Chicken Blood Machine; 28th March 2006 at 18:32.
    Save yourself some pain. Learn C++ before learning Qt.

  4. #4
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: setting EWM (extended window manager) hints via Qt4 (X11)

    hey chicken blood machine (CBM)!!,

    THANKS A MILLION FOR THE HELP!!!


    Well I just want to know a few things in your code.

    1.
    XSetWMHints(QX11Info::display(), static_cast<Window>(this->winId()), hints);

    Please elaborate on the use of QX11Info::display(), and static_cast...
    w.r.t. the given function XSetWMHints();

    2.
    #define QT_XA_MOTIF_WM_HINTS "_MOTIF_WM_HINTS"
    #define QT_MWM_HINTS_FUNCTIONS 0x01
    #define QT_MWM_HINTS_DECORATIONS 0x10
    #define QT_MWM_ALL_FUNCS_WITHOUT_RESIZE 0x3C
    #define QT_MWM_ALL_DECOR_WITHOUT_RESIZE_HANDLE 0x7A

    These are all user defined Macros, right? and why the specific Hex values, where did you get these from?

    Do reply,

    Thanks once again

    Nupul

  5. #5
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setting EWM (extended window manager) hints via Qt4 (X11)

    Quote Originally Posted by nupul
    1.
    XSetWMHints(QX11Info::display(), static_cast<Window>(this->winId()), hints);

    Please elaborate on the use of QX11Info::display(), and static_cast...
    w.r.t. the given function XSetWMHints();
    The first arg is the X11 display id being used by your application. This can be accessed with QX11Info::display().

    The second arg to XSetWMHints expects an X11 window id. QWidget::winId() returns the correct value to use here, but out of laziness, I added the cast, because I wasn't sure how the Qt WId type had been defined. Actually, I've just checked and it's defined as an int. A X11 'Window' is defined as an integral type on most implementations, but the cast is just there for thoroughness.

    #define QT_XA_MOTIF_WM_HINTS "_MOTIF_WM_HINTS"
    #define QT_MWM_HINTS_FUNCTIONS 0x01
    #define QT_MWM_HINTS_DECORATIONS 0x10
    #define QT_MWM_ALL_FUNCS_WITHOUT_RESIZE 0x3C
    #define QT_MWM_ALL_DECOR_WITHOUT_RESIZE_HANDLE 0x7A

    These are all user defined Macros, right? and why the specific Hex values, where did you get these from?
    I actually copied these values from a Motif header. I wanted to know the values of the MWM (Motif Window manager) hints that I needed, but I did not want my program to rely on Motif in any way. You can ignore these defines and just replace them with the NETWM values that you need to define.

    Let me know how you get on.
    Last edited by Chicken Blood Machine; 29th March 2006 at 23:48.
    Save yourself some pain. Learn C++ before learning Qt.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.