;;; hm--mouse-on-modeline.el: 
;;; v1.20; 13 Jun 1993
;;; Copyright (C) 1993  Heiko Muenkel
;;; email: muenkel@tnt.uni-hannover.de
;;;
;;; This file is based on the file mouse-on-modeline.el which was posted.
;;; I'am sorry, but I can't remember the name of the author of the orignal
;;; lisp code. Thank you for this nice code !
;;;
;;;
;;;  This program is free software; you can redistribute it and/or modify
;;;  it under the terms of the GNU General Public License as published by
;;;  the Free Software Foundation; either version 1, or (at your option)
;;;  any later version.
;;;
;;;  This program is distributed in the hope that it will be useful,
;;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;;  GNU General Public License for more details.
;;;
;;;  You should have received a copy of the GNU General Public License
;;;  along with this program; if not, write to the Free Software
;;;  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;;;
;;; 
;;; Description:
;;;
;;;	Scrolls the current buffer, if you are clicking the left or the rigth
;;;     button on a modeline.
;;; 
;;; Installation: 
;;;   
;;;	Put the following line in your .emacs:
;;;       (load-library "hm--mouse-on-modeline")
;;;     and this file in one of your load-path-directories (lisp/packages for 
;;;     example).  
;;;

(provide 'hm--mouse-on-modeline)


(defun mouse-on-modeline-p ()
  "Non-nil iff mouse pointer is within a modeline."
  (equal x-mode-pointer-shape (cdr (assq 'pointer (screen-parameters)))))

(defun mouse-left (event)
  "Perform commands bound to left mouse button."
  (interactive "@e")
  (if (mouse-on-modeline-p)
      (scroll-down)
    (mouse-track event)))


;; Mode specific scroll functions

(defun hm--buffer-mouse-right (event)
  "Perform commands bound to right mouse button."
  (interactive "@e")
  (if (mouse-on-modeline-p)
      (scroll-up)
    (Buffer-menu-popup-menu event)))



;; Key-Bindings

(global-set-key 'button1 'mouse-left)

(define-key Buffer-menu-mode-map '(button3) 'hm--buffer-mouse-right)

