From: owner-fractdev@lists.xmission.com To: owner-fractdev@lists.xmission.com Subject: BOUNCE fractdev@lists.xmission.com: Message too long (>40000 chars) Date sent: Tue, 27 Apr 1999 21:05:11 -0600 >From legalize@xmission.com Tue Apr 27 21:05:09 1999 Received: from [198.60.22.22] (helo=mail.xmission.com) by lists.xmission.com with esmtp (Exim 2.05 #1) id 10cKeq-0006bq-00 for fractdev@lists.xmission.com; Tue, 27 Apr 1999 21:05:08 -0600 Received: from xmission.xmission.com ([198.60.22.20] ident=root) by mail.xmission.com with esmtp (Exim 2.12 #1) id 10cKeq-00033u-00 for fractdev@lists.xmission.com; Tue, 27 Apr 1999 21:05:08 -0600 Received: from legalize (helo=xmission.xmission.com) by xmission.xmission.com with local-esmtp (Exim 2.12 #1) id 10cKep-0006B7-00 for fractdev@lists.xmission.com; Tue, 27 Apr 1999 21:05:07 -0600 To: fractdev@lists.xmission.com Subject: v19.61 pl66 xfractint code problems Reply-To: legalize@xmission.com Organization: multi-cellular, biological MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <23263.925268377.0@xmission.xmission.com> Date: Tue, 27 Apr 1999 21:05:06 -0600 From: Phil McRevis Message-Id: ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23263.925268377.1@xmission.xmission.com> Here's what I did: downloaded ftp://ftp.phoenix.net/pub/USERS/twegner/X1961p65.zip and ftp://ftp.phoenix.net/pub/USERS/twegner/1961p66.zip, unpacked the source and the patch, converting to unix eol convention edited the makefile as appropriate based on my last configuration of xfractint. did a make. had some problems -- see below. fixed them. along the way added support for non-LUT based visuals to fractint (i.e. default visuls other than pseudocolor will now work, but sometimes at the expense of speed). evolver.c contained an unresolved reference to "decode_evolver_info", which is presumed to be a file I/O routine based on its position, so I just commented the call out by reversing the sense of the #ifdef test. calcmandfpasm ended up not being defined properly, so I initilized it to calcmandfpasm_87 which was defined in calmanfp.c to replace the assembly coded version. soi.c used frexpl() instead of frexp() -- this looks like a portability thing here. frexpl() is for long doubles, frexp() for doubles. Solaris doesn't seem to have a frexpl(), but it has frexp(). fracsubr.c had a bunch of ^Z's at the end that made gcc whine. I took them out. The attached patch file contains those changes above to make the raw distribution work PLUS the code implementing the support for non-LUT based default visuals. I was able to test the truecolor code on the freeware X server I've been using, where the points and lines were drawn of the appropriate type. However, that freeware (the MI/X server) X server appears to have a bug in its putimage request unless the server is using an 8bit pseudocolor visual. (Even xv wouldn't display a JPEG image properly unless the server's visual was 8bit.) Ah well, another bug another dollar. I've been thinking about writing an open source DirectX port of the X server anyway, that would be kinda cool. The diffs are big on unixscr.c, because I sanified the indentation on several functions and split code into smaller blocks for better understanding. If someone out there in linuxland would be willing to try this out, I'd like to know if it works for others with a non-pseudocolor default visual. -- Legalize Adulthood! ``Ain't it funny that they all fire the pistol, at the wrong end of the race?''--PDBT ------- =_aaaaaaaaaa0 Content-Type: text/plain; name="patch.txt"; charset="us-ascii" Content-ID: <23263.925268377.2@xmission.xmission.com> Index: encoder.c =================================================================== RCS file: /home/users/l/legalize/Repository/src/xfractint/encoder.c,v retrieving revision 1.1.1.2 diff -c -r1.1.1.2 encoder.c *** 1.1.1.2 1999/04/27 02:10:37 --- encoder.c 1999/04/27 03:13:33 *************** *** 503,509 **** esave_info.future[i] = 0; /* some XFRACT logic for the doubles needed here */ ! #ifdef XFRACT decode_evolver_info(&esave_info, 0); #endif /* evolution info block, 006 */ --- 503,509 ---- esave_info.future[i] = 0; /* some XFRACT logic for the doubles needed here */ ! #ifndef XFRACT decode_evolver_info(&esave_info, 0); #endif /* evolution info block, 006 */ Index: fracsubr.c =================================================================== RCS file: /home/users/l/legalize/Repository/src/xfractint/fracsubr.c,v retrieving revision 1.1.1.2 diff -c -r1.1.1.2 fracsubr.c *** 1.1.1.2 1999/04/27 02:10:40 --- fracsubr.c 1999/04/27 02:17:23 *************** *** 1543,1546 **** blocksize+=blocksize; return(blocksize); } -  \ No newline at end of file --- 1543,1545 ---- Index: fractint.c =================================================================== RCS file: /home/users/l/legalize/Repository/src/xfractint/fractint.c,v retrieving revision 1.1.1.2 diff -c -r1.1.1.2 fractint.c *** 1.1.1.2 1999/04/27 02:10:43 --- fractint.c 1999/04/27 02:23:04 *************** *** 202,208 **** overflow = 1; } ! void main(int argc, char **argv) { int resumeflag; int kbdchar; /* keyboard key-hit value */ --- 202,209 ---- overflow = 1; } ! int ! main(int argc, char **argv) { int resumeflag; int kbdchar; /* keyboard key-hit value */ *************** *** 240,246 **** opy = newopy = -1.5; odpx = odpy = 0; gridsz = 9; ! fiddlefactor = 1; fiddle_reduction = 1.0; this_gen_rseed = (unsigned int)clock_ticks(); srand(this_gen_rseed); initgene(); /*initialise pointers to lots of fractint variables for the evolution engine*/ --- 241,248 ---- opy = newopy = -1.5; odpx = odpy = 0; gridsz = 9; ! fiddlefactor = 1; ! fiddle_reduction = 1.0; this_gen_rseed = (unsigned int)clock_ticks(); srand(this_gen_rseed); initgene(); /*initialise pointers to lots of fractint variables for the evolution engine*/ Index: helpdefs.h =================================================================== RCS file: /home/users/l/legalize/Repository/src/xfractint/helpdefs.h,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 helpdefs.h *** 1.1.1.1 1997/08/03 10:04:26 --- helpdefs.h 1999/04/27 02:30:39 *************** *** 1,6 **** /* ! * HELPDEFS.H * * Contains #defines for help. * --- 1,6 ---- /* ! * helpdefs.h * * Contains #defines for help. * *************** *** 32,200 **** #define HELPCOMMANDS 13 #define HELPCOORDS 14 #define HELPCYCLING 15 ! #define HELPFRACTALS 16 ! #define HELPLOADFILE 17 ! #define HELPMAIN 18 ! #define HELPMENU 19 ! #define HELPPARMFILE 20 ! #define HELPRDS 21 ! #define HELPSAVEREST 22 ! #define HELPSTARFLD 23 ! #define HELPVIDSEL 24 ! #define HELPVIEW 25 ! #define HELPXHAIR 26 ! #define HELPXOPTS 27 ! #define HELPYOPTS 28 ! #define HELPZOOM 29 ! #define HELP_JIIM 30 ! #define HELP_ORBITS 31 ! #define HF_ANT 32 ! #define HF_BARNSJ1 33 ! #define HF_BARNSJ2 34 ! #define HF_BARNSJ3 35 ! #define HF_BARNSM1 36 ! #define HF_BARNSM2 37 ! #define HF_BARNSM3 38 ! #define HF_BIFEQSINPI 39 ! #define HF_BIFLAMBDA 40 ! #define HF_BIFMAY 41 ! #define HF_BIFPLUSSINPI 42 ! #define HF_BIFSTEWART 43 ! #define HF_BIFURCATION 44 ! #define HF_CELLULAR 45 ! #define HF_CHIP 46 ! #define HF_CIRCLE 47 ! #define HF_CMPLXMARKSJUL 48 ! #define HF_CMPLXMARKSMAND 49 ! #define HF_COMPLEXNEWT 50 ! #define HF_DIFFUS 51 ! #define HF_DYNAM 52 ! #define HF_ESCHER 53 ! #define HF_FNPLUSFN 54 ! #define HF_FNPLUSFNPIX 55 ! #define HF_FNTIMESFN 56 ! #define HF_FNXZPLUSZ 57 ! #define HF_FNZTIMESZ 58 ! #define HF_FROTH 59 ! #define HF_GINGER 60 ! #define HF_HALLEY 61 ! #define HF_HENON 62 ! #define HF_HOPALONG 63 ! #define HF_HYPERC 64 ! #define HF_HYPERCJ 65 ! #define HF_ICON 66 ! #define HF_INVERSE 67 ! #define HF_JULFNPLUSEXP 68 ! #define HF_JULFNPLUSZSQRD 69 ! #define HF_JULIA 70 ! #define HF_JULIA4 71 ! #define HF_JULIAFNFN 72 ! #define HF_JULZPOWER 73 ! #define HF_JULZZPWR 74 ! #define HF_KAM 75 ! #define HF_LAMBDA 76 ! #define HF_LAMBDAFN 77 ! #define HF_LAMBDAFNFN 78 ! #define HF_LORENZ 79 ! #define HF_LORENZ3D1 80 ! #define HF_LORENZ3D3 81 ! #define HF_LORENZ3D4 82 ! #define HF_MAGJ1 83 ! #define HF_MAGJ2 84 ! #define HF_MAGM1 85 ! #define HF_MAGM2 86 ! #define HF_MANDEL 87 ! #define HF_MANDEL4 88 ! #define HF_MANDELCLOUD 89 ! #define HF_MANDELFNFN 90 ! #define HF_MANDFN 91 ! #define HF_MANDFNPLUSEXP 92 ! #define HF_MANDFNPLUSZSQRD 93 ! #define HF_MANDPHOENIX 94 ! #define HF_MANDPHOENIXCPLX 95 ! #define HF_MANLAMFNFN 96 ! #define HF_MANOWAR 97 ! #define HF_MANOWARJ 98 ! #define HF_MANZPOWER 99 ! #define HF_MANZZPWR 100 ! #define HF_MARKSJULIA 101 ! #define HF_MARKSMAND 102 ! #define HF_MARKSMANDPWR 103 ! #define HF_MARTIN 104 ! #define HF_MLAMBDA 105 ! #define HF_NEWT 106 ! #define HF_NEWTBAS 107 ! #define HF_PHOENIX 108 ! #define HF_PHOENIXCPLX 109 ! #define HF_PICKOVER 110 ! #define HF_PLASMA 111 ! #define HF_POPCJUL 112 ! #define HF_POPCORN 113 ! #define HF_QUADRUPTWO 114 ! #define HF_QUAT 115 ! #define HF_QUATJ 116 ! #define HF_ROSS 117 ! #define HF_SIER 118 ! #define HF_SPIDER 119 ! #define HF_SQRFN 120 ! #define HF_SQROVFN 121 ! #define HF_TEST 122 ! #define HF_TETRATE 123 ! #define HF_THREEPLY 124 ! #define HF_TIMSERR 125 ! #define HF_UNITY 126 ! #define HF_VL 127 ! #define HT_ANT 128 ! #define HT_BARNS 129 ! #define HT_BIF 130 ! #define HT_CELLULAR 131 ! #define HT_CIRCLE 132 ! #define HT_DIFFUS 133 ! #define HT_DYNAM 134 ! #define HT_ESCHER 135 ! #define HT_FNORFN 136 ! #define HT_FORMULA 137 ! #define HT_FROTH 138 ! #define HT_GINGER 139 ! #define HT_HALLEY 140 ! #define HT_HENON 141 ! #define HT_HYPERC 142 ! #define HT_ICON 143 ! #define HT_IFS 144 ! #define HT_INVERSE 145 ! #define HT_JULIA 146 ! #define HT_JULIBROT 147 ! #define HT_KAM 148 ! #define HT_LAMBDA 149 ! #define HT_LAMBDAFN 150 ! #define HT_LORENZ 151 ! #define HT_LSYS 152 ! #define HT_LYAPUNOV 153 ! #define HT_MAGNET 154 ! #define HT_MANDEL 155 ! #define HT_MANDELCLOUD 156 ! #define HT_MANDFN 157 ! #define HT_MANDJUL4 158 ! #define HT_MARKS 159 ! #define HT_MARTIN 160 ! #define HT_MLAMBDA 161 ! #define HT_NEWT 162 ! #define HT_NEWTBAS 163 ! #define HT_NEWTCMPLX 164 ! #define HT_PHOENIX 165 ! #define HT_PICK 166 ! #define HT_PICKMJ 167 ! #define HT_PLASMA 168 ! #define HT_POPCORN 169 ! #define HT_QUAT 170 ! #define HT_ROSS 171 ! #define HT_SCOTSKIN 172 ! #define HT_SIER 173 ! #define HT_TEST 174 ! #define HT_UNITY 175 ! #define HT_VL 176 ! #define INTRO_AUTHORS 177 ! #define INTRO_CREDITS 178 ! #define RDSKEYS 179 --- 32,203 ---- #define HELPCOMMANDS 13 #define HELPCOORDS 14 #define HELPCYCLING 15 ! #define HELPEVOL 16 ! #define HELPFRACTALS 17 ! #define HELPLOADFILE 18 ! #define HELPMAIN 19 ! #define HELPMENU 20 ! #define HELPPARMFILE 21 ! #define HELPRDS 22 ! #define HELPSAVEREST 23 ! #define HELPSTARFLD 24 ! #define HELPVIDSEL 25 ! #define HELPVIEW 26 ! #define HELPXHAIR 27 ! #define HELPXOPTS 28 ! #define HELPYOPTS 29 ! #define HELPZOOM 30 ! #define HELP_JIIM 31 ! #define HELP_ORBITS 32 ! #define HF_ANT 33 ! #define HF_BARNSJ1 34 ! #define HF_BARNSJ2 35 ! #define HF_BARNSJ3 36 ! #define HF_BARNSM1 37 ! #define HF_BARNSM2 38 ! #define HF_BARNSM3 39 ! #define HF_BIFEQSINPI 40 ! #define HF_BIFLAMBDA 41 ! #define HF_BIFMAY 42 ! #define HF_BIFPLUSSINPI 43 ! #define HF_BIFSTEWART 44 ! #define HF_BIFURCATION 45 ! #define HF_CELLULAR 46 ! #define HF_CHIP 47 ! #define HF_CIRCLE 48 ! #define HF_CMPLXMARKSJUL 49 ! #define HF_CMPLXMARKSMAND 50 ! #define HF_COMPLEXNEWT 51 ! #define HF_DIFFUS 52 ! #define HF_DYNAM 53 ! #define HF_ESCHER 54 ! #define HF_FNPLUSFN 55 ! #define HF_FNPLUSFNPIX 56 ! #define HF_FNTIMESFN 57 ! #define HF_FNXZPLUSZ 58 ! #define HF_FNZTIMESZ 59 ! #define HF_FROTH 60 ! #define HF_GINGER 61 ! #define HF_HALLEY 62 ! #define HF_HENON 63 ! #define HF_HOPALONG 64 ! #define HF_HYPERC 65 ! #define HF_HYPERCJ 66 ! #define HF_ICON 67 ! #define HF_INVERSE 68 ! #define HF_JULFNPLUSEXP 69 ! #define HF_JULFNPLUSZSQRD 70 ! #define HF_JULIA 71 ! #define HF_JULIA4 72 ! #define HF_JULIAFNFN 73 ! #define HF_JULZPOWER 74 ! #define HF_JULZZPWR 75 ! #define HF_KAM 76 ! #define HF_LAMBDA 77 ! #define HF_LAMBDAFN 78 ! #define HF_LAMBDAFNFN 79 ! #define HF_LATOO 80 ! #define HF_LORENZ 81 ! #define HF_LORENZ3D1 82 ! #define HF_LORENZ3D3 83 ! #define HF_LORENZ3D4 84 ! #define HF_MAGJ1 85 ! #define HF_MAGJ2 86 ! #define HF_MAGM1 87 ! #define HF_MAGM2 88 ! #define HF_MANDEL 89 ! #define HF_MANDEL4 90 ! #define HF_MANDELCLOUD 91 ! #define HF_MANDELFNFN 92 ! #define HF_MANDFN 93 ! #define HF_MANDFNPLUSEXP 94 ! #define HF_MANDFNPLUSZSQRD 95 ! #define HF_MANDPHOENIX 96 ! #define HF_MANDPHOENIXCPLX 97 ! #define HF_MANLAMFNFN 98 ! #define HF_MANOWAR 99 ! #define HF_MANOWARJ 100 ! #define HF_MANZPOWER 101 ! #define HF_MANZZPWR 102 ! #define HF_MARKSJULIA 103 ! #define HF_MARKSMAND 104 ! #define HF_MARKSMANDPWR 105 ! #define HF_MARTIN 106 ! #define HF_MLAMBDA 107 ! #define HF_NEWT 108 ! #define HF_NEWTBAS 109 ! #define HF_PHOENIX 110 ! #define HF_PHOENIXCPLX 111 ! #define HF_PICKOVER 112 ! #define HF_PLASMA 113 ! #define HF_POPCJUL 114 ! #define HF_POPCORN 115 ! #define HF_QUADRUPTWO 116 ! #define HF_QUAT 117 ! #define HF_QUATJ 118 ! #define HF_ROSS 119 ! #define HF_SIER 120 ! #define HF_SPIDER 121 ! #define HF_SQRFN 122 ! #define HF_SQROVFN 123 ! #define HF_TEST 124 ! #define HF_TETRATE 125 ! #define HF_THREEPLY 126 ! #define HF_TIMSERR 127 ! #define HF_UNITY 128 ! #define HF_VL 129 ! #define HT_ANT 130 ! #define HT_BARNS 131 ! #define HT_BIF 132 ! #define HT_CELLULAR 133 ! #define HT_CIRCLE 134 ! #define HT_DIFFUS 135 ! #define HT_DYNAM 136 ! #define HT_ESCHER 137 ! #define HT_FNORFN 138 ! #define HT_FORMULA 139 ! #define HT_FROTH 140 ! #define HT_GINGER 141 ! #define HT_HALLEY 142 ! #define HT_HENON 143 ! #define HT_HYPERC 144 ! #define HT_ICON 145 ! #define HT_IFS 146 ! #define HT_INVERSE 147 ! #define HT_JULIA 148 ! #define HT_JULIBROT 149 ! #define HT_KAM 150 ! #define HT_LAMBDA 151 ! #define HT_LAMBDAFN 152 ! #define HT_LATOO 153 ! #define HT_LORENZ 154 ! #define HT_LSYS 155 ! #define HT_LYAPUNOV 156 ! #define HT_MAGNET 157 ! #define HT_MANDEL 158 ! #define HT_MANDELCLOUD 159 ! #define HT_MANDFN 160 ! #define HT_MANDJUL4 161 ! #define HT_MARKS 162 ! #define HT_MARTIN 163 ! #define HT_MLAMBDA 164 ! #define HT_NEWT 165 ! #define HT_NEWTBAS 166 ! #define HT_NEWTCMPLX 167 ! #define HT_PHOENIX 168 ! #define HT_PICK 169 ! #define HT_PICKMJ 170 ! #define HT_PLASMA 171 ! #define HT_POPCORN 172 ! #define HT_QUAT 173 ! #define HT_ROSS 174 ! #define HT_SCOTSKIN 175 ! #define HT_SIER 176 ! #define HT_TEST 177 ! #define HT_UNITY 178 ! #define HT_VL 179 ! #define INTRO_AUTHORS 180 ! #define INTRO_CREDITS 181 ! #define RDSKEYS 182 Index: loadfile.c =================================================================== RCS file: /home/users/l/legalize/Repository/src/xfractint/loadfile.c,v retrieving revision 1.1.1.2.4.1 diff -c -r1.1.1.2.4.1 loadfile.c *** 1.1.1.2.4.1 1999/04/28 02:06:08 --- loadfile.c 1999/04/28 02:12:35 *************** *** 682,688 **** fseek(fp,(long)(0-block_len),SEEK_CUR); load_ext_blk((char far *)&eload_info,data_len); /* XFRACT processing of doubles here */ ! #ifdef XFRACT decode_evolver_info(&eload_info,1); #endif blk_6_info->length = data_len; --- 682,688 ---- fseek(fp,(long)(0-block_len),SEEK_CUR); load_ext_blk((char far *)&eload_info,data_len); /* XFRACT processing of doubles here */ ! #ifndef XFRACT decode_evolver_info(&eload_info,1); #endif blk_6_info->length = data_len; Index: prototyp.h =================================================================== RCS file: /home/users/l/legalize/Repository/src/xfractint/prototyp.h,v retrieving revision 1.1.1.2 diff -c -r1.1.1.2 prototyp.h *** 1.1.1.2 1999/04/27 02:11:15 --- prototyp.h 1999/04/27 04:33:30 *************** *** 19,29 **** /* extern long cdecl calcmandfpasm(void); */ extern long cdecl calcmandfpasm_287(void); extern long cdecl calcmandfpasm_87(void); - #ifndef XFRACT extern long (*calcmandfpasm)(void); - #else - extern long calcmandfpasm(void); - #endif #ifndef XFRACT /* calmanp5 -- assembler file prototypes */ --- 19,25 ---- *************** *** 590,596 **** /* fractint -- C file prototypes */ ! extern void main(int argc,char **argv ); extern int elapsed_time(int); /* framain2 -- C file prototypes */ --- 586,592 ---- /* fractint -- C file prototypes */ ! extern int main(int argc,char **argv ); extern int elapsed_time(int); /* framain2 -- C file prototypes */ Index: soi.c =================================================================== RCS file: /home/users/l/legalize/Repository/src/xfractint/soi.c,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 soi.c *** 1.1.1.1 1999/04/27 02:11:18 --- soi.c 1999/04/27 03:00:51 *************** *** 19,25 **** #define DBLS LDBL #define FABS(x) fabsl(x) ! #define FREXP(x,y) frexpl(x,y) #define TRUE 1 #define FALSE 0 --- 19,25 ---- #define DBLS LDBL #define FABS(x) fabsl(x) ! #define FREXP(x,y) frexp(x,y) #define TRUE 1 #define FALSE 0 Index: unixscr.c =================================================================== RCS file: /home/users/l/legalize/Repository/src/xfractint/unixscr.c,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 unixscr.c *** 1.1.1.1 1997/08/03 10:04:32 --- unixscr.c 1999/04/28 02:31:10 *************** *** 43,48 **** --- 43,49 ---- # include # define FNDELAY O_NONBLOCK #endif + #include /* Check if there is a character waiting for us. */ #define input_pending() (ioctl(0,FIONREAD,&iocount),(int)iocount) *************** *** 101,106 **** --- 102,115 ---- static int usepixtab = 0; static unsigned long pixtab[256]; static int ipixtab[256]; + typedef unsigned long XPixel; + static XPixel cmap_pixtab[256]; /* for faking a LUTs on non-LUT visuals */ + static int cmap_pixtab_alloced; + static int fake_lut = 0; + static unsigned long do_fake_lut(int idx) { + return fake_lut ? cmap_pixtab[idx] : idx; + } + #define FAKE_LUT(idx_) do_fake_lut(idx_) static int fastmode = 0; /* Don't draw pixels 1 at a time */ static int alarmon = 0; /* 1 if the refresh alarm is on */ *************** *** 373,378 **** --- 382,424 ---- static int xlastfcn = GXcopy; static BYTE *pixbuf = NULL; + static void + select_visual(void) + { + Xvi = XDefaultVisualOfScreen(Xsc); + Xdepth = DefaultDepth(Xdp, Xdscreen); + + switch (Xvi->class) { + case StaticGray: + case StaticColor: + colors = 1 << Xdepth; + gotrealdac = 0; + fake_lut = 0; + break; + + case GrayScale: + case PseudoColor: + colors = 1 << Xdepth; + gotrealdac = 1; + fake_lut = 0; + break; + + case TrueColor: + case DirectColor: + colors = 256; + gotrealdac = 0; + fake_lut = 1; + break; + + default: + /* those should be all the visual classes */ + assert(1); + break; + } + if (colors > 256) + colors = 256; + } + /* *---------------------------------------------------------------------- * *************** *** 392,410 **** void initUnixWindow() { ! XSetWindowAttributes Xwatt; ! XGCValues Xgcvals; ! int Xwinx=0,Xwiny=0; ! int i; ! ! if (Xdp != NULL) { ! /* We are already initialized */ ! return; } ! ! if (!simple_input) { ! old_fcntl = fcntl(0,F_GETFL); ! fcntl(0,F_SETFL,FNDELAY); } /* --- 438,543 ---- void initUnixWindow() { ! XSetWindowAttributes Xwatt; ! XGCValues Xgcvals; ! int Xwinx = 0, Xwiny = 0; ! int i; ! ! if (Xdp != NULL) { ! /* We are already initialized */ ! return; ! } ! ! if (!simple_input) { ! old_fcntl = fcntl(0, F_GETFL); ! fcntl(0, F_SETFL, FNDELAY); ! } ! ! adapter = 0; ! ! /* We have to do some X stuff even for disk video, to parse the geometry ! * string */ ! ! if (unixDisk) { ! int offx, offy; ! fastmode = 0; ! gotrealdac = 1; ! colors = 256; ! for (i = 0; i < colors; i++) { ! pixtab[i] = i; ! ipixtab[i] = i; ! } ! if (fixcolors > 0) { ! colors = fixcolors; ! } ! if (Xgeometry) { ! XParseGeometry(Xgeometry, &offx, &offy, (unsigned int *) &Xwinwidth, ! (unsigned int *) &Xwinheight); ! } ! sxdots = Xwinwidth; ! sydots = Xwinheight; ! } else { ! Xdp = XOpenDisplay(Xdisplay); ! if (Xdp == NULL) { ! fprintf(stderr, "Could not open display %s\n", Xdisplay); ! fprintf(stderr, "Note: xfractint can run without X in -disk mode\n"); ! UnixDone(); ! exit(-1); ! } ! Xdscreen = XDefaultScreen(Xdp); ! if (Xgeometry && !onroot) { ! XGeometry(Xdp, Xdscreen, Xgeometry, DEFXY, 0, 1, 1, 0, 0, ! &Xwinx, &Xwiny, &Xwinwidth, &Xwinheight); ! } ! if (sync) { ! XSynchronize(Xdp, True); ! } ! XSetErrorHandler(errhand); ! Xsc = ScreenOfDisplay(Xdp, Xdscreen); ! select_visual(); ! if (fixcolors > 0) { ! colors = fixcolors; ! } ! ! if (fullscreen || onroot) { ! Xwinwidth = DisplayWidth(Xdp, Xdscreen); ! Xwinheight = DisplayHeight(Xdp, Xdscreen); ! } ! sxdots = Xwinwidth; ! sydots = Xwinheight; ! ! Xwatt.background_pixel = BlackPixelOfScreen(Xsc); ! Xwatt.bit_gravity = StaticGravity; ! doesBacking = DoesBackingStore(Xsc); ! if (doesBacking) { ! Xwatt.backing_store = Always; ! } else { ! Xwatt.backing_store = NotUseful; } ! if (onroot) { ! Xroot = FindRootWindow(); ! RemoveRootPixmap(); ! Xgc = XCreateGC(Xdp, Xroot, 0, &Xgcvals); ! Xpixmap = XCreatePixmap(Xdp, Xroot, Xwinwidth, Xwinheight, Xdepth); ! Xw = Xroot; ! XFillRectangle(Xdp, Xpixmap, Xgc, 0, 0, Xwinwidth, Xwinheight); ! XSetWindowBackgroundPixmap(Xdp, Xroot, Xpixmap); ! } else { ! Xroot = DefaultRootWindow(Xdp); ! Xw = XCreateWindow(Xdp, Xroot, Xwinx, Xwiny, Xwinwidth, ! Xwinheight, 0, Xdepth, InputOutput, CopyFromParent, ! CWBackPixel | CWBitGravity | CWBackingStore, &Xwatt); ! XStoreName(Xdp, Xw, "xfractint"); ! Xgc = XCreateGC(Xdp, Xw, 0, &Xgcvals); ! } ! colors = xcmapstuff(); ! if (rotate_hi == 255) rotate_hi = colors-1; ! if (!onroot) { ! XSetBackground(Xdp, Xgc, FAKE_LUT(pixtab[0])); ! XSetForeground(Xdp, Xgc, FAKE_LUT(pixtab[1])); ! Xwatt.background_pixel = FAKE_LUT(pixtab[0]); ! XChangeWindowAttributes(Xdp, Xw, CWBackPixel, &Xwatt); ! XMapWindow(Xdp, Xw); } /* *************** *** 586,623 **** static void clearXwindow() { ! char *ptr; ! int i,len; ! if (pixtab[0] != 0) { ! /* ! * Initialize image to pixtab[0]. ! */ ! if (colors==2) { ! for (i=0;ibytes_per_line;i++) { ! Ximage->data[i] = 0xff; ! } ! } else { ! for (i=0;ibytes_per_line;i++) { ! Ximage->data[i] = pixtab[0]; ! } ! } ! for (i=1;iheight;i++) { ! bcopy(Ximage->data,Ximage->data+i*Ximage->bytes_per_line, ! Ximage->bytes_per_line); ! } } else { ! /* ! * Initialize image to 0's. ! */ ! bzero(Ximage->data,Ximage->bytes_per_line*Ximage->height); } ! xlastcolor = -1; ! XSetForeground(Xdp, Xgc, pixtab[0]); ! if (onroot) { ! XFillRectangle(Xdp,Xpixmap,Xgc,0,0,Xwinwidth,Xwinheight); } ! XFillRectangle(Xdp,Xw,Xgc,0,0,Xwinwidth,Xwinheight); ! xsync(); } /* --- 719,761 ---- static void clearXwindow() { ! char *ptr; ! int i, len; ! if (fake_lut) { ! int j; ! for (j = 0; j < Ximage->height; j++) ! for (i = 0; i < Ximage->width; i++) ! XPutPixel(Ximage, i, j, cmap_pixtab[pixtab[0]]); ! } else if (pixtab[0] != 0) { ! /* ! * Initialize image to pixtab[0]. ! */ ! if (colors == 2) { ! for (i = 0; i < Ximage->bytes_per_line; i++) { ! Ximage->data[i] = 0xff; ! } } else { ! for (i = 0; i < Ximage->bytes_per_line; i++) { ! Ximage->data[i] = pixtab[0]; ! } } ! for (i = 1; i < Ximage->height; i++) { ! bcopy(Ximage->data, Ximage->data+i*Ximage->bytes_per_line, ! Ximage->bytes_per_line); } ! } else { ! /* ! * Initialize image to 0's. ! */ ! bzero(Ximage->data, Ximage->bytes_per_line*Ximage->height); ! } ! xlastcolor = -1; ! XSetForeground(Xdp, Xgc, FAKE_LUT(pixtab[0])); ! if (onroot) { ! XFillRectangle(Xdp, Xpixmap, Xgc, 0, 0, Xwinwidth, Xwinheight); ! } ! XFillRectangle(Xdp, Xw, Xgc, 0, 0, Xwinwidth, Xwinheight); ! xsync(); } /* *************** *** 721,728 **** free(Ximage->data); XDestroyImage(Ximage); } ! Ximage = XCreateImage(Xdp,Xvi,Xdepth, ZPixmap, 0, NULL, sxdots, ! sydots,8, Xmwidth); if (Ximage == NULL) { printf("XCreateImage failed\n"); UnixDone(); --- 859,866 ---- free(Ximage->data); XDestroyImage(Ximage); } ! Ximage = XCreateImage(Xdp, Xvi, Xdepth, ZPixmap, 0, NULL, sxdots, ! sydots, Xdepth, 0); if (Ximage == NULL) { printf("XCreateImage failed\n"); UnixDone(); *************** *** 759,824 **** static int xcmapstuff() { ! int ncells,i,powr; ! ! if (onroot) { ! privatecolor = 0; ! } ! for (i=0;i=1;powr--) { ! ncells = 1<colors) continue; ! if (XAllocColorCells(Xdp,Xcmap,False,NULL,0,pixtab, ! (unsigned int)ncells)) { ! colors = ncells; ! printf("%d colors\n",colors); ! usepixtab = 1; ! break; ! } ! } ! if (!usepixtab) { ! printf("Couldn't allocate any colors\n"); ! gotrealdac = 0; ! } ! } ! for (i=0;i= 1; powr--) { ! ncells = 1 << powr; ! if (ncells > colors) ! continue; ! if (XAllocColorCells(Xdp, Xcmap, False, NULL, 0, pixtab, ! (unsigned int) ncells)) { ! colors = ncells; ! printf("%d colors\n", colors); usepixtab = 1; + break; + } } + if (!usepixtab) { + printf("Couldn't allocate any colors\n"); + gotrealdac = 0; + } + } + for (i = 0; i < colors; i++) { + ipixtab[pixtab[i]] = i; + } + /* We must make sure if any color uses position 0, that it is 0. + * This is so we can clear the image with bzero. + * So, suppose fractint 0 = cmap 42, cmap 0 = fractint 55. + * Then want fractint 0 = cmap 0, cmap 42 = fractint 55. + * I.e. pixtab[55] = 42, ipixtab[42] = 55. + */ + if (ipixtab[0] == 999) { + ipixtab[0] = 0; + } else if (ipixtab[0] != 0) { + int other; + other = ipixtab[0]; + pixtab[other] = pixtab[0]; + ipixtab[pixtab[other]] = other; + pixtab[0] = 0; + ipixtab[0] = 0; + } + + if (!gotrealdac && colors == 2 && BlackPixelOfScreen(Xsc) != 0) { + pixtab[0] = ipixtab[0] = 1; + pixtab[1] = ipixtab[1] = 0; + usepixtab = 1; + } ! return colors; } /* *---------------------------------------------------------------------- *************** *** 858,865 **** } else { pixline = pixels; } ! for (i=0;i truecolor, directcolor displays */ ! static unsigned char last_dac[256][3]; ! static int last_dac_inited = False; ! ! for (i = 0; i < 256; i++) { ! if (!last_dac_inited || ! last_dac[i][0] != dacbox[i][0] || ! last_dac[i][1] != dacbox[i][1] || ! last_dac[i][2] != dacbox[i][2]) { ! cols[i].flags = DoRed | DoGreen | DoBlue; ! cols[i].red = dacbox[i][0]*1024; ! cols[i].green = dacbox[i][1]*1024; ! cols[i].blue = dacbox[i][2]*1024; ! ! if (cmap_pixtab_alloced) { ! XFreeColors(Xdp, Xcmap, cmap_pixtab + i, 1, None); ! } ! if (XAllocColor(Xdp, Xcmap, &cols[i])) { ! cmap_pixtab[i] = cols[i].pixel; ! } else { ! assert(1); ! printf("Allocating color %d failed.\n", i); ! } ! ! last_dac[i][0] = dacbox[i][0]; ! last_dac[i][1] = dacbox[i][1]; ! last_dac[i][2] = dacbox[i][2]; ! } ! } ! cmap_pixtab_alloced = True; ! last_dac_inited = True; ! } else { ! /* !gotrealdac, !fake_lut => static color, static gray displays */ ! assert(1); ! } ! } else { ! /* gotrealdac => grayscale or pseudocolor displays */ ! for (i = 0; i < 256; i++) { ! cols[i].pixel = pixtab[i]; ! cols[i].flags = DoRed | DoGreen | DoBlue; ! cols[i].red = dacbox[i][0]*1024; ! cols[i].green = dacbox[i][1]*1024; ! cols[i].blue = dacbox[i][2]*1024; } if (!unixDisk) { ! XStoreColors(Xdp, Xcmap, cols, colors); ! XFlush(Xdp); } ! } + return 0; } /* *---------------------------------------------------------------------- *************** *** 1058,1064 **** XSetFunction(Xdp, Xgc, GXcopy); xlastfcn = GXcopy; } else { ! XSetForeground(Xdp, Xgc, colors-1); xlastcolor = -1; XSetFunction(Xdp, Xgc, GXxor); xlastfcn = GXxor; --- 1247,1253 ---- XSetFunction(Xdp, Xgc, GXcopy); xlastfcn = GXcopy; } else { ! XSetForeground(Xdp, Xgc, FAKE_LUT(colors-1)); xlastcolor = -1; XSetFunction(Xdp, Xgc, GXxor); xlastfcn = GXxor; *************** *** 1514,1522 **** int XZoomWaiting = 0; #define SENS 1 ! #define ABS(x) ((x)>0?(x):-(x)) ! #define MIN(x,y) ((x)<(y)?(x):(y)) ! #define SIGN(x) ((x)>0?1:-1) /* *---------------------------------------------------------------------- --- 1703,1872 ---- int XZoomWaiting = 0; #define SENS 1 ! #define ABS(x) ((x) > 0?(x):-(x)) ! #define MIN(x, y) ((x) < (y)?(x):(y)) ! #define SIGN(x) ((x) > 0?1:-1) ! ! static int ! ev_key_press(XEvent *xevent, int *ctl_mode, int *shift_mode) ! { ! int charcount; ! char buffer[1]; ! KeySym keysym; ! int compose; ! charcount = XLookupString(xevent, buffer, 1, &keysym, NULL); ! switch (keysym) { ! case XK_Control_L: ! case XK_Control_R: ! *ctl_mode = 1; ! return 1; ! ! case XK_Shift_L: ! case XK_Shift_R: ! *shift_mode = 1; ! break; ! case XK_Home: ! case XK_R7: ! xbufkey = *ctl_mode ? CTL_HOME : HOME; ! return 1; ! case XK_Left: ! case XK_R10: ! xbufkey = *ctl_mode ? LEFT_ARROW_2 : LEFT_ARROW; ! return 1; ! case XK_Right: ! case XK_R12: ! xbufkey = *ctl_mode ? RIGHT_ARROW_2 : RIGHT_ARROW; ! return 1; ! case XK_Down: ! case XK_R14: ! xbufkey = *ctl_mode ? DOWN_ARROW_2 : DOWN_ARROW; ! return 1; ! case XK_Up: ! case XK_R8: ! xbufkey = *ctl_mode ? UP_ARROW_2 : UP_ARROW; ! return 1; ! case XK_Insert: ! xbufkey = *ctl_mode ? CTL_INSERT : INSERT; ! return 1; ! case XK_Delete: ! xbufkey = *ctl_mode ? CTL_DEL : DELETE; ! return 1; ! case XK_End: ! case XK_R13: ! xbufkey = ctl_mode ? CTL_END : END; ! return 1; ! case XK_Help: ! xbufkey = F1; ! return 1; ! case XK_Prior: ! case XK_R9: ! xbufkey = *ctl_mode ? CTL_PAGE_UP : PAGE_UP; ! return 1; ! case XK_Next: ! case XK_R15: ! xbufkey = *ctl_mode ? CTL_PAGE_DOWN : PAGE_DOWN; ! return 1; ! case XK_F1: ! case XK_L1: ! xbufkey = shift_mode ? SF1: F1; ! return 1; ! case XK_F2: ! case XK_L2: ! xbufkey = shift_mode ? SF2: F2; ! return 1; ! case XK_F3: ! case XK_L3: ! xbufkey = shift_mode ? SF3: F3; ! return 1; ! case XK_F4: ! case XK_L4: ! xbufkey = shift_mode ? SF4: F4; ! return 1; ! case XK_F5: ! case XK_L5: ! xbufkey = shift_mode ? SF5: F5; ! return 1; ! case XK_F6: ! case XK_L6: ! xbufkey = shift_mode ? SF6: F6; ! return 1; ! case XK_F7: ! case XK_L7: ! xbufkey = shift_mode ? SF7: F7; ! return 1; ! case XK_F8: ! case XK_L8: ! xbufkey = shift_mode ? SF8: F8; ! return 1; ! case XK_F9: ! case XK_L9: ! xbufkey = shift_mode ? SF9: F9; ! return 1; ! case XK_F10: ! case XK_L10: ! xbufkey = shift_mode ? SF10: F10; ! return 1; ! case '+': ! xbufkey = *ctl_mode ? CTL_PLUS : '+'; ! return 1; ! case '-': ! xbufkey = *ctl_mode ? CTL_MINUS : '-'; ! return 1; ! break; ! case XK_Return: ! case XK_KP_Enter: ! xbufkey = *ctl_mode ? CTL('T') : '\n'; ! return 1; ! } ! if (charcount == 1) { ! xbufkey = buffer[0]; ! if (xbufkey == '\003') { ! goodbye(); ! } ! } ! } ! ! static void ! ev_key_release(XEvent *xevent, int *ctl_mode, int *shift_mode) ! { ! char buffer[1]; ! KeySym keysym; ! (void) XLookupString(&xevent, buffer, 1, &keysym, NULL); ! switch (keysym) { ! case XK_Control_L: ! case XK_Control_R: ! ctl_mode = 0; ! break; ! case XK_Shift_L: ! case XK_Shift_R: ! shift_mode = 0; ! break; ! } ! } ! ! static void ! ev_expose(XEvent *xevent) ! { ! if (!doesBacking) { ! int x, y, w, h; ! x = xevent->xexpose.x; ! y = xevent->xexpose.y; ! w = xevent->xexpose.width; ! h = xevent->xexpose.height; ! if (x+w > sxdots) { ! w = sxdots-x; ! } ! if (y+h > sydots) { ! h = sydots-y; ! } ! if (x < sxdots && y < sydots && w > 0 && h > 0) { ! XPutImage(Xdp, Xw, Xgc, Ximage, xevent->xexpose.x, ! xevent->xexpose.y, xevent->xexpose.x, ! xevent->xexpose.y, xevent->xexpose.width, ! xevent->xexpose.height); ! } ! } ! } /* *---------------------------------------------------------------------- *************** *** 1536,1853 **** static int xhandleevents() { ! XEvent xevent; ! static ctl_mode = 0; ! static shift_mode = 0; ! int bandx0,bandy0,bandx1,bandy1; ! static int bnum=0; ! static int lastx,lasty; ! static int dx,dy; ! ! if (doredraw) { ! redrawscreen(); ! } ! ! while (XPending(Xdp) && !xbufkey) { ! XNextEvent(Xdp,&xevent); ! switch (((XAnyEvent *)&xevent)->type) { ! case KeyRelease: ! { ! char buffer[1]; ! KeySym keysym; ! (void) XLookupString(&xevent,buffer,1,&keysym,NULL); ! switch (keysym) { ! case XK_Control_L: ! case XK_Control_R: ! ctl_mode = 0; ! break; ! case XK_Shift_L: ! case XK_Shift_R: ! shift_mode = 0; ! break; ! } ! } ! break; ! case KeyPress: ! { ! int charcount; ! char buffer[1]; ! KeySym keysym; ! int compose; ! charcount = XLookupString(&xevent,buffer,1,&keysym,NULL); ! switch (keysym) { ! case XK_Control_L: ! case XK_Control_R: ! ctl_mode = 1; ! return; ! case XK_Shift_L: ! case XK_Shift_R: ! shift_mode = 1; ! break; ! case XK_Home: ! case XK_R7: ! xbufkey = ctl_mode ? CTL_HOME : HOME; ! return; ! case XK_Left: ! case XK_R10: ! xbufkey = ctl_mode ? LEFT_ARROW_2 : LEFT_ARROW; ! return; ! case XK_Right: ! case XK_R12: ! xbufkey = ctl_mode ? RIGHT_ARROW_2 : RIGHT_ARROW; ! return; ! case XK_Down: ! case XK_R14: ! xbufkey = ctl_mode ? DOWN_ARROW_2 : DOWN_ARROW; ! return; ! case XK_Up: ! case XK_R8: ! xbufkey = ctl_mode ? UP_ARROW_2 : UP_ARROW; ! return; ! case XK_Insert: ! xbufkey = ctl_mode ? CTL_INSERT : INSERT; ! return; ! case XK_Delete: ! xbufkey = ctl_mode ? CTL_DEL : DELETE; ! return; ! case XK_End: ! case XK_R13: ! xbufkey = ctl_mode ? CTL_END : END; ! return; ! case XK_Help: ! xbufkey = F1; ! return; ! case XK_Prior: ! case XK_R9: ! xbufkey = ctl_mode ? CTL_PAGE_UP : PAGE_UP; ! return; ! case XK_Next: ! case XK_R15: ! xbufkey = ctl_mode ? CTL_PAGE_DOWN : PAGE_DOWN; ! return; ! case XK_F1: ! case XK_L1: ! xbufkey = shift_mode ? SF1: F1; ! return; ! case XK_F2: ! case XK_L2: ! xbufkey = shift_mode ? SF2: F2; ! return; ! case XK_F3: ! case XK_L3: ! xbufkey = shift_mode ? SF3: F3; ! return; ! case XK_F4: ! case XK_L4: ! xbufkey = shift_mode ? SF4: F4; ! return; ! case XK_F5: ! case XK_L5: ! xbufkey = shift_mode ? SF5: F5; ! return; ! case XK_F6: ! case XK_L6: ! xbufkey = shift_mode ? SF6: F6; ! return; ! case XK_F7: ! case XK_L7: ! xbufkey = shift_mode ? SF7: F7; ! return; ! case XK_F8: ! case XK_L8: ! xbufkey = shift_mode ? SF8: F8; ! return; ! case XK_F9: ! case XK_L9: ! xbufkey = shift_mode ? SF9: F9; ! return; ! case XK_F10: ! case XK_L10: ! xbufkey = shift_mode ? SF10: F10; ! return; ! case '+': ! xbufkey = ctl_mode ? CTL_PLUS : '+'; ! return; ! case '-': ! xbufkey = ctl_mode ? CTL_MINUS : '-'; ! return; ! break; ! case XK_Return: ! case XK_KP_Enter: ! xbufkey = ctl_mode ? CTL('T') : '\n'; ! return; ! } ! if (charcount==1) { ! xbufkey = buffer[0]; ! if (xbufkey=='\003') { ! goodbye(); ! } ! } ! } ! break; ! case MotionNotify: ! { ! if (editpal_cursor && !inside_help) { ! while ( XCheckWindowEvent(Xdp,Xw,PointerMotionMask, ! &xevent)) {} ! ! if (xevent.xmotion.state&Button2Mask || ! (xevent.xmotion.state&Button1Mask && ! xevent.xmotion.state&Button3Mask)) { ! bnum = 3; ! } else if (xevent.xmotion.state&Button1Mask) { ! bnum = 1; ! } else if (xevent.xmotion.state&Button3Mask) { ! bnum = 2; ! } else { ! bnum = 0; ! } ! ! #define MSCALE 1 ! if (lookatmouse==3 && bnum != 0) { ! dx += (xevent.xmotion.x-lastx)/MSCALE; ! dy += (xevent.xmotion.y-lasty)/MSCALE; ! lastx = xevent.xmotion.x; ! lasty = xevent.xmotion.y; ! } else { ! Cursor_SetPos(xevent.xmotion.x, xevent.xmotion.y); ! xbufkey = ENTER; ! } ! } ! } ! break; ! case ButtonPress: ! { ! int done = 0; ! int banding = 0; ! if (lookatmouse==3 || zoomoff == 0) { ! lastx = xevent.xbutton.x; ! lasty = xevent.xbutton.y; ! break; ! } ! bandx1 = bandx0 = xevent.xbutton.x; ! bandy1 = bandy0 = xevent.xbutton.y; ! while (!done) { ! XNextEvent(Xdp,&xevent); ! switch (xevent.type) { ! case MotionNotify: ! while ( XCheckWindowEvent(Xdp,Xw,PointerMotionMask, ! &xevent)) {} ! if (banding) { ! XDrawRectangle(Xdp,Xw,Xgc,MIN(bandx0,bandx1), ! MIN(bandy0,bandy1), ABS(bandx1-bandx0), ! ABS(bandy1-bandy0)); ! } ! bandx1 = xevent.xmotion.x; ! bandy1 = xevent.xmotion.y; ! if (ABS(bandx1-bandx0)*finalaspectratio > ! ABS(bandy1-bandy0)) { ! bandy1 = SIGN(bandy1-bandy0)*ABS(bandx1-bandx0)* ! finalaspectratio + bandy0; ! } else { ! bandx1 = SIGN(bandx1-bandx0)*ABS(bandy1-bandy0)/ ! finalaspectratio + bandx0; ! } ! if (!banding) { ! /* Don't start rubber-banding until the mouse ! gets moved. Otherwise a click messes up the ! window */ ! if (ABS(bandx1-bandx0)>10 || ! ABS(bandy1-bandy0)>10) { ! banding = 1; ! XSetForeground(Xdp, Xgc, colors-1); ! XSetFunction(Xdp, Xgc, GXxor); ! } ! } ! if (banding) { ! XDrawRectangle(Xdp,Xw,Xgc,MIN(bandx0,bandx1), ! MIN(bandy0,bandy1), ABS(bandx1-bandx0), ! ABS(bandy1-bandy0)); ! } ! XFlush(Xdp); ! break; ! case ButtonRelease: ! done = 1; ! break; ! } ! } ! if (!banding) { ! break; ! } ! XDrawRectangle(Xdp,Xw,Xgc,MIN(bandx0,bandx1), ! MIN(bandy0,bandy1), ABS(bandx1-bandx0), ! ABS(bandy1-bandy0)); ! if (bandx1==bandx0) { ! bandx1 = bandx0+1; ! } ! if (bandy1==bandy0) { ! bandy1 = bandy0+1; ! } ! zrotate = 0; ! zskew = 0; ! zbx = (MIN(bandx0,bandx1)-sxoffs)/dxsize; ! zby = (MIN(bandy0,bandy1)-syoffs)/dysize; ! zwidth = ABS(bandx1-bandx0)/dxsize; ! zdepth = zwidth; ! if (!inside_help) { ! xbufkey = ENTER; ! } ! if (xlastcolor != -1) { ! XSetForeground(Xdp, Xgc, xlastcolor); ! } ! XSetFunction(Xdp, Xgc, xlastfcn); ! XZoomWaiting = 1; ! drawbox(0); ! } ! break; ! case Expose: ! if (!doesBacking) { ! int x,y,w,h; ! x = xevent.xexpose.x; ! y = xevent.xexpose.y; ! w = xevent.xexpose.width; ! h = xevent.xexpose.height; ! if (x+w>sxdots) { ! w = sxdots-x; ! } ! if (y+h>sydots) { ! h = sydots-y; ! } ! if (x0 && h>0) { ! ! XPutImage(Xdp,Xw,Xgc,Ximage,xevent.xexpose.x, ! xevent.xexpose.y, xevent.xexpose.x, ! xevent.xexpose.y, xevent.xexpose.width, ! xevent.xexpose.height); ! } ! } ! break; } ! } ! if (!xbufkey && editpal_cursor && !inside_help && lookatmouse == 3 && ! (dx != 0 || dy != 0)) { ! if (ABS(dx)>ABS(dy)) { ! if (dx>0) { ! xbufkey = mousefkey[bnum][0]; /* right */ ! dx--; ! } else if (dx<0) { ! xbufkey = mousefkey[bnum][1]; /* left */ ! dx++; } ! } else { ! if (dy>0) { ! xbufkey = mousefkey[bnum][2]; /* down */ ! dy--; ! } else if (dy<0) { ! xbufkey = mousefkey[bnum][3]; /* up */ ! dy++; } } } ! } #define w_root Xroot --- 1886,2056 ---- static int xhandleevents() { ! XEvent xevent; ! static int ctl_mode = 0; ! static int shift_mode = 0; ! int bandx0, bandy0, bandx1, bandy1; ! static int bnum = 0; ! static int lastx, lasty; ! static int dx, dy; ! ! if (doredraw) { ! redrawscreen(); ! } ! ! while (XPending(Xdp) && !xbufkey) { ! XNextEvent(Xdp, &xevent); ! switch (((XAnyEvent *)&xevent)->type) { ! case KeyRelease: ! ev_key_release(&xevent, &ctl_mode, &shift_mode); ! break; ! case KeyPress: ! if (ev_key_press(&xevent, &ctl_mode, &shift_mode)) ! return; ! break; ! case MotionNotify: ! { ! if (editpal_cursor && !inside_help) { ! while (XCheckWindowEvent(Xdp, Xw, PointerMotionMask, &xevent)) ! 1; ! ! if (xevent.xmotion.state&Button2Mask || ! (xevent.xmotion.state&Button1Mask && ! xevent.xmotion.state&Button3Mask)) { ! bnum = 3; ! } else if (xevent.xmotion.state&Button1Mask) { ! bnum = 1; ! } else if (xevent.xmotion.state&Button3Mask) { ! bnum = 2; ! } else { ! bnum = 0; ! } ! #define MSCALE 1 ! if (lookatmouse == 3 && bnum != 0) { ! dx += (xevent.xmotion.x-lastx)/MSCALE; ! dy += (xevent.xmotion.y-lasty)/MSCALE; ! lastx = xevent.xmotion.x; ! lasty = xevent.xmotion.y; ! } else { ! Cursor_SetPos(xevent.xmotion.x, xevent.xmotion.y); ! xbufkey = ENTER; ! } } ! } ! break; ! case ButtonPress: ! { ! int done = 0; ! int banding = 0; ! if (lookatmouse == 3 || zoomoff == 0) { ! lastx = xevent.xbutton.x; ! lasty = xevent.xbutton.y; ! break; ! } ! bandx1 = bandx0 = xevent.xbutton.x; ! bandy1 = bandy0 = xevent.xbutton.y; ! while (!done) { ! XNextEvent(Xdp, &xevent); ! switch (xevent.type) { ! case MotionNotify: ! while (XCheckWindowEvent(Xdp, Xw, PointerMotionMask, &xevent)) ! 1; ! if (banding) { ! XDrawRectangle(Xdp, Xw, Xgc, MIN(bandx0, bandx1), ! MIN(bandy0, bandy1), ABS(bandx1-bandx0), ! ABS(bandy1-bandy0)); } ! bandx1 = xevent.xmotion.x; ! bandy1 = xevent.xmotion.y; ! if (ABS(bandx1-bandx0)*finalaspectratio > ! ABS(bandy1-bandy0)) { ! bandy1 = SIGN(bandy1-bandy0)*ABS(bandx1-bandx0)* ! finalaspectratio + bandy0; ! } else { ! bandx1 = SIGN(bandx1-bandx0)*ABS(bandy1-bandy0)/ ! finalaspectratio + bandx0; ! } ! if (!banding) { ! /* Don't start rubber-banding until the mouse ! gets moved. Otherwise a click messes up the ! window */ ! if (ABS(bandx1-bandx0) > 10 || ! ABS(bandy1-bandy0) > 10) { ! banding = 1; ! XSetForeground(Xdp, Xgc, FAKE_LUT(colors-1)); ! XSetFunction(Xdp, Xgc, GXxor); ! } } + if (banding) { + XDrawRectangle(Xdp, Xw, Xgc, MIN(bandx0, bandx1), + MIN(bandy0, bandy1), ABS(bandx1-bandx0), + ABS(bandy1-bandy0)); + } + XFlush(Xdp); + break; + case ButtonRelease: + done = 1; + break; + } } + if (!banding) { + break; + } + XDrawRectangle(Xdp, Xw, Xgc, MIN(bandx0, bandx1), + MIN(bandy0, bandy1), ABS(bandx1-bandx0), + ABS(bandy1-bandy0)); + if (bandx1 == bandx0) { + bandx1 = bandx0+1; + } + if (bandy1 == bandy0) { + bandy1 = bandy0+1; + } + zrotate = 0; + zskew = 0; + zbx = (MIN(bandx0, bandx1)-sxoffs)/dxsize; + zby = (MIN(bandy0, bandy1)-syoffs)/dysize; + zwidth = ABS(bandx1-bandx0)/dxsize; + zdepth = zwidth; + if (!inside_help) { + xbufkey = ENTER; + } + if (xlastcolor != -1) { + XSetForeground(Xdp, Xgc, FAKE_LUT(xlastcolor)); + } + XSetFunction(Xdp, Xgc, xlastfcn); + XZoomWaiting = 1; + drawbox(0); + } + break; + case Expose: + ev_expose(&xevent); + break; + } + } + + if (!xbufkey && editpal_cursor && !inside_help && lookatmouse == 3 && + (dx != 0 || dy != 0)) { + if (ABS(dx) > ABS(dy)) { + if (dx > 0) { + xbufkey = mousefkey[bnum][0]; /* right */ + dx--; + } else if (dx < 0) { + xbufkey = mousefkey[bnum][1]; /* left */ + dx++; + } + } else { + if (dy > 0) { + xbufkey = mousefkey[bnum][2]; /* down */ + dy--; + } else if (dy < 0) { + xbufkey = mousefkey[bnum][3]; /* up */ + dy++; + } } ! } } #define w_root Xroot *************** *** 1996,2052 **** unsigned char * xgetfont() { ! XFontStruct *font_info; ! Pixmap font_pixmap; ! XImage *font_image; ! char str[8]; ! int i,j,k,l; ! int width; ! fontPtr = (unsigned char *)malloc(128*8); ! bzero(fontPtr,128*8); ! XSetBackground(Xdp,Xgc,0); ! xlastcolor = -1; ! XSetForeground(Xdp,Xgc,1); ! #define FONT "-*-*-medium-r-*-*-9-*-*-*-*-*-iso8859-*" ! font_info = XLoadQueryFont(Xdp,FONT); ! if (font_info==NULL) { ! printf("No %s\n", FONT); ! } ! if (font_info==NULL || font_info->max_bounds.width>8 || ! font_info->max_bounds.width != font_info->min_bounds.width) { ! printf("Bad font: %s\n", FONT); ! sleep(2); ! font_info = XLoadQueryFont(Xdp,"6x12"); ! } ! if (font_info==NULL) return NULL; ! width = font_info->max_bounds.width; ! if (font_info->max_bounds.width>8 || ! font_info->max_bounds.width != font_info->min_bounds.width) { ! printf("Bad font\n"); ! return NULL; ! } ! font_pixmap = XCreatePixmap(Xdp,Xw,64,8,Xdepth); ! ! for (i=0;i<128;i+=8) { ! for (j=0;j<8;j++) { ! str[j] = i+j; ! } ! XDrawImageString(Xdp,font_pixmap,Xgc,0,8,str,8); ! font_image = XGetImage(Xdp,font_pixmap,0,0,64,8,AllPlanes,XYPixmap); ! for (j=0;j<8;j++) { ! for (k=0;k<8;k++) { ! for (l=0;lmax_bounds.width > 8 || ! font_info->max_bounds.width != font_info->min_bounds.width) { ! printf("Bad font: %s\n", FONT); ! sleep(2); ! font_info = XLoadQueryFont(Xdp, "6x12"); ! } ! if (font_info == NULL) return NULL; ! width = font_info->max_bounds.width; ! if (font_info->max_bounds.width > 8 || ! font_info->max_bounds.width != font_info->min_bounds.width) { ! printf("Bad font\n"); ! return NULL; ! } ! ! font_pixmap = XCreatePixmap(Xdp, Xw, 64, 8, 1); ! assert(font_pixmap); ! values.background = 0; ! values.foreground = 1; ! values.font = font_info->fid; ! font_gc = XCreateGC(Xdp, font_pixmap, ! GCForeground | GCBackground | GCFont, &values); ! assert(font_gc); ! ! for (i = 0; i < 128; i+=8) { ! for (j = 0; j < 8; j++) { ! str[j] = i+j; ! } ! XDrawImageString(Xdp, font_pixmap, Xgc, 0, 8, str, 8); ! font_image = XGetImage(Xdp, font_pixmap, 0, 0, 64, 8, AllPlanes, XYPixmap); ! assert(font_image); ! for (j = 0; j < 8; j++) { ! for (k = 0; k < 8; k++) { ! for (l = 0; l < width; l++) { ! if (XGetPixel(font_image, j*width+l, k)) { ! fontPtr[(i+j)*8+k] = (fontPtr[(i+j)*8+k] << 1) | 1; ! } else { ! fontPtr[(i+j)*8+k] = (fontPtr[(i+j)*8+k] << 1); ! } } ! } } ! XDestroyImage(font_image); ! } ! ! XFreeGC(Xdp, font_gc); ! XFreePixmap(Xdp, font_pixmap); ! ! return fontPtr; } /* *************** *** 2194,2206 **** void redrawscreen() { ! if (alarmon) { ! XPutImage(Xdp,Xw,Xgc,Ximage,0,0,0,0,sxdots,sydots); ! if (onroot) { ! XPutImage(Xdp,Xpixmap,Xgc,Ximage,0,0,0,0,sxdots,sydots); ! } ! alarmon = 0; } ! doredraw = 0; } --- 2411,2423 ---- void redrawscreen() { ! if (alarmon) { ! XPutImage(Xdp, Xw, Xgc, Ximage, 0, 0, 0, 0, sxdots, sydots); ! if (onroot) { ! XPutImage(Xdp, Xpixmap, Xgc, Ximage, 0, 0, 0, 0, sxdots, sydots); } ! alarmon = 0; ! } ! doredraw = 0; } ------- =_aaaaaaaaaa0--