View Single Post
Old 08-30-2009, 06:52 AM   #8
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
It's so great! This approach works.
Now LED and buttons on iLiad can be used in QT4 apps.

I borrowed some code from trayicon_x11.cpp and made some modification.

This is the code that I use in djview4 for iLiad:
Code:
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <QX11Info>



  Display *dsp = QX11Info::display();
  WId leader   = winId();
  // set the class hint
  XClassHint classhint;
  classhint.res_name  = (char*)"sh";
  classhint.res_class = (char*)"sh";
  XSetClassHint(dsp, leader, &classhint);
  // set the Window Manager hints
  XWMHints *hints;
  hints = XGetWMHints(dsp, leader); // init hints
  hints->flags = WindowGroupHint | IconWindowHint | StateHint; // set the window group hint
  hints->window_group = leader;  // set the window hint
  hints->initial_state = WithdrawnState; // initial state
  //hints->icon_window = icon;  // in WM, this should be winId() of separate widget
  hints->icon_x = 0;
  hints->icon_y = 0;
  
  XSetWMHints(dsp, leader, hints); // set the window hints for WM to use.
  XFree( hints );
  //end setting WM hints
ericshliao is offline   Reply With Quote