git: 673bb072f659 - main - x11-toolkits/open-motif*: Disable XmPIXMAP mode for drag-and-drop

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Tue, 05 Dec 2023 00:09:27 UTC
The branch main has been updated by cy:

URL: https://cgit.FreeBSD.org/ports/commit/?id=673bb072f65941cabebffbbdc73ebd5c7ade48cc

commit 673bb072f65941cabebffbbdc73ebd5c7ade48cc
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-12-05 00:00:23 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-12-05 00:02:06 +0000

    x11-toolkits/open-motif*: Disable XmPIXMAP mode for drag-and-drop
    
    In XmPIXMAP mode, Motif will draw to the root window with
    IncludeInferious without being under a GrabServer.
    
    This results in a variety of graphical glitches. For example, when a
    compositing window manager updates the screen it will erase the drag
    icon. This continues until the icon leaves the origin window, when Motif
    does a GrabServer. The GrabServer avoids the graphical glitches, but it
    also freezes the rest of the desktop (which is impolite).
    
    Given that all current X servers support SHAPE, and given that most
    users are running a compositing window manager, XmDRAG_WINDOW is always
    a better choice. Therefore, disable XmPIXMAP entirely.
    
    Obtained from:  https://sourceforge.net/p/motif/code/merge-requests/1/
---
 x11-toolkits/open-motif-devel/Makefile             |  2 +-
 .../open-motif-devel/files/patch-lib_Xm_DragC.c    | 76 ++++++++++++++++++++++
 x11-toolkits/open-motif/Makefile                   |  2 +-
 x11-toolkits/open-motif/files/patch-lib_Xm_DragC.c | 76 ++++++++++++++++++++++
 4 files changed, 154 insertions(+), 2 deletions(-)

diff --git a/x11-toolkits/open-motif-devel/Makefile b/x11-toolkits/open-motif-devel/Makefile
index 36f53474ca9d..ec74a5e473a9 100644
--- a/x11-toolkits/open-motif-devel/Makefile
+++ b/x11-toolkits/open-motif-devel/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	open-motif
 PORTVERSION=	${COMMIT_DATE}
-PORTREVISION=	5
+PORTREVISION=	6
 CATEGORIES=	x11-toolkits
 PKGNAMESUFFIX=	-devel
 
diff --git a/x11-toolkits/open-motif-devel/files/patch-lib_Xm_DragC.c b/x11-toolkits/open-motif-devel/files/patch-lib_Xm_DragC.c
new file mode 100644
index 000000000000..8001ce0251a6
--- /dev/null
+++ b/x11-toolkits/open-motif-devel/files/patch-lib_Xm_DragC.c
@@ -0,0 +1,76 @@
+--- lib/Xm/DragC.c.orig	2023-02-15 16:42:34.000000000 -0800
++++ lib/Xm/DragC.c	2023-12-04 15:58:13.960304000 -0800
+@@ -846,35 +846,18 @@
+   if (newStyle != oldStyle) 
+     {
+       /*
+-       * If we're not still waiting to hear from the window manager,
+-       * and we're not running dynamic, then we can grab.
++       * If we are in pixmap mode, release the grab.
+        */
+-      if ((dc->drag.trackingMode != XmDRAG_TRACK_WM_QUERY_PENDING) &&
+-	  (newStyle != XmDRAG_DYNAMIC) &&
+-	  (initiator != XmDRAG_DYNAMIC) &&
+-	  (initiator != XmDRAG_PREFER_DYNAMIC))
++      if (dc->drag.serverGrabbed)
+ 	{
+-	  if (!dc->drag.serverGrabbed)
+-	    {
+-	      XGrabServer(XtDisplay(dc));
+-	      dc->drag.serverGrabbed = True;
+-	      XtSetArg(args[0], XmNdragOverMode, XmPIXMAP);
+-	      XtSetValues( (Widget)dc->drag.curDragOver, args, 1);
+-	    }
++	  XUngrabServer(XtDisplay(dc));
++	  dc->drag.serverGrabbed = False;
++	  if (xmDisplay -> display.displayHasShapeExtension)
++	    XtSetArg(args[0], XmNdragOverMode, XmDRAG_WINDOW);
++	  else
++	    XtSetArg(args[0], XmNdragOverMode, XmCURSOR);
++	  XtSetValues( (Widget)dc->drag.curDragOver, args, 1);
+ 	}
+-      else
+-	{
+-	  if (dc->drag.serverGrabbed)
+-	    {
+-	      XUngrabServer(XtDisplay(dc));
+-	      dc->drag.serverGrabbed = False;
+-	      if (xmDisplay -> display.displayHasShapeExtension) 
+-		XtSetArg(args[0], XmNdragOverMode, XmDRAG_WINDOW);
+-	      else
+-		XtSetArg(args[0], XmNdragOverMode, XmCURSOR);
+-	      XtSetValues( (Widget)dc->drag.curDragOver, args, 1);
+-	    }
+-	}
+     }
+ }
+ 
+@@ -1687,23 +1670,13 @@
+   /* Build a new one */
+   i = 0;
+   /*
+-   * If this is the first call, tracking mode will be querypending
+-   * and we have to come up in cursor mode.  Otherwise, we come up
+-   * in cursor for dynamic and pixmap for preregister.
++   * Always come up in window mode (or cursor if SHAPE is not available).
+    */
+-  if ((dc->drag.trackingMode == XmDRAG_TRACK_WM_QUERY_PENDING) ||
+-      (dc->drag.activeProtocolStyle == XmDRAG_DYNAMIC))
+-    {
+-      if (dpy -> display.displayHasShapeExtension) 
+-	XtSetArg(args[i], XmNdragOverMode, XmDRAG_WINDOW);
+-      else
+-	XtSetArg(args[i], XmNdragOverMode, XmCURSOR); 
+-      i++;
+-    }
++  if (dpy -> display.displayHasShapeExtension)
++    XtSetArg(args[i], XmNdragOverMode, XmDRAG_WINDOW);
+   else
+-    {
+-      XtSetArg(args[i], XmNdragOverMode, XmPIXMAP); i++;
+-    }
++    XtSetArg(args[i], XmNdragOverMode, XmCURSOR);
++  i++;
+   
+   XtSetArg(args[i], XmNhotX, dc->core.x); i++;
+   XtSetArg(args[i], XmNhotY, dc->core.y); i++;
diff --git a/x11-toolkits/open-motif/Makefile b/x11-toolkits/open-motif/Makefile
index 99fa75185d19..2723ca4a7381 100644
--- a/x11-toolkits/open-motif/Makefile
+++ b/x11-toolkits/open-motif/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	open-motif
 PORTVERSION=	2.3.8
