[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

XGetClassHint + res_class



Hi @ all,

probiere gerade mit FvwmTransFocus (Modul für fvwm um Fenster an Hand des Focus transparent zu schalten, mit Hilfe von xcompmgr)

Funktioniert einwandfrei. Nun hat der Entwickler eine Funktion (ignoreWindow[0]) vorgesehen um bestimmte Fenster nicht transparent zu schalten (z.B für TV-Software) Sieht nehmlich nicht gut aus, wenn das Fernsehrbild halbtransparent ist ;-)

Die Funktion wird jedes mal von der Funktion transSet[1] gerufen und wenn Sie true zurück gibt wird das Fenster ignoriert. Die Entscheidung wird über !strncasecmp(class.res_class, "tvtime", 6) gemacht und klappt bei !strncasecmp(class.res_class, "xmms", 4) wunderbar nur halt bei tvtime nicht, da ist res_class null. Kann mir einer weiter helfen wo ich weiter suchen kann warum tvtime keine res_class liefert.

THX Marco

[0]
/* Checks whether the window should be ignored */
static int ignoreWindow(unsigned long int window) {
   XClassHint class = {0, 0};
   unsigned long int ignore, *children = 0;
   unsigned int num;

   /* Root window or no window */
   if (!window) {
       return 1;
   }

   /* Get class */
   /* FVWM gives us a ID of a parent window which does not have a
    * ClassHint so we need to find the child with ClassHint.  At least
    * that's what it looks like :) */
   while (!XGetClassHint(display, window, &class)) {
if (!XQueryTree(display, window, &ignore, &ignore, &children, &num)) {
           debug("RETURN IF: %s; %s\n", class.res_name, class.res_class);
           return 0;
       } else if (num!=1) {
           XFree((char*)children);
debug("RETURN ELSEIF: '%s'; %s %d\n", class.res_name, class.res_class, num);
           return 0;
       } else {
           window = children[0];
           XFree((char*)children);
       }
   }

   /* Ignore apps for watching TV */
   num = !strncasecmp(class.res_class, "tvtime", 6);

   /* Return */
   debug("ClassHint: '%s'; '%s'%s\n", class.res_name, class.res_class,
         num ? " (skipping)" : "");
   XFree(class.res_name);
   XFree(class.res_class);
   return num;
}


[1]
/********** Sets translucency **********/
void transSet(unsigned long int window, double value) {
   if (ignoreWindow(window)) {
       return;
   }
   debug("Changing 0x%08lx's opacity to %lf\n", window, value);

   if (value>=1) {
XDeleteProperty(display, window, XInternAtom(display, OPACITY, False));
   } else {
       unsigned long opacity = value<=0 ? 0 : OPAQUE * value;
XChangeProperty(display, window, XInternAtom(display, OPACITY, False),
                       XA_CARDINAL, 32, PropModeReplace,
                       (unsigned char *) &opacity, 1L);
   }
}

--
Softwareentwicklung

marco@marcomartinez.de
www.marcomartinez.de

funk: +49 (178) 731 55 53

Diese Mail ist digital unterschrieben, Sie ist nur gültig mit dem folgenden Fingerprint:

This mail is digitally signed, it is only valid with the following Fingerprint:

MD5-Fingerprint: 70:D7:D8:73:F1:62:FF:02:9A:3F:D1:D4:82:84:9E:DA

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


Reply to: