emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Semi-unhelpful error message given when trying to (provide 'CUA-mode


From: Jan Djärv
Subject: Re: Semi-unhelpful error message given when trying to (provide 'CUA-mode)
Date: Wed, 24 May 2006 13:19:15 +0200
User-agent: Thunderbird 1.5.0.2 (Macintosh/20060308)

Richard Stallman skrev:
Could you show us your existing patch?

Attached.  BTW, this does not work for non-toolkit menus (i.e. oldXmenu).


        Jan D.
diff -w -c lwlib/xlwmenu.c.orig lwlib/xlwmenu.c
Index: lwlib/xlwmenu.c
*** lwlib/xlwmenu.c.orig        2006-05-22 10:10:07.000000000 +0200
--- lwlib/xlwmenu.c     2006-05-22 10:06:28.000000000 +0200
***************
*** 2088,2093 ****
--- 2088,2094 ----
        mw->menu.windows [0].y = ev->xmotion.y_root - ev->xmotion.y;
  
        /* handles the down like a move, slots are compatible */
+       ev->xmotion.is_hint = 0;
        handle_motion_event (mw, &ev->xmotion);
      }
  }
***************
*** 2503,2508 ****
--- 2504,2510 ----
    x_uncatch_errors (display, count);
  #endif
  
+   ((XMotionEvent*)event)->is_hint = 0;
    handle_motion_event (mw, (XMotionEvent*)event);
  }
  
diff -w -c src/gtkutil.c.orig src/gtkutil.c
Index: src/gtkutil.c
*** src/gtkutil.c.orig  2006-03-06 17:51:14.000000000 +0100
--- src/gtkutil.c       2006-05-22 08:47:42.000000000 +0200
***************
*** 1970,1975 ****
--- 1970,1999 ----
    return w;
  }
  
+ /* Callback called when keyboard traversal (started by x-menu-bar-start) ends.
+    WMENU is the menu for which traversal has been done.  DATA points to the
+    frame for WMENU.  We must release grabs, some bad interaction between GTK
+    and Emacs makes the menus keep the grabs.  */
+ 
+ static void
+ menu_nav_ended (wmenu, data)
+      GtkMenuShell *wmenu;
+      gpointer data;
+ {
+   FRAME_PTR f = (FRAME_PTR) data;
+   Display *dpy = FRAME_X_DISPLAY (f);
+ 
+   BLOCK_INPUT;
+       GtkMenuShell *w = GTK_MENU_SHELL (FRAME_X_OUTPUT (f)->menubar_widget);
+       gtk_menu_shell_deactivate (w);
+       gtk_menu_shell_deselect (w);
+ 
+   XUngrabKeyboard (dpy, CurrentTime);
+   XUngrabPointer (dpy, CurrentTime);
+   UNBLOCK_INPUT;
+ }
+ 
+ 
  static GtkWidget *create_menus P_ ((widget_value *, FRAME_PTR, GCallback,
                                    GCallback, GCallback, int, int, int,
                                    GtkWidget *, xg_menu_cb_data *, char *));
***************
*** 2024,2029 ****
--- 2048,2059 ----
          }
        else wmenu = gtk_menu_bar_new ();
  
+       /* Fix up grabs after keyboard traversal ends.  */
+       g_signal_connect (G_OBJECT (wmenu),
+                         "selection-done",
+                         G_CALLBACK (menu_nav_ended),
+                         f);
+ 
        /* Put cl_data on the top menu for easier access.  */
        cl_data = make_cl_data (cl_data, f, highlight_cb);
        g_object_set_data (G_OBJECT (wmenu), XG_FRAME_DATA, (gpointer)cl_data);
diff -w -c src/xmenu.c.orig src/xmenu.c
Index: src/xmenu.c
*** src/xmenu.c.orig    2006-05-06 16:52:47.000000000 +0200
--- src/xmenu.c 2006-05-22 09:35:53.000000000 +0200
***************
*** 1301,1309 ****
--- 1301,1417 ----
      }
  }
  
