@@ -27,19 +27,11 @@ rcsid[] = "$Id: i_x.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
27
27
#include < stdlib.h>
28
28
#include < unistd.h>
29
29
#include < sys/ipc.h>
30
- #include < sys/shm.h>
31
30
32
31
#include < X11/Xlib.h>
33
32
#include < X11/Xutil.h>
34
33
#include < X11/keysym.h>
35
34
36
- #include < X11/extensions/XShm.h>
37
- // Had to dig up XShm.c for this one.
38
- // It is in the libXext, but not in the XFree86 headers.
39
- #ifdef LINUX
40
- int XShmGetEventBase ( Display* dpy ); // problems with g++?
41
- #endif
42
-
43
35
#include < stdarg.h>
44
36
#include < sys/time.h>
45
37
#include < sys/types.h>
@@ -71,12 +63,6 @@ XImage* image;
71
63
int X_width;
72
64
int X_height;
73
65
74
- // MIT SHared Memory extension.
75
- boolean doShm;
76
-
77
- XShmSegmentInfo X_shminfo;
78
- int X_shmeventtype;
79
-
80
66
// Fake mouse handling.
81
67
// This cannot work properly w/o DGA.
82
68
// Needs an invisible mouse cursor at least.
@@ -163,14 +149,6 @@ int xlatekey(void)
163
149
164
150
void I_ShutdownGraphics (void )
165
151
{
166
- // Detach from X server
167
- if (!XShmDetach (X_display, &X_shminfo))
168
- I_Error (" XShmDetach() failed in I_ShutdownGraphics()" );
169
-
170
- // Release shared memory.
171
- shmdt (X_shminfo.shmaddr );
172
- shmctl (X_shminfo.shmid , IPC_RMID, 0 );
173
-
174
152
// Paranoia.
175
153
if (image){
176
154
image->data = NULL ;
@@ -191,7 +169,6 @@ void I_StartFrame (void)
191
169
static int lastmousex = 0 ;
192
170
static int lastmousey = 0 ;
193
171
boolean mousemoved = false ;
194
- boolean shmFinished;
195
172
196
173
void I_GetEvent (void )
197
174
{
@@ -274,7 +251,6 @@ void I_GetEvent(void)
274
251
break ;
275
252
276
253
default :
277
- if (doShm && X_event.type == X_shmeventtype) shmFinished = true ;
278
254
break ;
279
255
}
280
256
@@ -482,28 +458,6 @@ void I_FinishUpdate (void)
482
458
Expand4 ((unsigned *)(screens[0 ]), (double *) (image->data ));
483
459
}
484
460
485
- if (doShm)
486
- {
487
-
488
- if (!XShmPutImage ( X_display,
489
- X_mainWindow,
490
- X_gc,
491
- image,
492
- 0 , 0 ,
493
- 0 , 0 ,
494
- X_width, X_height,
495
- True ))
496
- I_Error (" XShmPutImage() failed\n " );
497
-
498
- // wait for it to finish and processes all input events
499
- shmFinished = false ;
500
- do
501
- {
502
- I_GetEvent ();
503
- } while (!shmFinished);
504
-
505
- }
506
- else
507
461
{
508
462
509
463
// draw the image
@@ -587,110 +541,6 @@ void I_SetPalette (byte* palette)
587
541
}
588
542
589
543
590
- //
591
- // This function is probably redundant,
592
- // if XShmDetach works properly.
593
- // ddt never detached the XShm memory,
594
- // thus there might have been stale
595
- // handles accumulating.
596
- //
597
- void grabsharedmemory (int size)
598
- {
599
-
600
- int key = (' d' <<24 ) | (' o' <<16 ) | (' o' <<8 ) | ' m' ;
601
- struct shmid_ds shminfo;
602
- int minsize = 320 *200 ;
603
- int id;
604
- int rc;
605
- // UNUSED int done=0;
606
- int pollution=5 ;
607
-
608
- // try to use what was here before
609
- do
610
- {
611
- id = shmget ((key_t ) key, minsize, 0777 ); // just get the id
612
- if (id != -1 )
613
- {
614
- rc=shmctl (id, IPC_STAT, &shminfo); // get stats on it
615
- if (!rc)
616
- {
617
- if (shminfo.shm_nattch )
618
- {
619
- fprintf (stderr, " User %d appears to be running "
620
- " DOOM. Is that wise?\n " , shminfo.shm_cpid );
621
- key++;
622
- }
623
- else
624
- {
625
- if (getuid () == shminfo.shm_perm .cuid )
626
- {
627
- rc = shmctl (id, IPC_RMID, 0 );
628
- if (!rc)
629
- fprintf (stderr,
630
- " Was able to kill my old shared memory\n " );
631
- else
632
- I_Error (" Was NOT able to kill my old shared memory" );
633
-
634
- id = shmget ((key_t )key, size, IPC_CREAT|0777 );
635
- if (id==-1 )
636
- I_Error (" Could not get shared memory" );
637
-
638
- rc=shmctl (id, IPC_STAT, &shminfo);
639
-
640
- break ;
641
-
642
- }
643
- if (size >= shminfo.shm_segsz )
644
- {
645
- fprintf (stderr,
646
- " will use %d's stale shared memory\n " ,
647
- shminfo.shm_cpid );
648
- break ;
649
- }
650
- else
651
- {
652
- fprintf (stderr,
653
- " warning: can't use stale "
654
- " shared memory belonging to id %d, "
655
- " key=0x%x\n " ,
656
- shminfo.shm_cpid , key);
657
- key++;
658
- }
659
- }
660
- }
661
- else
662
- {
663
- I_Error (" could not get stats on key=%d" , key);
664
- }
665
- }
666
- else
667
- {
668
- id = shmget ((key_t )key, size, IPC_CREAT|0777 );
669
- if (id==-1 )
670
- {
671
- extern int errno;
672
- fprintf (stderr, " errno=%d\n " , errno);
673
- I_Error (" Could not get any shared memory" );
674
- }
675
- break ;
676
- }
677
- } while (--pollution);
678
-
679
- if (!pollution)
680
- {
681
- I_Error (" Sorry, system too polluted with stale "
682
- " shared memory segments.\n " );
683
- }
684
-
685
- X_shminfo.shmid = id;
686
-
687
- // attach to the shared memory segment
688
- image->data = X_shminfo.shmaddr = shmat (id, 0 , 0 );
689
-
690
- fprintf (stderr, " shared memory id=%d, addr=0x%x\n " , id,
691
- (int ) (image->data ));
692
- }
693
-
694
544
void I_InitGraphics (void )
695
545
{
696
546
@@ -774,23 +624,6 @@ void I_InitGraphics(void)
774
624
I_Error (" xdoom currently only supports 256-color PseudoColor screens" );
775
625
X_visual = X_visualinfo.visual ;
776
626
777
- // check for the MITSHM extension
778
- doShm = XShmQueryExtension (X_display);
779
-
780
- // even if it's available, make sure it's a local connection
781
- if (doShm)
782
- {
783
- if (!displayname) displayname = (char *) getenv (" DISPLAY" );
784
- if (displayname)
785
- {
786
- d = displayname;
787
- while (*d && (*d != ' :' )) d++;
788
- if (*d) *d = 0 ;
789
- if (!(!strcasecmp (displayname, " unix" ) || !*displayname)) doShm = false ;
790
- }
791
- }
792
-
793
- fprintf (stderr, " Using MITSHM extension\n " );
794
627
795
628
// create the colormap
796
629
X_cmap = XCreateColormap (X_display, RootWindow (X_display,
@@ -853,50 +686,6 @@ void I_InitGraphics(void)
853
686
GrabModeAsync, GrabModeAsync,
854
687
X_mainWindow, None, CurrentTime);
855
688
856
- if (doShm)
857
- {
858
-
859
- X_shmeventtype = XShmGetEventBase (X_display) + ShmCompletion;
860
-
861
- // create the image
862
- image = XShmCreateImage ( X_display,
863
- X_visual,
864
- 8 ,
865
- ZPixmap,
866
- 0 ,
867
- &X_shminfo,
868
- X_width,
869
- X_height );
870
-
871
- grabsharedmemory (image->bytes_per_line * image->height );
872
-
873
-
874
- // UNUSED
875
- // create the shared memory segment
876
- // X_shminfo.shmid = shmget (IPC_PRIVATE,
877
- // image->bytes_per_line * image->height, IPC_CREAT | 0777);
878
- // if (X_shminfo.shmid < 0)
879
- // {
880
- // perror("");
881
- // I_Error("shmget() failed in InitGraphics()");
882
- // }
883
- // fprintf(stderr, "shared memory id=%d\n", X_shminfo.shmid);
884
- // attach to the shared memory segment
885
- // image->data = X_shminfo.shmaddr = shmat(X_shminfo.shmid, 0, 0);
886
-
887
-
888
- if (!image->data )
889
- {
890
- perror (" " );
891
- I_Error (" shmat() failed in InitGraphics()" );
892
- }
893
-
894
- // get the X server to attach to it
895
- if (!XShmAttach (X_display, &X_shminfo))
896
- I_Error (" XShmAttach() failed in InitGraphics()" );
897
-
898
- }
899
- else
900
689
{
901
690
image = XCreateImage ( X_display,
902
691
X_visual,
0 commit comments