DtWidget: Improve portability of Motif interface
authorMarcin Cieslak <saper@saper.info>
Thu, 30 Aug 2012 23:17:48 +0000 (01:17 +0200)
committerJon Trulson <jon@radscan.com>
Fri, 31 Aug 2012 01:43:56 +0000 (19:43 -0600)
- Add missing includes and prototypes
- Improve type compatibility
- Use <Xm/XmPrivate.h> for unofficial libXm headers

With this patch, dtpad no longer crashes on startup
on FreeBSD/amd64 because of a truncated 64-bit pointer.

14 files changed:
cde/lib/DtWidget/ComboBox.c
cde/lib/DtWidget/Control.c
cde/lib/DtWidget/DialogBox.c
cde/lib/DtWidget/DtSvcInternal.h [new file with mode: 0644]
cde/lib/DtWidget/EditAreaData.c
cde/lib/DtWidget/EditCalls.c
cde/lib/DtWidget/Editor.c
cde/lib/DtWidget/Icon.c
cde/lib/DtWidget/Imakefile
cde/lib/DtWidget/MenuButton.c
cde/lib/DtWidget/NewCvt.c
cde/lib/DtWidget/SearchCalls.c
cde/lib/DtWidget/SpinBox.c
cde/lib/DtWidget/TitleBox.c

index 8b8d6f7caa7d63d90ca6dfb6ca1141b119a3813b..6ad6e9a1bb6e726925a066a074d3def02a2a4128 100644 (file)
@@ -109,9 +109,13 @@ express or implied warranty.
 #include <Xm/XmosP.h>          /* for INT_MAX */
 #include <Dt/DtMsgsP.h>
 #include "ComboBoxP.h"
+#include <Xm/DrawP.h>
 #include <Xm/DisplayP.h>
+#include <Xm/List.h>
 #include <Xm/ComboBox.h>       /* for redirecting utility functions */
 #include "DtWidgetI.h"         /* for _Dt thread-safety macros */
+/* some unpublished Motif interfaces */
+#include <Xm/XmPrivate.h>
 
 /*
  * MotifBc
index e937fc39bff0e01cb665b8137fa76e0eab48d5a7..8722d674662eb255c69ae366aaac0dc65b6ea0ed 100644 (file)
 #include <X11/Xos_r.h>
 #include <Xm/GadgetP.h>
 #include <Xm/DrawP.h>
+#include <Xm/XmP.h>
 #include <Dt/Control.h>
 #include <Dt/ControlP.h>
 #include <Xm/ManagerP.h>
 #include <Dt/MacrosP.h>
 #include <langinfo.h>
 #include "DtWidgetI.h"
+#include "DtSvcInternal.h"
 
 
 /********    Public Function Declarations    ********/