+ DEFUN ("x-menu-bar-start", Fx_menu_bar_start, Sx_menu_bar_start, 0, 1, "i",
+        doc: /* Start key navigation of the menu bar in FRAME.
+ Usually the "File" menu is opened and you can then navigate with the
+ arrow keys, select a menu entry with the return key or cancel with the
+ escape key.  If FRAME has no menu bar this function does nothing.
+ 
+ If FRAME is nil or not given, use the selected frame.  */)
+      (frame)
+      Lisp_Object frame;
+ {
+   XEvent ev;
+   FRAME_PTR f = check_x_frame (frame);
+   Widget menubar;
+   BLOCK_INPUT;
+ 
+   if (FRAME_EXTERNAL_MENU_BAR (f))
+     set_frame_menubar (f, 0, 1);
+ 
+   menubar = FRAME_X_OUTPUT (f)->menubar_widget;
+   if (menubar)
+     {
+       Window child;
+       int error_p = 0;
+ 
+       x_catch_errors (FRAME_X_DISPLAY (f));
+       memset (&ev, 0, sizeof ev);
+       ev.xbutton.display = FRAME_X_DISPLAY (f);
+       ev.xbutton.window = XtWindow (menubar);
+       ev.xbutton.root = FRAME_X_DISPLAY_INFO (f)->root_window;
+       ev.xbutton.time = XtLastTimestampProcessed (FRAME_X_DISPLAY (f));
+       ev.xbutton.button = Button1;
+       ev.xbutton.x = ev.xbutton.y = FRAME_MENUBAR_HEIGHT (f) / 2;
+       ev.xbutton.same_screen = True;
+ 
+ #ifdef USE_MOTIF
+       {
+         Arg al[2];
+         WidgetList list;
+         Cardinal nr;
+         XtSetArg (al[0], XtNchildren, &list);
+         XtSetArg (al[1], XtNnumChildren, &nr);
+         XtGetValues (menubar, al, 2);
+         ev.xbutton.window = XtWindow (list[0]);
+       }
+ #endif
+ 
+       XTranslateCoordinates (FRAME_X_DISPLAY (f),
+                              /* From-window, to-window.  */
+                              ev.xbutton.window, ev.xbutton.root,
+ 
+                              /* From-position, to-position.  */
+                              ev.xbutton.x, ev.xbutton.y,
+                              &ev.xbutton.x_root, &ev.xbutton.y_root,
+ 
+                              /* Child of win.  */
+                              &child);
+       error_p = x_had_errors_p (FRAME_X_DISPLAY (f));
+       x_uncatch_errors ();
+ 
+       if (! error_p)
+         {
+           ev.type = ButtonPress;
+           ev.xbutton.state = 0;
+ 
+           XtDispatchEvent (&ev);
+           ev.xbutton.type = ButtonRelease;
+           ev.xbutton.state = Button1Mask;
+           XtDispatchEvent (&ev);
+         }
+     }
+ 
+   UNBLOCK_INPUT;
+ }
  #endif /* USE_X_TOOLKIT */
  
+ 
  #ifdef USE_GTK
+ DEFUN ("x-menu-bar-start", Fx_menu_bar_start, Sx_menu_bar_start, 0, 1, "i",
+        doc: /* Start key navigation of the menu bar in FRAME.
+ Usually the "File" menu is opened and you can then navigate with the
+ arrow keys, select a menu entry with the return key or cancel with the
+ escape key.  If FRAME has no menu bar this function does nothing.
+ 
+ If FRAME is nil or not given, use the selected frame.  */)
+      (frame)
+      Lisp_Object frame;
+ {
+   GtkWidget *menubar;
+   BLOCK_INPUT;
+   FRAME_PTR f = check_x_frame (frame);
+ 
+   if (FRAME_EXTERNAL_MENU_BAR (f))
+     set_frame_menubar (f, 0, 1);
+ 
+   menubar = FRAME_X_OUTPUT (f)->menubar_widget;
+   if (menubar)
+     {
+       /* Activate the first menu.  */
+       GList *children = gtk_container_get_children (GTK_CONTAINER (menubar));
+ 
+       gtk_menu_shell_select_item (GTK_MENU_SHELL (menubar),
+                                   GTK_WIDGET (children->data));
+       
+       popup_activated_flag = 1;
+       g_list_free (children);
+     }
+   UNBLOCK_INPUT;
+ 
+   return Qnil;
+ }
+ 
  /* Loop util popup_activated_flag is set to zero in a callback.
     Used for popup menus and dialogs. */
  
***************
*** 3659,3664 ****
--- 3767,3777 ----
  #endif
  
    defsubr (&Sx_popup_menu);
+ 
+ #if defined (USE_GTK) || defined (USE_X_TOOLKIT)
+   defsubr (&Sx_menu_bar_start);
+ #endif
+ 
  #ifdef HAVE_MENUS
    defsubr (&Sx_popup_dialog);
  #endif
diff -w -c lisp/term/x-win.el.orig lisp/term/x-win.el
Index: lisp/term/x-win.el
*** lisp/term/x-win.el.orig     2006-02-14 08:57:16.000000000 +0100
--- lisp/term/x-win.el  2006-05-22 08:42:00.000000000 +0200
***************
*** 2516,2520 ****
--- 2516,2524 ----
  (add-hook 'after-make-frame-functions 'x-dnd-init-frame)
  (global-set-key [drag-n-drop] 'x-dnd-handle-drag-n-drop-event)
  
+ ;; Let F10 do menu bar navigation.
+ (and (fboundp 'x-menu-bar-start)
+      (global-set-key [f10] 'x-menu-bar-start))
+ 
  ;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
  ;;; x-win.el ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]