Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
;;; xwem-mouse.el --- Mouse support for XWEM.
;; Copyright (C) 2003 by Free Software Foundation, Inc.
;; Author: Zajcev Evgeny <zevlg@yandex.ru>
;; Created: 21 Mar 2003
;; Keywords: xlib, xwem
;; X-CVS: $Id$
;; This file is part of XWEM.
;; XWEM 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 2, or (at your option)
;; any later version.
;; XWEM 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 XEmacs; see the file COPYING. If not, write to the Free
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.
;;; Synched up with: Not in FSF
;;; Commentary:
;;
;; TODO:
;; * Add item here.
;;
;;; Code:
;;
(defcustom xwem-popup-menu-function 'popup-menu
"*Function used to popup menus."
:type 'function
:group 'xwem)
(defun xwem-mouse-change-cursor (cursor )
(XChangeActivePointerGrab (xwem-dpy) cursor
(Xmask-or XM-ButtonPress XM-ButtonRelease)))
;;;###autoload
(defun xwem-mouse-grab (cursor &optional win mask)
"Begin to grab mouse from root window with cursor typ CURSOR.."
;; TODO: install custom events handlers?
(XGrabPointer (xwem-dpy)
(or win (xwem-rootwin))
(or mask (Xmask-or XM-ButtonPress XM-ButtonRelease))
cursor)
)
;;;###autoload
(defun xwem-mouse-ungrab ()
"Stop grabing mouse."
(XUngrabPointer (xwem-dpy))
)
;;; Menus
(defvar xwem-applications-submenu
'("Applications"
["XEmacs" (make-frame)]
["xterm" (xwem-execute-program "xterm")]
["gv" (xwem-execute-program "gv")]
["xfontsel" (xwem-execute-program "xfontsel")]
)
"Submenu with applications.")
(defvar xwem-menu
(list "XWEM Menu"
xwem-applications-submenu
'("Windows"
["Vertical Split" (xwem-frame-split-vert nil)]
["Horizontal Split" (xwem-frame-split-horiz nil)]
["Delete Window" (xwem-window-delete)]
["Delete Others" (xwem-window-delete-others)]
["Balance" (xwem-balance-windows (xwem-frame-selected))])
)
"Popup menu to be used by xwem."
)
(defun xwem-menu-generate ()
"Generates xwem menu on fly."
(list "XWEM Menu"
'("xwem-frames" :filter
(lambda (not-used)
(mapcar (lambda (el)
(let ((fn (xwem-frame-num el)))
(vector
(concat "Frame " (int-to-string fn))
`(xwem-frame-switch-nth ,fn))))
xwem-frames-list)))
'("xwem-clients" :filter
(lambda (not-used)
(mapcar (lambda (el)
(let ((nam (xwem-hints-wm-name (xwem-cl-hints el))))
(vector nam `(xwem-cl-pop-to-client ,el t)
:active (if (xwem-cl-exclude-p el) nil t))))
xwem-clients)))
"--"
xwem-applications-submenu
;; XXX - it is just demo of popup menus
))
(defun xwem-popup-menu (menu &optional event)
"Popup MENU.
MENU and EVENT is same as for `popup-menu'."
(funcall xwem-popup-menu-function menu event))
(define-xwem-command xwem-popup-function-menu (arg)
"Just popup `xwem-menu'."
(xwem-interactive "_P")
;; TODO:
;; * use ARG
(xwem-popup-menu xwem-menu))
(define-xwem-command xwem-popup-auto-menu (arg)
"Popup menu generated by `xwem-menu-generate'."
(xwem-interactive "_P")
(xwem-popup-menu (xwem-menu-generate)))
(provide 'xwem-mouse)
;;; xwem-mouse.el ends here