From lars@e.0x20.net  Wed Dec 24 17:36:17 2008
Return-Path: <lars@e.0x20.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 40B3E106567B
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Dec 2008 17:36:17 +0000 (UTC)
	(envelope-from lars@e.0x20.net)
Received: from mail.0x20.net (mail.0x20.net [IPv6:2001:aa8:fffb::3])
	by mx1.freebsd.org (Postfix) with ESMTP id 8F2B18FC21
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Dec 2008 17:36:16 +0000 (UTC)
	(envelope-from lars@e.0x20.net)
Received: by mail.0x20.net (Postfix, from userid 1002)
	id 04A7E3A6A4; Wed, 24 Dec 2008 18:36:14 +0100 (CET)
Message-Id: <20081224173615.04A7E3A6A4@mail.0x20.net>
Date: Wed, 24 Dec 2008 18:36:14 +0100 (CET)
From: Lars Engels <lme@FreeBSD.org>
Reply-To: Lars Engels <lme@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] net-im/amsn: fix tray icon issues with fluxbox / stalonetray
X-Send-Pr-Version: 3.113
X-GNATS-Notify: yinjieh@csie.nctu.edu.tw

>Number:         129914
>Category:       ports
>Synopsis:       [patch] net-im/amsn: fix tray icon issues with fluxbox / stalonetray
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lme
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 24 17:40:00 UTC 2008
>Closed-Date:    Sat Jan 31 13:05:05 UTC 2009
>Last-Modified:  Sat Jan 31 13:10:05 UTC 2009
>Originator:     Lars Engels
>Release:        FreeBSD 5.5-RELEASE-p19 i386
>Organization:
>Environment:
System: FreeBSD e.0x20.net 5.5-RELEASE-p19 FreeBSD 5.5-RELEASE-p19 #6: Fri Feb 15 15:16:05 CET 2008 root@e.0x20.net:/data/sysstuff/obj/data/sysstuff/5.5/src/sys/NADE_55_b0 i386


	
>Description:
The attached patch is taken from upstream's SVN repo. It fixes the issue that the tray icon is not displayed in stalonetray / fluxbox tray
from time to time.

See http://amsn.svn.sourceforge.net/viewvc/amsn/trunk/amsn/utils/linux/traydock/libtray.c?view=log for more information.
	
>How-To-Repeat:
	
>Fix:

	

--- amsn-0.9.7.2_2.patch begins here ---
Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/net-im/amsn/Makefile,v
retrieving revision 1.35
diff -u -r1.35 Makefile
--- Makefile	10 Aug 2008 21:58:42 -0000	1.35
+++ Makefile	24 Dec 2008 10:38:17 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=	amsn
 PORTVERSION=	0.97.2
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	net-im
 MASTER_SITES=	SF
 
