summarylogtreecommitdiffstats
path: root/xzoom.diff
blob: 7b30cd0e177d5d050e312c8bd248ec3be7a57b8a (plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
diff -Naur xzoom-0.3/debian/changelog xzoom-0.3.patched/debian/changelog
--- xzoom-0.3/debian/changelog	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/debian/changelog	2024-12-28 08:21:51.434313760 +0100
@@ -0,0 +1,187 @@
+xzoom (0.3-24) unstable; urgency=medium
+
+  * QA upload.
+  * Set Maintainer to Debian QA group as this package is orphaned.
+  * Add .desktop file, thanks to Martin Wimpress at Launchpad (Closes:
+    #1368188)
+
+ -- Iain Lane <laney@debian.org>  Mon, 29 Sep 2014 13:16:32 +0100
+
+xzoom (0.3-23) unstable; urgency=low
+
+  [ Anibal Avelar ]
+  * New mantainer 
+  * Fixed the FTBFS bug added the xutils-dev dependency.
+    (Closes: #485733)
+  * Bumped to Standards-version 3.8.0.
+  * Added the Homepage field in the debian/control file.
+  * Cleaned the debian/copyright file with cosmetic changes.
+
+  [ Piotr Ożarowski ]
+  * debian/watch file added
+
+ -- Anibal Avelar <aavelar@cofradia.org>  Sun, 15 Jun 2008 22:27:53 -0400
+
+xzoom (0.3-22) unstable; urgency=low
+
+  * Cap menu item. Closes: #438103
+
+ -- Joey Hess <joeyh@debian.org>  Wed, 15 Aug 2007 13:29:53 -0400
+
+xzoom (0.3-21) unstable; urgency=low
+
+  * Maintaining this package again.
+  * Improve description, fix typos.
+  * Remove debian/pbuild-test directory, seems to be added by accident.
+  * De-dpatchify (personal preference).
+  * Clean up rules file.
+  * Remove various autogenerated files from source package, seems they were
+    added by accident.
+  * debhelper v5.
+  * The Apps/Tools menu is obsolete. Use Applications/Accessibility, 
+    hope that's not too big a stretch.
+  * Remove CVS dirs from debian patch.
+
+ -- Joey Hess <joeyh@debian.org>  Tue, 07 Aug 2007 22:01:43 -0700
+
+xzoom (0.3-20) unstable; urgency=low
+
+  * orphan
+
+ -- Junichi Uekawa <dancer@debian.org>  Sat, 04 Aug 2007 09:37:51 +0900
+
+xzoom (0.3-19) unstable; urgency=low
+
+  * Standards-version: 3.7.2
+  * debian/compat: 4
+
+ -- Junichi Uekawa <dancer@debian.org>  Sat,  2 Sep 2006 19:42:17 +0900
+
+xzoom (0.3-18) unstable; urgency=low
+
+  * support for X11R7, and install to standard FHS locations.
+    (Closes: #364168).
+  * use dpatch.
+  * quote menu item string.
+  * Standards-version: 3.6.2
+
+ -- Junichi Uekawa <dancer@debian.org>  Sat, 22 Apr 2006 12:50:12 +0900
+
+xzoom (0.3-17) unstable; urgency=low
+
+  * Bug fix: "xzoom: FTBFS: build-depends on removed xlibs-dev"
+    Changed to x-dev, libxext-dev, libxt-dev (Closes: #346867). 
+  * Bug fix: "'man xzoom' typo: "magniications"", thanks to A
+    Costa (Closes: #306710).
+  * add simple test for resulting binary.
+
+ -- Junichi Uekawa <dancer@debian.org>  Mon,  9 Jan 2006 13:10:09 +0900
+
+xzoom (0.3-16) unstable; urgency=low
+
+  * New maintainer (closes: #202330)
+  * Standards-version: 3.6.0
+  * Modified the package description.
+
+ -- Junichi Uekawa <dancer@debian.org>  Sat,  9 Aug 2003 07:38:11 +0900
+
+xzoom (0.3-15) unstable; urgency=low
+
+  * orphaned; set maintainer to packages@qa.debian.org
+
+ -- tony mancill <tmancill@debian.org>  Mon, 21 Jul 2003 15:46:51 -0700
+
+xzoom (0.3-14) unstable; urgency=low
+
+  * updated build-depends for sid (closes: #170185)
+
+ -- tony mancill <tmancill@debian.org>  Sat, 23 Nov 2002 16:04:04 -0800
+
+xzoom (0.3-13) unstable; urgency=low
+
+  * updated manpage (closes: #93253)
+  * hacked in WM_DELETE_WINDOW support (closes: #93250)
+    (you can now use standard window manager methods to close the client)
+
+ -- tony mancill <tmancill@debian.org>  Tue, 12 Feb 2002 22:59:09 -0800
+
+xzoom (0.3-12) unstable; urgency=low
+
+  * binaries built against xfree 4.x for woody release
+
+ -- tony mancill <tmancill@debian.org>  Mon, 26 Nov 2001 20:08:29 -0800
+
+xzoom (0.3-11) unstable; urgency=low
+
+  * new maintainer <tmancill@debian.org> (Closes: bug#69658)
+
+ -- tony mancill <tmancill@debian.org>  Mon, 28 Aug 2000 17:43:02 -0700
+
+xzoom (0.3-10) unstable; urgency=low
+
+  * Build deps.
+
+ -- Joey Hess <joeyh@debian.org>  Sat,  4 Dec 1999 18:42:28 -0800
+
+xzoom (0.3-9) unstable; urgency=low
+
+  * FHS
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 12 Sep 1999 14:27:43 -0700
+
+xzoom (0.3-8) unstable; urgency=low
+
+  * Fixed package description: no longer limited to 8bpp.
+  * Documented the 'g' key in the man page.
+
+ -- Joey Hess <joeyh@debian.org>  Wed, 25 Feb 1998 11:09:59 -0800
+
+xzoom (0.3-7) unstable; urgency=low
+
+  * Added changes from Markus F.X.J. Oberhumer 
+    <k3040e4@c210.edvz.uni-linz.ac.at>, for greater than 8 bpp support 
+    plus some other features.
+
+ -- Joey Hess <joeyh@debian.org>  Thu, 19 Feb 1998 10:59:43 -0800
+
+xzoom (0.3-6) unstable; urgency=low
+
+  * Moved binary to /usr/X11R6/bin.
+
+ -- Joey Hess <joeyh@debian.org>  Mon,  9 Feb 1998 12:44:08 -0800
+
+xzoom (0.3-5) unstable; urgency=low
+
+  * Use debhelper.
+
+ -- Joey Hess <joeyh@debian.org>  Sat,  7 Feb 1998 20:48:22 -0800
+
+xzoom (0.3-4) unstable; urgency=low
+
+  * libc6.
+  * Routine update of debian/rules:
+    Fixed binary-indep target.
+
+ -- Joey Hess <joeyh@debian.org>  Mon,  8 Sep 1997 14:08:03 -0400
+
+xzoom (0.3-3) unstable; urgency=low
+
+  * Added note to description that it only works at 8bpp.
+
+ -- Joey Hess <joeyh@debian.org>  Thu,  5 Jun 1997 19:36:27 -0400
+
+xzoom (0.3-2) unstable; urgency=low
+
+  * Fixed man page permissions. (#10275)
+  * Moved man page to X11R6.
+  * Updated menu file to menu-1 format.
+  * Routine update of debian/rules:
+    Run dpkg-gencontrol after debstd, and delete substvars during clean.
+
+ -- Joey Hess <joeyh@debian.org>  Sun,  1 Jun 1997 14:12:42 -0400
+
+xzoom (0.3-1) unstable; urgency=low
+
+  * First release.
+
+ -- Joey Hess <joeyh@debian.org>  Sat, 8 Mar 1997 15:30:09 -0500
diff -Naur xzoom-0.3/debian/compat xzoom-0.3.patched/debian/compat
--- xzoom-0.3/debian/compat	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/debian/compat	2024-12-28 08:21:51.434313760 +0100
@@ -0,0 +1 @@
+5
diff -Naur xzoom-0.3/debian/control xzoom-0.3.patched/debian/control
--- xzoom-0.3/debian/control	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/debian/control	2024-12-28 08:21:51.434313760 +0100
@@ -0,0 +1,17 @@
+Source: xzoom
+Section: x11
+Priority: optional
+Build-Depends: debhelper (>= 5), libxext-dev, libxt-dev, xutils-dev
+Maintainer: Debian QA Group <packages@qa.debian.org>
+Homepage: ftp://sunsite.unc.edu/pub/linux/libs/X/
+Standards-Version: 3.8.0
+
+Package: xzoom
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: magnify part of X display, with real-time updates
+ Like xmag, xzoom magnifies a section of the X display. Xzoom is different
+ because it will continuously update the magnified area as the display
+ changes. It is fast enough to enlarge small animations, for example.
+ .
+ It can also mirror or rotate a part of the screen.
diff -Naur xzoom-0.3/debian/copyright xzoom-0.3.patched/debian/copyright
--- xzoom-0.3/debian/copyright	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/debian/copyright	2024-12-28 08:21:51.434313760 +0100
@@ -0,0 +1,22 @@
+This package was maintained by tony mancill <tmancill@debian.org>, for a 
+while, and then picked up by Junichi Uekawa <dancer@debian.org>. Since Sun, 15 Jun 2008 maintained by Anibal Avelar <aavelar@cofradia.org>.
+
+This package was put together by Joey Hess <joeyh@debian.org>, using
+sources from:
+	ftp://sunsite.unc.edu/pub/linux/libs/X/xzoom-0.3.tgz
+
+Copyright: 1995-2008 Itai Nahshon
+
+License:
+
+   This program is distributed with no warranty.
+
+   Source files for this program may be distributed freely.
+   Modifications to this file are okay as long as:
+    a. This copyright notice and comment are preserved and
+     left at the top of the file.
+    b. The man page is fixed to reflect the change.
+    c. The author of this change adds his name and change
+     description to the list of changes below.
+   Executable files may be distributed with sources, or with
+   exact location where the source code can be obtained.
diff -Naur xzoom-0.3/debian/install xzoom-0.3.patched/debian/install
--- xzoom-0.3/debian/install	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/debian/install	2024-12-28 08:21:51.437647056 +0100
@@ -0,0 +1 @@
+debian/xzoom.desktop usr/share/applications
diff -Naur xzoom-0.3/debian/menu xzoom-0.3.patched/debian/menu
--- xzoom-0.3/debian/menu	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/debian/menu	2024-12-28 08:21:51.437647056 +0100
@@ -0,0 +1,2 @@
+?package(xzoom):needs="x11" section="Applications/Accessibility" \
+	title="Xzoom" command="xzoom"
diff -Naur xzoom-0.3/debian/rules xzoom-0.3.patched/debian/rules
--- xzoom-0.3/debian/rules	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/debian/rules	2024-12-28 08:21:51.437647056 +0100
@@ -0,0 +1,39 @@
+#!/usr/bin/make -f
+
+build: build-stamp 
+build-stamp:
+	dh_testdir
+	xmkmf -a
+	$(MAKE)
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+	if [ -e Makefile ]; then $(MAKE) -i clean; fi
+	dh_clean Makefile
+
+binary-indep: build
+
+binary-arch: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	$(MAKE) DESTDIR=debian/xzoom install
+	dh_installman xzoom.man
+	dh_installdocs README
+	dh_installmenu
+	dh_installchangelogs
+	dh_install
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary
diff -Naur xzoom-0.3/debian/watch xzoom-0.3.patched/debian/watch
--- xzoom-0.3/debian/watch	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/debian/watch	2024-12-28 08:21:51.437647056 +0100
@@ -0,0 +1,2 @@
+version=3
+ftp://sunsite.unc.edu/pub/linux/libs/X/xzoom-(.*)\.tgz
diff -Naur xzoom-0.3/debian/xzoom.desktop xzoom-0.3.patched/debian/xzoom.desktop
--- xzoom-0.3/debian/xzoom.desktop	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/debian/xzoom.desktop	2024-12-28 08:21:51.437647056 +0100
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=Screen Magnifier
+GenericName=Screen Magnifier
+Comment=Magnify part of display, with real-time updates.
+Keywords=screen magnifier;
+Exec=xzoom -mag 3 -geometry 320x240
+Icon=system-search
+Terminal=false
+Type=Application
+StartupNotify=true
+Categories=GTK;GNOME;Utility;Accessibility;
diff -Naur xzoom-0.3/Imakefile xzoom-0.3.patched/Imakefile
--- xzoom-0.3/Imakefile	1996-04-17 11:04:51.000000000 +0200
+++ xzoom-0.3.patched/Imakefile	2024-12-28 08:21:51.434313760 +0100
@@ -15,11 +15,11 @@
 
 DEFINES = -DFRAME -DXSHM
 
-LOCAL_LIBRARIES = -lXext -lX11
+LOCAL_LIBRARIES = -lXext -lX11 -lXt
 
 NAME = xzoom
 
-BINDIR = /usr/local/bin
-MANPATH = /usr/local/man
+BINDIR = /usr/bin
+MANPATH = /usr/share/man
 
 SimpleProgramTarget($(NAME))
diff -Naur xzoom-0.3/scale.h xzoom-0.3.patched/scale.h
--- xzoom-0.3/scale.h	1970-01-01 01:00:00.000000000 +0100
+++ xzoom-0.3.patched/scale.h	2024-12-28 08:21:51.437647056 +0100
@@ -0,0 +1,102 @@
+/* scale image from SRC to DST - parameterized by type T */
+
+/* get pixel address of point (x,y) in image t */
+#define getP(t,x,y) \
+	(T *) (&ximage[t]->data[(ximage[t]->xoffset+(x))*sizeof(T) + \
+	                        (y)*ximage[t]->bytes_per_line])
+
+{
+	int i, j, k;
+
+	/* copy scaled lines from SRC to DST */
+	j = flipxy ? width[SRC] - 1 : height[SRC] - 1;
+	do {
+		T *p1;
+		T *p2;
+		int p2step;
+		T *p1_save;
+
+		/* p1 point to begining of scanline j*magy in DST */
+		p1 = getP(DST,0,j*magy);
+		p1_save = p1;
+		/* p2 point to begining of scanline j in SRC */
+		/* if flipy then line height[SRC]-1-j */
+		p2 = getP(SRC,0,flipy ? (height[SRC]-1-j) : j);
+
+		if (flipxy)
+		{
+			p2 = getP(SRC,flipy ? j : (width[SRC]-1-j),0);
+			p2step = ximage[SRC]->bytes_per_line / sizeof(T);
+
+			if (flipx)
+			{
+				p2 += p2step * (height[SRC]-1);
+				p2step = -p2step;
+			}
+
+			i = height[SRC];
+			do {
+				T c = *p2; p2 += p2step;
+				k = magx; do *p1++ = c; while (--k > 0);
+			} while (--i > 0);
+		}
+		else if (flipx)
+		{
+			p2 += width[SRC];
+			i = width[SRC];
+			do {
+				T c = *--p2;
+				k = magx; do *p1++ = c; while (--k > 0);
+			} while (--i > 0);
+		}
+		else
+		{
+			i = width[SRC];
+			do {
+				T c = *p2++;
+				k = magx; do *p1++ = c; while (--k > 0);
+			} while (--i > 0);
+		}
+
+		/* draw vertical grid */
+		if (gridy && magx >= 2)
+		{
+			p1 = p1_save - 1;
+			i = magx;
+			k = flipxy ? height[SRC] : width[SRC];
+			do {
+				p1 += i;
+				*p1 ^= ~((T)0);
+			} while (--k > 0);
+		}
+
+		/* duplicate that line as needed */
+		if (magy > 1)
+		{
+			/* p1 point to begining of scanline j*magy in DST */
+			p1 = p1_save;
+			/* p2 points to begining of next line */
+			p2 = p1;
+			p2step = ximage[DST]->bytes_per_line / sizeof(T);
+
+			i = width[DST] * sizeof(T);
+			k = magy - 1;
+			do {
+				p2 += p2step;
+				memcpy(p2, p1, i);
+			} while (--k > 0);
+
+			/* draw horizontal grid */
+			if (gridx && magy >= 2)
+			{
+				k = width[DST];
+				do {
+					*p2++ ^= ~((T)0);
+				} while (--k > 0);
+			}
+		}
+	} while (--j >= 0);
+}
+
+#undef getP
+
diff -Naur xzoom-0.3/xzoom.c xzoom-0.3.patched/xzoom.c
--- xzoom-0.3/xzoom.c	1996-05-29 11:40:51.000000000 +0200
+++ xzoom-0.3.patched/xzoom.c	2024-12-28 08:23:09.723432163 +0100
@@ -12,18 +12,28 @@
    exact location where the source code can be obtained.
 
 Changelist:
-Author			Description
-------			-----------
-Itai Nahshon	Version 0.1, Nov. 21 1995
-Itai Nahshon    Version 0.2, Apr. 17 1996
-		include <sys/types.h>
-		Use memmove() instead of memcopy()
-		Optional macro to replace call to usleep().
+Author                    Description
+------                    -----------
+Itai Nahshon              Version 0.1, Nov. 21 1995
+Itai Nahshon              Version 0.2, Apr. 17 1996
+                          include <sys/types.h>
+                          Use memmove() instead of memcopy()
+                          Optional macro to replace call to usleep().
+Markus F.X.J. Oberhumer   Version 0.4, Feb. 18 1998
+                          split into 2 files (scale.h)
+                          added support for 15, 16, 24 and 32 bpp displays
+                          added a grid (press key 'g')
+                          optimized scaling routines
+                          use memcpy() instead of memmove() ;-)
+                          some other minor changes/fixes
+tony mancill		2002/02/13 <tmancill@debian.org>
+			hacked in support for WM_DELETE_WINDOW
 */
 
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <sys/types.h>
 #include <sys/signal.h>
 
@@ -48,6 +58,9 @@
 Display *dpy;
 Screen *scr;
 Window win;
+Atom wm_delete_window;
+Atom wm_protocols;
+Status status;
 
 GC gc;
 #ifdef FRAME
@@ -87,8 +100,12 @@
 int xzoom_flag = False;			/* next mag change only to magx */
 int yzoom_flag = False;			/* next mag change only to magy */
 
+int gridx = False;
+int gridy = False;
+
 int width[2] = { 0, WIDTH };
 int height[2] = { 0, HEIGHT };
+unsigned depth = 0;
 
 #ifdef XSHM
 XShmSegmentInfo shminfo[2];			/* Segment info.  */
@@ -106,6 +123,7 @@
 void
 timeout_func(int signum) {
 	set_title = True;
+	signum = signum;          /* UNUSED */
 }
 
 #ifdef FRAME
@@ -116,9 +134,6 @@
 void
 allocate_images(void) {
 	int i;
-#ifndef XSHM
-	char *data;
-#endif
 
 	for(i = 0; i < 2; i++) {
 
@@ -137,7 +152,7 @@
 		shminfo[i].shmid = shmget(IPC_PRIVATE,
 			(unsigned int)(ximage[i]->bytes_per_line * ximage[i]->height),
 			IPC_CREAT | 0777);
-		
+
 		if(shminfo[i].shmid < 0) {
 			perror("shmget");
 			exit(-1);
@@ -163,20 +178,21 @@
 
 		shmctl(shminfo[i].shmid, IPC_RMID, 0);
 #else
-		data = malloc(width[i] * height[i]);
+		char *data;
+		data = malloc(BitmapUnit(dpy) / 8 * width[i] * height[i]);
 
 		ximage[i] = XCreateImage(dpy,
 			DefaultVisualOfScreen(scr),
 			DefaultDepthOfScreen(scr),
 			ZPixmap, 0, data,
-			width[i], height[i], 8, width[i]);
+			width[i], height[i], 32, 0);
 
 		if(ximage[i] == NULL) {
 			perror("XCreateImage");
 			exit(-1);
 		}
 
-#endif XSHM
+#endif /* XSHM */
 	}
 	created_images = True;
 }
@@ -185,6 +201,9 @@
 destroy_images(void) {
 	int i;
 
+	if (!created_images)
+		return;
+
 	for(i = 0; i < 2; i++) {
 #ifdef XSHM
 		XShmDetach(dpy, &shminfo[i]);	/* ask X11 to detach shared segment */
@@ -195,6 +214,8 @@
 		ximage[i]->data = NULL;			/* remove refrence to that address */
 		XDestroyImage(ximage[i]);		/* and destroy image */
 	}
+
+	created_images = False;
 }
 
 void
@@ -230,8 +251,7 @@
 void
 resize(int new_width, int new_height) {
 
-	if(created_images)
-		destroy_images();		/* we can get rid of these */
+	destroy_images();		/* we can get rid of these */
 
 	/* find new dimensions for source */
 
@@ -244,9 +264,13 @@
 		height[SRC] = (new_height+magy-1) / magy;
 	}
 
+	if(width[SRC] < 1)
+		width[SRC] = 1;
 	if(width[SRC] > WidthOfScreen(scr))
 		width[SRC] = WidthOfScreen(scr);
 
+	if(height[SRC] < 1)
+		height[SRC] = 1;
 	if(height[SRC] > HeightOfScreen(scr))
 		height[SRC] = HeightOfScreen(scr);
 
@@ -270,12 +294,34 @@
 		height[DST] = new_height;
 }
 
+
+void scale8(void)
+{
+#define T unsigned char
+#include "scale.h"
+#undef T
+}
+
+
+void scale16(void)
+{
+#define T unsigned short
+#include "scale.h"
+#undef T
+}
+
+
+void scale32(void)
+{
+#define T unsigned int
+#include "scale.h"
+#undef T
+}
+
+
 int
 main(int argc, char **argv) {
 	XSetWindowAttributes xswa;
-	int i, j, k;
-	char c;
-	char *p1, *p2;
 	XEvent event;
 	int buttonpressed = False;
 	int unmapped = True;
@@ -286,8 +332,9 @@
 	int source_geom_mask = NoValue,
 	    dest_geom_mask = NoValue,
 	    copy_from_src_mask;
-	int xpos = 0, ypos = 0; 
+	int xpos = 0, ypos = 0;
 
+	atexit(destroy_images);
 	progname = strrchr(argv[0], '/');
 	if(progname)
 		++progname;
@@ -312,7 +359,7 @@
 
 			if(magx <= 0)
 				Usage();
-			
+
 
 			magy = argc > 1 ? atoi(argv[1]) : -1;
 
@@ -340,7 +387,7 @@
 			flipxy = True;
 			continue;
 		}
-		
+
 		if(!strcmp(argv[0], "-source")) {
 			++argv; --argc;
 
@@ -438,23 +485,24 @@
 
 	scr = DefaultScreenOfDisplay(dpy);
 
-	if(DefaultDepthOfScreen(scr) != 8) {
-		fprintf(stderr, "%s: can work only with 8 bits/pixel\n", progname);
+	depth = DefaultDepthOfScreen(scr);
+	if (depth < 8) {
+		fprintf(stderr, "%s: need at least 8 bits/pixel\n", progname);
 		exit(1);
 	}
 
 	if(source_geom_mask & XNegative)
 		xgrab += WidthOfScreen(scr);
-	
+
 	if(source_geom_mask & YNegative)
 		ygrab += HeightOfScreen(scr);
 
 	if(dest_geom_mask & XNegative)
 		xpos += WidthOfScreen(scr);
-	
+
 	if(source_geom_mask & YNegative)
 		ypos += HeightOfScreen(scr);
-	
+
 	/* printf("=%dx%d+%d+%d\n", width[DST], height[DST], xpos, ypos); */
 
 	xswa.event_mask = ButtonPressMask|ButtonReleaseMask|ButtonMotionMask;
@@ -463,24 +511,33 @@
 	xswa.background_pixel = BlackPixelOfScreen(scr);
 
 	win = XCreateWindow(dpy, RootWindowOfScreen(scr),
-	    xpos, ypos, width[DST], height[DST], 0, 
+	    xpos, ypos, width[DST], height[DST], 0,
 	    DefaultDepthOfScreen(scr), InputOutput,
 	    DefaultVisualOfScreen(scr),
 	    CWEventMask | CWBackPixel, &xswa);
 
-	XChangeProperty(dpy, win, XA_WM_ICON_NAME, XA_STRING, 8, 
+	XChangeProperty(dpy, win, XA_WM_ICON_NAME, XA_STRING, 8,
 			PropModeReplace,
 			(unsigned char *)progname, strlen(progname));
 
 	/*
-	XChangeProperty(dpy, win, XA_WM_NAME, XA_STRING, 8, 
+	XChangeProperty(dpy, win, XA_WM_NAME, XA_STRING, 8,
 			PropModeReplace,
 			(unsigned char *)progname, strlen(progname));
 	*/
 
+
+ 	/***	20020213
+		code added by <tmancill@debian.org> to handle
+		window manager "close" event
+	***/
+	wm_delete_window = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
+	wm_protocols = XInternAtom(dpy, "WM_PROTOCOLS", False);
+        status = XSetWMProtocols(dpy, win, &wm_delete_window, 1);
+
 	set_title = True;
 
-	XMapWindow(dpy, win);
+	status = XMapWindow(dpy, win);
 
 	gcv.plane_mask = AllPlanes;
 	gcv.subwindow_mode = IncludeInferiors;
@@ -512,7 +569,7 @@
 	{
 		static char bitmap_data[] = { 0 };
 		static XColor col = { 0 };
-		Pixmap curs = XCreatePixmapFromBitmapData(dpy, 
+		Pixmap curs = XCreatePixmapFromBitmapData(dpy,
 			RootWindowOfScreen(scr), bitmap_data, 1, 1, 0, 0, 1);
 
 		when_button = XCreatePixmapCursor(dpy, curs, curs, &col, &col, 0, 0);
@@ -526,11 +583,22 @@
 
 	for(;;) {
 
+		/*****
+		old event loop updated to support WM messages
 		while(unmapped?
 			(XWindowEvent(dpy, win, (long)-1, &event), 1):
 			XCheckWindowEvent(dpy, win, (long)-1, &event)) {
+		******/
 
+		while(XPending(dpy)) {
+			XNextEvent(dpy, &event);
 			switch(event.type) {
+			case ClientMessage:
+                        	if ((event.xclient.message_type == wm_protocols) &&
+                                    (event.xclient.data.l[0] == wm_delete_window)) {
+                                	exit(0);
+                        	}
+                        	break;
 			case ConfigureNotify:
 				if(event.xconfigure.width != width[DST] ||
 				   event.xconfigure.height != height[DST]) {
@@ -567,6 +635,7 @@
 
 				case '+':
 				case '=':
+				case XK_KP_Add:
 					if(!yzoom_flag) ++magx;
 					if(!xzoom_flag) ++magy;
 					xzoom_flag = yzoom_flag = False;
@@ -575,6 +644,7 @@
 					break;
 
 				case '-':
+				case XK_KP_Subtract:
 					if(!yzoom_flag) --magx;
 					if(!xzoom_flag) --magy;
 					xzoom_flag = yzoom_flag = False;
@@ -585,6 +655,7 @@
 					break;
 
 				case XK_Left:
+				case XK_KP_Left:
 					if(flipxy)
 						if(flipx)
 							ygrab += scroll;
@@ -598,6 +669,7 @@
 					break;
 
 				case XK_Right:
+				case XK_KP_Right:
 					if(flipxy)
 						if(flipx)
 							ygrab -= scroll;
@@ -611,6 +683,7 @@
 					break;
 
 				case XK_Up:
+				case XK_KP_Up:
 					if(flipxy)
 						if(flipy)
 							xgrab -= scroll;
@@ -624,6 +697,7 @@
 					break;
 
 				case XK_Down:
+				case XK_KP_Down:
 					if(flipxy)
 						if(flipy)
 							xgrab += scroll;
@@ -666,12 +740,17 @@
 					xzoom_flag = False;
 					break;
 
+				case 'g':
+					gridx = !gridx;
+					gridy = !gridy;
+					break;
+
 				case 'd':
 					if(++delay_index >= NDELAYS)
 						delay_index = 0;
 					delay = delays[delay_index];
 					sprintf(title, "delay = %d ms", delay/1000);
-					XChangeProperty(dpy, win, XA_WM_NAME, XA_STRING, 8, 
+					XChangeProperty(dpy, win, XA_WM_NAME, XA_STRING, 8,
 						PropModeReplace,
 						(unsigned char *)title, strlen(title));
 					signal(SIGALRM, timeout_func);
@@ -717,6 +796,7 @@
 #endif
 				}
 				break;
+
 			}
 
 			/* trying XShmGetImage when part of the rect is
@@ -736,6 +816,7 @@
 
 			if(ygrab > HeightOfScreen(scr)-height[SRC])
 				ygrab = HeightOfScreen(scr)-height[SRC];
+
 		}
 
 #ifdef XSHM
@@ -753,63 +834,12 @@
 		}
 #endif
 
-		/* copy scaled lines from src to dst */
-		for(j = flipxy?width[SRC]:height[SRC]; --j >= 0; ) {
-			/* p1 point to begining of scanline j*magy in DST */
-			p1 = &ximage[DST]->data[ximage[DST]->xoffset +
-					j*magy*ximage[DST]->bytes_per_line ];
-			/* p2 point to begining of scanline j in SRC */
-			/* if flipy then line height[SRC]-1-j */
-			p2 = &ximage[SRC]->data[ximage[SRC]->xoffset +
-					(flipy?(height[SRC]-1-j):j)*ximage[SRC]->bytes_per_line ];
-
-			if(flipxy) {
-				int p2step = ximage[SRC]->bytes_per_line;
-				p2 = &ximage[SRC]->data[ximage[SRC]->xoffset + (flipy?j:(width[SRC]-1-j))];
-
-				if(flipx) {
-					p2 += p2step * (height[SRC]-1);
-					p2step = -p2step;
-				}
-
-				for(i = height[SRC]; --i >= 0;) {
-					c = *p1++ = *p2;
-					p2 += p2step;
-					for(k = magx; --k > 0; )
-						*p1++ = c;
-				}	
-			}
-			else if(flipx) {
-				p2 += width[SRC];
-				for(i = width[SRC]; --i >= 0;) {
-					c = *p1++ = *--p2;
-					for(k = magx; --k > 0; )
-						*p1++ = c;
-				}	
-			}
-			else {
-				for(i = width[SRC]; --i >= 0;) {
-					c = *p1++ = *p2++;
-					for(k = magx; --k > 0; )
-						*p1++ = c;
-				}	
-			}
-
-			/* p1 point to begining of scanline j*magy in DST */
-			p1 = &ximage[DST]->data[ximage[DST]->xoffset +
-										  j*magy*ximage[DST]->bytes_per_line ];
-			/* p2 points to begining of next line */
-			p2 = p1 + ximage[DST]->bytes_per_line;
-			/* duplicate that line as needed */
-			for(k = magy; --k > 0; ) {
-#ifdef BCOPY
-				bcopy(p1, p2, width[DST]);
-#else
-				memmove(p2, p1, width[DST]);
-#endif
-				p2 += ximage[DST]->bytes_per_line;
-			}
-		}
+		if (depth == 8)
+			scale8();
+		else if (depth <= 8*sizeof(short))
+			scale16();
+		else if (depth <= 8*sizeof(int))
+			scale32();
 
 #ifdef XSHM
 		XShmPutImage(dpy, win, gc, ximage[DST], 0, 0, 0, 0, width[DST], height[DST], False);
@@ -825,7 +855,7 @@
 						flipx?"-":"", magx,
 						flipxy?" <=>":";",
 						flipy?"-":"", magy);
-			XChangeProperty(dpy, win, XA_WM_NAME, XA_STRING, 8, 
+			XChangeProperty(dpy, win, XA_WM_NAME, XA_STRING, 8,
 				PropModeReplace,
 				(unsigned char *)title, strlen(title));
 			set_title = False;
diff -Naur xzoom-0.3/xzoom.man xzoom-0.3.patched/xzoom.man
--- xzoom-0.3/xzoom.man	1996-04-17 18:37:48.000000000 +0200
+++ xzoom-0.3.patched/xzoom.man	2024-12-28 08:21:51.437647056 +0100
@@ -1,9 +1,9 @@
 .\" xzoom.man
 .\" Copyright Itai Nahshon
 .\"
-.TH XZOOM 1X
+.TH XZOOM 1x
 .SH NAME
-xzoom \- 
+xzoom \- magnify part of the screen, with fast updates
 .SH SYNOPSIS
 .B xzoom
 [ \-display \fIdisplayname\fP ] [ \-mag \fImag\fP [ \fImag\fP ] ]
@@ -18,7 +18,7 @@
 .TP 5
 .B \-mag \fImag\fP [ \fImag\fP ]
 What magnification to use. If two number arguments are supplied the
-first is used for X magniications and the second is used for Y magnification.
+first is used for X magnifications and the second is used for Y magnification.
 Magnification should be greater than 0.
 .TP 5
 .B \-x
@@ -85,6 +85,9 @@
 sets the delay between frame updates. 
 Built-in delays are 200, 100, 50, 10 and 0 ms.
 .TP 5
+.B g
+toggle grid on and off.
+.TP 5
 .B Mouse buttons
 To set the location of the magnified are click the left mouse
 button inside xzoom's window and then move it (keep the button
@@ -147,11 +150,6 @@
 display is not on the local host.
 .LP 5
 \(dg
-The Ximage data is accessed directly, in a way which may
-not be portable. Xzoom will not run with display depth other
-than 8 bits per pixel.
-.LP 5
-\(dg
 Xzoom is given with no warranty. It was tested only under
 Linux with Xfree86 release 3.1.2 (X11R6).
 .LP 5