From 60e13a774db2e891b9595b072907a0e0819113d8 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Fri, 9 Dec 2022 16:20:14 -0800 Subject: [PATCH] Net reduction of about 150 warnings when compiling with clang 15.0.6 devif.h, mnxdefs.h: Update MRegion to reflect that width/height are unsigned. Update ...EventMask fields in XWINDOW section of DspInterfaceRec to match parameter type used in XSelectInput() to which they are passed. Add padding to explicitly align colors field (short among longs) xbitmaps.h: Reorder fields in LISP_CURSOR struct to avoid requiring padding for alignment constraints, and adjust initialization to match. Declare cursors static const. Move Lisp_Icon from xbitmaps.h to xmkicon.c xinit.c, xinitdefs.h Replace bound() (xwinmandefs.h) with static inline unsigned ubound() in xinit.c Change signature of X_init() to use unsigned values for width, height, depth. Add casts where necessary to avoid implicit signedness conversions. Add extern declarations for all globals defined in xinit.c xwinman.c, xwinmandefs.h Remove bound() from xwinmandefs.h and use static inline unsigned ubound() in xwinman.c Change signature of lisp_Xconfigure() to use unsigned width and height parameters. Make GravSize unsigned to match its usage context. Add casts where necessary to avoid implicit signedness conversions. Add missing break to correct switch case fall-through warning. dspif.c Change LispDisplayRequestedWidth/Height to unsigned to reflect context of use. xlspwin.c Eliminate declaration for unused XEvent report. Move global variable gcv, used only locally, to local variable in the procedures where needed. Change various variables used in width/height calculation to unsigned to match usage context. Add casts where necessary to avoid implicit signedness conversions. xmkicon.c Move Lisp_Icon from xbitmaps.h to xmkicon.c. Move global XImage IconImage to local in function where it is required. Add cast where necessary to avoid implicit signedness conversions. xrdopt.c Remove incorrect casts for signedness causing implicit sign conversion warnings. Add extern declarations for all globals defined in xrdopt.c xscroll.c Replace bound() (xwinmandefs.h) with static inline signed sbound() in xscroll.c initdsp.c, initdspdefs.h Change signedness of various display variables from int to unsigned. Change signature of init_display2() to unsigned display_max. Add extern declarations for some globals defined in initdsp.c xbbt.c Add explicit casts for type warnings from MRegion width/height change. Add explicit casts for type warnings in arguments to XPutImage(). --- inc/devif.h | 11 ++-- inc/initdspdefs.h | 2 +- inc/mnxdefs.h | 4 +- inc/xbitmaps.h | 134 ++++++++++++---------------------------------- inc/xinitdefs.h | 2 +- inc/xwinmandefs.h | 1 - src/dspif.c | 4 +- src/initdsp.c | 8 +-- src/xbbt.c | 8 +-- src/xinit.c | 52 ++++++++++++------ src/xlspwin.c | 61 ++++++++++----------- src/xmkicon.c | 74 ++++++++++++++++++++++--- src/xrdopt.c | 24 +++++---- src/xscroll.c | 28 ++++++---- src/xwinman.c | 56 +++++++++---------- 15 files changed, 253 insertions(+), 216 deletions(-) diff --git a/inc/devif.h b/inc/devif.h index 657c9ca..1e52314 100644 --- a/inc/devif.h +++ b/inc/devif.h @@ -52,8 +52,8 @@ typedef struct { int x; int y; - int width; - int height; + unsigned width; + unsigned height; } MRegion; @@ -216,8 +216,9 @@ typedef struct This method makes the mouse visible on the screen. Note that the dsp supplies the method and the iop supplies the data. */ MRegion Display; /* Dimensions of the physical display. */ + unsigned short unused0; /* alignment padding for next field */ unsigned short bitsperpixel; - unsigned long colors; /* cash for the available_colors */ + unsigned long colors; /* cache for the available_colors */ unsigned long oldstate; /* Keep the old state around */ unsigned long graphicsmode; /* Magic cookie used to set the state. */ unsigned long numberofbanks; @@ -256,8 +257,8 @@ typedef struct Pixmap GravityOnPixmap; Pixmap GravityOffPixmap; XImage ScreenBitmap; - Mask DisableEventMask; - Mask EnableEventMask; + long DisableEventMask; + long EnableEventMask; #endif /* XWINDOW */ } DspInterfaceRec, *DspInterface; diff --git a/inc/initdspdefs.h b/inc/initdspdefs.h index c84eb58..3176f46 100644 --- a/inc/initdspdefs.h +++ b/inc/initdspdefs.h @@ -5,7 +5,7 @@ void init_cursor(void); void set_cursor(void); void clear_display(void); -void init_display2(DLword *display_addr, int display_max); +void init_display2(DLword *display_addr, unsigned display_max); void display_before_exit(void); void flush_display_buffer(void); void flush_display_region(int x, int y, int w, int h); diff --git a/inc/mnxdefs.h b/inc/mnxdefs.h index b58ac4b..8d528b1 100644 --- a/inc/mnxdefs.h +++ b/inc/mnxdefs.h @@ -216,8 +216,8 @@ typedef struct dspifrec { int error; /* A generic errornumber */ Display *handle; /* The X Display this dspif describes */ - Mask DisableEventMask; - Mask EnableEventMask; + long DisableEventMask; + long EnableEventMask; XImage image; /* The scratch image structure (used in blt'ing) */ XImage tmpimage; /* The tmp image (used for depth conversion) */ GC TitleGC; /* The gc for title blitting. */ diff --git a/inc/xbitmaps.h b/inc/xbitmaps.h index 519eab3..734e51f 100644 --- a/inc/xbitmaps.h +++ b/inc/xbitmaps.h @@ -17,9 +17,9 @@ typedef struct { - short cubitsprepixel; /* bits per pixel in the cursor, mostly 1 */ const uint8_t *cuimage; /* the image bitmap */ const uint8_t *cumask; /* the mask bitmap */ + short cubitsperpixel; /* bits per pixel in the cursor, mostly 1 */ short cuhotspotx; /* hot-spot X coordinate */ short cuhotspoty; /* hot-spot Y coordinate */ short cudata; /* ?? */ @@ -33,11 +33,11 @@ static const uint8_t defaultcursor_bitmap[]= , 0x06, 0, 0x06, 0, 0x03, 0, 0x03, 0 }; -LISP_CURSOR default_cursor = +static const LISP_CURSOR default_cursor = { - 1 - , defaultcursor_bitmap + defaultcursor_bitmap , defaultcursor_bitmap + , 1 , 0 , 15 , 0 @@ -52,11 +52,11 @@ static const uint8_t waitcursor_bitmap[]= , 0x37, 0xD8, 0x67, 0xEC, 0xFF, 0xFE, 0xFF, 0xFE }; -LISP_CURSOR wait_cursor = +static const LISP_CURSOR wait_cursor = { - 1 - , waitcursor_bitmap + waitcursor_bitmap , waitcursor_bitmap + , 1 , 7 , 8 , 0 @@ -81,10 +81,10 @@ static const uint8_t horizscrollcursor_bitmap[]={ , 0x08, 0x20 }; -LISP_CURSOR horizscroll_cursor = { - 1 - , horizscrollcursor_bitmap +static const LISP_CURSOR horizscroll_cursor = { + horizscrollcursor_bitmap , horizscrollcursor_bitmap + , 1 , 7 , 5 , 0 @@ -111,10 +111,10 @@ static const uint8_t horizthumbcursor_bitmap[]={ , 0xAA, 0xA8 }; -LISP_CURSOR horizthumb_cursor = { - 1 - , horizthumbcursor_bitmap +static const LISP_CURSOR horizthumb_cursor = { + horizthumbcursor_bitmap , horizthumbcursor_bitmap + , 1 , 6 , 8 , 0 @@ -141,10 +141,10 @@ static const uint8_t scrolldowncursor_bitmap[]={ , 0x01, 0x00 }; -LISP_CURSOR scrolldown_cursor = { - 1 - , scrolldowncursor_bitmap +static const LISP_CURSOR scrolldown_cursor = { + scrolldowncursor_bitmap , scrolldowncursor_bitmap + , 1 , 7 , 15 , 0 @@ -171,10 +171,10 @@ static const uint8_t scrollleftcursor_bitmap[]={ , 0x00, 0x80 }; -LISP_CURSOR scrollleft_cursor = { - 1 - , scrollleftcursor_bitmap +static const LISP_CURSOR scrollleft_cursor = { + scrollleftcursor_bitmap , scrollleftcursor_bitmap + , 1 , 8 , 5 , 0 @@ -201,10 +201,10 @@ static const uint8_t scrollrightcursor_bitmap[]={ , 0x01, 0x00 }; -LISP_CURSOR scrollright_cursor = { - 1 - , scrollrightcursor_bitmap +static const LISP_CURSOR scrollright_cursor = { + scrollrightcursor_bitmap , scrollrightcursor_bitmap + , 1 , 7 , 5 , 0 @@ -231,10 +231,10 @@ static const uint8_t scrollupcursor_bitmap[]={ , 0x03, 0x80 }; -LISP_CURSOR scrollup_cursor = { - 1 - , scrollupcursor_bitmap +static const LISP_CURSOR scrollup_cursor = { + scrollupcursor_bitmap , scrollupcursor_bitmap + , 1 , 7 , 15 , 0 @@ -261,10 +261,10 @@ static const uint8_t vertscrollcursor_bitmap[]={ , 0x01, 0x00 }; -LISP_CURSOR vertscroll_cursor = { - 1 - , vertscrollcursor_bitmap +static const LISP_CURSOR vertscroll_cursor = { + vertscrollcursor_bitmap , vertscrollcursor_bitmap + , 1 , 7 , 15 , 0 @@ -291,19 +291,19 @@ static const uint8_t vertthumbcursor_bitmap[]={ ,0x00,0x00 }; -LISP_CURSOR vertthumb_cursor = { - 1 - , vertthumbcursor_bitmap +static const LISP_CURSOR vertthumb_cursor = { + vertthumbcursor_bitmap , vertthumbcursor_bitmap + , 1 , 8 , 8 , 0 }; -int check_width = 16; -int check_height = 16; +static unsigned int check_width = 16; +static unsigned int check_height = 16; -static const uint8_t check_bits[] = { 0x88, 0x88, +static uint8_t check_bits[] = { 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, @@ -319,7 +319,7 @@ static const uint8_t check_bits[] = { 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00 }; -static const uint8_t plain_bits[] = { 0x00, 0x00, +static uint8_t plain_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -336,68 +336,4 @@ static const uint8_t plain_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -int Lisp_icon_width = 88; -int Lisp_icon_height = 58; - -const uint8_t Lisp_icon[] = - { - 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, - 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x3f, 0xe2, - 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x10, 0x20, - 0xbf, 0xff, 0xff, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x97, 0xa8, - 0x3f, 0xff, 0xff, 0xa0, 0x82, 0x08, 0x20, 0x82, 0x08, 0x30, 0x22, - 0x20, 0x00, 0x00, 0x88, 0x20, 0x82, 0x08, 0x20, 0x83, 0xf0, 0x20, - 0xa0, 0x00, 0x00, 0x82, 0x08, 0x20, 0x82, 0x08, 0x21, 0x10, 0x28, - 0x24, 0x01, 0x00, 0xa0, 0x87, 0xff, 0xff, 0xc2, 0x09, 0x1f, 0xe2, - 0x29, 0xb2, 0x00, 0x88, 0x24, 0x00, 0x00, 0x60, 0x83, 0x04, 0x20, - 0xa9, 0xb2, 0x50, 0x82, 0x0c, 0x00, 0x00, 0x48, 0x21, 0x06, 0x08, - 0x29, 0xb2, 0x00, 0xa0, 0x87, 0xff, 0xff, 0xc2, 0x09, 0xfc, 0x82, - 0x24, 0x01, 0x00, 0xbf, 0xff, 0xff, 0xff, 0xe0, 0x82, 0x08, 0x20, - 0xa0, 0x00, 0x00, 0xbf, 0xff, 0xe0, 0x08, 0x48, 0x21, 0xfe, 0x08, - 0x20, 0x01, 0x20, 0xe0, 0x00, 0x20, 0x0f, 0x42, 0x0a, 0x02, 0x82, - 0x20, 0x00, 0x90, 0xe0, 0x00, 0x3f, 0xf8, 0x60, 0x83, 0xfe, 0x20, - 0xa5, 0x48, 0x90, 0xbf, 0xff, 0xff, 0xff, 0x48, 0x20, 0x82, 0x08, - 0x20, 0x00, 0x90, 0xbf, 0xff, 0xe0, 0x08, 0x42, 0x08, 0x20, 0x82, - 0x20, 0x01, 0x20, 0xa0, 0x00, 0x35, 0x4f, 0x7f, 0xff, 0xff, 0xe0, - 0xa0, 0x00, 0x00, 0xaa, 0xa0, 0x20, 0x08, 0x5f, 0xff, 0xff, 0xe8, - 0x20, 0x00, 0x00, 0xa0, 0x00, 0x35, 0x4f, 0x50, 0x00, 0x00, 0x22, - 0x3f, 0xff, 0xff, 0xab, 0x56, 0x20, 0x08, 0x70, 0x07, 0xc0, 0x20, - 0x82, 0x00, 0x00, 0x20, 0x00, 0x35, 0x0f, 0xd0, 0x0c, 0x47, 0xa8, - 0x22, 0x00, 0x00, 0x2d, 0x5a, 0xa0, 0x08, 0x90, 0x0f, 0xcc, 0xa2, - 0x0a, 0x00, 0x00, 0x20, 0x00, 0x34, 0x08, 0x30, 0x10, 0x17, 0xa0, - 0x82, 0x00, 0x00, 0x20, 0x00, 0x20, 0x0a, 0x10, 0x17, 0xd0, 0x28, - 0x22, 0x00, 0x00, 0x20, 0x00, 0x35, 0x08, 0x90, 0x2c, 0x67, 0xa2, - 0x0a, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x30, 0x37, 0xdc, 0xa0, - 0x82, 0x00, 0x00, 0x20, 0x00, 0x35, 0x4a, 0x17, 0xe0, 0x07, 0xa8, - 0x22, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x94, 0x57, 0xc0, 0x22, - 0x0a, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x37, 0xec, 0x40, 0x20, - 0x83, 0xff, 0xff, 0xe0, 0x00, 0x20, 0x0a, 0x10, 0x27, 0xc0, 0x28, - 0x20, 0x82, 0x08, 0x20, 0x00, 0x20, 0x08, 0x90, 0x10, 0x00, 0x22, - 0x08, 0x20, 0x82, 0x20, 0x00, 0x3f, 0xf8, 0x30, 0x1f, 0xc0, 0x20, - 0x82, 0x08, 0x20, 0xa0, 0x00, 0x20, 0x82, 0x10, 0x0c, 0x40, 0x28, - 0x20, 0x82, 0x08, 0x3f, 0xff, 0xe8, 0x20, 0x90, 0x07, 0xc0, 0x22, - 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x30, 0x00, 0x00, 0x20, - 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x10, 0x00, 0x00, 0x28, - 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x9f, 0xff, 0xff, 0xe2, - 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, - 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, - 0x42, 0x13, 0x18, 0xc7, 0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, - 0x99, 0x34, 0xa5, 0x24, 0x29, 0x26, 0x38, 0xc5, 0x04, 0x00, 0x00, - 0xa1, 0x14, 0x99, 0x27, 0x35, 0x29, 0x40, 0x26, 0x9c, 0x00, 0x00, - 0xa1, 0x13, 0xa4, 0xe4, 0x25, 0x29, 0x30, 0xe4, 0xa4, 0x00, 0x00, - 0xa1, 0x10, 0xa4, 0x24, 0x24, 0xc9, 0x09, 0x24, 0xa4, 0x00, 0x00, - 0x5a, 0x13, 0x18, 0xc7, 0xa4, 0xc6, 0x70, 0xd4, 0x9c, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0xc0, 0x50, 0x84, 0x00, 0x00, 0x01, 0xc0, 0x02, 0x10, 0x20, - 0x02, 0x12, 0x00, 0x48, 0xcb, 0x32, 0x22, 0x0c, 0x02, 0x38, 0x20, - 0x03, 0x92, 0x50, 0x31, 0x2c, 0x49, 0x42, 0x12, 0x02, 0x10, 0xe0, - 0x02, 0x12, 0x50, 0x31, 0xe8, 0x48, 0x82, 0x12, 0x02, 0x11, 0x20, - 0x02, 0x16, 0x50, 0x49, 0x08, 0x49, 0x42, 0x12, 0x02, 0x15, 0x20, - 0x02, 0x0a, 0x50, 0x84, 0xc8, 0x32, 0x21, 0xcc, 0x93, 0xc8, 0xe0, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; #endif /* XBITMAPS_H */ diff --git a/inc/xinitdefs.h b/inc/xinitdefs.h index ee5bf65..4df9bf6 100644 --- a/inc/xinitdefs.h +++ b/inc/xinitdefs.h @@ -7,5 +7,5 @@ void lisp_Xexit(DspInterface dsp); void Xevent_before_raid(DspInterface dsp); void Xevent_after_raid(DspInterface dsp); void Open_Display(DspInterface dsp); -DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, int width_hint, int height_hint, int depth_hint); +DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, unsigned width_hint, unsigned height_hint, unsigned depth_hint); #endif diff --git a/inc/xwinmandefs.h b/inc/xwinmandefs.h index b1ee029..e1f58f2 100644 --- a/inc/xwinmandefs.h +++ b/inc/xwinmandefs.h @@ -3,7 +3,6 @@ #include /* for Window */ #include /* for XButtonEvent */ #include "devif.h" /* for DspInterface */ -int bound(int a, int b, int c); void Set_BitGravity(XButtonEvent *event, DspInterface dsp, Window window, int grav); void enable_Xkeyboard(DspInterface dsp); void disable_Xkeyboard(DspInterface dsp); diff --git a/src/dspif.c b/src/dspif.c index 69155d8..1ef7772 100644 --- a/src/dspif.c +++ b/src/dspif.c @@ -25,8 +25,8 @@ DspInterfaceRec curdsp; DspInterface currentdsp = &curdsp; #ifdef XWINDOW -extern int LispDisplayRequestedWidth; -extern int LispDisplayRequestedHeight; +extern unsigned LispDisplayRequestedWidth; +extern unsigned LispDisplayRequestedHeight; #endif /* XWINDOW */ #ifdef DOS diff --git a/src/initdsp.c b/src/initdsp.c index cea5b53..115a057 100644 --- a/src/initdsp.c +++ b/src/initdsp.c @@ -57,8 +57,8 @@ extern DspInterface currentdsp; int LispWindowFd = -1; int FrameBufferFd = -1; -int displaywidth, displayheight, DisplayRasterWidth, DisplayType; -int DisplayByteSize; +extern unsigned displaywidth, displayheight, DisplayRasterWidth, DisplayType, DisplayByteSize; +unsigned displaywidth, displayheight, DisplayRasterWidth, DisplayType, DisplayByteSize; DLword *DisplayRegion68k; /* 68k addr of #{}22,0 */ #ifdef DISPLAYBUFFER @@ -158,7 +158,7 @@ void clear_display() { /* ================================================================ */ /* Now takes 68k address, function renamed for safety */ -void init_display2(DLword *display_addr, int display_max) +void init_display2(DLword *display_addr, unsigned display_max) { @@ -187,7 +187,7 @@ void init_display2(DLword *display_addr, int display_max) #endif /* XWINDOW */ init_cursor(); - DisplayByteSize = ((displaywidth * displayheight / 8 + (getpagesize() - 1)) & -getpagesize()); + DisplayByteSize = ((displaywidth * displayheight / 8 + ((unsigned)getpagesize() - 1)) & (unsigned)-getpagesize()); DBPRINT(("Display address: %p\n", (void *)DisplayRegion68k)); DBPRINT((" length : 0x%x\n", DisplayByteSize)); diff --git a/src/xbbt.c b/src/xbbt.c index e3d04f0..c04f224 100644 --- a/src/xbbt.c +++ b/src/xbbt.c @@ -31,8 +31,8 @@ unsigned long clipping_Xbitblt(DspInterface dsp, DLword *dummy, int x, int y, in { int temp_x, temp_y, LowerRightX, LowerRightY; - LowerRightX = dsp->Visible.x + dsp->Visible.width - 1; - LowerRightY = dsp->Visible.y + dsp->Visible.height - 1; + LowerRightX = dsp->Visible.x + (int)dsp->Visible.width - 1; + LowerRightY = dsp->Visible.y + (int)dsp->Visible.height - 1; /* display region of interest lower right x, y pixel */ temp_x = x + w - 1; @@ -48,7 +48,7 @@ unsigned long clipping_Xbitblt(DspInterface dsp, DLword *dummy, int x, int y, in (temp_y <= LowerRightY)) { XLOCK; XPutImage(dsp->display_id, dsp->DisplayWindow, dsp->Copy_GC, &dsp->ScreenBitmap, x, y, - x - dsp->Visible.x, y - dsp->Visible.y, w, h); + x - dsp->Visible.x, y - dsp->Visible.y, (unsigned)w, (unsigned)h); XFlush(dsp->display_id); XUNLOCK(dsp); return (1); @@ -75,7 +75,7 @@ unsigned long clipping_Xbitblt(DspInterface dsp, DLword *dummy, int x, int y, in if ((w > 0) && (h > 0)) { XLOCK; XPutImage(dsp->display_id, dsp->DisplayWindow, dsp->Copy_GC, &dsp->ScreenBitmap, x, y, - x - dsp->Visible.x, y - dsp->Visible.y, w, h); + x - dsp->Visible.x, y - dsp->Visible.y, (unsigned)w, (unsigned)h); XFlush(dsp->display_id); XUNLOCK(dsp); } diff --git a/src/xinit.c b/src/xinit.c index 10ebb38..0a7c283 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -25,7 +25,6 @@ #include "xdefs.h" // for XLOCK, XUNLOCK, DEF_BDRWIDE, DEF_WIN_HEIGHT #include "xinitdefs.h" // for Open_Display, X_init, Xevent_after_raid #include "xlspwindefs.h" // for Create_LispWindow -#include "xwinmandefs.h" // for bound /* DISPLAY_MAX same magic number is in ldsout.c */ #define DISPLAY_MAX (65536 * 16 * 2) @@ -34,22 +33,45 @@ extern DLword *Lisp_world; extern char Display_Name[128]; extern DLword *DisplayRegion68k; extern int noscroll; + +extern bool Lisp_Xinitialized; bool Lisp_Xinitialized = false; +extern int xsync; int xsync = False; +extern int LispWindowRequestedX; +extern int LispWindowRequestedY; +extern unsigned LispWindowRequestedWidth; +extern unsigned LispWindowRequestedHeight; int LispWindowRequestedX = 0; int LispWindowRequestedY = 0; unsigned LispWindowRequestedWidth = DEF_WIN_WIDTH; unsigned LispWindowRequestedHeight = DEF_WIN_HEIGHT; +extern int LispDisplayRequestedX, LispDisplayRequestedY; +extern unsigned LispDisplayRequestedWidth, LispDisplayRequestedHeight; int LispDisplayRequestedX, LispDisplayRequestedY; unsigned LispDisplayRequestedWidth, LispDisplayRequestedHeight; +extern Colormap Colors; Colormap Colors; +extern volatile sig_atomic_t XLocked; volatile sig_atomic_t XLocked = 0; /* non-zero while doing X ops, to avoid signals */ +extern volatile sig_atomic_t XNeedSignal; volatile sig_atomic_t XNeedSignal = 0; /* T if an X interrupt happened while XLOCK asserted */ +/* ubound: return (unsigned) value if it is between lower and upper otherwise lower or upper */ +static inline unsigned ubound(unsigned lower, unsigned value, unsigned upper) +{ + if (value <= lower) + return (lower); + else if (value >= upper) + return (upper); + else + return (value); +} + /************************************************************************/ /* */ /* i n i t _ X e v e n t */ @@ -205,8 +227,8 @@ void Open_Display(DspInterface dsp) /* */ /*********************************************************************/ -DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, int width_hint, int height_hint, - int depth_hint) +DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, unsigned width_hint, unsigned height_hint, + unsigned depth_hint) { Screen *Xscreen; @@ -236,17 +258,17 @@ DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, int width_hint, int he /* Set the width and height of the display. */ if (height_hint == 0) { dsp->Display.height = - HeightOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp); /* In the default case, + (unsigned)HeightOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp); /* In the default case, adjust for scroll gadgets*/ } else - dsp->Display.height = bound(WIN_MIN_HEIGHT, height_hint, WIN_MAX_HEIGHT); + dsp->Display.height = ubound(WIN_MIN_HEIGHT, height_hint, WIN_MAX_HEIGHT); if (width_hint == 0) { dsp->Display.width = - WidthOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp); /* In the default case, + (unsigned)WidthOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp); /* In the default case, adjust for scroll gadgets*/ } else - dsp->Display.width = bound(WIN_MIN_WIDTH, width_hint, WIN_MAX_WIDTH); + dsp->Display.width = ubound(WIN_MIN_WIDTH, width_hint, WIN_MAX_WIDTH); /************************************************************/ /* Set the size of ScreenBitMap */ @@ -270,18 +292,18 @@ DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, int width_hint, int he /* Set the geometry of the Visible (Lisp) window. */ dsp->Visible.width = - bound(OUTER_SB_WIDTH(dsp), LispWindowRequestedWidth, - min(dsp->Display.width, (WidthOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp)))); + ubound(OUTER_SB_WIDTH(dsp), LispWindowRequestedWidth, + min(dsp->Display.width, (unsigned)WidthOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp))); dsp->Visible.height = - bound(OUTER_SB_WIDTH(dsp), LispWindowRequestedHeight, - min(dsp->Display.height, (HeightOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp)))); + ubound(OUTER_SB_WIDTH(dsp), LispWindowRequestedHeight, + min(dsp->Display.height, (unsigned)HeightOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp))); /* Initialize the screen image structure. */ - dsp->ScreenBitmap.width = dsp->Display.width; - dsp->ScreenBitmap.height = dsp->Display.height; + dsp->ScreenBitmap.width = (int)dsp->Display.width; + dsp->ScreenBitmap.height = (int)dsp->Display.height; dsp->ScreenBitmap.xoffset = 0; dsp->bitsperpixel = - DefaultDepthOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id))); + (unsigned short)DefaultDepthOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id))); #if (defined(BYTESWAP)) dsp->ScreenBitmap.byte_order = LSBFirst; #else /* BYTESWAP */ @@ -298,7 +320,7 @@ DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, int width_hint, int he dsp->ScreenBitmap.bitmap_pad = 32; dsp->ScreenBitmap.depth = 8; dsp->ScreenBitmap.bits_per_pixel = 8; - dsp->ScreenBitmap.bytes_per_line = (dsp->Display.width); + dsp->ScreenBitmap.bytes_per_line = (int)dsp->Display.width; dsp->ScreenBitmap.red_mask = 7; dsp->ScreenBitmap.green_mask = 7; dsp->ScreenBitmap.blue_mask = 3; diff --git a/src/xlspwin.c b/src/xlspwin.c index a6129c7..0bd4494 100644 --- a/src/xlspwin.c +++ b/src/xlspwin.c @@ -47,8 +47,6 @@ extern char **save_argv; extern DspInterface currentdsp; -XGCValues gcv; -XEvent report; Cursor WaitCursor, DefaultCursor, VertScrollCursor, VertThumbCursor, ScrollUpCursor, ScrollDownCursor, HorizScrollCursor, HorizThumbCursor, ScrollLeftCursor, ScrollRightCursor; @@ -72,20 +70,22 @@ void Create_LispWindow(DspInterface dsp) XClassHint xclasshint = {0}; XTextProperty IconText = {0}, WindowNameText = {0}; XSetWindowAttributes Lisp_SetWinAttributes = {0}; + XGCValues gcv = {0}; Screen *screen; - int Col2, Row2, Col3, Row3, GravSize; + unsigned int Col2, Row2, Col3, Row3; + unsigned int GravSize; char *WT, *IT; WT = Window_Title; IT = Icon_Title; - GravSize = (int)(dsp->ScrollBarWidth / 2) - (dsp->InternalBorderWidth); + GravSize = (dsp->ScrollBarWidth / 2) - dsp->InternalBorderWidth; Col2 = dsp->Visible.width; Row2 = dsp->Visible.height; - Col3 = dsp->Visible.width + (int)(OUTER_SB_WIDTH(dsp) / 2); - Row3 = dsp->Visible.height + (int)(OUTER_SB_WIDTH(dsp) / 2); + Col3 = dsp->Visible.width + (OUTER_SB_WIDTH(dsp) / 2); + Row3 = dsp->Visible.height + (OUTER_SB_WIDTH(dsp) / 2); screen = ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)); dsp->LispWindow = XCreateSimpleWindow( @@ -117,10 +117,10 @@ void Create_LispWindow(DspInterface dsp) dsp->Copy_GC = XCreateGC(dsp->display_id, dsp->LispWindow, GCForeground | GCBackground | GCFunction, &gcv); - szhint.max_width = dsp->Display.width + OUTER_SB_WIDTH(dsp); - szhint.max_height = dsp->Display.height + OUTER_SB_WIDTH(dsp); - szhint.min_width = OUTER_SB_WIDTH(dsp); - szhint.min_height = OUTER_SB_WIDTH(dsp); + szhint.max_width = (int)(dsp->Display.width + OUTER_SB_WIDTH(dsp)); + szhint.max_height = (int)(dsp->Display.height + OUTER_SB_WIDTH(dsp)); + szhint.min_width = (int)OUTER_SB_WIDTH(dsp); + szhint.min_height = (int)OUTER_SB_WIDTH(dsp); szhint.win_gravity = dsp->BitGravity; szhint.flags = PMaxSize | PWinGravity | PSize; @@ -155,14 +155,14 @@ void Create_LispWindow(DspInterface dsp) dsp->ScrollBarPixmap = XCreatePixmapFromBitmapData( dsp->display_id, dsp->LispWindow, (char *)check_bits, check_width, check_height, - BlackPixelOfScreen(screen), WhitePixelOfScreen(screen), DefaultDepthOfScreen(screen)); + BlackPixelOfScreen(screen), WhitePixelOfScreen(screen), (unsigned)DefaultDepthOfScreen(screen)); dsp->GravityOnPixmap = XCreatePixmapFromBitmapData( dsp->display_id, dsp->LispWindow, (char *)check_bits, 16, 16, BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen), DefaultDepthOfScreen(screen)); + WhitePixelOfScreen(screen), (unsigned)DefaultDepthOfScreen(screen)); dsp->GravityOffPixmap = XCreatePixmapFromBitmapData( dsp->display_id, dsp->LispWindow, (char *)plain_bits, 16, 16, BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen), DefaultDepthOfScreen(screen)); + WhitePixelOfScreen(screen), (unsigned)DefaultDepthOfScreen(screen)); set_Xcursor(dsp, default_cursor.cuimage, (int)default_cursor.cuhotspotx, (int)(15 - default_cursor.cuhotspoty), &DefaultCursor, 0); @@ -189,8 +189,8 @@ void Create_LispWindow(DspInterface dsp) /********************************/ /* Make all the toolkit windows */ /********************************/ - dsp->VerScrollBar = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col2, - 0 - dsp->InternalBorderWidth, /* y */ + dsp->VerScrollBar = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, (int)Col2, + 0 - (int)dsp->InternalBorderWidth, /* y */ dsp->ScrollBarWidth, /* width */ dsp->Visible.height, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); @@ -198,7 +198,7 @@ void Create_LispWindow(DspInterface dsp) XMapWindow(dsp->display_id, dsp->VerScrollBar); dsp->HorScrollBar = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, - 0 - dsp->InternalBorderWidth, Row2, /* y */ + 0 - (int)dsp->InternalBorderWidth, (int)Row2, /* y */ dsp->Visible.width, /* width */ dsp->ScrollBarWidth, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); @@ -208,10 +208,10 @@ void Create_LispWindow(DspInterface dsp) XMapWindow(dsp->display_id, dsp->HorScrollBar); dsp->VerScrollButton = XCreateSimpleWindow( - dsp->display_id, dsp->VerScrollBar, 0 - dsp->InternalBorderWidth, /* x */ - (int)((dsp->Visible.y * dsp->Visible.height) / dsp->Display.height), /* y */ + dsp->display_id, dsp->VerScrollBar, 0 - (int)dsp->InternalBorderWidth, /* x */ + (dsp->Visible.y * (int)dsp->Visible.height) / (int)dsp->Display.height, /* y */ dsp->ScrollBarWidth, /* width */ - (int)((dsp->Visible.height * dsp->Visible.height) / dsp->Display.height) + 1, + ((dsp->Visible.height * dsp->Visible.height) / dsp->Display.height) + 1, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); XChangeWindowAttributes(dsp->display_id, dsp->VerScrollButton, CWOverrideRedirect, &Lisp_SetWinAttributes); @@ -221,9 +221,9 @@ void Create_LispWindow(DspInterface dsp) dsp->HorScrollButton = XCreateSimpleWindow( dsp->display_id, dsp->HorScrollBar, - (int)((dsp->Visible.x * dsp->Visible.width) / dsp->Display.width), - 0 - dsp->InternalBorderWidth, /* y */ - (int)((dsp->Visible.width * dsp->Visible.width) / dsp->Display.width) + 1, + (dsp->Visible.x * (int)dsp->Visible.width) / (int)dsp->Display.width, + 0 - (int)dsp->InternalBorderWidth, /* y */ + ((dsp->Visible.width * dsp->Visible.width) / dsp->Display.width) + 1, dsp->ScrollBarWidth, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); XChangeWindowAttributes(dsp->display_id, dsp->HorScrollButton, CWOverrideRedirect, @@ -232,7 +232,7 @@ void Create_LispWindow(DspInterface dsp) XClearWindow(dsp->display_id, dsp->HorScrollButton); XMapWindow(dsp->display_id, dsp->HorScrollButton); - dsp->NWGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col2, Row2, GravSize, + dsp->NWGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, (int)Col2, (int)Row2, GravSize, GravSize, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); XSetWindowBackgroundPixmap(dsp->display_id, dsp->NWGrav, dsp->GravityOnPixmap); @@ -241,7 +241,7 @@ void Create_LispWindow(DspInterface dsp) XClearWindow(dsp->display_id, dsp->NWGrav); XMapWindow(dsp->display_id, dsp->NWGrav); - dsp->SEGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col3, Row3, GravSize, + dsp->SEGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, (int)Col3, (int)Row3, GravSize, GravSize, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); XSetWindowBackgroundPixmap(dsp->display_id, dsp->SEGrav, dsp->GravityOffPixmap); @@ -250,7 +250,7 @@ void Create_LispWindow(DspInterface dsp) XClearWindow(dsp->display_id, dsp->NWGrav); XMapWindow(dsp->display_id, dsp->SEGrav); - dsp->SWGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col2, Row3, GravSize, + dsp->SWGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, (int)Col2, (int)Row3, GravSize, GravSize, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); XSetWindowBackgroundPixmap(dsp->display_id, dsp->SWGrav, dsp->GravityOffPixmap); @@ -258,7 +258,7 @@ void Create_LispWindow(DspInterface dsp) XClearWindow(dsp->display_id, dsp->NWGrav); XMapWindow(dsp->display_id, dsp->SWGrav); - dsp->NEGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col3, Row2, GravSize, + dsp->NEGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, (int)Col3, (int)Row2, GravSize, GravSize, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); XSetWindowBackgroundPixmap(dsp->display_id, dsp->NEGrav, dsp->GravityOffPixmap); @@ -278,6 +278,7 @@ void lisp_Xvideocolor(int flag) { Screen *screen; XEvent event; + XGCValues gcv = {0}; unsigned long newForeground; XLOCK; @@ -296,8 +297,8 @@ void lisp_Xvideocolor(int flag) event.xexpose.window = currentdsp->DisplayWindow; event.xexpose.x = 0; event.xexpose.y = 0; - event.xexpose.width = currentdsp->Visible.width; - event.xexpose.height = currentdsp->Visible.height; + event.xexpose.width = (int)currentdsp->Visible.width; + event.xexpose.height = (int)currentdsp->Visible.height; XSendEvent(currentdsp->display_id, currentdsp->DisplayWindow, True, 0, &event); } @@ -315,8 +316,8 @@ void set_Xmouseposition(int x, int y) dest_x = (x & 0xFFFF) + Current_Hot_X - currentdsp->Visible.x; dest_y = (y & 0xFFFF) + Current_Hot_Y - currentdsp->Visible.y; - if ((dest_x >= 0) && (dest_x <= currentdsp->Visible.width) && (dest_y >= 0) && - (dest_y <= currentdsp->Visible.height)) { + if ((dest_x >= 0) && (dest_x <= (int)currentdsp->Visible.width) && (dest_y >= 0) && + (dest_y <= (int)currentdsp->Visible.height)) { XLOCK; XWarpPointer(currentdsp->display_id, (Window)NULL, currentdsp->DisplayWindow, 0, 0, 0, 0, dest_x, dest_y); diff --git a/src/xmkicon.c b/src/xmkicon.c index 4a76c12..591ce99 100644 --- a/src/xmkicon.c +++ b/src/xmkicon.c @@ -19,14 +19,74 @@ #include "devif.h" // for (anonymous), DspInterface #include "xmkicondefs.h" // for make_Xicon -XImage IconImage; - -extern int Lisp_icon_width, Lisp_icon_height; -extern uint8_t Lisp_icon[]; - static Pixmap IconPixmap; extern char iconpixmapfile[1024]; +static const unsigned int Lisp_icon_width = 88; +static const unsigned int Lisp_icon_height = 58; + +static const uint8_t Lisp_icon[] = + { + 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, + 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x3f, 0xe2, + 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x10, 0x20, + 0xbf, 0xff, 0xff, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x97, 0xa8, + 0x3f, 0xff, 0xff, 0xa0, 0x82, 0x08, 0x20, 0x82, 0x08, 0x30, 0x22, + 0x20, 0x00, 0x00, 0x88, 0x20, 0x82, 0x08, 0x20, 0x83, 0xf0, 0x20, + 0xa0, 0x00, 0x00, 0x82, 0x08, 0x20, 0x82, 0x08, 0x21, 0x10, 0x28, + 0x24, 0x01, 0x00, 0xa0, 0x87, 0xff, 0xff, 0xc2, 0x09, 0x1f, 0xe2, + 0x29, 0xb2, 0x00, 0x88, 0x24, 0x00, 0x00, 0x60, 0x83, 0x04, 0x20, + 0xa9, 0xb2, 0x50, 0x82, 0x0c, 0x00, 0x00, 0x48, 0x21, 0x06, 0x08, + 0x29, 0xb2, 0x00, 0xa0, 0x87, 0xff, 0xff, 0xc2, 0x09, 0xfc, 0x82, + 0x24, 0x01, 0x00, 0xbf, 0xff, 0xff, 0xff, 0xe0, 0x82, 0x08, 0x20, + 0xa0, 0x00, 0x00, 0xbf, 0xff, 0xe0, 0x08, 0x48, 0x21, 0xfe, 0x08, + 0x20, 0x01, 0x20, 0xe0, 0x00, 0x20, 0x0f, 0x42, 0x0a, 0x02, 0x82, + 0x20, 0x00, 0x90, 0xe0, 0x00, 0x3f, 0xf8, 0x60, 0x83, 0xfe, 0x20, + 0xa5, 0x48, 0x90, 0xbf, 0xff, 0xff, 0xff, 0x48, 0x20, 0x82, 0x08, + 0x20, 0x00, 0x90, 0xbf, 0xff, 0xe0, 0x08, 0x42, 0x08, 0x20, 0x82, + 0x20, 0x01, 0x20, 0xa0, 0x00, 0x35, 0x4f, 0x7f, 0xff, 0xff, 0xe0, + 0xa0, 0x00, 0x00, 0xaa, 0xa0, 0x20, 0x08, 0x5f, 0xff, 0xff, 0xe8, + 0x20, 0x00, 0x00, 0xa0, 0x00, 0x35, 0x4f, 0x50, 0x00, 0x00, 0x22, + 0x3f, 0xff, 0xff, 0xab, 0x56, 0x20, 0x08, 0x70, 0x07, 0xc0, 0x20, + 0x82, 0x00, 0x00, 0x20, 0x00, 0x35, 0x0f, 0xd0, 0x0c, 0x47, 0xa8, + 0x22, 0x00, 0x00, 0x2d, 0x5a, 0xa0, 0x08, 0x90, 0x0f, 0xcc, 0xa2, + 0x0a, 0x00, 0x00, 0x20, 0x00, 0x34, 0x08, 0x30, 0x10, 0x17, 0xa0, + 0x82, 0x00, 0x00, 0x20, 0x00, 0x20, 0x0a, 0x10, 0x17, 0xd0, 0x28, + 0x22, 0x00, 0x00, 0x20, 0x00, 0x35, 0x08, 0x90, 0x2c, 0x67, 0xa2, + 0x0a, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x30, 0x37, 0xdc, 0xa0, + 0x82, 0x00, 0x00, 0x20, 0x00, 0x35, 0x4a, 0x17, 0xe0, 0x07, 0xa8, + 0x22, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x94, 0x57, 0xc0, 0x22, + 0x0a, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x37, 0xec, 0x40, 0x20, + 0x83, 0xff, 0xff, 0xe0, 0x00, 0x20, 0x0a, 0x10, 0x27, 0xc0, 0x28, + 0x20, 0x82, 0x08, 0x20, 0x00, 0x20, 0x08, 0x90, 0x10, 0x00, 0x22, + 0x08, 0x20, 0x82, 0x20, 0x00, 0x3f, 0xf8, 0x30, 0x1f, 0xc0, 0x20, + 0x82, 0x08, 0x20, 0xa0, 0x00, 0x20, 0x82, 0x10, 0x0c, 0x40, 0x28, + 0x20, 0x82, 0x08, 0x3f, 0xff, 0xe8, 0x20, 0x90, 0x07, 0xc0, 0x22, + 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x30, 0x00, 0x00, 0x20, + 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x10, 0x00, 0x00, 0x28, + 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x9f, 0xff, 0xff, 0xe2, + 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, + 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, + 0x42, 0x13, 0x18, 0xc7, 0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x99, 0x34, 0xa5, 0x24, 0x29, 0x26, 0x38, 0xc5, 0x04, 0x00, 0x00, + 0xa1, 0x14, 0x99, 0x27, 0x35, 0x29, 0x40, 0x26, 0x9c, 0x00, 0x00, + 0xa1, 0x13, 0xa4, 0xe4, 0x25, 0x29, 0x30, 0xe4, 0xa4, 0x00, 0x00, + 0xa1, 0x10, 0xa4, 0x24, 0x24, 0xc9, 0x09, 0x24, 0xa4, 0x00, 0x00, + 0x5a, 0x13, 0x18, 0xc7, 0xa4, 0xc6, 0x70, 0xd4, 0x9c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0xc0, 0x50, 0x84, 0x00, 0x00, 0x01, 0xc0, 0x02, 0x10, 0x20, + 0x02, 0x12, 0x00, 0x48, 0xcb, 0x32, 0x22, 0x0c, 0x02, 0x38, 0x20, + 0x03, 0x92, 0x50, 0x31, 0x2c, 0x49, 0x42, 0x12, 0x02, 0x10, 0xe0, + 0x02, 0x12, 0x50, 0x31, 0xe8, 0x48, 0x82, 0x12, 0x02, 0x11, 0x20, + 0x02, 0x16, 0x50, 0x49, 0x08, 0x49, 0x42, 0x12, 0x02, 0x15, 0x20, + 0x02, 0x0a, 0x50, 0x84, 0xc8, 0x32, 0x21, 0xcc, 0x93, 0xc8, 0xe0, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + /************************************************************************/ /* */ /* m a k e _ X i c o n */ @@ -39,6 +99,8 @@ Pixmap make_Xicon(DspInterface dsp) { unsigned int width, height; int value, x_hot, y_hot; + XImage IconImage; + #ifdef TRACE printf("In make_Xicon().\n"); @@ -68,7 +130,7 @@ Pixmap make_Xicon(DspInterface dsp) IconPixmap = XCreatePixmap( dsp->display_id, dsp->LispWindow, Lisp_icon_width, Lisp_icon_height, - DefaultDepthOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)))); + (unsigned)DefaultDepthOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)))); XPutImage(dsp->display_id, IconPixmap, dsp->Copy_GC, &IconImage, 0, 0, 0, 0, Lisp_icon_width, Lisp_icon_height); diff --git a/src/xrdopt.c b/src/xrdopt.c index cfcde73..c0fa657 100644 --- a/src/xrdopt.c +++ b/src/xrdopt.c @@ -77,9 +77,13 @@ static XrmOptionDescRec opTable[] = { reasons /jarl */ +extern char Display_Name[128]; char Display_Name[128]; +extern char iconpixmapfile[1024]; char iconpixmapfile[1024]; +extern char Window_Title[255]; char Window_Title[255]; +extern char Icon_Title[255]; char Icon_Title[255]; extern char sysout_name[]; @@ -200,7 +204,7 @@ void read_Xoption(int *argc, char *argv[]) /* protocol. */ if (XrmGetResource(commandlineDB, "ldex.display", "Ldex.Display", str_type, &value) == True) { - (void)strncpy(Display_Name, value.addr, (int)value.size); + (void)strncpy(Display_Name, value.addr, value.size); } else if (getenv("DISPLAY") == (char *)NULL) { fprintf(stderr, "Can't find a display. Either set the shell\n"); fprintf(stderr, "variable DISPLAY to an appropriate display\n"); @@ -241,7 +245,7 @@ void read_Xoption(int *argc, char *argv[]) if (XrmGetResource(rDB, "ldex.sysout", "Ldex.Sysout", str_type, &value) == True) { /* Get Sysout */ - (void)strncpy(sysout_name, value.addr, (int)value.size); + (void)strncpy(sysout_name, value.addr, value.size); } if (sysout_name[0] == '\0') { fprintf(stderr, "Couldn't find a sysout to run;\n"); @@ -249,30 +253,30 @@ void read_Xoption(int *argc, char *argv[]) } if (XrmGetResource(rDB, "ldex.title", "Ldex.Title", str_type, &value) == True) { - (void)strncpy(Window_Title, value.addr, (int)value.size); + (void)strncpy(Window_Title, value.addr, value.size); } else { (void)strcpy(Window_Title, WINDOW_NAME); } if (XrmGetResource(rDB, "ldex.icontitle", "Ldex.icontitle", str_type, &value) == True) { - (void)strncpy(Icon_Title, value.addr, (int)value.size); + (void)strncpy(Icon_Title, value.addr, value.size); } else { (void)strcpy(Icon_Title, "Medley"); } if (XrmGetResource(rDB, "ldex.iconbitmap", "Ldex.Iconbitmap", str_type, &value) == True) { - (void)strncpy(iconpixmapfile, value.addr, (int)value.size); + (void)strncpy(iconpixmapfile, value.addr, value.size); } /* Old style geometry definition. */ if (XrmGetResource(rDB, "ldex.geometry", "Ldex.geometry", str_type, &value) == True) { /* Get Geometry */ - (void)strncpy(tmp, value.addr, (int)value.size); + (void)strncpy(tmp, value.addr, value.size); bitmask = XParseGeometry(tmp, &LispWindowRequestedX, &LispWindowRequestedY, &LispWindowRequestedWidth, &LispWindowRequestedHeight); } if (XrmGetResource(rDB, "ldex.screen", "Ldex.screen", str_type, &value) == True) { /* Get Geometry */ - (void)strncpy(tmp, value.addr, (int)value.size); + (void)strncpy(tmp, value.addr, value.size); bitmask = XParseGeometry(tmp, &LispDisplayRequestedX, &LispDisplayRequestedY, &LispDisplayRequestedWidth, &LispDisplayRequestedHeight); } @@ -291,12 +295,12 @@ void read_Xoption(int *argc, char *argv[]) "ldex.maxpages", "Ldex.maxpages", str_type, &value) == True) { - (void)strncpy(tmp, value.addr, (int)value.size); + (void)strncpy(tmp, value.addr, value.size); maxpages = atoi(tmp); } */ if (XrmGetResource(rDB, "ldex.memory", "Ldex.memory", str_type, &value) == True) { - (void)strncpy(tmp, value.addr, (int)value.size); + (void)strncpy(tmp, value.addr, value.size); errno = 0; i = (int)strtol(tmp, (char **)NULL, 10); if (errno == 0 && i > 0) @@ -309,7 +313,7 @@ void read_Xoption(int *argc, char *argv[]) #ifdef MAIKO_ENABLE_ETHERNET if (XrmGetResource(rDB, "ldex.EtherNet", "Ldex.EtherNet", str_type, &value) == True) { int b0, b1, b2, b3, b4, b5; - (void)strncpy(tmp, value.addr, (int)value.size); + (void)strncpy(tmp, value.addr, value.size); #if defined(USE_DLPI) if (sscanf(tmp, "%d:%x:%x:%x:%x:%x:%x", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5) == 7) #elif defined(USE_NIT) diff --git a/src/xscroll.c b/src/xscroll.c index 5f90254..8000282 100644 --- a/src/xscroll.c +++ b/src/xscroll.c @@ -15,34 +15,44 @@ #include "devif.h" // for (anonymous), MRegion, DspInterface #include "xdefs.h" // for SCROLL_PITCH #include "xscrolldefs.h" // for JumpScrollHor, JumpScrollVer, Scroll, Scrol... -#include "xwinmandefs.h" // for bound int ScrollPitch = SCROLL_PITCH; +/* sbound: return (signed) value if it is between lower and upper otherwise lower or upper */ +static inline int sbound(int lower, int value, int upper) +{ + if (value <= lower) + return (lower); + else if (value >= upper) + return (upper); + else + return (value); +} + /* Move the DisplayWindow and the ScrollButtons to a new */ /* position. newX, newY refers to the upper left corner */ /* of the LispDisplay */ void Scroll(DspInterface dsp, int newX, int newY) { /* Limit the newX and newY values. */ - dsp->Visible.x = bound(0, newX, dsp->Display.width - dsp->Visible.width); - dsp->Visible.y = bound(0, newY, dsp->Display.height - dsp->Visible.height); + dsp->Visible.x = sbound(0, newX, dsp->Display.width - dsp->Visible.width); + dsp->Visible.y = sbound(0, newY, dsp->Display.height - dsp->Visible.height); - newX = (int)((dsp->Visible.x * dsp->Visible.width) / dsp->Display.width); - newY = (int)((dsp->Visible.y * dsp->Visible.height) / dsp->Display.height); + newX = (dsp->Visible.x * (int)dsp->Visible.width) / (int)dsp->Display.width; + newY = (dsp->Visible.y * (int)dsp->Visible.height) / (int)dsp->Display.height; - XMoveWindow(dsp->display_id, dsp->HorScrollButton, newX, -dsp->InternalBorderWidth); - XMoveWindow(dsp->display_id, dsp->VerScrollButton, -dsp->InternalBorderWidth, newY); + XMoveWindow(dsp->display_id, dsp->HorScrollButton, newX, -(int)dsp->InternalBorderWidth); + XMoveWindow(dsp->display_id, dsp->VerScrollButton, -(int)dsp->InternalBorderWidth, newY); (dsp->bitblt_to_screen)(dsp, 0, dsp->Visible.x, dsp->Visible.y, dsp->Visible.width, dsp->Visible.height); } /* end Scroll */ void JumpScrollVer(DspInterface dsp, int y) -{ Scroll(dsp, dsp->Visible.x, (int)((dsp->Display.width * y) / dsp->Visible.height)); } +{ Scroll(dsp, dsp->Visible.x, ((int)dsp->Display.width * y) / (int)dsp->Visible.height); } void JumpScrollHor(DspInterface dsp, int x) -{ Scroll(dsp, (int)((dsp->Display.width * x) / dsp->Visible.width), dsp->Visible.y); } +{ Scroll(dsp, (((int)dsp->Display.width * x) / (int)dsp->Visible.width), dsp->Visible.y); } void ScrollLeft(DspInterface dsp) { Scroll(dsp, dsp->Visible.x - ScrollPitch, dsp->Visible.y); } diff --git a/src/xwinman.c b/src/xwinman.c index 8ad3c41..3bcc628 100644 --- a/src/xwinman.c +++ b/src/xwinman.c @@ -23,7 +23,7 @@ #include "xdefs.h" // for XLOCK, XUNLOCK #include "xlspwindefs.h" // for DoRing #include "xscrolldefs.h" // for JumpScrollHor, JumpScrollVer, Scroll, Scro... -#include "xwinmandefs.h" // for Set_BitGravity, beep_Xkeyboard, bound, dis... +#include "xwinmandefs.h" // for Set_BitGravity, beep_Xkeyboard, dis... int Mouse_Included = FALSE; @@ -51,15 +51,15 @@ extern u_char *SUNLispKeyMap; #define MOUSE_RIGHT 14 #define MOUSE_MIDDLE 15 -/* bound: return b if it is between a and c otherwise it returns a or c */ -int bound(int a, int b, int c) +/* ubound: return (unsigned) value if it is between lower and upper otherwise lower or upper */ +static inline unsigned ubound(unsigned lower, unsigned value, unsigned upper) { - if (b <= a) - return (a); - else if (b >= c) - return (c); + if (value <= lower) + return (lower); + else if (value >= upper) + return (upper); else - return (b); + return (value); } void Set_BitGravity(XButtonEvent *event, DspInterface dsp, Window window, int grav) @@ -85,50 +85,51 @@ void Set_BitGravity(XButtonEvent *event, DspInterface dsp, Window window, int gr XUNLOCK(dsp); } /* end Set_BitGravity */ -static void lisp_Xconfigure(DspInterface dsp, int x, int y, int lspWinWidth, int lspWinHeight) +static void lisp_Xconfigure(DspInterface dsp, int x, int y, unsigned lspWinWidth, unsigned lspWinHeight) { - int GravSize, Col2, Row2, Col3, Row3; + int Col2, Row2, Col3, Row3; + unsigned int GravSize; /* The Visible width and height changes when */ /* we configure the window. Make them */ /* stay within bounds. */ dsp->Visible.width = - bound(OUTER_SB_WIDTH(dsp) + 2, lspWinWidth, dsp->Display.width + OUTER_SB_WIDTH(dsp)) - + ubound(OUTER_SB_WIDTH(dsp) + 2, lspWinWidth, dsp->Display.width + OUTER_SB_WIDTH(dsp)) - OUTER_SB_WIDTH(dsp); dsp->Visible.height = - bound(OUTER_SB_WIDTH(dsp) + 2, lspWinHeight, dsp->Display.height + OUTER_SB_WIDTH(dsp)) - + ubound(OUTER_SB_WIDTH(dsp) + 2, lspWinHeight, dsp->Display.height + OUTER_SB_WIDTH(dsp)) - OUTER_SB_WIDTH(dsp); - GravSize = (int)(dsp->ScrollBarWidth / 2) - (dsp->InternalBorderWidth); - Col2 = dsp->Visible.width; - Row2 = dsp->Visible.height; - Col3 = dsp->Visible.width + (int)(OUTER_SB_WIDTH(dsp) / 2); - Row3 = dsp->Visible.height + (int)(OUTER_SB_WIDTH(dsp) / 2); + GravSize = (dsp->ScrollBarWidth / 2) - (dsp->InternalBorderWidth); + Col2 = (int)dsp->Visible.width; + Row2 = (int)dsp->Visible.height; + Col3 = (int)(dsp->Visible.width + (OUTER_SB_WIDTH(dsp) / 2)); + Row3 = (int)(dsp->Visible.height + (OUTER_SB_WIDTH(dsp) / 2)); XLOCK; XMoveResizeWindow(dsp->display_id, dsp->DisplayWindow, 0, 0, dsp->Visible.width, dsp->Visible.height); if (noscroll == 0) { /* Scroll bars */ - XMoveResizeWindow(dsp->display_id, dsp->VerScrollBar, Col2, 0 - dsp->InternalBorderWidth, /* y */ + XMoveResizeWindow(dsp->display_id, dsp->VerScrollBar, Col2, 0 - (int)dsp->InternalBorderWidth, /* y */ dsp->ScrollBarWidth, /* width */ dsp->Visible.height); /* height */ - XMoveResizeWindow(dsp->display_id, dsp->HorScrollBar, 0 - dsp->InternalBorderWidth, Row2, /* y */ + XMoveResizeWindow(dsp->display_id, dsp->HorScrollBar, 0 - (int)dsp->InternalBorderWidth, Row2, /* y */ dsp->Visible.width, /* width */ dsp->ScrollBarWidth); /* height */ /* Scroll buttons */ XMoveResizeWindow( dsp->display_id, dsp->HorScrollButton, - (int)((dsp->Visible.x * dsp->Visible.width) / dsp->Display.width), /* x */ - 0 - dsp->InternalBorderWidth, /* y */ - (int)((dsp->Visible.width * dsp->Visible.width) / dsp->Display.width) + 1, /* width */ + (dsp->Visible.x * (int)dsp->Visible.width) / (int)dsp->Display.width, /* x */ + 0 - (int)dsp->InternalBorderWidth, /* y */ + ((dsp->Visible.width * dsp->Visible.width) / dsp->Display.width) + 1, /* width */ dsp->ScrollBarWidth); /* height */ XMoveResizeWindow( - dsp->display_id, dsp->VerScrollButton, 0 - dsp->InternalBorderWidth, /* x */ - (int)((dsp->Visible.y * dsp->Visible.height) / dsp->Display.height), /* y */ + dsp->display_id, dsp->VerScrollButton, 0 - (int)dsp->InternalBorderWidth, /* x */ + (dsp->Visible.y * (int)dsp->Visible.height) / (int)dsp->Display.height, /* y */ dsp->ScrollBarWidth, /* width */ - (int)((dsp->Visible.height * dsp->Visible.height) / dsp->Display.height) + 1); /* height */ + ((dsp->Visible.height * dsp->Visible.height) / dsp->Display.height) + 1); /* height */ /* Gravity windows */ XMoveResizeWindow(dsp->display_id, dsp->NWGrav, Col2, Row2, GravSize, GravSize); @@ -245,8 +246,8 @@ void process_Xevents(DspInterface dsp) else if (report.xany.window == dsp->LispWindow) switch (report.xany.type) { case ConfigureNotify: - lisp_Xconfigure(dsp, report.xconfigure.x, report.xconfigure.y, report.xconfigure.width, - report.xconfigure.height); + lisp_Xconfigure(dsp, report.xconfigure.x, report.xconfigure.y, (unsigned)report.xconfigure.width, + (unsigned)report.xconfigure.height); break; case EnterNotify: enable_Xkeyboard(currentdsp); break; case LeaveNotify: break; @@ -290,6 +291,7 @@ void process_Xevents(DspInterface dsp) break; default: break; } /* end switch */ + break; default: break; } else if (report.xany.window == dsp->VerScrollBar)