View | Details | Raw Unified | Return to bug 129914
Collapse All | Expand All

(-)Makefile (-1 / +1 lines)
Lines 7-13 Link Here
7
7
8
PORTNAME=	amsn
8
PORTNAME=	amsn
9
PORTVERSION=	0.97.2
9
PORTVERSION=	0.97.2
10
PORTREVISION=	1
10
PORTREVISION=	2
11
CATEGORIES=	net-im
11
CATEGORIES=	net-im
12
MASTER_SITES=	SF
12
MASTER_SITES=	SF
13
13
(-)files/patch-utils-linux-traydock-libtray.c (+191 lines)
Added Link Here
1
--- utils/linux/traydock/libtray.c.orig	2008-12-24 11:30:51.000000000 +0100
2
+++ utils/linux/traydock/libtray.c	2008-12-24 11:32:00.000000000 +0100
3
@@ -128,70 +128,25 @@
4
     //}
5
 }
6
 
7
-static char
8
-*get_wm_name (void)
9
-{
10
-	int screen = DefaultScreen(display);
11
-	Atom type;
12
-	int format;
13
-	unsigned long bytes_returned, n_returned;
14
-	unsigned char *buffer;
15
-	
16
-	Window root = RootWindow(display, screen);
17
-	Window *child;
18
-	Atom supwmcheck = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
19
-	Atom wmname = XInternAtom(display, "_NET_WM_NAME", False);
20
-	
21
-	XGetWindowProperty(display, root, supwmcheck, 0, 8, False, AnyPropertyType, &type, &format, &n_returned,
22
-			&bytes_returned, (unsigned char **)&child);
23
-	
24
-	if (n_returned != 1) return NULL;
25
-	
26
-	XGetWindowProperty(display, *child, wmname, 0, 128, False, AnyPropertyType, &type, &format, &n_returned,
27
-			&bytes_returned, &buffer);
28
-	
29
-	if (n_returned == 0) return NULL;
30
-	
31
-	XFree(child);
32
-	return (char *) buffer;
33
-}
34
-
35
 /* Procedure that Docks the icon */
36
 static void
37
 DockIcon(ClientData clientData)
