Blame SOURCES/revert-of-motifzone_1565.patch

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