On Tue, 2006-05-09 at 17:36 +0200, Boris Faure (aka billiob) wrote:
> The TODO-List is not long, but too hard for me :( I've searched the
> thing about non fully compliant WM and linflash, but it gave me no
> interesting answers.
>
attached is a diff that will work.. But I'd rather have it use
freedesktop stuff when it has the option.. So someone that can code c
should look up how to query the WM for what messages it understands, and
according to that use the right way (including fallback to what we had
in amsn before)
The diff was sent by a user on irc, forgot his name unfortunatly
Index: utils/linux/linflash/flash.c
===================================================================
RCS file: /cvsroot/amsn/msn/utils/linux/linflash/flash.c,v
retrieving revision 1.3
diff -u -r1.3 flash.c
--- utils/linux/linflash/flash.c 14 Mar 2006 19:28:23 -0000 1.3
+++ utils/linux/linflash/flash.c 28 Apr 2006 09:58:20 -0000
@@ -62,7 +62,7 @@
}
- return flash_window(interp, objv[1], 1l);
+ return flash_window(interp, objv[1], 1);
}
int Tk_UnFlashWindow (ClientData clientData,
@@ -78,10 +78,10 @@
}
- return flash_window(interp, objv[1], 0l);
+ return flash_window(interp, objv[1], 0);
}
-int flash_window (Tcl_Interp *interp, Tcl_Obj *CONST objv1, long flash) {
+int flash_window (Tcl_Interp *interp, Tcl_Obj *CONST objv1, int flash) {
// We declare our variables, we need one for every intermediate token we get,
// so we can verify if one of the function calls returned NULL
@@ -90,13 +90,9 @@
Window window;
Display * xdisplay;
Window root, parent, *children;
+ XWMHints *hints;
unsigned int n;
- static Atom demandsAttention;
- static Atom wmState;
-
- XEvent e;
- memset(&e, 0, sizeof(e));
// Get the first argument string (object name) and check it
win = Tcl_GetStringFromObj(objv1, NULL);
@@ -124,32 +120,24 @@
return TCL_ERROR;
}
-
xdisplay = Tk_Display(tkwin);
- // We need Atom-s created only once, they don't change during runtime
- demandsAttention = XInternAtom(xdisplay, "_NET_WM_STATE_DEMANDS_ATTENTION", True);
- wmState = XInternAtom(xdisplay, "_NET_WM_STATE", True);
-
XQueryTree(xdisplay, window, &root, &parent, &children, &n);
- XFree(children);
+ XFree(children); // don't care about those, really...
+
+ hints = XGetWMHints(xdisplay, parent);
+
+ if (!hints)
+ hints = XAllocWMHints();
+
+ if (flash)
+ hints->flags |= XUrgencyHint;
+ else
+ hints->flags &= ~XUrgencyHint;
+
+ XSetWMHints(xdisplay, parent, hints);
+ XFree(hints);
- e.xclient.type = ClientMessage;
- e.xclient.message_type = wmState;
- //Since under *nix Tk wraps all windows in another one to put a menu bar, we must use the parent window ID which is the top one
- e.xclient.window = parent;
- e.xclient.display = xdisplay;
- e.xclient.format = 32;
- e.xclient.data.l[0] = flash;
- e.xclient.data.l[1] = demandsAttention;
- e.xclient.data.l[2] = 0l;
- e.xclient.data.l[3] = 0l;
- e.xclient.data.l[4] = 0l;
-
-
- if (XSendEvent(xdisplay, root, False, (SubstructureRedirectMask | SubstructureNotifyMask), &e) == 0)
- return TCL_ERROR;
-
return TCL_OK;
}
Index: utils/linux/linflash/flash.h
===================================================================
RCS file: /cvsroot/amsn/msn/utils/linux/linflash/flash.h,v
retrieving revision 1.1
diff -u -r1.1 flash.h
--- utils/linux/linflash/flash.h 27 Jan 2006 13:51:16 -0000 1.1
+++ utils/linux/linflash/flash.h 28 Apr 2006 09:58:21 -0000
@@ -64,7 +64,7 @@
int objc,
Tcl_Obj *CONST objv[]);
-EXTERN int flash_window (Tcl_Interp *interp, Tcl_Obj *CONST objv1, long flash);
+EXTERN int flash_window (Tcl_Interp *interp, Tcl_Obj *CONST objv1, int flash);