Blame SOURCES/revert-of-motifzone_1565.patch

94fd7f
From 18de86345d5e455b815fe0395d2992b9a2f1195f Mon Sep 17 00:00:00 2001
94fd7f
From: Oleksiy Chernyavskyy <ochern@ics.com>
94fd7f
Date: Tue, 28 Mar 2017 01:11:59 +0300
94fd7f
Subject: [PATCH] removed bugfix 1565. See details on
94fd7f
 http://bugs.motifzone.net/show_bug.cgi?id=1565
94fd7f
94fd7f
---
94fd7f
 lib/Xm/ComboBox.c   |   8 ---
94fd7f
 lib/Xm/DropDown.c   |   7 ---
94fd7f
 lib/Xm/GrabShell.c  |  15 +----
94fd7f
 lib/Xm/GrabShellP.h |   3 -
94fd7f
 lib/Xm/RCMenu.c     |  40 ------------
94fd7f
 lib/Xm/Xm.c         | 173 ----------------------------------------------------
94fd7f
 lib/Xm/XmI.h        |   4 --
94fd7f
 7 files changed, 2 insertions(+), 248 deletions(-)
94fd7f
94fd7f
diff --git a/lib/Xm/ComboBox.c b/lib/Xm/ComboBox.c
94fd7f
index cf507da4..1472e458 100644
94fd7f
--- a/lib/Xm/ComboBox.c
94fd7f
+++ b/lib/Xm/ComboBox.c
94fd7f
@@ -3164,9 +3164,6 @@ CreatePulldown(Widget    parent,
94fd7f
   Arg      args[4];
94fd7f
   ArgList  merged_args;
94fd7f
   Cardinal n;
94fd7f
-#ifdef FIX_1565
94fd7f
-  XmGrabShellWidget grabsh;
94fd7f
-#endif
94fd7f
 
94fd7f
   n = 0;
94fd7f
   XtSetArg(args[n], XmNlayoutDirection, LayoutM(parent)), n++;
94fd7f
@@ -3178,11 +3175,6 @@ CreatePulldown(Widget    parent,
94fd7f
 			     merged_args, n + *num_args);
94fd7f
   XtFree((char*)merged_args);
94fd7f
 
94fd7f
-#ifdef FIX_1565
94fd7f
-  grabsh = (XmGrabShellWidget) shell;
94fd7f
-  grabsh->grab_shell.set_input_focus = False;
94fd7f
-#endif
94fd7f
-
94fd7f
   return shell;
94fd7f
 }
94fd7f
 
94fd7f
diff --git a/lib/Xm/DropDown.c b/lib/Xm/DropDown.c
94fd7f
index 5cd15cae..37fec03f 100644
94fd7f
--- a/lib/Xm/DropDown.c
94fd7f
+++ b/lib/Xm/DropDown.c
94fd7f
@@ -2027,9 +2027,6 @@ CreatePopup(Widget w, ArgList args, Cardinal num_args)
94fd7f
     Arg *new_list, largs[10];
94fd7f
     Cardinal num_largs;
94fd7f
     Widget sb;
94fd7f
-#ifdef FIX_1565
94fd7f
-    XmGrabShellWidget grabsh;
94fd7f
-#endif
94fd7f
 
94fd7f
     num_largs = 0;
94fd7f
     XtSetArg(largs[num_largs], XmNoverrideRedirect, True); num_largs++;
94fd7f
@@ -2043,10 +2040,6 @@ CreatePopup(Widget w, ArgList args, Cardinal num_args)
94fd7f
 						xmGrabShellWidgetClass, w,
94fd7f
 						new_list,
94fd7f
 						num_largs + num_args);
94fd7f
-#ifdef FIX_1565
94fd7f
-    grabsh = (XmGrabShellWidget) XmDropDown_popup_shell(cbw);
94fd7f
-    grabsh->grab_shell.set_input_focus = False;
94fd7f
-#endif
94fd7f
     XtFree((char *) new_list);
94fd7f
 
94fd7f
 #ifdef FIX_1446
94fd7f
diff --git a/lib/Xm/GrabShell.c b/lib/Xm/GrabShell.c
94fd7f
index af13e0b7..a73f7cb9 100644
94fd7f
--- a/lib/Xm/GrabShell.c
94fd7f
+++ b/lib/Xm/GrabShell.c
94fd7f
@@ -284,9 +284,6 @@ Initialize(Widget req,		/* unused */
94fd7f
   /* CR 9920:  Popdown may be requested before MapNotify. */
94fd7f
   grabsh->grab_shell.mapped = False;
94fd7f
 
94fd7f
-#ifdef FIX_1565
94fd7f
-  grabsh->grab_shell.set_input_focus = True;
94fd7f
-#endif
94fd7f
 }
