Blame SOURCES/revert-of-motifzone_1565.patch

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