File: patch

package info (click to toggle)
xbatt 1.2-4
  • links: PTS
  • area: main
  • in suites: potato
  • size: 176 kB
  • ctags: 456
  • sloc: ansic: 572; makefile: 492
file content (108 lines) | stat: -rw-r--r-- 3,616 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
--- xbatt-1.2.orig/xbatt.c	Tue Jan 21 23:21:27 1997
+++ xbatt-1.2/xbatt.c	Tue Jun  2 12:22:04 1998
@@ -126,6 +126,9 @@
 static	int		forceRedraw = 0;
 static	int		apmfd = 0;
 static	Widget		toplevel;
+/* >>>> written by kawamura@debian.org */
+static	Widget		icon;
+/* <<<< written by kawamura@debian.org */
 static	Pixmap		xpmData, xpmMask;
 static	GC		gc;
 static	XpmAttributes	attr;
@@ -179,9 +182,11 @@
   char	*argv[]
 ) {
     XSizeHints		size_hints;
+    XWMHints		hints;
     Visual*	visual;
     int		depth;
     XtAppContext appContext;
+    Boolean	withdrawn = False;
 
 #if !defined(NOAPM) && defined(__FreeBSD__)
     /* initialize APM Interface */
@@ -199,12 +204,22 @@
 				 options, XtNumber(options),
 				 &argc, argv, NULL, 
 				 sessionShellWidgetClass, NULL, ZERO);
-    if (!toplevel) {
+/* >>>> written by kawamura@debian.org */
+    icon = XtVaCreateManagedWidget("icon", sessionShellWidgetClass,
+				   toplevel, NULL);
+/* <<<< written by kawamura@debian.org */
+    if (!toplevel || !icon) {	/* added `|| !icon' by kawamura@debian.org */
 	fprintf(stderr, "xbatt: cannot start x-session\n");
 	exit(1);
     }
+/* >>>> written by kawamura@debian.org */
+    if (argv[1] && strcasecmp(argv[1], "-withdrawn") == 0) {
+	withdrawn = True;
+	argc--;
+    }
+/* <<<< written by kawamura@debian.org */
     if (argc != 1) {
-	fprintf(stderr, "usage: xbatt [X-Toolkit standard option]\n");
+	fprintf(stderr, "usage: xbatt [X-Toolkit standard option|-withdrawn]\n"); /* added `|-withdrawn' by kawamura@debian.org */
 	exit(1);
     }
 
@@ -259,10 +274,28 @@
 		      (XtEventHandler)CallbackEnter, NULL);
     XtAddEventHandler(toplevel, LeaveWindowMask, False,
 		      (XtEventHandler)CallbackLeave, NULL);
+/* >>>> written by kawamura@debian.org */
+    XtAddEventHandler(icon, KeyPressMask, False,
+		      (XtEventHandler)CallbackTyped, NULL);
+    XtAddEventHandler(icon, EnterWindowMask, False,
+		      (XtEventHandler)CallbackEnter, NULL);
+    XtAddEventHandler(icon, LeaveWindowMask, False,
+		      (XtEventHandler)CallbackLeave, NULL);
+/* <<<< written by kawamura@debian.org */
 
     /* display current battery status, and set timer callback */
     updateStatus(NULL, NULL);
 
+/* >>>> written by kawamura@debian.org */
+    /* specify initial state and icon window */
+    if (withdrawn) {
+	hints.flags = StateHint | IconWindowHint;
+	hints.icon_window = XtWindow(icon);
+	hints.initial_state = WithdrawnState;
+	XSetWMHints(XtDisplay(toplevel), XtWindow(toplevel), &hints); 
+    }
+/* <<<< written by kawamura@debian.org */
+
     /* start main loop */
     XtAppMainLoop(appContext);
 
@@ -591,17 +624,29 @@
     }
 
     /* set pixmap data */
+/* >>>> written by kawamura@debian.org */
+    XSetWindowBackgroundPixmap(XtDisplay(toplevel),
+			       XtWindow(icon),
+			       xpmData);
+/* <<<< written by kawamura@debian.org */
     XSetWindowBackgroundPixmap(XtDisplay(toplevel),
 			       XtWindow(toplevel),
 			       xpmData);
 
     /* if pixmap has transparent pixel, set mask pixmap */
     if (xpmMask) {
+/* >>>> written by kawamura@debian.org */
+	XShapeCombineMask(XtDisplay(toplevel), XtWindow(icon),
+			  ShapeBounding, 0, 0, xpmMask, ShapeSet);
+/* <<<< written by kawamura@debian.org */
 	XShapeCombineMask(XtDisplay(toplevel), XtWindow(toplevel),
 			  ShapeBounding, 0, 0, xpmMask, ShapeSet);
     }
 
     /* redraw window */
+/* >>>> written by kawamura@debian.org */
+    XClearWindow(XtDisplay(toplevel), XtWindow(icon));
+/* <<<< written by kawamura@debian.org */
     XClearWindow(XtDisplay(toplevel), XtWindow(toplevel));
 
     /* map window */