Implement Ctrl-Mouse-2 (split vertically) for toolkit scrollbars
authorJan Djärv <jan.h.d@swipnet.se>
Sun, 9 Mar 2003 20:43:04 +0000 (20:43 +0000)
committerJan Djärv <jan.h.d@swipnet.se>
Sun, 9 Mar 2003 20:43:04 +0000 (20:43 +0000)
src/ChangeLog
src/gtkutil.h
src/keyboard.c
src/xterm.c

index 06ec1b2..76f05fb 100644 (file)
@@ -1,3 +1,25 @@
+2003-03-09  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
+
+       * keyboard.c (make_lispy_event): Extend mouse_syms if needed for
+       toolkit scrollbar click.
+
+       * xterm.c (x_window_to_scroll_bar): Call xg_get_scroll_id_for_window
+       for USE_GTK.
+       (x_scroll_bar_handle_click): Use this function for toolkit scrollbars
+       also.
+       (handle_one_xevent): ButtonPress/Release:  If event is for a toolkit
+       scrollbar and control is pressed, call x_scroll_bar_handle_click.
+       
+       * gtkutil.h: Declare xg_get_scroll_id_for_window.
+
+       * gtkutil.c (xg_get_scroll_id_for_window): New function.
+       (xg_tool_bar_item_expose_callback): New function.
+       (xg_tool_bar_expose_callback): Call update_frame_tool_bar.
+       (xg_create_tool_bar): Connect xg_tool_bar_expose_callback to expose
+       on the tool bar widget.
+       (update_frame_tool_bar): Connect xg_tool_bar_item_expose_callback
+       to expose on the tool bar item widgets.
+
 2003-03-08  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
 
        * gtkutil.c (update_frame_tool_bar): Compare pixmap ID instead of
index b6779b4..b79b5fd 100644 (file)
@@ -151,6 +151,8 @@ extern int xg_update_frame_menubar P_ ((FRAME_PTR f));
 
 extern void xg_keep_popup P_ ((GtkWidget *menu, GtkWidget *submenu));
 
+extern int xg_get_scroll_id_for_window P_ ((Window wid));
+
 extern void xg_create_scroll_bar P_ ((FRAME_PTR f,
                                       struct scroll_bar *bar,
                                       GCallback scroll_callback,
index 86fdb9a..11e3980 100644 (file)
@@ -5431,6 +5431,9 @@ make_lispy_event (event)
        event->modifiers |= click_modifier;
        event->modifiers &= ~up_modifier;
 
+       if (event->code >= ASIZE (mouse_syms))
+          mouse_syms = larger_vector (mouse_syms, event->code + 1, Qnil);
+
        /* Get the symbol we should use for the mouse click.  */
        head = modify_event_symbol (event->code,
                                    event->modifiers,
index 56a57b2..f6566c1 100644 (file)
@@ -8436,6 +8436,10 @@ x_window_to_scroll_bar (window_id)
 {
   Lisp_Object tail;
 
+#ifdef USE_GTK
+  window_id = (Window) xg_get_scroll_id_for_window (window_id);
+#endif /* USE_GTK */
+
   for (tail = Vframe_list;
        XGCTYPE (tail) == Lisp_Cons;
        tail = XCDR (tail))
@@ -9860,7 +9864,6 @@ x_scroll_bar_expose (bar, event)
    This may be called from a signal handler, so we have to ignore GC
    mark bits.  */
 
-#ifndef USE_TOOLKIT_SCROLL_BARS
 
 static void
 x_scroll_bar_handle_click (bar, event, emacs_event)
@@ -9914,6 +9917,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event)
       XSETINT (bar->dragging, y - XINT (bar->start));
 #endif
 
+#ifndef USE_TOOLKIT_SCROLL_BARS
     /* If the user has released the handle, set it to its final position.  */
     if (event->type == ButtonRelease
        && ! NILP (bar->dragging))
@@ -9924,6 +9928,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event)
        x_scroll_bar_set_handle (bar, new_start, new_end, 0);
        bar->dragging = Qnil;
       }
+#endif
 
     /* Same deal here as the other #if 0.  */
 #if 0
@@ -9941,6 +9946,8 @@ x_scroll_bar_handle_click (bar, event, emacs_event)
   }
 }
 
+#ifndef USE_TOOLKIT_SCROLL_BARS
+
 /* Handle some mouse motion while someone is dragging the scroll bar.
 
    This may be called from a signal handler, so we have to ignore GC
@@ -11421,10 +11428,18 @@ handle_one_xevent (dpyinfo, eventp, bufp_r, numcharsp, finish)
           }
         else
           {
-#ifndef USE_TOOLKIT_SCROLL_BARS
             struct scroll_bar *bar
               = x_window_to_scroll_bar (event.xbutton.window);
 
+#ifdef USE_TOOLKIT_SCROLL_BARS
+            /* Make the "Ctrl-Mouse-2 splits window" work for toolkit
+               scroll bars.  */
+            if (bar && event.xbutton.state & ControlMask)
+              {
+                x_scroll_bar_handle_click (bar, &event, &emacs_event);
+                *finish = X_EVENT_DROP;
+              }
+#else /* not USE_TOOLKIT_SCROLL_BARS */
             if (bar)
               x_scroll_bar_handle_click (bar, &event, &emacs_event);
 #endif /* not USE_TOOLKIT_SCROLL_BARS */
@@ -11534,7 +11549,8 @@ handle_one_xevent (dpyinfo, eventp, bufp_r, numcharsp, finish)
     OTHER:
 #ifdef USE_X_TOOLKIT
     BLOCK_INPUT;
-    XtDispatchEvent (&event);
+    if (*finish != X_EVENT_DROP)
+      XtDispatchEvent (&event);
     UNBLOCK_INPUT;
 #endif /* USE_X_TOOLKIT */
     break;