home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March / PCWK3A99.iso / Linux / DDD331 / DDD-3_1_.000 / DDD-3_1_ / ddd-3.1.1 / patches / lesstif-0.83.patch < prev    next >
Encoding:
Text File  |  1998-03-20  |  15.1 KB  |  499 lines

  1. # $Id: lesstif-0.83.patch,v 1.1 1998/03/20 12:08:33 zeller Exp $
  2.  
  3. This file contains a variety of patches for lesstif-0.83.  Although
  4. none of them is really serious, we suggest that these patches be
  5. applied (using `patch -l < lesstif-0.83.patch') before building
  6. LessTif and running DDD with LessTif.
  7.  
  8.  
  9. Subject: LessTif 0.83: Modifiers cause XBell on read-only Text, and a patch
  10. To: lesstif@hungry.com (LessTif Mailing List)
  11. Date: Sun, 15 Mar 1998 17:43:52 +0100 (MET)
  12.  
  13. Hi!
  14.  
  15. The following problem occurs in LessTif 0.83 and earlier:
  16.  
  17. * Pressing a modifier while the pointer is over a read-only Text
  18.   widget causes the X bell to be rung.
  19.  
  20. The enclosed patch fixes this.
  21.  
  22. Thanks for your work,
  23.  
  24. -- 
  25. Andreas Zeller     Technische Universitaet Braunschweig, Germany
  26.                    mailto:zeller@acm.org http://www.cs.tu-bs.de/~zeller/
  27. *** lesstif-0.83/lib/Xm/TextIn.c.orig       Sun Mar 15 17:33:39 1998
  28. --- lesstif-0.83/lib/Xm/TextIn.c    Sun Mar 15 17:35:20 1998
  29. ***************
  30. *** 543,552 ****
  31. --- 543,558 ----
  32.       if (len <= 0)
  33.       {
  34.         return;
  35.       }
  36.   
  37. +     if (!Text_Editable(w))
  38. +     {
  39. +       VerifyBell(w);
  40. +       return;
  41. +     }
  42.       (*Text_Output(w)->DrawInsertionPoint) (w, Text_CursorPos(w), off);
  43.   
  44.       blockrec.ptr = XtMalloc(len + 1);
  45.       blockrec.length = len;
  46.       blockrec.format = XmFMT_8_BIT;
  47. ***************
  48. *** 1889,1904 ****
  49.       char buf[INSERTCHARBUFSIZ];
  50.       KeySym keysym;
  51.       int len, status;
  52.   
  53.       DEBUGOUT(XdbDebug(__FILE__, w, "SelfInsert"));
  54. -     if (!Text_Editable(w))
  55. -     {
  56. -       VerifyBell((XmTextWidget)w);
  57. -       return;
  58. -     }
  59.   
  60.       len = XmImMbLookupString((Widget)w, (XKeyPressedEvent *)ev, buf, INSERTCHARBUFSIZ, &keysym, &status);
  61.   
  62.       if (XdbInDebug(__FILE__, w))
  63.       {
  64. --- 1895,1904 ----
  65. *** lesstif-0.83/lib/Xm/TextF.c.orig        Fri Mar 13 18:43:10 1998
  66. --- lesstif-0.83/lib/Xm/TextF.c     Sun Mar 15 17:39:23 1998
  67. ***************
  68. *** 2714,2723 ****
  69. --- 2714,2734 ----
  70.   }
  71.   
  72.   static void
  73.   DoInsert(XmTextFieldWidget w, XEvent *ev, char *buf, int len)
  74.   {
  75. +     if (len <= 0)
  76. +     {
  77. +       return;
  78. +     }
  79. +     if (!TextF_Editable(w))
  80. +     {
  81. +       VerifyBell(w);
  82. +       return;
  83. +     }
  84.       if (XdbInDebug(__FILE__, (Widget)w))
  85.       {
  86.       char *tmp;
  87.   
  88.         /* buf is not necessarily NULL terminated!!!! */
  89. ***************
  90. *** 4029,4047 ****
  91.       char buf[INSERTCHARBUFSIZ];
  92.       KeySym keysym;
  93.       int len, status;
  94.   
  95.       DBGW("self_insert");
  96. -     if (!TextF_Editable(tfw))
  97. -     {
  98. -       if (TextF_VerifyBell(tfw))
  99. -       {
  100. -           beep((Widget)tfw, ev, params, num_params);
  101. -       }
  102. -       return;
  103. -     }
  104.   
  105.       len = XmImMbLookupString((Widget)tfw,
  106.                              (XKeyPressedEvent *)ev, buf,
  107.                              INSERTCHARBUFSIZ,
  108.                              &keysym,
  109. --- 4040,4049 ----
  110.  
  111. Subject: XmTrackingEvent() bugs in LessTif 0.83, and a patch
  112. To: lesstif@hungry.com (LessTif Mailing List)
  113. Date: Tue, 17 Mar 1998 12:39:23 +0100 (MET)
  114.  
  115. Hi!
  116.  
  117. I reported two bugs in LessTif 0.83 XmTrackingEvent(); the enclosed
  118. patch fixes them.
  119.  
  120. >  In XmTrackingEvent(), a KeyRelease event causes the tracking to be
  121. >  finished right away.  This has a disadvantage: if I invoke
  122. >  XmTrackingEvent using some key (say, F1), the tracking is finished
  123. >  as soon as the key is released.  In M*tif, AFAIK, tracking is not
  124. >  influenced by key events.  Suggestion: check for ButtonRelease
  125. >  events only.
  126.  
  127. The patch modifies XmTrackingEvent() such that the tracking is
  128. finished only if a key is first pressed, then released, in accordance
  129. with the Motif 1.2 spec.
  130.  
  131. > In LessTif 0.83 (TrackLoc.c), XmTrackingEvent() does not return
  132. > anything in event_return.
  133.  
  134. The patch fixes this problem, too.
  135.  
  136. The patch also fixes the following improvements:
  137.  
  138. * If the pointer grab fails, issues an error message
  139. * Use XtLastTimestampProcessed() instead of CurrentTime for grabs
  140.  
  141. Happy hacking,
  142. -- 
  143. Andreas Zeller     Technische Universitaet Braunschweig, Germany
  144.                    mailto:zeller@acm.org http://www.cs.tu-bs.de/~zeller/
  145. *** lesstif-0.83/lib/Xm/TrackLoc.c.orig     Tue Mar 17 12:09:15 1998
  146. --- lesstif-0.83/lib/Xm/TrackLoc.c  Tue Mar 17 12:25:21 1998
  147. ***************
  148. *** 34,43 ****
  149. --- 34,45 ----
  150.   XmTrackingEvent(Widget widget, Cursor cursor,
  151.                 Boolean confine_to, XEvent *event_return)
  152.   {
  153.       Window confine_to_this;
  154.       XEvent ev;
  155. +     Boolean key_pressed = False;
  156. +     Time time;
  157.   
  158.       if (confine_to)
  159.       {
  160.         confine_to_this = XtWindow(widget);
  161.       }
  162. ***************
  163. *** 46,75 ****
  164.         confine_to_this = None;
  165.       }
  166.   
  167.       DEBUGOUT(XdbDebug(__FILE__, widget, "XmTrackingEvent: XtGrabPointer()\n"));
  168.   
  169. !     XtGrabPointer(widget,
  170. !                 True,
  171. !                 ButtonReleaseMask | ButtonPressMask,
  172. !                 GrabModeAsync,
  173. !                 GrabModeAsync,
  174. !                 confine_to_this,
  175. !                 cursor,
  176. !                 CurrentTime);
  177.   
  178.       while (True)
  179.       {
  180.         XtAppNextEvent(XtWidgetToApplicationContext(widget), &ev);
  181.   
  182. !       if (ev.xbutton.type == KeyRelease ||
  183. !           (ev.xbutton.type == ButtonRelease && ev.xbutton.button == 1))
  184.         {
  185.             DEBUGOUT(XdbDebug(__FILE__, widget,
  186.                               "XmTrackingEvent: XtUngrabPointer()\n"));
  187.   
  188. !           XtUngrabPointer(widget, CurrentTime);
  189.   
  190.             /* If the button was clicked outside of this programs windows,
  191.              * the widget that grabbed the pointer will get the event.  So,
  192.              * we check the bounds of the widget against the coordinates of
  193.              * the event.  If they're outside, we return NULL.  Otherwise we
  194. --- 48,88 ----
  195.         confine_to_this = None;
  196.       }
  197.   
  198.       DEBUGOUT(XdbDebug(__FILE__, widget, "XmTrackingEvent: XtGrabPointer()\n"));
  199.   
  200. !     time = XtLastTimestampProcessed(XtDisplay(widget));
  201. !     if (XtGrabPointer(widget, True,
  202. !                     ButtonReleaseMask | ButtonPressMask,
  203. !                     GrabModeAsync, GrabModeAsync,
  204. !                     confine_to_this, cursor, time) != GrabSuccess)
  205. !     {
  206. !       _XmWarning(widget, "XmTrackingEvent: Could not grab pointer");
  207. !       return NULL;
  208. !     }
  209.   
  210.       while (True)
  211.       {
  212.         XtAppNextEvent(XtWidgetToApplicationContext(widget), &ev);
  213. +       time = XtLastTimestampProcessed(XtDisplay(widget));
  214.   
  215. !       if (ev.xbutton.type == KeyPress)
  216.         {
  217. +           /* Avoid exiting upon releasing the key that caused
  218. +                XmTrackingEvent() to be invoked */
  219. +           key_pressed = True;
  220. +       }
  221. +       else if ((ev.xbutton.type == KeyRelease && key_pressed) ||
  222. +                (ev.xbutton.type == ButtonRelease && ev.xbutton.button == 1))
  223. +       {
  224. +           if (event_return != NULL)
  225. +               *event_return = ev;
  226.             DEBUGOUT(XdbDebug(__FILE__, widget,
  227.                               "XmTrackingEvent: XtUngrabPointer()\n"));
  228.   
  229. !           XtUngrabPointer(widget, time);
  230.   
  231.             /* If the button was clicked outside of this programs windows,
  232.              * the widget that grabbed the pointer will get the event.  So,
  233.              * we check the bounds of the widget against the coordinates of
  234.              * the event.  If they're outside, we return NULL.  Otherwise we
  235.  
  236. Subject: An XmCvtXmStringToText() implementation
  237. To: lesstif@hungry.com (LessTif Mailing List)
  238. Date: Tue, 17 Mar 1998 15:23:39 +0100 (MET)
  239.  
  240. Hi!
  241.  
  242. I want to contribute an implementation of the XmCvtXmStringToText()
  243. function - a XmString -> String converter.  Among others, this
  244. converter is useful in creating the titles of tear-off menus (see
  245. second mail).
  246.  
  247. Greetings,
  248.  
  249. -- 
  250. Andreas Zeller     Technische Universitaet Braunschweig, Germany
  251.                    mailto:zeller@acm.org http://www.cs.tu-bs.de/~zeller/
  252.  
  253. *** lesstif-0.83/lib/Xm/ResConvert.c.orig   Tue Mar 17 15:18:35 1998
  254. --- lesstif-0.83/lib/Xm/ResConvert.c        Tue Mar 17 15:16:42 1998
  255. ***************
  256. *** 908,919 ****
  257.   Boolean
  258.   XmCvtXmStringToText(Display *display, XrmValuePtr args,
  259.                     Cardinal *num_args, XrmValue *from_val, XrmValue *to_val,
  260.                     XtPointer *converter_data)
  261.   {
  262. !     DEBUGOUT(XdbDebug(__FILE__, NULL, "XmCvtXmStringToText\n"));
  263. !     return False;
  264.   }
  265.   
  266.   /*
  267.    * Compare two strings to see if they're equivalent. This one is used
  268.    * whenever comparing motif constants with resource string values. The
  269. --- 908,980 ----
  270.   Boolean
  271.   XmCvtXmStringToText(Display *display, XrmValuePtr args,
  272.                     Cardinal *num_args, XrmValue *from_val, XrmValue *to_val,
  273.                     XtPointer *converter_data)
  274.   {
  275. !     char *value = strdup("");
  276. !     XmString m = (XmString)from_val->addr;
  277. !     XmStringContext c;
  278. !     XmStringComponentType t = XmSTRING_COMPONENT_UNKNOWN;
  279. !     if (*num_args != 0)
  280. !     {
  281. !       XtWarningMsg("wrongParameters", "XmCvtXmStringToText",
  282. !                    "XtToolkitError",
  283. !                    "XmString to String conversion needs no extra arguments",
  284. !                    (String *)NULL, (Cardinal *)NULL);
  285. !     }
  286. !     XmStringInitContext(&c, m);
  287. !     while (t != XmSTRING_COMPONENT_END)
  288. !     {
  289. !       char *s_text            = NULL;
  290. !       XmStringCharSet s_cs    = NULL;
  291. !       XmStringDirection d     = XmSTRING_DIRECTION_DEFAULT;
  292. !       XmStringComponentType u = XmSTRING_COMPONENT_UNKNOWN;
  293. !       unsigned short ul       = 0;
  294. !       unsigned char *s_uv     = NULL;
  295. !       char *text              = NULL;
  296. !       
  297. !       t = XmStringGetNextComponent(c, &s_text, &s_cs, &d, &u, &ul, &s_uv);
  298. !       switch (t)
  299. !       {
  300. !       case XmSTRING_COMPONENT_TEXT:
  301. !       case XmSTRING_COMPONENT_LOCALE_TEXT:
  302. !           text = s_text;
  303. !           break;
  304. !       case XmSTRING_COMPONENT_SEPARATOR:
  305. !           text = "\n";
  306. !           break;
  307. !       default:
  308. !           /* Unknown component */
  309. !           text = NULL;
  310. !           break;
  311. !       }
  312. !       if (text != NULL)
  313. !       {
  314. !           value = XtRealloc(value, strlen(value) + strlen(text) + 1);
  315. !           strcat(value, text);
  316. !       }
  317. !       XtFree(s_text);
  318. !       XtFree(s_cs);
  319. !       XtFree((char *)s_uv);
  320. !     }
  321. !     to_val->addr = value;
  322. !     to_val->size = strlen(value);  /* FIXME: should this be sizeof(value)? */
  323. !     DEBUGOUT(XdbDebug(__FILE__, NULL,
  324. !                     "XmCvtXmStringToText(%p) => %s\n",
  325. !                     from_val->addr, to_val->addr));
  326. !     return True;
  327.   }
  328.   
  329.   /*
  330.    * Compare two strings to see if they're equivalent. This one is used
  331.    * whenever comparing motif constants with resource string values. The
  332.  
  333. Subject: An improved method for determining tear-off titles
  334. To: lesstif@hungry.com (LessTif Mailing List)
  335. Date: Tue, 17 Mar 1998 15:26:41 +0100 (MET)
  336.  
  337. Hi!
  338.  
  339. The default implementation of tear-off menus uses XmStringGetLtoR() to
  340. copy the label string to the tear-off menu title.  This fails on a
  341. number of occasions - if the label does not use a standard font, or
  342. uses accelerators, for example.  The included patch makes tear-off
  343. menus use the XmCvtXmStringToText() converter instead; an
  344. implementation is given in a second mail.
  345.  
  346. Greetings,
  347.  
  348. -- 
  349. Andreas Zeller     Technische Universitaet Braunschweig, Germany
  350.                    mailto:zeller@acm.org http://www.cs.tu-bs.de/~zeller/
  351.  
  352. *** lesstif-0.83/lib/Xm/TearOff.c.orig      Tue Mar 17 15:18:21 1998
  353. --- lesstif-0.83/lib/Xm/TearOff.c   Tue Mar 17 15:16:34 1998
  354. ***************
  355. *** 352,378 ****
  356.   
  357.       sprintf(to_shell_name, "%s%s",
  358.                 RC_CascadeBtn(w) ? XtName(RC_CascadeBtn(w)) : "",
  359.                 TEAR_OFF_SHELL_NAME);
  360.       {
  361. !     XmString string;
  362. !     unsigned char type;
  363.   
  364.         if ( RC_Type(w) != XmMENU_POPUP)
  365.         {
  366.             XtVaGetValues(RC_CascadeBtn(w),
  367.                     XmNlabelString, &string,
  368.                     XmNlabelType, &type,
  369.                     NULL);
  370.             if (type == XmSTRING)
  371.             {
  372. !               XmStringGetLtoR(string, XmFONTLIST_DEFAULT_TAG, &to_shell_title);
  373.                 XmStringFree(string);
  374.             }
  375.             else
  376.             {
  377. !                   to_shell_title = strdup("");
  378.             }
  379.         }
  380.         else
  381.         {
  382.                 to_shell_title = strdup("");
  383. --- 352,394 ----
  384.   
  385.       sprintf(to_shell_name, "%s%s",
  386.                 RC_CascadeBtn(w) ? XtName(RC_CascadeBtn(w)) : "",
  387.                 TEAR_OFF_SHELL_NAME);
  388.       {
  389. !       XmString string;
  390. !       unsigned char type;
  391.   
  392.         if ( RC_Type(w) != XmMENU_POPUP)
  393.         {
  394.             XtVaGetValues(RC_CascadeBtn(w),
  395.                     XmNlabelString, &string,
  396.                     XmNlabelType, &type,
  397.                     NULL);
  398.             if (type == XmSTRING)
  399.             {
  400. !               /* Invoke XmString -> String converter */
  401. !               Cardinal zero = 0;
  402. !               XrmValue from;
  403. !               XrmValue to;
  404. !               from.addr = (char *)string;
  405. !               if (XmCvtXmStringToText(XtDisplay(w), NULL, &zero, 
  406. !                                       &from, &to, NULL))
  407. !               {
  408. !                   to_shell_title = to.addr;
  409. !               }
  410. !               else
  411. !               {
  412. !                   /* converter failed - use simple fallback */
  413. !                   XmStringGetLtoR(string, XmFONTLIST_DEFAULT_TAG, 
  414. !                                   &to_shell_title);
  415. !               }
  416.                 XmStringFree(string);
  417.             }
  418.             else
  419.             {
  420. !               to_shell_title = strdup("");
  421.             }
  422.         }
  423.         else
  424.         {
  425.                 to_shell_title = strdup("");
  426.  
  427. Subject: Button3 popup menus are insensitive the first time they pop up, 
  428.      and a patch
  429. To: lesstif@hungry.com (LessTif Mailing List)
  430. Date: Fri, 20 Mar 1998 12:49:58 +0100 (MET)
  431.  
  432. Hi!
  433.  
  434. In LessTif 0.83, a popup menu bound to Button3 is insensitive the
  435. first time they pop up - the menu is not placed in drag mode, as it
  436. should be.  The enclosed patch to RowColumn.c:_XmPostPopupMenu() fixes
  437. this problem; in the long run, one should care to pass a correct event
  438. structure to _XmPostPopupMenu().
  439.  
  440. This was the last outstanding problem with DDD and LessTif 0.83.  You
  441. guys surely have done a great work.
  442.  
  443. Happy hacking,
  444.  
  445. -- 
  446. Andreas Zeller     Technische Universitaet Braunschweig, Germany
  447.                    mailto:zeller@acm.org http://www.cs.tu-bs.de/~zeller/
  448. *** lesstif-0.83/lib/Xm/RowColumn.c.orig    Fri Mar 13 23:25:33 1998
  449. --- lesstif-0.83/lib/Xm/RowColumn.c    Fri Mar 20 13:06:51 1998
  450. ***************
  451. *** 3050,3060 ****
  452.       DEBUGOUT(XdbDebug(__FILE__, wid, "PostPopupMenu()\n"));
  453.   
  454.       time = XtLastTimestampProcessed(XtDisplay(wid));
  455.       if (type == 0)
  456.       {
  457. !     type = KeyPress;
  458.       }
  459.   
  460.       state->RC_ButtonEventStatus.waiting_to_be_managed = False;
  461.       state->RC_ButtonEventStatus.time = time;
  462.   
  463. --- 3050,3066 ----
  464.       DEBUGOUT(XdbDebug(__FILE__, wid, "PostPopupMenu()\n"));
  465.   
  466.       time = XtLastTimestampProcessed(XtDisplay(wid));
  467.       if (type == 0)
  468.       {
  469. !     /* Was KeyPress in LessTif 0.83, but this makes button3 popup
  470. !            menus insensitive the first time they pop up - they are not
  471. !            placed in drag mode.
  472. !        - Andreas Zeller <zeller@ips.cs.tu-bs.de>
  473. !        FIXME: Don't know whether this breaks keypress popup menus. */
  474. !        
  475. !     type = ButtonPress;
  476.       }
  477.   
  478.       state->RC_ButtonEventStatus.waiting_to_be_managed = False;
  479.       state->RC_ButtonEventStatus.time = time;
  480.   
  481.