-PORTREVISION=	6
+PORTREVISION=	7
 CATEGORIES=	x11-toolkits
 # MASTER_SITES=	SF/${PORTNAME}/Motif%202.3.4%20Source%20Code/
 MASTER_SITES=	SF/motif/Motif%20${PORTVERSION}%20Source%20Code/
diff --git a/x11-toolkits/open-motif/files/patch-lib_Xm_DragC.c b/x11-toolkits/open-motif/files/patch-lib_Xm_DragC.c
new file mode 100644
index 000000000000..4a96f46a04f4
--- /dev/null
+++ b/x11-toolkits/open-motif/files/patch-lib_Xm_DragC.c
@@ -0,0 +1,76 @@
+--- lib/Xm/DragC.c.orig	2017-08-16 17:38:43.000000000 -0700
++++ lib/Xm/DragC.c	2023-12-04 15:58:26.431030000 -0800
+@@ -846,35 +846,18 @@
+   if (newStyle != oldStyle) 
+     {
+       /*
+-       * If we're not still waiting to hear from the window manager,
+-       * and we're not running dynamic, then we can grab.
++       * If we are in pixmap mode, release the grab.
+        */
+-      if ((dc->drag.trackingMode != XmDRAG_TRACK_WM_QUERY_PENDING) &&
+-	  (newStyle != XmDRAG_DYNAMIC) &&
+-	  (initiator != XmDRAG_DYNAMIC) &&
+-	  (initiator != XmDRAG_PREFER_DYNAMIC))
++      if (dc->drag.serverGrabbed)
+ 	{
+-	  if (!dc->drag.serverGrabbed)
+-	    {
+-	      XGrabServer(XtDisplay(dc));
+-	      dc->drag.serverGrabbed = True;
+-	      XtSetArg(args[0], XmNdragOverMode, XmPIXMAP);
+-	      XtSetValues( (Widget)dc->drag.curDragOver, args, 1);
+-	    }
++	  XUngrabServer(XtDisplay(dc));
++	  dc->drag.serverGrabbed = False;
++	  if (xmDisplay -> display.displayHasShapeExtension)
++	    XtSetArg(args[0], XmNdragOverMode, XmDRAG_WINDOW);
++	  else
++	    XtSetArg(args[0], XmNdragOverMode, XmCURSOR);
++	  XtSetValues( (Widget)dc->drag.curDragOver, args, 1);
+ 	}
+-      else
+-	{
+-	  if (dc->drag.serverGrabbed)
+-	    {
+-	      XUngrabServer(XtDisplay(dc));
+-	      dc->drag.serverGrabbed = False;
+-	      if (xmDisplay -> display.displayHasShapeExtension) 
+-		XtSetArg(args[0], XmNdragOverMode, XmDRAG_WINDOW);
+-	      else
+-		XtSetArg(args[0], XmNdragOverMode, XmCURSOR);
+-	      XtSetValues( (Widget)dc->drag.curDragOver, args, 1);
+-	    }
+-	}
+     }
+ }
+ 
+@@ -1687,23 +1670,13 @@
+   /* Build a new one */
+   i = 0;
+   /*
+-   * If this is the first call, tracking mode will be querypending
+-   * and we have to come up in cursor mode.  Otherwise, we come up
+-   * in cursor for dynamic and pixmap for preregister.
++   * Always come up in window mode (or cursor if SHAPE is not available).
+    */
+-  if ((dc->drag.trackingMode == XmDRAG_TRACK_WM_QUERY_PENDING) ||
+-      (dc->drag.activeProtocolStyle == XmDRAG_DYNAMIC))
+-    {
+-      if (dpy -> display.displayHasShapeExtension) 
+-	XtSetArg(args[i], XmNdragOverMode, XmDRAG_WINDOW);
+-      else
+-	XtSetArg(args[i], XmNdragOverMode, XmCURSOR); 
+-      i++;
+-    }
++  if (dpy -> display.displayHasShapeExtension)
++    XtSetArg(args[i], XmNdragOverMode, XmDRAG_WINDOW);
+   else
+-    {
+-      XtSetArg(args[i], XmNdragOverMode, XmPIXMAP); i++;
+-    }
++    XtSetArg(args[i], XmNdragOverMode, XmCURSOR);
++  i++;
+   
+   XtSetArg(args[i], XmNhotX, dc->core.x); i++;
+   XtSetArg(args[i], XmNhotY, dc->core.y); i++;