94fd7f
 
94fd7f
 /*
94fd7f
@@ -399,16 +396,8 @@ MapNotifyHandler(Widget shell, XtPointer client_data,
94fd7f
   XGetInputFocus(XtDisplay(shell), &grabshell->grab_shell.old_focus,
94fd7f
 		 &grabshell->grab_shell.old_revert_to);
94fd7f
   old_handler = XSetErrorHandler(IgnoreXErrors);
94fd7f
-#ifdef FIX_1565
94fd7f
-  if (! grabshell->grab_shell.set_input_focus) {
94fd7f
-    XmForceGrabKeyboard(shell, time);
94fd7f
-  } else {
94fd7f
-#endif
94fd7f
-    XSetInputFocus(XtDisplay(shell), XtWindow(shell), RevertToParent, time);
94fd7f
-    XSync(XtDisplay(shell), False);
94fd7f
-#ifdef FIX_1565
94fd7f
-  }
94fd7f
-#endif
94fd7f
+  XSetInputFocus(XtDisplay(shell), XtWindow(shell), RevertToParent, time);
94fd7f
+  XSync(XtDisplay(shell), False);
94fd7f
   XSetErrorHandler(old_handler);
94fd7f
 }
94fd7f
 
94fd7f
diff --git a/lib/Xm/GrabShellP.h b/lib/Xm/GrabShellP.h
94fd7f
index 025f0015..e2585540 100644
94fd7f
--- a/lib/Xm/GrabShellP.h
94fd7f
+++ b/lib/Xm/GrabShellP.h
94fd7f
@@ -56,9 +56,6 @@ typedef struct
94fd7f
   Boolean	mapped;
94fd7f
   Window	old_focus;
94fd7f
   int		old_revert_to;
94fd7f
-#ifdef FIX_1565
94fd7f
-  Boolean	set_input_focus;
94fd7f
-#endif
94fd7f
 } XmGrabShellPart;
94fd7f
 
94fd7f
 
94fd7f
diff --git a/lib/Xm/RCMenu.c b/lib/Xm/RCMenu.c
94fd7f
index 8b156da5..2c698d4f 100644
94fd7f
--- a/lib/Xm/RCMenu.c
94fd7f
+++ b/lib/Xm/RCMenu.c
94fd7f
@@ -85,9 +85,6 @@ static char *rcsid = "$TOG: RCMenu.c /main/25 1999/05/24 18:06:57 samborn $";
94fd7f
 #include "TraversalI.h"
94fd7f
 #include "UniqueEvnI.h"
94fd7f
 #include "VendorSI.h"
94fd7f
-#ifdef FIX_1565
94fd7f
-#include <Xm/GrabShell.h>
94fd7f
-#endif
94fd7f
 
94fd7f
 #define FIX_1535
94fd7f
 
94fd7f
@@ -946,13 +943,6 @@ _XmMenuFocus(
94fd7f
    XmMenuState mst = _XmGetMenuState((Widget)w);
94fd7f
    Window tmpWindow;
94fd7f
    int tmpRevert;
94fd7f
-#ifdef FIX_1565
94fd7f
-   Widget shell;
94fd7f
-
94fd7f
-   shell = w;
94fd7f
-   while (! XtIsSubclass(shell, shellWidgetClass))
94fd7f
-     shell = XtParent(shell);
94fd7f
-#endif
94fd7f
  
94fd7f
    if (_time == CurrentTime) 
94fd7f
      _time = XtLastTimestampProcessed(XtDisplay(w));
94fd7f
@@ -993,11 +983,6 @@ _XmMenuFocus(
94fd7f
 			  shell.popped_up))
94fd7f
 **/