Index: files/patch-utils-linux-traydock-libtray.c
===================================================================
RCS file: files/patch-utils-linux-traydock-libtray.c
diff -N files/patch-utils-linux-traydock-libtray.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-utils-linux-traydock-libtray.c	24 Dec 2008 10:38:17 -0000
@@ -0,0 +1,191 @@
+--- utils/linux/traydock/libtray.c.orig	2008-12-24 11:30:51.000000000 +0100
++++ utils/linux/traydock/libtray.c	2008-12-24 11:32:00.000000000 +0100
+@@ -128,70 +128,25 @@
+     //}
+ }
+ 
+-static char
+-*get_wm_name (void)
+-{
+-	int screen = DefaultScreen(display);
+-	Atom type;
+-	int format;
+-	unsigned long bytes_returned, n_returned;
+-	unsigned char *buffer;
+-	
+-	Window root = RootWindow(display, screen);
+-	Window *child;
+-	Atom supwmcheck = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
+-	Atom wmname = XInternAtom(display, "_NET_WM_NAME", False);
+-	
+-	XGetWindowProperty(display, root, supwmcheck, 0, 8, False, AnyPropertyType, &type, &format, &n_returned,
+-			&bytes_returned, (unsigned char **)&child);
+-	
+-	if (n_returned != 1) return NULL;
+-	
+-	XGetWindowProperty(display, *child, wmname, 0, 128, False, AnyPropertyType, &type, &format, &n_returned,
+-			&bytes_returned, &buffer);
+-	
+-	if (n_returned == 0) return NULL;
+-	
+-	XFree(child);
+-	return (char *) buffer;
+-}
+-
+ /* Procedure that Docks the icon */
+ static void
+ DockIcon(ClientData clientData)
+ {
+ 
+-	Window root, parent, *children;
+-	unsigned int n, ret, atom;
++	Window parent;
++	unsigned int ret, atom;
+ 	TrayIcon *icon= clientData;
+ 	char* wm_name;
+ 
+-	Tk_MapWindow(icon->win);
+-
+-	XQueryTree(display, Tk_WindowId(icon->win), &root, &parent, &children, &n);
+-	XFree(children);
++    Tk_MakeWindowExist(icon->win);
+ 
+ 	Tk_SetWindowBackgroundPixmap(icon->win, ParentRelative);
+-	XSetWindowBackgroundPixmap(display, parent, ParentRelative);
+ 
+ 	xembed_set_info(icon->win,XEMBED_MAPPED);
+ 
+-	Tk_UnmapWindow(icon->win);
+-
+-	if ( (atom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", True )) == None ) {
+-		wm_name = get_wm_name();
+-		if (wm_name != NULL && !strcmp(wm_name, "KWin")) {
+-			atom = XInternAtom(display, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False);
+-			ret = XChangeProperty(display, parent, atom,
+-				XA_WINDOW, 32, PropModeReplace, (unsigned char *)&parent, 1);
+-			Tk_MapWindow(icon->win);
+-		}
+-		XFree(wm_name);
+-	} else {
+-		send_message(display,systemtray, atom,
+-				SYSTEM_TRAY_REQUEST_DOCK,Tk_WindowId(icon->win),0,0);
+-	}
+-
++	atom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", False );
++	send_message(display,systemtray, atom,
++			SYSTEM_TRAY_REQUEST_DOCK,Tk_WindowId(icon->win),0,0);
+ }
+ 
+ /* Draw the icon */
+@@ -204,10 +159,32 @@
+ 	int widthImg, heightImg;
+ 	Window r;
+ 	char cmdBuffer[1024];
++	XSizeHints *hints = NULL;
++	long supplied = 0;
+ 
+ 	XGetGeometry(display, Tk_WindowId(icon->win), &r, &x, &y, &w, &h, &b, &d);
+ 	XClearWindow(display, Tk_WindowId(icon->win));
+ 
++	/*
++	 * Here we get the window hints because in some cases the XGetGeometry
++	 * function returns the wrong width/height. We only check that 
++	 * min_width <= width <= max_width and min_height <= height <= max_height
++	 */
++	hints = XAllocSizeHints();
++	XGetWMNormalHints(display, Tk_WindowId(icon->win), hints, &supplied);
++	if( supplied & PMaxSize ) {
++		w = (hints->max_width < w) ? hints->max_width : w;
++		h = (hints->max_height < h) ? hints->max_height : h;
++	}
++	if( supplied & PMinSize ) {
++		w = (hints->min_width > w) ? hints->min_width : w;
++		h = (hints->min_height > h) ? hints->min_height : h;
++	}
++	if(hints) {
++		XFree(hints);
++		hints = NULL;
++	}
++
+ 	if (((icon->width != w) || (icon->height != h) || (icon->mustUpdate)) && (icon->cmdCallback[0] != '\0')) {
+ 		snprintf(cmdBuffer,sizeof(cmdBuffer),"%s %u %u",icon->cmdCallback,w,h);
+ 		Tcl_EvalEx(globalinterp,cmdBuffer,-1,TCL_EVAL_GLOBAL);
+@@ -222,6 +199,8 @@
+ 	if (heightImg > h)
+ 		heightImg = h;
+ 
++	if( !Tk_IsMapped(icon->win) )
++		Tk_MapWindow(icon->win);
+ 	Tk_RedrawImage(icon->pixmap, 0, 0, widthImg, heightImg, Tk_WindowId(icon->win), (w-widthImg)/2 , (h-heightImg)/2 );
+ 
+ }
+@@ -328,6 +307,12 @@
+ 	XSizeHints *hint;
+ 	char cmdBuffer[1024];
+ 
++	/* systemtray was not available in Init */
++	if (systemtray==0) {
++		Tcl_AppendResult (interp, "cannot create a tray icon without a system tray", (char *) NULL);
++		return TCL_ERROR;
++	}
++
+ 	/* Get memory for trayicon data and zero it*/
+ 	icon = (TrayIcon *) malloc(sizeof(TrayIcon));
+ 	memset((void *) icon, 0, (sizeof(TrayIcon)));
+@@ -335,18 +320,11 @@
+ 	
+ 	mainw=Tk_MainWindow(interp);
+ 
+-	/* systemtray was not available in Init */
+-	if (systemtray==0) {
+-		Tcl_AppendResult (interp, "cannot create a tray icon without a system tray", (char *) NULL);
+-		return TCL_ERROR;
+-	}
+-
+ 	/* Get the first argument string (object name) and check it */
+ 	arg=Tcl_GetStringFromObj(objv[1],(int *) &length);
+ 	//printf("Arg: %s\n",arg);
+-	if (strncmp(arg,".",1)) {
+-		Tcl_AppendResult (interp, "bad path name: ",
+-			Tcl_GetStringFromObj(objv[1],(int *) &length) , (char *) NULL);
++	if (arg == NULL || length < 1 || strncmp(arg, ".", 1)) {
++		Tcl_AppendResult (interp, "bad path name: ", arg , (char *) NULL);
+ 		return TCL_ERROR;
+ 	}
+ 	
+@@ -391,7 +369,7 @@
+ 				n++;
+ 				strcpy (icon->tooltip,Tcl_GetStringFromObj(objv[n],(int *) &length));
+ 			} else if (!strncmp(arg,"-command",length)) {
+-				/* Copy tooltip string */
++				/* Copy command string */
+ 				n++;
+ 				strcpy (icon->cmdCallback,Tcl_GetStringFromObj(objv[n],(int *) &length));
+ 			} else {
+@@ -408,10 +386,12 @@
+ 	if (pixmap != NULL) {
+ 		/* Create the window */
+ 		icon->win=Tk_CreateWindowFromPath(interp,mainw,
+-				Tcl_GetStringFromObj(objv[1],(int *) &length),"");
++				Tcl_GetStringFromObj(objv[1],(int *) &length),NULL);
+ 
+ 		DockIcon((ClientData)icon);
+ 
++		Tk_GeometryRequest( icon->win, 24, 24);
++
+ 		icon->pixmap=Tk_GetImage(interp,icon->win,pixmap,ImageChangedProc, (ClientData)icon);
+ 		
+ 		/* Create callback function for event handling */
+@@ -421,9 +401,11 @@
+ 		
+ 		/* Set default icon size hint */
+ 		hint = XAllocSizeHints();
+-		hint->flags |=PMinSize;
++		hint->flags |=PMinSize|PMaxSize;
+ 		hint->min_width=24;
++		hint->max_width=64;
+ 		hint->min_height=24;
++		hint->max_height=64;
+ 	
+ 		XSetWMNormalHints(display,Tk_WindowId(icon->win),hint);
+ 		XFree(hint);
--- amsn-0.9.7.2_2.patch ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->lme 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed Dec 24 17:40:10 UTC 2008 
Responsible-Changed-Why:  
Submitter has GNATS access (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129914 
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Wed Dec 24 17:40:14 UTC 2008 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129914 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: yinjieh@csie.nctu.edu.tw
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/129914: [patch] net-im/amsn: fix tray icon issues with fluxbox / stalonetray
Date: Wed, 24 Dec 2008 17:40:12 UT

 Maintainer of net-im/amsn,
 
 Please note that PR ports/129914 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/129914
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org
State-Changed-From-To: feedback->closed 
State-Changed-By: lme 
State-Changed-When: Sat Jan 31 13:05:04 UTC 2009 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129914 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/129914: commit references a PR
Date: Sat, 31 Jan 2009 13:05:07 +0000 (UTC)

 lme         2009-01-31 13:04:50 UTC
 
   FreeBSD ports repository
 
   Modified files:
     net-im/amsn          Makefile 
   Added files:
     net-im/amsn/files    patch-utils-linux-traydock-libtray.c 
   Log:
   - Fix tray icon issues with fluxbox / stalonetray
   - Bump PORTREVISION
   
   PR:         ports/129914
   
   Revision  Changes    Path
   1.37      +1 -1      ports/net-im/amsn/Makefile
   1.1       +191 -0    ports/net-im/amsn/files/patch-utils-linux-traydock-libtray.c (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