@@ -577,7 +579,7 @@ BusyTimeout(
   else
     {
       G_Set (g) = False;
-      G_BlinkTimer (g) = NULL;
+      G_BlinkTimer (g) = 0;
       G_BlinkElapsed (g) = 0;
       G_Busy (g) = 0;
       (*call_callback) ((DtIconGadget) g, G_Callback (g), XmCR_BUSY_STOP, NULL);
@@ -830,7 +832,7 @@ Initialize(
       G_ControlType (new) != XmCONTROL_MAIL &&
       G_ControlType (new) != XmCONTROL_MONITOR)
     {
-      G_ControlType (new) == XmCONTROL_NONE;
+      G_ControlType (new) = XmCONTROL_NONE;
     }
   
   if (G_ControlType (new) == XmCONTROL_SWITCH)
index 59f337a27097e6da155823c168f67b66771ee05c..ff240f36c42093c3d676d069c66d66b4b4c6233f 100644 (file)
@@ -274,7 +274,7 @@ DtDialogBoxClassRec dtDialogBoxClassRec =
        {
                XtInheritTranslations,          /* default_translations */
                NULL,                           /* get_resources        */
-               NULL,                           /* num_get_resources    */
+               0,                              /* num_get_resources    */
                NULL,                           /* get_cont_resources   */
                0,                              /* num_get_cont_resources */
                XmInheritParentProcess,         /* parent_process       */
@@ -788,7 +788,7 @@ CreateChildren(
                        XtSetArg (al[ac], XmNlabelString, string[i]);  ac++;
                }
                XtSetArg (al[ac], XmNchildType, XmBUTTON);  ac++;
-               sprintf (button_name, "%s_%d\0", M_Name (new), i+1);
+               sprintf (button_name, "%s_%d", M_Name (new), i+1);
                btn = XmCreatePushButtonGadget ((Widget)new, button_name, al, ac);
                XtManageChild (btn);
                XtAddCallback (btn, XmNactivateCallback,
diff --git a/cde/lib/DtWidget/DtSvcInternal.h b/cde/lib/DtWidget/DtSvcInternal.h
new file mode 100644 (file)
index 0000000..3e4021e
--- /dev/null
@@ -0,0 +1,2 @@
+/* Additional import */
+extern Pixmap _DtGetMask(Screen *screen, char *image_name);
index d3ae6f2afd4874a813a0800c0480b6f25aef4644..5971383f0a6f0b13efacf5d6bf8aa355f7473ffe 100644 (file)
@@ -1266,7 +1266,7 @@ LoadFile(
         */
         loadError = Check4EnoughMemory( file_length );
        if (loadError == DtEDITOR_INSUFFICIENT_MEMORY)
-         returnVal == loadError;
+         returnVal = loadError;
        else {
 
          /* 
index 8d3d6a76fa4fef059b5e9ab1fb6c19c475609ce4..9a9b29eab7404f60529331ec75a35638ea40c5b7 100644 (file)
@@ -49,6 +49,7 @@
 
 #include "EditorP.h"
 #include "DtWidgetI.h"
+#include <Xm/XmPrivate.h>  /* _XmStringSourceGetString */
 
 void
 _DtEditorResetUndo(
index 431dbb5b78998ea4e518f3d850e8a8816b92382d..09718bd79d9618a0569c33cc8bd603f46109872f 100644 (file)
@@ -69,6 +69,7 @@
 # define NO_putwc
 #elif defined(CSRG_BASED)
 # include <wctype.h>
+# include <wchar.h>
 #endif /* linux */
 
 #include <sys/wait.h>
 #include <Xm/MessageB.h>
 #include <Xm/MwmUtil.h>
 #include <Xm/TextF.h>
+#include <Xm/LabelG.h>
+#include <Xm/SeparatoG.h>
+#include <Xm/PushBG.h>
+#include <Xm/ToggleBG.h>
+#include <Xm/RowColumn.h>
 
 /* Need the following for _DtOkString */
 #include <Dt/DtP.h>
 
 #include <Dt/DtMsgsP.h>
+#include <Dt/HourGlass.h>
 
 #include "DtWidgetI.h"
 
@@ -762,8 +769,10 @@ static XtActionsRec EditorActionTable[] = {
 #endif /* _AIX */
 
 #if !(defined(sun) && (_XOPEN_VERSION==3))
+#if !(defined(__FreeBSD__))
 #  define iswblank(wc) iswctype((wc),blnkclass)
 #  undef getwc                         /* Use the libc function */
+#endif
 #if defined(__osf__) || defined(_AIX) /* __osf__ || _AIX */
 /* function prototype for wctype() was changed to meet spec1170 */
 /* digital compiler flagged warning */
@@ -1344,13 +1353,13 @@ dtEditorClassRec =
 /*     XmForm Part 
 */
        {
-               (int) NULL,                     /* extension            */
+               NULL,                   /* extension            */
        },
 
 /*     DtEditor Part
 */
        {
-               (int) NULL,                     /* extension            */
+               0,                      /* extension            */
        }
 };
 
index 62166b37aae0b4777d864e7072db75d0246e0d03..c1bdb7b4243a7a107a196e7d2b15d17203491036 100644 (file)
@@ -62,7 +62,9 @@
 #include <Dt/DtMsgsP.h>
 #include <Dt/Dnd.h>
 #include "DtWidgetI.h"
+#include "DtSvcInternal.h"
 
+#include <Xm/XmPrivate.h>  /* Motif _XmEnterGadget and friends */
 
 /*-------------------------------------------------------------
 **     Public Interface
@@ -527,7 +529,7 @@ static XmBaseClassExtRec       iconBaseClassExtRec = {
     (WidgetClass)&dtIconCacheObjClassRec,     /* secondary class      */
     (XtInitProc)SecondaryObjectCreate,        /* creation proc        */
     (XmGetSecResDataFunc) GetIconClassSecResData,    /* getSecResData */
-    {NULL},                                   /* fast subclass        */
+    {0},                                      /* fast subclass        */
     GetValuesPrehook,                         /* get_values prehook   */
     GetValuesPosthook,                        /* get_values posthook  */
     NULL,                                     /* classPartInitPrehook */
@@ -1717,10 +1719,10 @@ Initialize(
 
        G_Armed (new) = False;
 
-       G_Mask (new) = NULL;
+       G_Mask (new) = None;
 
        if (G_Pixmap (new) == XmUNSPECIFIED_PIXMAP)
-               G_Pixmap (new) = NULL;
+               G_Pixmap (new) = None;
 
        if (G_ImageName (new) || G_Pixmap (new))
        {
@@ -1744,7 +1746,7 @@ Initialize(
                        {
 /* warning? */                         
                                name = NULL;
-                               G_Pixmap (new) = NULL;
+                               G_Pixmap (new) = None;
                        }
                }
 
@@ -1830,7 +1832,7 @@ Initialize(
                        XmeGetDefaultRenderTable ((Widget)new, XmBUTTON_FONTLIST);
        G_FontList (new) = XmFontListCopy (G_FontList (new));
 
-       if ((unsigned int)G_String (new) == (unsigned int)XmUNSPECIFIED_STRING)
+       if (G_String (new) == XmUNSPECIFIED_STRING)
                G_String (new) = (_XmString) NULL;
        
        if (G_String (new))
@@ -2240,7 +2242,7 @@ SetValues(
                else
                {
                        name = NULL;
-                       G_Pixmap (new) = NULL;
+                       G_Pixmap (new) = None;
                        w = 0;
                        h = 0;
                }
@@ -2265,7 +2267,7 @@ SetValues(
 
                if (G_Pixmap (new) != G_Pixmap (current))
                {
-                       if ((G_Pixmap (new) != NULL) &&
+                       if ((G_Pixmap (new) != None) &&
                            (G_PixmapWidth (new) == w) &&
                            (G_PixmapHeight (new) == h))
                        {
@@ -2292,7 +2294,7 @@ SetValues(
                        if (G_Mask(new) != XmUNSPECIFIED_PIXMAP)
                          XmDestroyPixmap (XtScreen(new),G_Mask (current));
                        XmDestroyPixmap (XtScreen(new),G_Pixmap (current));
-                       G_Pixmap (new) = NULL;                  
+                       G_Pixmap (new) = None;                  
                        G_PixmapWidth (new) = 0;
                        G_PixmapHeight (new) = 0;
                }
@@ -2693,7 +2695,7 @@ BorderUnhighlight( DtIconGadget g)
 
    register int window_width;
    register int window_height;
-   register highlight_width;
+   register int highlight_width;
    CallCallbackProc    call_callback;
 
    window_width = g->rectangle.width;
@@ -2856,6 +2858,7 @@ VisualChange(
          else
            return (False);
       }
+      return (False);
 }
 
 \f
@@ -3326,8 +3329,8 @@ Draw(
 
                  if (((G_Behavior (g) == XmICON_BUTTON) && G_Armed (g)) ||
                      ((G_Behavior (g) == XmICON_TOGGLE) &&
-                      (!G_Set (g) && G_Armed (g)) ||
-                      (G_Set (g) && !G_Armed (g))))
+                      ((!G_Set (g) && G_Armed (g)) ||
+                      (G_Set (g) && !G_Armed (g)))))
                    shadow_type = XmSHADOW_IN;
                  else
                    shadow_type = XmSHADOW_OUT;
@@ -3719,7 +3722,7 @@ _DtDuplicateIcon(
    {
       /* No pixmap to load */
       G_ImageName(new) = NULL;
-      G_Pixmap(new) = NULL;
+      G_Pixmap(new) = None;
       G_PixmapWidth(new) = 0;
       G_PixmapHeight(new) = 0;
    }
index f167e35aba847d41bbebca125c351724ae593efd..43ad0706b2aadb590f1dd2b67983d2acf26a2458 100644 (file)
@@ -10,7 +10,7 @@ XCOMM $XConsortium: Imakefile /main/8 1996/04/21 19:11:16 drk $
 #include <Threads.tmpl>
 
 #ifndef DtWidgetDefines
-# define DtWidgetDefines       -DI18N_MSG -DXK_MISCELLANY -DMULTIBYTE
+# define DtWidgetDefines       -DI18N_MSG -DMULTIBYTE
 #endif
 DEFINES = DtWidgetDefines
 #if defined(LinuxArchitecture)
index 931c361ab964426f1b8be80d7949dec5031d1acb..19ce910664a8adc0e8091b39a7eeea5b91fbbccd 100644 (file)
@@ -63,6 +63,9 @@
 #include <Xm/LabelP.h>
 #include <Xm/MenuUtilP.h>
 #include <Xm/DrawP.h>
+#include <Xm/XmP.h>
+
+#include <Xm/XmPrivate.h>   /* _XmRecordEvent, _XmSetInDragMode, ... */
 
 #include <X11/keysymdef.h>
 #include "DtWidgetI.h"
@@ -795,7 +798,7 @@ SetValues(
        Boolean flag = FALSE;
        Boolean adjustWidth = FALSE;
        Boolean adjustHeight = FALSE;
-       unsigned char rowcol_type = NULL;
+       unsigned char rowcol_type = 0;
        Display *dpy = XtDisplay(nw);
        Boolean menu_glyph_changed = FALSE;
        
@@ -911,7 +914,7 @@ Initialize(
        Boolean adjustWidth = FALSE;
        Boolean adjustHeight = FALSE;
        Widget    parent = XtParent(new_w);
-       unsigned char rowcol_type = NULL;
+       unsigned char rowcol_type = 0;
        char *name = NULL;
        
        if ((XmIsRowColumn (parent))) {
index daf56095f4affe2eb9f4608080c3f0e7eb4e6340..8b0c5427b6c98023e3cbcb5884d81ca9473ee7ac 100644 (file)
@@ -51,6 +51,7 @@
 #include <Dt/TitleBox.h>
 #include "DtWidgetI.h"
 
+#include <ctype.h>
 
 extern void _DtRegisterNewConverters( void ) ;
 
index 616ca24d703dce3e3e65f8847000876b40273209..0444202d02180ed7c5225c6c9a3f9ebff93dc90d 100644 (file)
 #include "EditorP.h"
 #include <Xm/TextF.h>
 #include <Xm/MessageB.h>
+#include <Xm/List.h>
 #include <ctype.h>
 #include <limits.h>
 #include <Dt/DtMsgsP.h>
+#include <Dt/HourGlass.h>
 #include "DtWidgetI.h"
 
+#include <Xm/XmPrivate.h>    /* _XmStringSourceGetString */
+
 #define X_INCLUDE_STRING_H
 #define XOS_USE_XT_LOCKING
 #include <X11/Xos_r.h>
index 9b7383f7c088c52e82641a9650f72821dfad0987..4a4178f069b41cc43420afd6e5e9d988fdd02266 100644 (file)
@@ -89,10 +89,14 @@ express or implied warranty.
  */
 
 #include <Dt/DtMsgsP.h>
+#include <Xm/DrawP.h>
+#include <Xm/XmP.h>
 #include <Xm/RepType.h>
 #include "SpinBoxP.h"
 #include "DtWidgetI.h"
 
+#include <Xm/XmPrivate.h>    /* _XmShellIsExclusive */
+
 #ifdef I18N_MSG
 #include <langinfo.h>
 #endif 
@@ -1929,7 +1933,7 @@ SetTextFieldData(DtSpinBoxWidget spin)
        }
        else {
            xm_string = (Items(spin))[Position(spin)];
-           if (text = GetTextString(xm_string)) {
+           if ((text = GetTextString(xm_string))) {
                XtSetArg(arg, XmNvalue, text);
                XtSetValues(Text(spin), &arg, 1);
                XtFree(text);
@@ -2201,7 +2205,7 @@ FinishUpDown(     DtSpinBoxWidget spin,
                            repeat_delay, timer_dispatch, (XtPointer)spin);
 
     /* Try to get Xevent */
-    if (arrow_data = (XmArrowButtonCallbackStruct*)arrow_call_data)
+    if ((arrow_data = (XmArrowButtonCallbackStruct*)arrow_call_data))
        last_event = arrow_data->event;
 
     /* 
@@ -2605,7 +2609,7 @@ DtSpinBoxDeletePos(       Widget spinw,
 
     /* To keep Position of SpinBox up to date */
     if (Position(spin) > 0 && 
-       (Position(spin) >= total_items) || pos < Position(spin) )
+       ((Position(spin) >= total_items) || pos < Position(spin)) )
        Position(spin) = Position(spin) - 1;
 
     if (pos < ItemCount(spin)) {
index 263f1bffe52d303c782f5782bb8a44e1eaa06b6d..5f8959ce781891f01a88e40f917a675aa86b89f5 100644 (file)
 #include <Xm/GadgetP.h>
 #endif /* RiversVersion == _31 */
 #include <Xm/DrawP.h>
+#include <Xm/XmP.h>
 #include <Dt/TitleBoxP.h>
 #include <Dt/MacrosP.h>
 #include <Dt/DtMsgsP.h>
 #include "DtWidgetI.h"
 
+#include <Xm/XmPrivate.h>         /* _XmClearShadowType */