94fd7f
 		     {
94fd7f
-#ifdef FIX_1565
94fd7f
-               if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
94fd7f
-                 XmForceGrabKeyboard(w, _time);
94fd7f
-               else
94fd7f
-#endif
94fd7f
 		       SetInputFocus(XtDisplay(w), mst->RC_menuFocus.oldFocus,
94fd7f
 				     mst->RC_menuFocus.oldRevert,
94fd7f
 				     mst->RC_menuFocus.oldTime);
94fd7f
@@ -1011,11 +996,6 @@ _XmMenuFocus(
94fd7f
  	      */
94fd7f
  	     else
94fd7f
  	       {
94fd7f
-#ifdef FIX_1565
94fd7f
-               if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
94fd7f
-                 XmForceGrabKeyboard(w, _time);
94fd7f
-               else
94fd7f
-#endif
94fd7f
  		  SetInputFocus(XtDisplay(w), mst->RC_menuFocus.oldFocus,
94fd7f
 				mst->RC_menuFocus.oldRevert,
94fd7f
 				mst->RC_menuFocus.oldTime);
94fd7f
@@ -1034,11 +1014,6 @@ _XmMenuFocus(
94fd7f
 	     RC_menuFocus.oldFocus);
94fd7f
 	  mst->RC_menuFocus.oldTime = _time - 1;
94fd7f
 
94fd7f
-#ifdef FIX_1565
94fd7f
-      if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
94fd7f
-        XmForceGrabKeyboard(w, _time);
94fd7f
-      else
94fd7f
-#endif
94fd7f
 	  SetInputFocus(XtDisplay(w), XtWindow(w), mst->RC_menuFocus.oldRevert,
94fd7f
 			mst->RC_menuFocus.oldTime);
94fd7f
 
94fd7f
@@ -1052,11 +1027,6 @@ _XmMenuFocus(
94fd7f
 	  XGetInputFocus(XtDisplay(w), &tmpWindow, &tmpRevert);
94fd7f
 	  if (tmpWindow != XtWindow(w))
94fd7f
 	  {
94fd7f
-#ifdef FIX_1565
94fd7f
-        if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
94fd7f
-          XmForceGrabKeyboard(w, _time);
94fd7f
-        else
94fd7f
-#endif
94fd7f
 	    SetInputFocus(XtDisplay(w), XtWindow(w), tmpRevert, _time);
94fd7f
 
94fd7f
 	    mst->RC_menuFocus.oldRevert = tmpRevert;
94fd7f
@@ -1078,11 +1048,6 @@ _XmMenuFocus(
94fd7f
 
94fd7f
 	  break;
94fd7f
 	case XmMENU_MIDDLE:
94fd7f
-#ifdef FIX_1565
94fd7f
-      if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
94fd7f
-        XmForceGrabKeyboard(w, _time);
94fd7f
-      else
94fd7f
-#endif
94fd7f
 	  SetInputFocus(XtDisplay(w), XtWindow(w),
94fd7f
 			mst->RC_menuFocus.oldRevert,
94fd7f
 			mst->RC_menuFocus.oldTime);
94fd7f
@@ -1097,11 +1062,6 @@ _XmMenuFocus(
94fd7f
 	  if ((tmpWindow != XtWindow(w)) &&
94fd7f
 	      (_time > mst->RC_menuFocus.oldTime))
94fd7f
 	  {
94fd7f
-#ifdef FIX_1565
94fd7f
-        if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
94fd7f
-          XmForceGrabKeyboard(w, _time);
94fd7f
-        else
94fd7f
-#endif
94fd7f
 	    SetInputFocus(XtDisplay(w), XtWindow(w), tmpRevert, _time);
94fd7f
 
94fd7f
 	    mst->RC_menuFocus.oldRevert = tmpRevert;
94fd7f
diff --git a/lib/Xm/Xm.c b/lib/Xm/Xm.c
94fd7f
index 45d48b61..657f9041 100644
94fd7f
--- a/lib/Xm/Xm.c
94fd7f
+++ b/lib/Xm/Xm.c
94fd7f
@@ -40,10 +40,6 @@
94fd7f
 #ifdef FIX_345
94fd7f
 #include <X11/keysym.h>
94fd7f
 #endif
94fd7f
-#ifdef FIX_1565
94fd7f
-#include <Xm/GrabShell.h>
94fd7f
-#include <Xm/MenuShell.h>
94fd7f
-#endif
94fd7f
 
94fd7f
 
94fd7f
 /**************************************************************************
94fd7f
@@ -535,172 +531,3 @@ _XmAssignInsensitiveColor(Widget w)
94fd7f
 }
94fd7f
 #endif
94fd7f
 
94fd7f
-#ifdef FIX_1565
94fd7f
-
94fd7f
-typedef struct _GrabData GrabData;
94fd7f
-struct _GrabData {
94fd7f
-  Widget w;
94fd7f
-  GrabData *next;
94fd7f
-};
94fd7f
-
94fd7f
-static void _XmSendFocusEvent(Widget child, int type);
94fd7f
-static void _XmStartDispatcher(Display *display);
94fd7f
-static Boolean _XmEventDispatcher(XEvent *event);
94fd7f
-static void UnmapHandler(Widget w, XtPointer client_data, XEvent *event, Boolean *cont);
94fd7f
-static Boolean _UngrabKeyboard(Widget w);
94fd7f
-
94fd7f
-static GrabData *grabw_top = NULL;
94fd7f
-static int xm_dispatcher_on = 0;
94fd7f
-static XtEventDispatchProc saved_dispatcher_proc = NULL;
94fd7f
-static XtEventDispatchProc xt_dispatcher_proc = NULL;
94fd7f
-
94fd7f
-/*
94fd7f
-   XmForceGrabKeyboard function is defined to be a substitutor of XSetInputFocus calls
94fd7f
-   for popup and pulldown menus that should grab keyboard focus yet main window at the
94fd7f
-   same time should visually stay in focus for window manager. This resolves focus flip
94fd7f
-   issue when popup or pulldown menu is raised. ~ochern
94fd7f
- */
94fd7f
-void XmForceGrabKeyboard(Widget w, Time time)
94fd7f
-{
94fd7f
-  GrabData *grabw;
94fd7f
-
94fd7f
-  if (!w)
94fd7f
-    return;
94fd7f
-
94fd7f
-  while (! XtIsSubclass(w, shellWidgetClass))
94fd7f
-    w = XtParent(w);
94fd7f
-
94fd7f
-  if (! (XtIsSubclass(w, xmGrabShellWidgetClass) || XtIsSubclass(w, xmMenuShellWidgetClass)))
94fd7f
-    return;
94fd7f
-
94fd7f
-  _XmStartDispatcher(XtDisplay(w));
94fd7f
-
94fd7f
-  _UngrabKeyboard(w);
94fd7f
-
94fd7f
-  grabw = (GrabData *) XtMalloc(sizeof(GrabData));
94fd7f
-  grabw->w = w;
94fd7f
-  _XmProcessLock();
94fd7f
-  grabw->next = grabw_top;
94fd7f
-  grabw_top = grabw;
94fd7f
-  _XmProcessUnlock();
94fd7f
-
94fd7f
-  XtInsertEventHandler(w, StructureNotifyMask, False, UnmapHandler, NULL, XtListHead);
94fd7f
-
94fd7f
-  _XmSendFocusEvent(w, FocusIn);
94fd7f
-
94fd7f
-  /* Following the XSetInputFocus behaviour we force sending FocusOut (see XGrabKeyboard(3))
94fd7f
-     event to a previous keyboard holder */
94fd7f
-  XtGrabKeyboard(w, True, GrabModeAsync, GrabModeAsync, time);
94fd7f
-}
94fd7f
-
94fd7f
-static void _XmStartDispatcher(Display *display)
94fd7f
-{
94fd7f
-  if (!display)
94fd7f
-    return;
94fd7f
-
94fd7f
-  _XmProcessLock();
94fd7f
-
94fd7f
-  if (xm_dispatcher_on) {
94fd7f
-    _XmProcessUnlock();
94fd7f
-    return;
94fd7f
-  }
94fd7f
-
94fd7f
-  saved_dispatcher_proc = XtSetEventDispatcher(display, KeyPress, _XmEventDispatcher);
94fd7f
-  if (! xt_dispatcher_proc)
94fd7f
-    xt_dispatcher_proc = saved_dispatcher_proc;
94fd7f
-  XtSetEventDispatcher(display, KeyRelease, _XmEventDispatcher);
94fd7f
-  xm_dispatcher_on = 1;
94fd7f
-
94fd7f
-  _XmProcessUnlock();
94fd7f
-}
94fd7f
-
94fd7f
-static Boolean _XmEventDispatcher(XEvent *event)
94fd7f
-{
94fd7f
-  _XmProcessLock();
94fd7f
-  if (grabw_top) {
94fd7f
-    if (event->type == KeyPress || event->type == KeyRelease)
94fd7f
-      event->xany.window = XtWindow(grabw_top->w);
94fd7f
-  }
94fd7f
-  _XmProcessUnlock();
94fd7f
-
94fd7f
-  if (saved_dispatcher_proc) {
94fd7f
-    return (*saved_dispatcher_proc)(event);
94fd7f
-  } else if (xt_dispatcher_proc) {
94fd7f
-    return (*xt_dispatcher_proc)(event);
94fd7f
-  } else {
94fd7f
-    if (grabw_top)
94fd7f
-      XtSetEventDispatcher(XtDisplay(grabw_top->w), event->type, NULL);
94fd7f
-    return XtDispatchEvent(event);
94fd7f
-  }
94fd7f
-}
94fd7f
-
94fd7f
-static void UnmapHandler(Widget w, XtPointer client_data, XEvent *event, Boolean *cont)
94fd7f
-{
94fd7f
-  if (event->type == UnmapNotify)
94fd7f
-    _UngrabKeyboard(w);
94fd7f
-  if (! grabw_top) {
94fd7f
-    XtSetEventDispatcher(XtDisplay(w), KeyPress, saved_dispatcher_proc);
94fd7f
-    XtSetEventDispatcher(XtDisplay(w), KeyRelease, saved_dispatcher_proc);
94fd7f
-    xm_dispatcher_on = 0;
94fd7f
-  }
94fd7f
-
94fd7f
-  /* we do not call XtUngrabKeyboard since X server automatically performs an
94fd7f
-     UngrabKeyboard request if the event window for an active keyboard grab becomes
94fd7f
-     not viewable. ~ochern */
94fd7f
-}
94fd7f
-
94fd7f
-static Boolean _UngrabKeyboard(Widget w)
94fd7f
-{
94fd7f
-  GrabData *grabw, *grabw_prev;
94fd7f
-
94fd7f
-  _XmProcessLock();
94fd7f
-  if (! grabw_top) {
94fd7f
-    _XmProcessUnlock();
94fd7f
-    return False;
94fd7f
-  }
94fd7f
-
94fd7f
-  grabw = grabw_top;
94fd7f
-  grabw_prev = NULL;
94fd7f
-  while(grabw && grabw->w != w) {
94fd7f
-    grabw_prev = grabw;
94fd7f
-    grabw = grabw->next;
94fd7f
-  }
94fd7f
-  if (grabw) {
94fd7f
-    if (grabw_prev)
94fd7f
-      grabw_prev->next = grabw->next;
94fd7f
-    else
94fd7f
-      grabw_top = grabw->next;
94fd7f
-    XtFree((char*) grabw);
94fd7f
-
94fd7f
-    _XmProcessUnlock();
94fd7f
-    return True;
94fd7f
-  }
94fd7f
-
94fd7f
-  _XmProcessUnlock();
94fd7f
-  return False;
94fd7f
-}
94fd7f
-
94fd7f
-static void _XmSendFocusEvent(Widget child, int type)
94fd7f
-{
94fd7f
-  child = XtIsWidget(child) ? child : _XtWindowedAncestor(child);
94fd7f
-  if (XtIsSensitive(child) && !child->core.being_destroyed
94fd7f
-      && XtIsRealized(child) && (XtBuildEventMask(child) & FocusChangeMask))
94fd7f
-  {
94fd7f
-    XFocusChangeEvent event;
94fd7f
-    Display* dpy = XtDisplay (child);
94fd7f
-
94fd7f
-    event.type = type;
94fd7f
-    event.serial = LastKnownRequestProcessed(dpy);
94fd7f
-    event.send_event = True;
94fd7f
-    event.display = dpy;
94fd7f
-    event.window = XtWindow(child);
94fd7f
-    event.mode = NotifyNormal;
94fd7f
-    event.detail = NotifyAncestor;
94fd7f
-    if (XFilterEvent((XEvent*)&event, XtWindow(child)))
94fd7f
-      return;
94fd7f
-    XtDispatchEventToWidget(child, (XEvent*)&event);
94fd7f
-  }
94fd7f
-}
94fd7f
-
94fd7f
-#endif
94fd7f
-
94fd7f
diff --git a/lib/Xm/XmI.h b/lib/Xm/XmI.h
94fd7f
index ef6165c5..769e5f0a 100644
94fd7f
--- a/lib/Xm/XmI.h
94fd7f
+++ b/lib/Xm/XmI.h
94fd7f
@@ -237,9 +237,6 @@ extern Boolean _XmIsISO10646(Display *dpy,
94fd7f
 extern XChar2b* _XmUtf8ToUcs2(char *draw_text,
94fd7f
                               size_t seg_len,
94fd7f
 			      size_t *ret_str_len);
94fd7f
-#ifdef FIX_1565
94fd7f
-extern void XmForceGrabKeyboard(Widget w, Time time);
94fd7f
-#endif
94fd7f
 
94fd7f
 /********    End Private Function Declarations    ********/
94fd7f
 
94fd7f
@@ -294,7 +291,6 @@ extern Pixel _XmAssignInsensitiveColor(Widget w);
94fd7f
 #define FIX_1501
94fd7f
 #define FIX_1521
94fd7f
 #define FIX_1505
94fd7f
-#define FIX_1565
94fd7f
 
94fd7f
 #endif /* _XmI_h */
94fd7f
 /* DON'T ADD ANYTHING AFTER THIS #endif */
94fd7f
-- 
94fd7f
2.13.5
94fd7f