38
 {
39
 
40
-	Window root, parent, *children;
41
-	unsigned int n, ret, atom;
42
+	Window parent;
43
+	unsigned int ret, atom;
44
 	TrayIcon *icon= clientData;
45
 	char* wm_name;
46
 
47
-	Tk_MapWindow(icon->win);
48
-
49
-	XQueryTree(display, Tk_WindowId(icon->win), &root, &parent, &children, &n);
50
-	XFree(children);
51
+    Tk_MakeWindowExist(icon->win);
52
 
53
 	Tk_SetWindowBackgroundPixmap(icon->win, ParentRelative);
54
-	XSetWindowBackgroundPixmap(display, parent, ParentRelative);
55
 
56
 	xembed_set_info(icon->win,XEMBED_MAPPED);
57
 
58
-	Tk_UnmapWindow(icon->win);
59
-
60
-	if ( (atom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", True )) == None ) {
61
-		wm_name = get_wm_name();
62
-		if (wm_name != NULL && !strcmp(wm_name, "KWin")) {
63
-			atom = XInternAtom(display, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False);
64
-			ret = XChangeProperty(display, parent, atom,
65
-				XA_WINDOW, 32, PropModeReplace, (unsigned char *)&parent, 1);
66
-			Tk_MapWindow(icon->win);
67
-		}
68
-		XFree(wm_name);
69
-	} else {
70
-		send_message(display,systemtray, atom,
71
-				SYSTEM_TRAY_REQUEST_DOCK,Tk_WindowId(icon->win),0,0);
72
-	}
73
-
74
+	atom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", False );
75
+	send_message(display,systemtray, atom,
76
+			SYSTEM_TRAY_REQUEST_DOCK,Tk_WindowId(icon->win),0,0);
77
 }
78
 
79
 /* Draw the icon */
80
@@ -204,10 +159,32 @@
81
 	int widthImg, heightImg;
82
 	Window r;
83
 	char cmdBuffer[1024];
84
+	XSizeHints *hints = NULL;
85
+	long supplied = 0;
86
 
87
 	XGetGeometry(display, Tk_WindowId(icon->win), &r, &x, &y, &w, &h, &b, &d);
88
 	XClearWindow(display, Tk_WindowId(icon->win));
89
 
90
+	/*
91
+	 * Here we get the window hints because in some cases the XGetGeometry
92
+	 * function returns the wrong width/height. We only check that 
93
+	 * min_width <= width <= max_width and min_height <= height <= max_height
94
+	 */
95
+	hints = XAllocSizeHints();
96
+	XGetWMNormalHints(display, Tk_WindowId(icon->win), hints, &supplied);
97
+	if( supplied & PMaxSize ) {
98
+		w = (hints->max_width < w) ? hints->max_width : w;
99
+		h = (hints->max_height < h) ? hints->max_height : h;
100
+	}
101
+	if( supplied & PMinSize ) {
102
+		w = (hints->min_width > w) ? hints->min_width : w;
103
+		h = (hints->min_height > h) ? hints->min_height : h;
104
+	}
105
+	if(hints) {
106
+		XFree(hints);
107
+		hints = NULL;
108
+	}
109
+
110
 	if (((icon->width != w) || (icon->height != h) || (icon->mustUpdate)) && (icon->cmdCallback[0] != '\0')) {
111
 		snprintf(cmdBuffer,sizeof(cmdBuffer),"%s %u %u",icon->cmdCallback,w,h);
112
 		Tcl_EvalEx(globalinterp,cmdBuffer,-1,TCL_EVAL_GLOBAL);
113
@@ -222,6 +199,8 @@
114
 	if (heightImg > h)
115
 		heightImg = h;
116
 
117
+	if( !Tk_IsMapped(icon->win) )
118
+		Tk_MapWindow(icon->win);
119
 	Tk_RedrawImage(icon->pixmap, 0, 0, widthImg, heightImg, Tk_WindowId(icon->win), (w-widthImg)/2 , (h-heightImg)/2 );
120
 
121
 }
122
@@ -328,6 +307,12 @@
123
 	XSizeHints *hint;
124
 	char cmdBuffer[1024];
125
 
126
+	/* systemtray was not available in Init */
127
+	if (systemtray==0) {
128
+		Tcl_AppendResult (interp, "cannot create a tray icon without a system tray", (char *) NULL);
129
+		return TCL_ERROR;
130
+	}
131
+
132
 	/* Get memory for trayicon data and zero it*/
133
 	icon = (TrayIcon *) malloc(sizeof(TrayIcon));
134
 	memset((void *) icon, 0, (sizeof(TrayIcon)));
135
@@ -335,18 +320,11 @@
136
 	
137
 	mainw=Tk_MainWindow(interp);
138
 
139
-	/* systemtray was not available in Init */
140
-	if (systemtray==0) {
141
-		Tcl_AppendResult (interp, "cannot create a tray icon without a system tray", (char *) NULL);
142
-		return TCL_ERROR;
143
-	}
144
-
145
 	/* Get the first argument string (object name) and check it */
146
 	arg=Tcl_GetStringFromObj(objv[1],(int *) &length);
147
 	//printf("Arg: %s\n",arg);
148
-	if (strncmp(arg,".",1)) {
149
-		Tcl_AppendResult (interp, "bad path name: ",
150
-			Tcl_GetStringFromObj(objv[1],(int *) &length) , (char *) NULL);
151
+	if (arg == NULL || length < 1 || strncmp(arg, ".", 1)) {
152
+		Tcl_AppendResult (interp, "bad path name: ", arg , (char *) NULL);
153
 		return TCL_ERROR;
154
 	}
155
 	
156
@@ -391,7 +369,7 @@
157
 				n++;
158
 				strcpy (icon->tooltip,Tcl_GetStringFromObj(objv[n],(int *) &length));
159
 			} else if (!strncmp(arg,"-command",length)) {
160
-				/* Copy tooltip string */
161
+				/* Copy command string */
162
 				n++;
163
 				strcpy (icon->cmdCallback,Tcl_GetStringFromObj(objv[n],(int *) &length));
164
 			} else {
165
@@ -408,10 +386,12 @@
166
 	if (pixmap != NULL) {
167
 		/* Create the window */
168
 		icon->win=Tk_CreateWindowFromPath(interp,mainw,
169
-				Tcl_GetStringFromObj(objv[1],(int *) &length),"");
170
+				Tcl_GetStringFromObj(objv[1],(int *) &length),NULL);
171
 
172
 		DockIcon((ClientData)icon);
173
 
174
+		Tk_GeometryRequest( icon->win, 24, 24);
175
+
176
 		icon->pixmap=Tk_GetImage(interp,icon->win,pixmap,ImageChangedProc, (ClientData)icon);
177
 		
178
 		/* Create callback function for event handling */
179
@@ -421,9 +401,11 @@
180
 		
181
 		/* Set default icon size hint */
182
 		hint = XAllocSizeHints();
183
-		hint->flags |=PMinSize;
184
+		hint->flags |=PMinSize|PMaxSize;
185
 		hint->min_width=24;
186
+		hint->max_width=64;
187
 		hint->min_height=24;
188
+		hint->max_height=64;
189
 	
190
 		XSetWMNormalHints(display,Tk_WindowId(icon->win),hint);
191
 		XFree(hint);

Return to bug 129914